Skip to content

fix(shared): thread find no longer matches across line breaks in user HTML - #49449

Merged
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
only21mil:fix/shared-thread-find-splits-multiline-user-inline-html
Dec 5, 2026
Merged

juliusmarminge merged 3 commits into
pingdotgg:mainfrom
only21mil:fix/shared-thread-find-splits-multiline-user-inline-html

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

Multi-line raw HTML in a user paragraph or list item (Fix <Button\nvariant="outline"> and <Button variant="ghost">) causes thread find to match across the break and shift highlights instead of splitting at <br>, because markdownThreadFindText collapsed raw-HTML newlines into spaces.

Change

packages/shared/src/markdownListIndentation.ts records recovered over-indented list items and their blocks during its recursive pass, so packages/shared/src/threadFindText.ts skips list-item line splitting on them at any nesting depth. threadFindText.ts also notes direct list-item HTML blocks during remark-rehype and splits user raw-HTML line breaks where ChatMarkdown/wordsHast inserts <br>: paragraphs, tight list items, and recovered paragraphs drop trailing break spaces (without touching preceding inline elements) and leading continuation indentation, while regular list-item HTML blocks keep indentation. Footnote HTML blocks, recovered list-item siblings, root/blockquote blocks, headings, <pre>, and assistant HTML stay unchanged (+16 cases in threadFindText.test.ts).

Scope

Two source files (plus one test file) in packages/shared; bug fix for wrong search match counts and shifted active highlights, reproducible from the one-line trigger above, so no separate issue is needed.

Verification

Trigger: For <Button variant above, the server indexer found 2 matches vs 1 in the rendered DOM.
Setup: Linux x86_64, Node v26.13.1 (vp env exec), Vitest + Chromium, fresh run per commit (temp probe removed before check:changed). An AI agent ran these.
Steps: Same threadFindText.test.ts (24 cases) and 65-case Chromium <ChatMarkdown> + collectThreadFindRanges probe on base vs candidate, plus 100k-space timing and check:changed.

Before (3f1c1722f3e4):

# unit tests: 12 failed | 12 passed (24) — 63ms
# Chromium probe: 43/65 mismatches
MISMATCH: inline HTML in paragraph (user)
  DOM: ["Fix <Button"," variant=\"outline\"> and <Button variant=\"ghost\">"]
  SRV: ["Fix <Button variant=\"outline\"> and <Button variant=\"ghost\">"]
  query="<Button variant" DOM=1 SERVER=2

After (b6ded180c2e3):

# unit tests: 24 passed (24) — 54ms
# Chromium probe: 65/65 passed (0 mismatches)
PASS: inline HTML in paragraph (user) => ["Fix <Button"," variant=\"outline\"> and <Button variant=\"ghost\">"]
# 100k-space timing: 15.68 ms (before tag), 10.00 ms (inside tag)

Not shown: Interactive find-bar clicks/screenshots (no UI code changed; the visible effect is corrected find-bar counts and highlights, verified via rendered DOM ranges in Chromium). Full CI left to CI (check:changed passed on Node v26.13.1).

Full verification logs (pinned Node v26.13.1 `check:changed`, DOM parity, and linear-time summary)

Test file: packages/shared/src/threadFindText.test.ts

vp env exec --node 26.13.1 vp run check:changed 3f1c1722f3e423850fe63dff499b2b314eb8d5e5 on b6ded180c2e3

vp env exec --node 26.13.1 node -v → v26.13.1 (pinned engines.node).

check:changed summary
  pass  format  0.5s
  pass  lint  0.6s
  pass  knip  17.3s
  pass  i18n  17.0s
  pass  typecheck (38 packages)  11.7s
  pass  test (3 files)  4.1s
  CI also runs: full test suites, build, release smoke
  unused patch check skipped: no dependency files changed

Test files run by check:changed under Node v26.13.1:

 ✓ |root| packages/shared/src/markdownListIndentation.test.ts (3 tests) 16ms
 ✓ |root| packages/shared/src/threadFindText.test.ts (24 tests) 53ms
 ✓ |t3| src/provider/AgentContextBudget.test.ts (2 tests) 74ms

 Test Files  3 passed (3)
      Tests  29 passed (29)

Standalone unit run (vp env exec --node 26.13.1 vp test run packages/shared/src/threadFindText.test.ts):

 ✓ |root| packages/shared/src/threadFindText.test.ts (24 tests) 54ms

 Test Files  1 passed (1)
      Tests  24 passed (24)

