Skip to content

feat(web): optional type-to-cite, adapted from upstream #32600 - #82

Merged
e-kotov merged 1 commit into
mainfrom
feat/type-to-cite-20261113
Nov 13, 2026
Merged

e-kotov merged 1 commit into
mainfrom
feat/type-to-cite-20261113

Conversation

@e-kotov

@e-kotov e-kotov commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Summary

Adapts pingdotgg#32600 at 0c103588e109fc7da58b3e88e78c4520acce88aa onto fork main a74b2b1393ef8a3c19d1669d76c1b6f28877586b, independently of sync PR #81.

  • Optional Settings → Appearance behavior: typing/pasting with selected assistant text starts a citation comment. Existing composer behavior remains the default.
  • Retains fork hidden-chat, claimed-shortcut, explicit paste-as-text, and existing custom settings behavior. Does not replace fork-owned tests.
  • Moves routing/buffering, setting UI and new tests into fork-owned files; registers feature protection and explicitly records reviewed upstream mount footprint.
  • Fixes an independently reproduced upstream lifecycle defect: unregistering the foreground selection toolbar previously left its pending buffer capturing later input. Disposal now releases only its own active buffer; regressions cover foreground teardown and replacement.

Upstream CI diagnosis

Current upstream red run 43296469296, job 131456121715, had 3971 passes and one failure in unchanged CloudVoiceConfiguration.browser.test.tsx:238: the OpenRouter Save click had only 189ms remaining in the 15-second test budget. The voice test and production panel were unchanged by pingdotgg#32600; citation tests passed. This is not evidence of a citation bug. No voice assertion or timeout has been weakened here. Dedicated fork CI reruns that test alongside citation/shortcut regressions.

Validation

  • Frozen offline install completed with pnpm 12.14.0 / Node 26.12.1.
  • Web effect-tsgo tsrs --noEmit: passed.
  • Targeted vp lint and formatting: passed.
  • Knip files/dependencies: passed. Initial parallel export scan was killed (137); sequential knip:check:exports retry passed.
  • Fork feature guard: 34 features / 206 protecting tests passed; footprint guard passed.
  • Actual production routing/buffer probe: after toolbar disposal, later input is not prevented, original buffer remains unchanged and pending=false. This uses browser mocks, not a full thread-switch UI test.
  • New/old browser regressions attempted locally, but Chromium could not start (socket() EPERM); Playwright download also returned an invalid archive. Installed Chromium fallback was equally startup-blocked. No local browser pass or UI screenshot claimed.
  • Remote tree 579c2f914ca677772c0cb645a0b504e6bb1bf8eb exactly matches the locally checked source tree.

Pending before ready

Dedicated Fork type to cite CI executes new citation tests plus existing citation drafts, chips, shortcuts and the upstream voice failure case. Browser execution and visual before/after evidence remain required; this is deliberately a draft, not a merge-ready claim. No upstream changes or merge performed.

Adapt pingdotgg#32600 at 0c10358. Preserve fork shortcut/paste guards, isolate feature logic and tests, and release pending input on foreground teardown.
@e-kotov
e-kotov marked this pull request as ready for review November 13, 2026 21:29
@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects input routing in the web chat composer when assistant text is selected.

Fix citation input inside math and move the direct router tests to the required unit-test layer before merging.

Findings

  1. P1 Math swallows citation input ▶
  2. P2 Logic tests require Chromium ▶

Summary

Adds optional type-to-cite behavior while keeping composer input as the default.

  • Typing on selected assistant text can start a citation comment.
  • The citation comment editor keeps the text that started it.
  • Removing a citation toolbar stops it from capturing later input.

Acknowledgment: e-kotov explicitly records browser execution and visual evidence as pending because Chromium could not start locally. Those missing checks are not reported again.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Typing or plain-text paste] --> B{Type-to-cite enabled?}
  B -->|No| C[Composer]
  B -->|Yes| D{Selection and insertion accepted?}
  D -->|No| C
  D -->|Yes| E[Insert citation and buffer comment]
  E --> F{Citation node exists?}
  F -->|Yes| G[Open comment editor]
  F -->|No, inside math| H[Release buffer without restoring input]
  G --> I[Focus editor and release buffer]
Loading

Reviews (1) · Last reviewed commit: "feat(web): adapt optional type-to-cite w..." · Reviewed by Greptile

Comment on lines +1767 to +1773
canInsertCitation: () => {
if (!editor || literalText) return false;
const { $from } = editor.state.selection;
const citationType = editor.schema.nodes["composer-citation"];
return (
!!citationType && $from.parent.canReplaceWith($from.index(), $from.index(), citationType)
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Math swallows citation input

canInsertCitation accepts a caret inside editable math such as $x + y$, because the surrounding paragraph allows citation nodes. But buildTiptapContent keeps the formula's contents as plain text, including the inserted citation. With type-to-cite enabled, selecting assistant text and typing consumes the character, inserts a raw citation link into the formula, and never opens the comment editor.

Check whether the proposed insertion actually produces a citation node before accepting it. Otherwise, leave the input for the composer.

},
);

it("releases pending input when its toolbar leaves the foreground", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Logic tests require Chromium

This buffer-lifetime test and the replacement case at line 351 call the router directly without mounting a component or testing browser input. AGENTS.md requires logic called by components to use unit tests, reserving browser tests for behavior that needs a real browser. These cases add browser setup and dependencies to checks that only need small source and selection stand-ins.

Move both cases into a unit test beside forkCitationInputRouting.ts before merging to satisfy the repository requirement.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@e-kotov
e-kotov merged commit bdd9cae into main Nov 13, 2026
11 checks passed
@e-kotov
e-kotov deleted the feat/type-to-cite-20261113 branch November 13, 2026 21:36
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