Skip to content

feat(chat): quote selected chat text into the composer - #593

Merged
Leo310 merged 6 commits into
mainfrom
feat/chat-selection-attach
Nov 26, 2026
Merged

Leo310 merged 6 commits into
mainfrom
feat/chat-selection-attach

Conversation

@Leo310

@Leo310 Leo310 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What

Text selected in a chat's messages can now be attached to the composer, as a note selection already can. Closes #591

  • The chip shows as soon as you select, like a note selection. The composer pins it: a capture-phase pointerdown/focusin on the input card runs before the press collapses the selection, and the chip adopted on the last refresh covers the case where it already has. A selection that goes away before that (copied, then clicked elsewhere) drops its chip, and leaving the chat for a note does not pin it. Clicking back into message text dismisses a pinned quote, mirroring the note behaviour.
  • Only message text is quotable: rendered assistant text (.s2b-message-text, which includes tool-timeline text) and user bubbles (new .s2b-user-bubble-text marker). Tool cards, bars, the tray and the composer are ignored.
  • Framed as a quote for the model: [Quoted from earlier in this conversation] for the same thread, [Quoted from the chat "<title>" (<path>)] for another chat. sameThread is decided at send time and stored on the SelectionRef, because stripAugmentedSuffix rebuilds the block from the ref and a thread's path changes when it is auto-titled.
  • Selecting in chat A and engaging chat B's composer works the same way and is labelled as the other chat.
  • The tracker reads chat selections from the DOM rather than the active leaf, since a sidebar chat is never getMostRecentLeaf().

How I tested it

New unit suite test/hooks/chatSelection.test.ts (shown live, dropped when the selection goes away unengaged, pinned after the press already collapsed the selection, non-message text ignored, cross-chat labelling, dismissal on a click into message text, and the three context-block formats). Full check/format/lint/test pass. I built into the slot vault and the plugin loads with no errors. I have not clicked through it live on desktop or mobile; that's for the maintainer's live test. On mobile, a long press on a user bubble opens its menu, so in practice only assistant text is quotable there.

AI assistance: Claude Code wrote the change and tests from the maintainer's brief on #591 (live chip pinned on composer engagement, quote framing, message-text-only scope); live testing is still pending from the maintainer.

Checklist

  • bun run check, bun run format, bun run lint, and bun run test pass locally
  • I tried the change in a real Obsidian vault (or explained above why that isn't applicable)
  • I read CONTRIBUTING.md, including the section on AI assistance
  • If this adds a provider, a bundled skill, a built-in tool, or changes manifest.json: I noted that the docs site needs updating (see "Documentation" in CONTRIBUTING.md)

Text selected in a chat's message text (assistant replies, tool-timeline
text, user bubbles) now becomes the composer's selection chip, like a
note selection does. It is held back while selecting, since chat text is
mostly selected to copy, and pins when the composer is pressed or
focused (capture phase, before the press collapses the selection).

The model sees it as a quote, not a file: "[Quoted from earlier in this
conversation]" for the same thread, or the source chat's title and path
for another one. Whether it is the same thread is fixed on the ref at
capture, because the block is rebuilt to strip it and a thread's path
changes when it is auto-titled.

Closes #591

Co-Authored-By: Claude <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no blocking issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Adds chat-message quotes to the composer.

  • People can quote selected text from chat messages.
  • Chat quotes tell the model which conversation they came from.

All four earlier, unnumbered findings are addressed: quotes exclude intervening tool output, destination labels are set at send time, popout documents receive selection listeners, and saved quote paths follow chat renames. No new actionable issues were found.

Reviews (6) · Last reviewed commit: "fix(chat): keep the highlight on a pinne..." · Reviewed by Greptile

Comment thread src/hooks/useSelection.svelte.ts Resolved
Comment thread src/hooks/useSelection.svelte.ts Resolved
Comment thread src/hooks/useSelection.svelte.ts Resolved
- A selection spanning several messages keeps only their text: the UI
  between them (an expanded tool card's output, footers) is cut out,
  one clamped range per message element.
- Whether a quote comes from the same thread is decided at send time,
  not when it was pinned, so a quote that outlives the composer
  switching threads is no longer sent as "this conversation".
- selectionchange is listened on every window document (popouts too),
  and the pinned highlight is registered on the window that owns it.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread src/components/chat/Input.svelte Resolved
Leo310 and others added 4 commits November 25, 2026 20:01
A chat auto-titles itself after its first turn. A quote pinned from it
kept the old path, so at send time it no longer matched the composer's
thread and went out labelled as coming from another chat.

Co-Authored-By: Claude <noreply@anthropic.com>
A chat selection now shows its chip live, like a note selection. The
composer still pins it; a selection that collapses before that (copied,
then clicked away) drops the chip.

Co-Authored-By: Claude <noreply@anthropic.com>
A selection is a quote wherever it came from; the icon also sets its chip
apart from the file chips of visible notes. The icon is no longer stored on
the SelectionRef; an icon on older persisted refs is ignored.

Co-Authored-By: Claude <noreply@anthropic.com>
The highlight went to the active Markdown view, but a note selection is
pinned on active-leaf-change, when the active view is already the chat, so
no editor ever got it. Find the editor that owns the selection by path.

Co-Authored-By: Claude <noreply@anthropic.com>
@Leo310
Leo310 merged commit 32ba5e1 into main Nov 26, 2026
3 checks passed
@Leo310
Leo310 deleted the feat/chat-selection-attach branch November 26, 2026 11:17
Leo310 added a commit that referenced this pull request Nov 26, 2026
Google Gemini (#584), Mistral (#585) and LM Studio (#583) as providers, a
directory of OpenAI-compatible services under More providers (#589), and a
per-agent reasoning effort (#582). Quoting chat text into the input (#593),
chats that open where the last one was (#592), model details read from each
provider instead of models.dev (#586), and mobile fixes for the sidebar
drawer, the Cupertino theme, the formatting toolbar and the empty-chat
greeting (#594, #595, #596).

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Selecting text inside the chat view should also be attachable to chat input

1 participant