Skip to content

fix(shared): keep words separated when hiding citations - #33049

Open
Na0s wants to merge 2 commits into
pingdotgg:fix/issue-30979from
Na0s:fix/citation-word-boundaries
Open

Na0s wants to merge 2 commits into
pingdotgg:fix/issue-30979from
Na0s:fix/citation-word-boundaries

Conversation

@Na0s

@Na0s Na0s commented Nov 8, 2026

Copy link
Copy Markdown

The web-citation fix in #31053 hides the raw markers from #30979, but can also eat the only separator between words: red citeturn0search0blue becomes redblue in display, native Markdown, and copy.

This is a stacked follow-up to #31053, targeting fix/issue-30979, not a second implementation of that fix. It addresses the separator issue already identified in review. Please merge the base first (or fold this correction into it).

Keep the existing delimiter recognizer and use the Markdown AST's next inline source position to decide whether a consumed space/tab is still needed. The source-offset projections insert that separator after closing inline syntax: **red citeturn0search0**blue becomes **red** blue, not the invalid Markdown **red **blue. Block boundaries stop the lookahead. Existing code exclusions and autolink cleanup stay in place; no storage, provider protocol, UI components, or source-link UX changes.

Investigation

Verification

  • Added the regression table first. On the base implementation, the initial 18 selected cases produced 12 failures / 6 passes, including plain text, tabs, and both sides of bold spans; the failure was redblue instead of red blue.
  • vp test run packages/shared/src/codexMarkdownDirectives.test.ts: 65 passed. Covers all three shared entry points, round-trips projected Markdown through the ordinary parser, and includes directive boundaries, existing/trailing spaces, paragraphs, and headings. Existing code and autolink tests pass too.
  • vp run check:changed origin/fix/issue-30979: passed format, lint, both knip phases, typecheck of 34 affected/dependent packages, and 67 tests in 2 files.
  • vp test run packages/shared/src/markdownPipeline.test.ts apps/web/src/markdown-incremental.test.tsx: 25 passed.
  • No full desktop/mobile app session was manually exercised; verification is of the shared parsing and source-projection behavior, not a native UI/device run. CI still owns the full suites/build.

Created with gpt-6.1-sol in Codex (T3 Code).

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 8, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at df1b364

Macroscope's review found this PR approvable — This preserves word separation when hidden citation markers occur within or between Markdown spans. Its effects are limited to displayed and copied text, with no storage or product-default changes.

You can add or adjust custom eligibility rules. Learn more.

@maria-rcks

maria-rcks commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Written by claude-opus-5-5 on behalf of Maria

Takeover update at f7201b053c

the stacked base fix/issue-30979 gained three commits that fix the same separator bug with a different rule, so this pr conflicted with it. merged the base into this branch (merge commit, no rebase) and kept both sides:

  • from the base: its delimiter rule (DROPS_PRECEDING_SPACE), link and reference destination cleanup, file citation handling, and **Result**. dropping the space before closing emphasis.
  • from this pr: a marker that ends a text node is judged by the next inline node, stopping at the block, and copy/native output puts the kept space after closing syntax (**red** blue, not **red **blue).
  • one small addition to make the two agree: the next node is judged by its first content, so red <cite>:codex-followup[blue] keeps its space instead of treating : as punctuation.

before the merge resolution, this pr's separator table failed 8 cases against the base's current code (**red **blue in copy and native output, redblue around follow-up directives).

  • blacksmith: vp test run packages/shared/src/codexMarkdownDirectives.test.ts packages/shared/src/markdownPipeline.test.ts apps/web/src/markdown-incremental.test.tsx passed 108 of 108.
  • blacksmith: vp run check:changed against the base tip passed format, lint, knip, typecheck of 35 packages, and 83 tests.
  • no review-bot findings were open.

unverified at this head: the live web render and copy run below was done at df1b364, before the merge, and was not repeated. native and desktop remain unverified as before.


Earlier verification at df1b364 (written by gpt-6.1-sol)

verified as-is at df1b36493c92132edaa70f49a8342fc01bc3c1e9 on linux using the repository’s playwright dependency and /usr/bin/google-chrome.

created a real git repository, added it through the web app, and submitted real codex gpt-6.1-sol turns through the local provider proxy. the prompt asked the provider to emit literal citation-marked markdown, so the boundary cases were deterministic. no replay provider, mocks, seeded messages, or direct database writes. read-only inspection confirmed the assistant response text was identical on main and the pr.

  • github/main at b48b8ea2a0: reproduced raw citation markers in rendered and copied output.
  • stacked base at 6ab7d10a45: reopening that real response reproduced redblue in plain text, before bold, and after bold. copying also lost the separator.
  • pr head: all three cases render red blue. clicking copy message produces the expected markdown exactly, including red **blue** and **red** blue.
  • nearby behavior: existing whitespace and paragraph boundaries stay intact; inline and fenced code retain literal markers; both bare and ordinary link destinations remain https://example.com.
  • restarted the pr server and reopened the thread: the response persisted and still rendered correctly.
  • blacksmith: vp test run packages/shared/src/codexMarkdownDirectives.test.ts packages/shared/src/markdownPipeline.test.ts apps/web/src/markdown-incremental.test.tsx passed all 90 tests in 3 files. pr status reported 30 successful checks, zero failing or pending.

main before:

main shows raw citation markers

stacked base before:

stacked base joins red and blue

pr after, matching response content:

pr preserves word boundaries and code exclusions

copy and paste interaction, inspected after upload with playback and seeking:

copy message and paste into the composer

Not verified

native ios/android rendering and copy, and the electron desktop shell were not exercised on this linux web run. native markdown projection is covered by the existing shared tests, but that is not a native-device verification. actual web-search-generated source metadata was not exercised; this run used literal citation markers emitted by the real provider. no source changes or pushes were needed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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.

2 participants