Skip to content

feat(native-chat): quote a selection from an agent reply into the composer - #26018

Merged
brennanb2025 merged 4 commits into
stablyai:mainfrom
AmoabaKelvin:quote-selected-reply-text
Oct 8, 2026
Merged

brennanb2025 merged 4 commits into
stablyai:mainfrom
AmoabaKelvin:quote-selected-reply-text

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When you select text in an agent's reply, a small "Add to chat" button appears next to it. Clicking it puts that text into the message box as a quote, so you can reply to that exact part.

What Changed

Before: selecting text in a reply offered nothing except Copy in the right-click menu. To refer to part of a reply you had to copy it, click into the message box, paste, and add the > yourself.

After: selecting text inside an agent's reply (with the mouse or the keyboard) shows an "Add to chat" button beside the selection. Clicking it adds the text to the message box as a markdown quote, below anything already typed, and puts the cursor on a new line under it.

  • Only text inside a single agent reply can be quoted. Your own messages, tool output, reasoning rows, and selections that span more than one reply offer nothing.
  • The button stays with the selected text while the chat scrolls, including while a reply is still streaming, and hides once that text scrolls out of view.
  • It is not offered while the message box cannot take text (for example when a question card has replaced it, or another device holds the terminal input).
  • It works the same in structured chats and in the chat view over a terminal agent.

How it works: the prose of an agent reply is marked in the transcript. On mouse or key release the chat checks whether the whole selection sits inside one marked reply; if so it opens a small popover anchored to the selected text. The message box gained one operation, "append this text after the draft", built on the same rule Stop and a queued message's Edit already use to hand text back to the draft.

Why

Replying to one sentence of a long answer is common, and the manual copy-and-paste route is slow enough that people skip it and write vaguer follow-ups.

Alternatives considered:

  • A citation chip that links back to the source message (as some other chat clients do). It needs a new format in the draft and expansion on the host before the agent sees it, which reaches older remote hosts and cannot work where the text is typed into a terminal agent. The agent already has its own reply, so the quoted text is enough.
  • A right-click menu item instead of, or as well as, the button. The button appears at the moment you would reach for it; a second entry point added state to the menu for little gain.
  • Closing the button on any scroll. Simpler, but it would vanish whenever a streaming reply auto-scrolls, which is exactly when people quote.

Visual Proof

Before:

CleanShot.2026-10-07.at.12.42.37.AM.mp4

After:
https://github.com/user-attachments/assets/4b38ebe1-b606-4890-be1e-670baa135004

Testing

Steps to try it:

  1. Open a chat with an agent and get a reply.
  2. Drag across some text in the reply and release. "Add to chat" appears above the pointer.
  3. Click it. The text lands in the message box as > … lines with the cursor on a blank line below.
  4. Type something first, then quote: the quote is added below what you typed.
  5. Double-click a word (the button appears after a short pause), then triple-click a paragraph, including the last paragraph of a reply.
  6. Select with Shift+arrow keys: the button appears at the end of the selection.
  7. Select text in your own message, or across two replies: nothing is offered.
  8. With the button showing, scroll the chat: it follows the text and hides when the text leaves view.
  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

New tests cover: quoting as a blockquote, nothing offered outside a reply, a triple-click whose range runs into the next block or over unselectable text, a press that leaves the selection unchanged, keyboard selection, a message box that cannot take text, the offer going away when the selection does, and which message rows are quotable.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no new data leaves the app; the quote is ordinary draft text.
  • Cross-platform: no platform-specific code or shortcuts. Not run on Windows or Linux.
  • Remote SSH / backwards compatibility: renderer only. No IPC, RPC or stored-state change, so mixed client and host versions are unaffected.
  • Mobile: not touched.
  • Performance: nothing runs while the button is closed beyond setting a flag; position updates happen only while it is open.
  • Quoting the same text twice in a row adds it once. That is the existing rule for text handed back to the draft.
  • Quoted text is the rendered text, so inline code and list markers lose their markdown.
  • NativeChatResolvedView.tsx was at the 400-line limit, so one local was shortened there to make room for the new argument.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