Base (3f1c1722f3e4) vs Head (b6ded180c2e3) parity and timing summary (all on Node v26.13.1)

  • Base 3f1c1722f3e4: 12 failed | 12 passed (24) in packages/shared/src/threadFindText.test.ts (all 12 broken-behavior rows fail; the 8 existing tests + 4 guard rows pass); temporary Chromium <ChatMarkdown> + collectThreadFindRanges parity probe failed with 43/65 mismatches.
  • Head b6ded180c2e3: 24 passed (24) in packages/shared/src/threadFindText.test.ts; same temporary Chromium parity probe (removed before check:changed) passed 65/65 cases (0 mismatches, including single-level and nested over-indented list items recovered as prose, footnote <li> HTML blocks and footnote <p> inline HTML, tight-<li> inline HTML sandwiched between blocks, trailing spaces inside inline <code>/<a>/<strong> before <li> HTML blocks, task list items, and inline skills). The 3 non-<p> footnote parity cases were compared ignoring one pre-existing space difference before ↩ (identical on base).
  • Linear-time check on b6ded180c2e3:
100k spaces before tag: 15.68 ms, segments=2, seg0.len=100003, seg1=" y>"
100k trailing spaces inside tag: 10.00 ms, segments=2, seg0="a <x", seg1=" y>"

Sample head passes from temporary Chromium parity probe on b6ded180c2e3:

PASS: inline HTML in paragraph (user) => ["Fix <Button"," variant=\"outline\"> and <Button variant=\"ghost\">"]
PASS: inline HTML in tight list item (user) => ["Fix <Button"," variant=\"outline\"> click"]
PASS: HTML block inside list item (user) => [" <div>"," hello"," </div> "]
PASS: HTML block inside list item after text (user) => ["text"," <div>"," hello"," </div> "]
PASS: root HTML block div (user) => ["<div> hello </div>"]
PASS: HTML block inside blockquote (user) => [" <div> hello </div> "]
PASS: fenced code block with multiline HTML (user) => ["<Button\nvariant=\"outline\">\n"]
PASS: assistant inline HTML (assistant) => ["Fix  and "]
=== ALL 65/65 PASSED ===
 ✓ |@t3tools/web (browser) (chromium)| src/components/chat/__parity_probe.browser.test.tsx (1 test) 348ms

Generated with Gemini 4 Neon in T3 Code Nightly

… HTML

User messages render with parseRawHtml={false} and lineBreaks, so ChatMarkdown escapes raw HTML and inserts <br> on line breaks in paragraphs and regular list items. Previously, threadFindText.ts collapsed newlines inside user raw HTML nodes into spaces, creating phantom server matches across rendered line breaks and shifting activeOccurrence highlights.

Record recovered over-indented list items and their recovered blocks inside remarkNormalizeListItemIndentation (markdownListIndentation.ts) so nested recoveries at any depth are tracked in one place. Tag direct listItem HTML blocks and recovered over-indented list items during remark-rehype conversion in threadFindText.ts, split multi-line user raw HTML line breaks during HAST traversal for paragraphs, recovered paragraphs, and non-footnote list items, and trim trailing horizontal spaces linearly without crossing preceding inline element boundaries. Footnote list-item HTML blocks, recovered list-item siblings, root/blockquote blocks, setext headings, fenced code, and assistant HTML remain unchanged.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Dec 5, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b6ded18

Macroscope's review found this PR approvable — Thread find now respects line boundaries in user HTML, including list-item edge cases. The change is limited to search-text extraction and transient parser metadata, with no persistent-data or operational impact identified.

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

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

User Markdown processing tracks HTML in list items and recovered blocks. Text traversal preserves selected line breaks when generating searchable message segments. Tests cover line-broken HTML in user and assistant messages.

Changes: Markdown Searchable Line Breaks

Layer / File(s) Summary
Track list-item HTML during conversion
packages/shared/src/markdownListIndentation.ts, packages/shared/src/threadFindText.ts
Custom conversion handlers record HTML in list items and recovered blocks. recoveredListItemBlocks associates list items with recovered blocks when the first recovered block is a paragraph or heading.
Split selected line breaks into searchable segments
packages/shared/src/threadFindText.ts, packages/shared/src/threadFindText.test.ts
Text traversal trims whitespace before breaks and splits selected paragraph and list-item HTML line breaks. Tests cover line-broken HTML in user and assistant messages.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant UserMarkdown
  participant userProcessor
  participant textTraversal
  participant SearchableSegments
  UserMarkdown->>userProcessor: Convert Markdown with custom handlers
  userProcessor->>textTraversal: Provide converted HTML tree and list-item metadata
  textTraversal->>SearchableSegments: Emit text segments with selected line breaks
