Skip to content

feat(web): edit and number chat annotations - #5267

Draft
darox wants to merge 2 commits into
pingdotgg:mainfrom
darox:codex/chat-annotations-full
Draft

feat(web): edit and number chat annotations#5267
darox wants to merge 2 commits into
pingdotgg:mainfrom
darox:codex/chat-annotations-full

Conversation

@darox

@darox darox commented Aug 3, 2026

Copy link
Copy Markdown

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:

  • See numbered markers beside annotated assistant text.
  • Distinguish plain selections from selections with comments.
  • Click a marker to highlight the source text and edit or delete pending annotations.
  • Keep multiple annotations tied to their exact source ranges while reviewing them in the composer.

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.

Before: response-text annotations without numbered source markers

After

Selecting response text still opens the existing Add to chat action.

selection-popover

Pending annotations now show numbered markers beside the source response and a matching composer summary.

numbered-annotation

Clicking a marker highlights the source text and opens an editor for the comment.

edit-annotation

Multiple annotations receive stable sequential numbers and remain visible alongside the prompt.

multiple-numbered-annotations-with-prompt

After sending, the conversation keeps the compact annotation summary without exposing serialized markup.

sent-summary

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 typecheck
  • git diff --check
  • Manual verification in an isolated local T3 environment: selection popover, optional comment entry, numbered markers, edit/delete editor, multiple annotations, and sent summary.

Checklist

  • This PR is explicitly stacked on feat(web): attach selected response text #5224
  • This PR contains one follow-up commit
  • I explained what changed and why
  • I included before/after screenshots for the UI changes
  • I included interaction coverage in the validation notes

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 optional onTextSelection. 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 to sourceStart / sourceEnd for stable highlighting.

Composer and send store chatSelectionAnnotations in 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

  • Users can select text in assistant messages to create numbered annotations; a popover (ChatTextSelectionPopover) lets users add an optional comment before saving.
  • Annotations render as numbered margin indicators (AssistantMessageIndicators) with highlight overlays; clicking opens an inline editor (ChatSelectionAnnotationEditor) to edit or delete.
  • Pending annotations are appended to the prompt on send (via appendChatSelectionAnnotationsToPrompt) and shown as a removable chip in the composer (ComposerPendingChatSelectionAnnotations).
  • User messages with sent annotations show a compact summary chip with a count and hide the appended annotation markup from the visible bubble and copy text.
  • Annotation state is persisted in composerDraftStore (bumped to version 9) and survives send failures via draft restoration.
  • Risk: DOM text-index diffing and ResizeObserver-driven highlight recomputation in ChatMarkdown add 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.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3699bf60-f320-4a26-af21-f94c0e3642d6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Aug 3, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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]);

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.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9c74775. Configure here.

Comment thread apps/web/src/components/chat/ChatTextSelectionPopover.tsx Outdated
Comment thread apps/web/src/components/ChatMarkdown.tsx Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@darox
darox marked this pull request as draft August 3, 2026 09:39
@darox
darox force-pushed the codex/chat-annotations-full branch from 9c74775 to 71f95fa Compare August 3, 2026 09:48
Comment thread apps/web/src/components/chat/ChatSelectionAnnotationEditor.tsx
@darox
darox force-pushed the codex/chat-annotations-full branch from 71f95fa to 9009d69 Compare August 3, 2026 11:26
Comment thread apps/web/src/components/ChatMarkdown.tsx
Comment thread packages/shared/src/chatSelectionAnnotation.ts
@darox
darox force-pushed the codex/chat-annotations-full branch 2 times, most recently from 3ab570f to 62408e0 Compare August 3, 2026 11:42
Comment thread apps/web/src/components/ChatMarkdown.tsx Outdated
Comment thread packages/shared/src/chatSelectionAnnotation.ts
Comment thread packages/shared/src/chatSelectionAnnotation.ts
@darox
darox force-pushed the codex/chat-annotations-full branch 2 times, most recently from 5f839b6 to 6f185af Compare August 3, 2026 15:22
Comment thread apps/web/src/components/ChatMarkdown.tsx
@darox
darox force-pushed the codex/chat-annotations-full branch from 6f185af to 1302b0c Compare August 3, 2026 15:44
Comment thread apps/web/src/components/chat/MessagesTimeline.tsx Outdated
Comment thread apps/web/src/components/ChatMarkdown.tsx
Comment thread apps/web/src/components/ChatView.logic.ts
@darox
darox force-pushed the codex/chat-annotations-full branch from 1302b0c to a867790 Compare August 3, 2026 16:06
Comment thread apps/web/src/components/chat/MessagesTimeline.tsx Outdated
@darox
darox force-pushed the codex/chat-annotations-full branch from a867790 to 2f32022 Compare August 3, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant