feat(desktop): comment on selected chat text

UR
1d ago
+470-3

ParaDev desktop users can select text in an agent response, add a comment, and append the quote and comment to the current prompt draft.

Before: Source-derived: selecting response text offers no action to add an annotated quote to the prompt.

After: Source-derived, covered by component tests: select text → Add comment → enter feedback → Add to prompt. The existing prompt and attachments remain, and nothing is sent to the agent.

Risk: Two-way door Narrow blast radius

Reversible; limited to desktop chat selection and prompt drafts. Uses the existing draft-restoration path, including its handling of a change in the active chat target. A revert removes the selection UI.

Implementation, verification, and checklist

What & why

Add a selection action to agent responses. Its popover shows the captured quote and accepts a comment. Submission appends a Markdown blockquote and the comment to the prompt draft after the popover closes. Cancel leaves the draft alone. User messages, selections across responses, other panes, and read-only subagent prompts do not offer the action. The action resets when switching chat targets. Adds the new button translation in all 18 locales. No new dependency or persisted state.

How I tested it

Verification

Verification status: WARN — tested through the real shared prompt editor in happy-dom; the Electron user journey remains unverified.

  • 15 passing tests: the new selection/comment tests and existing composer-draft tests, including the real prompt editor retaining the existing text, attachment, and caret selection.

  • 12 passing draft-segment tests, including appending to an existing prompt.

  • Focused TypeScript check for the new component and its tests passes.

  • Biome check for all changed TypeScript files and git diff --check pass.

  • bun run check:i18n passes, including strict compilation and the compiled-message ID check.

  • The broader shared-editor suite has six failures (formatting shortcuts, chip undo, and command navigation). All six also fail by name on the base commit c42dbed2 with the same installed dependencies on macOS/Bun 1.4.4.

  • Full desktop typecheck is not clean: dependency installation failed to retrieve packages including @anthropic-ai/claude-agent-sdk; public-registry downloads report ConnectionRefused and some corporate-registry tarballs return 404. No full-typecheck success is claimed.

  • Still unverified: screenshots; this isolated checkout has no configured .env, API/auth session, or running desktop instance, and dependency installation is incomplete.

  • Still unverified: video; the same missing desktop API/auth setup and incomplete dependency installation prevent recording the real baseline/head interaction.

  • Coverage: SelectionComment.test.tsx — captures a response quote, adds a comment only on submit, and preserves existing prompt text, attachment, and caret in the real editor.

  • Coverage: SelectionComment.test.tsx — Cancel leaves the prompt alone; user messages, other panes, cross-response selections, and read-only targets offer no comment action.

  • Not covered:

    • In the desktop app, select response text with mouse and keyboard, add a comment, and confirm it appears in the prompt without sending; repeat after scrolling.
    • Switch between main and subagent chats while the popover is open; confirm the comment UI resets and drafts stay with the correct target.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR)

Summary by cubic

Lets desktop users select text in an agent response, add a comment, and append the quoted text as a Markdown blockquote with the comment to the current prompt draft.

Behavior

  • A compact icon trigger appears above the selection end and only on agent responses; user messages, selections across responses or other panes, and read-only subagent prompts never show it.
  • While the popover is open, the quoted text stays tinted via the CSS Custom Highlight API and its response is ringed, since focusing the textarea hides the native selection.
  • Submitting preserves the existing prompt text, attachments, and caret, and sends nothing to the agent; cancel leaves the draft unchanged. Cmd/Ctrl+Enter submits the comment.
  • The comment UI resets when switching chat targets, and new button translations cover all 18 locales.

Summary by CodeRabbit

  • New Features
    • Select text in an assistant response, add a comment, and insert the quoted text and comment into the prompt.
    • Existing draft text and attachments are preserved when adding a comment. Selected text is highlighted while commenting, and selections are cleared when scrolling.
    • Commenting is unavailable when the active subagent is blocked.
  • Localization
    • Added translations for the “Add to prompt” label in supported languages.