Skip to content

feat(native): cite assistant selections in the composer - #96

Merged
rynfar merged 3 commits into
nativefrom
nw/92-citations
Nov 3, 2026
Merged

rynfar merged 3 commits into
nativefrom
nw/92-citations

Conversation

@rynfar

@rynfar rynfar commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Assistant text selections had no citation action or composer citation editor in the native client. This ports an initial TR-CITE slice: the Cite toolbar, citation chips with optional comments, web-compatible t3-citation://v1 links carried through the existing prompt/draft/send path, and source-row reveal with bounded history paging.

The toolbar uses the pinned markdown renderer's existing shared selection, retaining links, highlighted code and normal copy handling. Pure UTF-16 selector, serialization/validation, dismissal, history and phase rules live in t3-core with cases mirroring the web tests. Selection state is bounded; nothing repaints continuously. The snapshot driver gains --type for focused text input.

Citation insertion uses the active caret, including backward selections, and preserves the retained prompt text; cancellation removes only the new link and inserted spaces. Selectors exclude renderer-added trailing paragraph whitespace and refuse repeated or overlapping matches. Chips retain original link bytes and ranges for editing/removal. Comment drafts settle before a question stashes the prompt and retire when the prompt is replaced. Open comment editors relocate by unique raw link bytes on every prompt edit; missing or duplicate links close the editor and unblock Send. Each source activation can retry an old page error, and Escape cancels pending navigation independently of the selection toolbar.

TR-CITE remains partial, and #92 stays open. Remaining gaps:

  • Inline rich composer chips: this slice follows native context chips with a chip row and serialized links still visible in the textarea.
  • Exact occurrence offsets for repeated quotes: ambiguous quotes withhold Cite rather than save the wrong source position.
  • Source-anchored comment popups, source-disappearance observation, quote-range highlighting/pulse and toolbar restoration after scroll; this slice anchors comments at the composer and tints the revealed row.
  • Sent-message citation chip/popover rendering, cross-environment source navigation, and citation insertion while answering a provider question or editing a queued message.

Verification:

  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace -- --test-threads=1: 1,025 tests passed serially after rebasing on fork/native, including the three latest regressions first observed failing without their fixes.
  • Theme generation, 42 parity sync tests, conformance generation check, and vp run check:changed fork/native passed.
  • Offscreen smoke-server captures: ordinary selection across inline code, multiline code selection, Cite, chip/comment editor. No turn was dispatched; the wire link is checked against a known web URL in the core test. Normal copy code paths were retained; verification did not invoke Copy.
  • Read-only probe: Connecting → Connected, shell/config synchronized, showcase thread status=completed, runtimeMode=auto-accept-edits, no pending requests.

Local offscreen evidence (absolute paths on Trevor’s machine):

  • Before: /tmp/t3-92-source-before.png
  • Selection toolbar: /tmp/t3-92-toolbar.png
  • Chip and comment editor: /tmp/t3-92-chip-editor.png
  • Saved comment: /tmp/t3-92-final-comment.png
  • Multiline code selection: /tmp/t3-92-code-selection.png
  • Tab/Enter citation activation: /tmp/t3-92-keyboard-verified.png
  • Escape cancellation: /tmp/t3-92-cancel-verified.png

Additional local offscreen regression evidence:

  • Insert at caret with retained selection: /tmp/t3-92-review-cite-at-cursor.png
  • Prompt preserved after Cancel: /tmp/t3-92-review-preserved-prompt.png
  • Final-word selection: /tmp/t3-92-review-final-word.png
  • Noncanonical link: /tmp/t3-92-review-raw-link.png
  • Noncanonical link comment saved: /tmp/t3-92-review-raw-saved.png
  • Noncanonical link removed: /tmp/t3-92-review-raw-removed.png
  • Noncanonical link moved by a prompt edit, then saved: /tmp/t3-92-review-raw-shifted-saved.png

Latest local offscreen regression evidence:

  • Backward selection active-caret insertion: /tmp/t3-92-last-backward-caret.png
  • Overlength draft follows moved raw link: /tmp/t3-92-last-comment-moved.png
  • Removed link closes overlength editor: /tmp/t3-92-last-comment-removed.png
  • Duplicate raw links close overlength editor: /tmp/t3-92-last-comment-ambiguous.png

Built with GPT-6.1 Sol in Codex

@rynfar
rynfar merged commit fa22673 into native Nov 3, 2026
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