Repository navigation
Feat/snippet usage instructions - #224
Open
JemimahEkong wants to merge 2 commits into
Open
JemimahEkong wants to merge 2 commits into
JemimahEkong wants to merge 2 commits into
Conversation
Commit 12b814f left components/ui/button.tsx unparseable (unterminated 'button string, @lib/utils alias, variants not nested under `variant`, typos such as srink-0 / ring-ing / 9over / has-;[svg]). Every test suite that imports Button failed to load. Restore the last working version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvL6Yz2Zfg7spM1F9DXXtz
Adds a "Usage Instructions" panel to the snippet details view with Overview, Prerequisites, Setup, Input/Output examples and Notes. - usage_instructions JSONB column (migration 005); saving does not bump updated_at so SnippetForm's conflict check is unaffected - PUT/DELETE /api/snippets/[id]/usage: verified JWT + live session, owner or "edit" collaborator only; x-wallet-address is not trusted - zod schema shared by client and server (size limits, strict keys, control-character and language checks, field-level errors) - SafeMarkdown renderer: React elements only, no dangerouslySetInnerHTML, links limited to http(s)/mailto with rel=noopener noreferrer nofollow ugc; code is displayed, never executed - Editor with Write/Preview tabs, labelled fields, aria-invalid errors, loading/empty/error/retry states; also available from the edit form - Tests for model, renderer (XSS), route (auth/validation/persistence) and panel (create/edit/delete/empty/a11y/errors) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvL6Yz2Zfg7spM1F9DXXtz
|
@JemimahEkong is attempting to deploy a commit to the Sudipta 's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@JemimahEkong Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Usage Instructions panel to the snippet details view. It gives authors a structured place to document how a snippet works and how to use it.
Closes #214
What's included
Sections: Overview, Prerequisites, Setup Instructions, an Input Example and an Output Example (each a separate code block with its own language label), and Notes.
Markdown: headings, paragraphs, ordered and unordered lists, fenced code blocks, inline code, bold and italic text, and links.
Where it appears:
Editing:
editpermission (canEdit).API
/api/snippets/[id]/usageGET{canEdit}PUT{error, fields}, 401, 403, 404, 500DELETEReads need no new endpoint.
usage_instructionsis a column, soGET /api/snippets/[id]already returns it under the existing visibility rules.Storage
scripts/migrations/005_add_snippet_usage_instructions.sqladds the nullableusage_instructions JSONBcolumn.updated_at: saving does not change it. That waySnippetForm'sIf-Unmodified-Sinceconflict check doesn't fire on a later code edit.Security
verifyAuthentication).x-wallet-addressheader is not accepted. A test checks that a spoofed header naming the owner gets a 401.[A-Za-z0-9+#._-].lib/safe-markdown.tsxbuilds React elements only and never usesdangerouslySetInnerHTML.<script>or<img onerror>is shown as text.http(s)andmailtoURLs, withrel="noopener noreferrer nofollow ugc".javascript:,data:and relative links are shown as plain text.Accessibility and responsiveness
sectionregion with an h3. Author headings are offset to h4 and below, so the page outline stays correct. Each section has anaria-label.tablist/tabroles. Every field has a label. Errors are linked througharia-invalidandaria-describedby. Loading usesrole="status"and errors userole="alert".Tests
97 new tests, all passing:
lib/usage-instructions.test.tslib/safe-markdown.test.tsxon*attributes, attribute whitelist, unsafe linksapp/api/snippets/[id]/usage/route.test.tscomponents/__tests__/UsageInstructionsPanel.test.tsxMutation checks:
x-wallet-addresstrust makes the spoofed-header test fail.javascript:links makes 3 renderer tests fail.Also fixed (separate commit)
fix(ui): restore Button component corrupted in #189. Commit 12b814f leftcomponents/ui/button.tsxunparseable, so every suite that importsButtonfailed to load. This restores the last working version. As a side effect,ForkSnippetModaltests pass again.Results compared with
mainRun locally:
mainpnpm linttsc --noEmitThe one "new" failure is
WalletConnect signAction › should successfully prompt freighter…invalidiation/frontend-signature.test.tsx. Before this branch, that suite could not load because of the brokenbutton.tsx, so the failure was hidden rather than introduced. It may also be affected by the local wallet-kit stub (see the notes below).