Loading

Suggested reviewers: saphid

Merge Risk: Minimal · up to 9fed7

This change makes thread-find match counts agree with the highlighted ranges when raw HTML spans several lines. No concrete merge-blocking risk is evident, and a revert would undo it cleanly.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the actual change: thread find no longer matches across line breaks in user HTML. It also uses a conventional commit prefix, fix(shared). The raw summary and PR objectives both describ…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives a reproduction trigger and the expected behavior. The Change section explains …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the actual change: thread find no longer matches across line breaks in user HTML. It also uses a conventional commit prefix, fix(shared). The raw summary and PR objectives both describe splitting user raw-HTML line breaks in threadFindText.ts so search matches align with rendered DOM ranges. The title matches the main change.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives a reproduction trigger and the expected behavior. The Change section explains the list-item recovery marking and the line-break splitting. The Scope section explains why no issue is linked. It gives a reason, not an issue link. The Verification section gives before and after test results, a Chromium parity probe, and timing data. It also names the agent and harness, as the template asks. The description has one gap. The Scope section does not link an issue or a maintainer request. It gives a reason for omitting the issue, which the template allows for small obvious fixes. The description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b6ded18 and 9fed7f1.

Files selected for processing: 1

  • packages/shared/src/threadFindText.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 5, 2026
juliusmarminge and others added 2 commits December 5, 2026 14:56
…gressions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Real web app, headless Chromium, 1280×800, light theme, fresh synthetic databases, Replay (dev). The same scenario runs on both commits. Paragraph and control use the composer; exact list messages use the real user-message RPC to preserve Markdown whitespace.

On each commit, seed a fresh project and four Replay multi-turn threads. Open each thread directly. Send the paragraph Fix <Button\nvariant="outline"> and <Button variant="ghost"> through the composer using Shift+Enter. Seed the exact tight-list user message - Fix <Button\n variant="outline"> click\n- Also <Button variant="ghost"> and recovered-list user message - <div>\n hello\n </div>\n\n <!-- next --> through the real message.dispatch RPC with createdBy=user and creationSource=web (the rich composer otherwise rewrites their Markdown). Send the plain control Control: Fix Button\nvariant outline and Button variant ghost through the composer. Ctrl+F: search <Button variant in the paragraph and tight-list threads, capture, click Next match, capture again. In recovered-list search <div> hello (three spaces), capture, then search hello and capture the visible highlight. Search Button variant in the control and step Next. Expected totals are 1, 1, 0, 1. Observed base totals are 2, 2, 1, 1; head totals are 1, 1, 0, 1.

Scenario: User HTML find respects paragraph, tight list and recovered list line breaks

Proven: the scenario fails on base 8b306d5d8f and passes on head 9fed7f1c17.

Before — base 8b306d5d8f After — head 9fed7f1c17
Result ❌ failed
ASSERTION_FAILED: expected ["1/2","1/2","1/1","1/1"] to equal ["1/1","1/1","0/0","1/1"]
✅ passed
paragraph first Base 8b306d5d8f: paragraph first Head 9fed7f1c17: paragraph first
paragraph next Base 8b306d5d8f: paragraph next Head 9fed7f1c17: paragraph next
tight list first Base 8b306d5d8f: tight list first Head 9fed7f1c17: tight list first
tight list next Base 8b306d5d8f: tight list next Head 9fed7f1c17: tight list next
recovered list first Base 8b306d5d8f: recovered list first Head 9fed7f1c17: recovered list first
recovered list visible word Base 8b306d5d8f: recovered list visible word Head 9fed7f1c17: recovered list visible word
plain control first Base 8b306d5d8f: plain control first Head 9fed7f1c17: plain control first
plain control next Base 8b306d5d8f: plain control next Head 9fed7f1c17: plain control next
failure Base 8b306d5d8f: failure

Before recording · After recording

Scenario driver (one test; not committed).