Native chat can offer a quote action for selected text in eligible message content. The selection reader validates and formats the text, and the composer API can append the formatted quote after the current draft. The context-menu hook mounts the offer and receives the required composer ref. Translations and tests were added or updated.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to ee947

If the composer becomes unavailable after a quote offer appears, clicking can dismiss the offer without adding the text; users can retry by selecting text again. This is a limited, recoverable issue, and a focused draft-and-caret test would improve confidence before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.62% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 18 files. (6 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the user experience, implementation, rationale, visual proof, testing, platform considerations, and checklist. However, it omits the required Linked Issue sectio… Add the required Linked Issue section with a valid issue reference, such as Fixes #12345. Also complete the Review section if the repository requires content there.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main feature: quoting selected text from an agent reply into the composer.
Full details: Docstring Coverage

Explanation

Docstring coverage is 47.62% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 18 files. (6 skipped: 6 unsupported.)

Full details: Description check

Explanation

The description is detailed and covers the user experience, implementation, rationale, visual proof, testing, platform considerations, and checklist. However, it omits the required Linked Issue section and does not provide a Fixes #... reference.

  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f384254-9eb7-45a7-a0ea-2afcf2307849
📥 Commits

Reviewing files that changed from the base of the PR and between 9c6702b and 7a1232b.

📒 Files selected for processing (23)
  • src/renderer/src/components/native-chat/NativeChatMessageList.reader-navigation.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatResolvedView.prompt-card-composer.test.tsx
  • src/renderer/src/components/native-chat/NativeChatResolvedView.tsx
  • src/renderer/src/components/native-chat/NativeChatSelectionQuote.test.tsx
  • src/renderer/src/components/native-chat/NativeChatSelectionQuote.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.test-harness.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-reveal-focus.test.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-types.ts
  • src/renderer/src/components/native-chat/native-chat-paste-routing.test.tsx
  • src/renderer/src/components/native-chat/native-chat-quote-selection.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-handle.ts
  • src/renderer/src/components/native-chat/use-native-chat-context-menu.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-context-menu.tsx
  • src/renderer/src/components/native-chat/use-native-chat-typed-insertion.ts
  • src/renderer/src/components/native-chat/use-structured-native-chat-pane-commands.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

…6018-merge

# Conflicts:
#	src/renderer/src/components/native-chat/NativeChatStructuredSession.test-harness.tsx
…6018-merge

# Conflicts:
#	src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
#	src/renderer/src/components/native-chat/use-native-chat-composer-handle.ts
#	src/renderer/src/components/native-chat/use-native-chat-context-menu.test.tsx
#	src/renderer/src/components/native-chat/use-native-chat-context-menu.tsx
#	src/renderer/src/components/native-chat/use-native-chat-typed-insertion.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/renderer/src/components/native-chat/NativeChatSelectionQuote.test.tsx (1)

76-86: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the real composer append path.

NativeChatSelectionQuote.test.tsx:76-86 injects a vi.fn for appendText, so the test stops before useNativeChatTypedInsertion.appendText. Add a fixture with an existing draft and assert the combined draft and final caret after clicking Add to chat. The current test can pass if either behavior regresses.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20e70371-e6d5-4f0f-bddc-c68b8ab6201e
📥 Commits

Reviewing files that changed from the base of the PR and between 57de799 and ee947a1.

📒 Files selected for processing (8)
  • src/renderer/src/components/native-chat/NativeChatSelectionQuote.test.tsx
  • src/renderer/src/components/native-chat/NativeChatSelectionQuote.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/components/native-chat/NativeChatSelectionQuote.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor

Changed the button wording from "Quote" to "Add to chat" in ee947a1, since that's the common label for this action. The icon is now the message-plus icon. I also updated the translations (es/fr/ja/ko/zh), the tests, and the PR description. What the button does hasn't changed: it still adds the selected text to the message box as a > quote.

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.

2 participants