feat: add hashtag references to notes, commits & reviews in prompt textareas - #608
Conversation
…xtareas Users can type `#` in any AI prompt textarea to reference notes, commits, and reviews. A filtered dropdown appears at the caret position with matching items, and selected items render as colored inline badges within the text. Frontend changes: - Add HashtagItem type and HashtagInput.svelte contenteditable editor with inline badge rendering, caret-positioned dropdown, and keyboard navigation - Create hashtagItems.ts utility for building scoped item lists from branch timelines and project notes - Integrate into all 4 prompt textareas: NewSessionModal, SessionModal, ProjectSection, and DiffCommitSessionLauncher - Render hashtag tokens as badges in session chat history Backend changes: - Pass referenced item tokens through to session prompts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a prompt textarea is prefilled from a note or review, prepend a `Re: #<type>:<id>` line so the AI session knows which item triggered it. - NewSessionModal: shows the Re line in the prefilled text - NoteModal next-step buttons: prepends Re line to the action prompt - DiffCommitSessionLauncher: prepends Re line on submit (hidden from UI) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a prompt textarea was prefilled with Re: #type:id references, the tokens rendered as plain text because the items list hadn't loaded yet. Add a second effect that re-renders the editor content when items become available and there are unresolved tokens from a prior render. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When items loaded after the prefilled select-all ran, renderContent() replaced the DOM and destroyed the selection. Now save and restore the selection state around the items-loaded re-render. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e408a38d3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| <HashtagInput | ||
| bind:textareaEl={textareaElement} | ||
| bind:value={draftPrompt} | ||
| class="composer-input" |
There was a problem hiding this comment.
Keep diff modal hotkeys from firing while typing in composer
The diff composer now mounts HashtagInput, which renders a contenteditable div instead of a <textarea>. DiffModal’s document-level key handler only ignores HTMLInputElement/HTMLTextAreaElement targets, so when focus is in this new composer, pressing keys like Escape can still trigger modal-level actions (for example closing the modal) and discard in-progress prompt edits. Please preserve the previous input-guard behavior for contenteditable targets when using this component.
Useful? React with 👍 / 👎.
| const afterNode = document.createTextNode('\u200B' + after); | ||
|
|
There was a problem hiding this comment.
Insert a real delimiter between consecutive hashtag selections
selectItem appends only a zero-width character before/after inserted badges, and extractFromNode later strips zero-width characters from the serialized value. If a user inserts one hashtag and immediately inserts another without typing whitespace, the stored prompt becomes a concatenated token like #note:...#commit:..., which no longer matches the token parser as two references. This makes back-to-back references unresolvable after re-render/submission.
Useful? React with 👍 / 👎.
Address review comments from 276326b1: - Remove misleading doc comment on build_full_prompt that claimed it parses and resolves #type:id tokens (it doesn't; that's future work) - Add staleness guards to async $effect hashtag-item fetches in DiffCommitSessionLauncher, NewSessionModal, and SessionModal so stale promises from a previous branchId/projectId don't overwrite state - Extract shared HASHTAG_TOKEN_RE, hashtagTypeLabels, and hashtagTypeColors constants into hashtagItems.ts and import them from HashtagInput.svelte and SessionModal.svelte (eliminates duplication) - Fix escape-then-regex ordering in SessionModal's renderHashtagTokens: regex-match on raw text first, then escape non-token segments individually, so IDs with HTML-special characters are looked up correctly against the items map Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
HashtagInputcomponent that lets users reference notes, commits, and reviews using#type:idhashtag syntax with autocomplete and badge renderingRe: #type:idreference lines to prefilled prompts when launching sessions from diff/review contextsTest plan
#in session prompt textareasRe:reference lines🤖 Generated with Claude Code