All paired screenshots and both recordings were visually inspected. The right-hand project panel is present on both sides and does not obscure the messages. Both sides show the same Working shelf layout; timing is not used as evidence.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 5, 2026
@juliusmarminge
juliusmarminge merged commit e85320e into pingdotgg:main Dec 5, 2026
56 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 5, 2026
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Dec 6, 2026
**v0.1.15-nightly.20261205.5786** · 61 changes from 12 contributors

- **Large file previews.** Load remote files that exceed the automatic preview limit.
- **Project-specific MCP servers.** Import configurations with the same name and command but different credentials or headers.
- **GitHub issue forms.** Use issue templates with numeric or boolean options and empty optional fields.
- **Cursor text generation.** Generate commit messages, branch names, and thread titles with Cursor again.
- **Workflow reasons.** Unsent workflow question reasons now survive an environment reconnect.
- **Shared worktree protection.** Deleting a thread no longer removes a worktree another thread started using during confirmation.

### Plus 53 more bug fixes and performance improvements.

<details>
<summary>Full changelog</summary>

## What's Changed
* fix(server): stopping Codex during startup no longer loses its accepted turn by @StiensWout in pingdotgg/t3code#49435
* fix(workflows): open invoked runs from older workflows by @UtkarshUsername in pingdotgg/t3code#49437
* fix(web): omit inverted line range on empty file reads by @only21mil in pingdotgg/t3code#49452
* perf(server): t3 --version no longer loads the whole CLI by @juliusmarminge in pingdotgg/t3code#49461
* fix(preview): let users load oversized files by @Yash-Singh1 in pingdotgg/t3code#49470
* fix(mobile): a saved draft waits for a project choice when its project is removed by @StiensWout in pingdotgg/t3code#49455
* fix(client-runtime): file previews refresh when a background command finishes late by @StiensWout in pingdotgg/t3code#49458
* fix(server): fixed-time scheduled tasks interrupted before dispatch no longer skip the slot by @taogezhizun in pingdotgg/t3code#49417
* perf(web): reuse the read-only file preview cache key by @UtkarshUsername in pingdotgg/t3code#49464
* fix(shared): thread find no longer matches across line breaks in user HTML by @only21mil in pingdotgg/t3code#49449
* fix(web): ignore Shift and Alt on prompt stash delete shortcut by @only21mil in pingdotgg/t3code#49473
* fix(server): failed updates no longer lose recent data when the database is symlinked by @StiensWout in pingdotgg/t3code#49459
* fix(shared): relative file links with ../ resolve to the normalized path by @juliusmarminge in pingdotgg/t3code#49479
* fix(test): VcsStatusBroadcaster checkout test no longer flakes when HEAD.lock events arrive apart by @t3dotgg in pingdotgg/t3code#49494
* fix(server): fresh-session task waits while its previous occurrence awaits background work by @juliusmarminge in pingdotgg/t3code#49490
* fix(server): finish force stop when the target run settles by @UtkarshUsername in pingdotgg/t3code#49486
* perf(client-runtime): recording a thread open no longer replaces quiet thread shells by @shivamhwp in pingdotgg/t3code#49475
* perf(server): Read saved previews for live workflow lists by @UtkarshUsername in pingdotgg/t3code#49484
* fix(server): commit on new branch waits for a multi-repository worktree thread by @StiensWout in pingdotgg/t3code#49482
* fix(web): only capture keybindings while recording a SnapShot shortcut by @only21mil in pingdotgg/t3code#49489
* fix(web): ignore extra modifiers on workflow editor save shortcut by @only21mil in pingdotgg/t3code#49506
* fix(server): SSH readiness check retries after an interrupted response by @StiensWout in pingdotgg/t3code#49512
* fix(web): importing an MCP server keeps other projects' configurations available by @StiensWout in pingdotgg/t3code#49516
* fix(web): ignore Shift, Alt, and IME composition on spreadsheet copy by @only21mil in pingdotgg/t3code#49520
* fix(web): Word previews handle malformed links and spaced internal parts by @only21mil in pingdotgg/t3code#49519
* fix(shared): byte sizes just under the next unit no longer read "1024 KB" by @dev-dami in pingdotgg/t3code#49524
* fix(server): connecting during a checkout keeps the current Git status by @StiensWout in pingdotgg/t3code#49526
* fix(server): keep content search highlights and whole-word matches accurate on non-UTF-8 lines by @only21mil in pingdotgg/t3code#49535
* fix(web): image annotation shortcuts ignore extra modifiers and work with CapsLock by @only21mil in pingdotgg/t3code#49534
* fix(web): show the linked workflow run in All runs by @UtkarshUsername in pingdotgg/t3code#49543
* fix(provider-core): surface Codex managed requirements rejections for granular approval policies by @vibecodooor in pingdotgg/t3code#49540
* fix(web,mobile): choosing a question option sets an image-only answer aside by @juliusmarminge in pingdotgg/t3code#49517
* fix(server): MCP PR review comments preserve the old path on renamed files by @only21mil in pingdotgg/t3code#49557
* fix(server): creating a missing workflow helper makes its workflow load by @StiensWout in pingdotgg/t3code#49562
* fix(github): accept YAML scalars and empty keys in issue templates by @only21mil in pingdotgg/t3code#49558
* fix(server): a stalled cancellation cleanup no longer holds up other workflows' timeouts by @StiensWout in pingdotgg/t3code#49561
* fix(mobile): Usage cache savings ratio uses the app language's decimal separator by @tiliakoos in pingdotgg/t3code#49560
* fix(server): restarting after a pool place is given back keeps the requested resume by @StiensWout in pingdotgg/t3code#49567
* fix(server): retrying a failed project action save now saves it by @StiensWout in pingdotgg/t3code#49573
* fix(server): client connections no longer start Xwayland on Linux by @juliusmarminge in pingdotgg/t3code#49596
* fix(mobile-nitro): Android draft screen matches React Native's header, font and composer by @juliusmarminge in pingdotgg/t3code#49441
* fix(workflows): an agent step's turn no longer waits on its issue tracker by @Kamo2323 in pingdotgg/t3code#49582
* fix(mobile-nitro): a list shows its new rows at once when all of them are replaced on Android by @juliusmarminge in pingdotgg/t3code#49454
* fix(mobile-nitro): Android text fields are readable in dark mode by @juliusmarminge in pingdotgg/t3code#49466
* fix(web): unsent workflow reasons survive an environment reconnect by @StiensWout in pingdotgg/t3code#49603
* fix(server): service install after uninstall no longer refuses as a downgrade by @juliusmarminge in pingdotgg/t3code#49611
* fix(web): deleting a thread keeps a worktree another thread started using by @StiensWout in pingdotgg/t3code#49599
* fix(web,mobile): voice model benchmarks use the app language's decimal separator by @tiliakoos in pingdotgg/t3code#49581
* fix(cursor): Cursor text generation uses Composer 2.5 instead of the retired Composer 2 by @juliusmarminge in pingdotgg/t3code#49614
* fix(mobile-nitro): iOS text inputs use the app theme's colors by @juliusmarminge in pingdotgg/t3code#49509
* fix(mobile-nitro): Android survives Activity recreation (blank screen, colour scheme crash) by @juliusmarminge in pingdotgg/t3code#49572
* fix(mobile-nitro): a tap on a markdown link opens it, and thread links open their thread by @juliusmarminge in pingdotgg/t3code#49546
* fix(server): device access error says the setting is in desktop or web settings by @juliusmarminge in pingdotgg/t3code#49616
* fix(server): OpenCode commands no longer stay running after a failed status check by @StiensWout in pingdotgg/t3code#49602
* feat(mobile-nitro): user message links, thread chips and mentions match React Native by @juliusmarminge in pingdotgg/t3code#49569
* fix(mobile-nitro): Android markdown draws chips, mentions and quoted links like iOS by @juliusmarminge in pingdotgg/t3code#49590
* fix(mobile): guide file links open hidden test files by @StiensWout in pingdotgg/t3code#49600
* fix(server): workflows retry an engine that did not start after a reload by @StiensWout in pingdotgg/t3code#49563
* fix(mobile-nitro): choosing another project drops the draft's pull request by @StiensWout in pingdotgg/t3code#49597
* fix(mobile): pull request diffs no longer mix revisions after reconnecting by @StiensWout in pingdotgg/t3code#49607

## New Contributors
* @dev-dami made their first contribution in pingdotgg/t3code#49524
* @vibecodooor made their first contribution in pingdotgg/t3code#49540

**Full Changelog**: pingdotgg/t3code@v0.1.14-nightly.20261205.5772...v0.1.15-nightly.20261205.5786

</details>


Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.1.15-nightly.20261205.5786
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 Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants