feat(web): edit and number chat annotations - #5267
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9c74775. Configure here.
| const [editorAnchorRect, setEditorAnchorRect] = useState< | ||
| ChatTextSelectionPopoverProps["rect"] | null | ||
| >(null); | ||
| const indicators = useMemo(() => deriveChatSelectionIndicators(annotations), [annotations]); |
There was a problem hiding this comment.
Mismatched annotation marker numbers
Medium Severity
Pending annotation markers are numbered from the per-message annotation list via deriveChatSelectionIndicators, while the composer chip numbers the full pending list globally. When annotations span multiple assistant messages, marker numbers restart at 1 on each message and no longer match the composer summary, breaking the intended numbered link between them.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 9c74775. Configure here.
ApprovabilityVerdict: Needs human review 2 blocking correctness issues found. This PR introduces a substantial new feature (chat text selection annotations) with multiple new UI components, state management changes, and cross-component integration. New features with significant new logic warrant human review, and unresolved review comments identify correctness issues with marker numbering, popover positioning, and duplicate text matching. You can customize Macroscope's approvability policy. Learn more. |
9c74775 to
71f95fa
Compare
71f95fa to
9009d69
Compare
3ab570f to
62408e0
Compare
5f839b6 to
6f185af
Compare
6f185af to
1302b0c
Compare
1302b0c to
a867790
Compare
a867790 to
2f32022
Compare


Note
Stacked on pingdotgg/t3code#5224. The branch contains exactly one follow-up commit on top of #5224. GitHub cannot use a fork-only branch as an upstream PR base, so this PR targets
main; review the follow-up commit after #5224 lands.What Changed
Adds editing and numbered indicators to the response-text annotations introduced in #5224.
Users can now:
Why
The base annotation flow makes it possible to attach selected response text, but pending annotations are difficult to locate again and cannot be corrected without removing and recreating them. Numbered markers make the relationship between the composer summary and assistant response obvious, while the editor keeps small comment changes fast.
UI Changes
Before
The base flow exposes selection and composer actions, but does not show numbered source markers or an edit affordance.
After
Selecting response text still opens the existing Add to chat action.
Pending annotations now show numbered markers beside the source response and a matching composer summary.
Clicking a marker highlights the source text and opens an editor for the comment.
Multiple annotations receive stable sequential numbers and remain visible alongside the prompt.
After sending, the conversation keeps the compact annotation summary without exposing serialized markup.
Validation
./node_modules/.bin/vp test run apps/web/src/chatSelectionAnnotation.test.ts apps/web/src/components/ChatView.logic.test.ts apps/web/src/components/chat/MessagesTimeline.test.tsx apps/web/src/composerDraftStore.test.ts apps/web/src/proposedPlan.test.ts(158 passed)./node_modules/.bin/vp run --filter @t3tools/web typecheck./node_modules/.bin/vp run --filter @t3tools/shared typecheckgit diff --checkChecklist
Model: OpenAI Codex · Harness: Codex desktop
Note
Medium Risk
Large changes to message rendering, selection handling, and composer send/retry paths increase regression risk in chat UX, though behavior is covered by unit tests and markup is scoped to app-appended blocks.
Overview
Extends response-text annotations with numbered source markers, highlight/edit/delete for pending items, and a cleaner send and display path.
Assistant messages (
ChatMarkdown) now accept pending annotations and optionalonTextSelection. Selecting text opens Add to chat; numbered indicators sit beside the source range (with highlight overlays and collision-aware placement). Clicking a marker opens an editor to change the comment or remove the annotation. DOM text indexing maps selections tosourceStart/sourceEndfor stable highlighting.Composer and send store
chatSelectionAnnotationsin the draft store (persist version 9), show pending chips, count annotations toward sendable content, and append serialized<chat_selection>blocks only on send. User bubbles summarize sent annotations in a compact chip and hide raw markup; copy uses stripped text.Plan follow-up treats annotation-only drafts as plan-mode refine (not implement), and can restore prompt plus annotations if send fails.
Shared logic lives in
@t3tools/shared/chatSelectionAnnotation(format/parse, indicators, message grouping).Reviewed by Cursor Bugbot for commit 9c74775. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add text selection annotations to chat assistant messages with numbered indicators and composer chips
appendChatSelectionAnnotationsToPrompt) and shown as a removable chip in the composer (ComposerPendingChatSelectionAnnotations).composerDraftStore(bumped to version 9) and survives send failures via draft restoration.ResizeObserver-driven highlight recomputation inChatMarkdownadd per-render overhead proportional to assistant message length and annotation count.📊 Macroscope summarized 9c74775. 14 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.