Repository navigation
Feat/snippet usage instructions - #224
Merged
SudiptaPaul-31 merged 4 commits intoOct 23, 2026
Merged
SudiptaPaul-31 merged 4 commits into
SudiptaPaul-31 merged 4 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! 🚀 |
package.json lists prettier ^3.9.9 (added with the code-formatting feature), but pnpm-lock.yaml never got the entry, so `pnpm install --frozen-lockfile` stopped every Accessibility checks run with ERR_PNPM_OUTDATED_LOCKFILE. Adds the importer specifier and prettier@3.9.10 (the newest match, with its registry integrity) in pnpm's lockfile v9 layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvL6Yz2Zfg7spM1F9DXXtz
…ility workflow The Accessibility checks workflow runs `pnpm lint` and the whole jest suite, and both failed on main before this PR. Lint (7 errors -> 0): - app/dashboard/page.tsx, components/SnippetCardContextMenu.tsx and components/ui/dropdown-menu.tsx were mangled in SudiptaPaul-31#189 ("} client", `<div <div`, broken generics) and no longer parse; restored to their state before SudiptaPaul-31#189, as SudiptaPaul-31#189's button.tsx already was on this branch. - components/ui/switch.tsx held two Switch components after a merge; keep one. - SnippetForm destructured watch/getValues twice. Bugs the tests exposed: - SignatureMiddleware passed strings to Keypair.verify, so every valid signature was rejected; it now verifies the message and base64 signature as bytes. - duplicateSnippet read the route's request body as a title string and threw on `.trim()`, so every duplicate request returned 500; the body is now validated with duplicateSnippetSchema. - createSnippet passed `id: undefined` to the repository when no ownership proof was given. - SnippetForm's autosave effect keyed on `watch()`'s new-each-render object, so a status re-render scheduled a second save alongside the pending retry. - formatWalletAddress rendered "ABC" as "ABC...ABC". Tests brought in line with the code they test: - SnippetForm / autosave: mock the wallet hook and the usage-instructions panel, stub ResizeObserver. - Route and middleware suites run in the node environment (Request). - Wallet validation uses a checksum-valid address; the signature test restores the session through the encrypted session store. - Fork/duplicate suites cover the current create()-based design (forked_from_id, "Fork of …", "(Copy)", owners may duplicate their own). - Activity timeline and visibility fixtures corrected. jest: 53/53 suites, 664 tests pass; eslint: 0 errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvL6Yz2Zfg7spM1F9DXXtz
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).