Skip to content

feat: add hashtag references to notes, commits & reviews in prompt textareas - #608

Merged
matt2e merged 6 commits into
mainfrom
refer-to-notes
Apr 13, 2026
Merged

feat: add hashtag references to notes, commits & reviews in prompt textareas#608
matt2e merged 6 commits into
mainfrom
refer-to-notes

Conversation

@matt2e

@matt2e matt2e commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a new HashtagInput component that lets users reference notes, commits, and reviews using #type:id hashtag syntax with autocomplete and badge rendering
  • Prepend Re: #type:id reference lines to prefilled prompts when launching sessions from diff/review contexts
  • Resolve prefilled hashtag tokens into visual badges once referenced items finish loading
  • Fix select-all behavior to work correctly across hashtag badge re-renders

Test plan

  • Verify hashtag autocomplete appears when typing # in session prompt textareas
  • Verify selecting a hashtag item inserts a styled badge
  • Verify prefilled prompts from diff/review launchers include Re: reference lines
  • Verify select-all (Cmd+A) works correctly in the hashtag input

🤖 Generated with Claude Code

matt2e and others added 5 commits April 10, 2026 17:57
…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>
@matt2e
matt2e requested review from baxen and wesbillman as code owners April 13, 2026 00:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +163 to 166
<HashtagInput
bind:textareaEl={textareaElement}
bind:value={draftPrompt}
class="composer-input"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +323 to +324
const afterNode = document.createTextNode('\u200B' + after);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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>
@matt2e
matt2e merged commit 1e257fb into main Apr 13, 2026
5 checks passed
@matt2e
matt2e deleted the refer-to-notes branch April 13, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant