Skip to content

perf(terminal): stop HTTP link backward scans at rows that cannot continue a URL - #35767

Merged
nwparker merged 2 commits into
mainfrom
perf/terminal-link-provider-rescan
Oct 29, 2026
Merged

nwparker merged 2 commits into
mainfrom
perf/terminal-link-provider-rescan

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38

ELI5

When the pointer sits over terminal output, Orca checks the nearby rows for links, including URLs that were wrapped across several rows. For tables, that check looked back up to 2048 rows every time. Now it stops as soon as it reaches a row that could not be part of the same URL, such as a table border, a blank line or a line of prose.

What Changed

  • src/shared/hard-wrapped-terminal-http-links.ts: the backward scan for URLs wrapped inside a framed table stops at the first row that cannot continue a framed URL. A continuation row must end in a URL fragment, have a frame before that fragment, and have nothing after it except spaces and a right frame.
  • src/shared/edge-wrapped-terminal-http-links.ts: the backward scan for URLs wrapped at the terminal edge stops when a later row has a frame. It also stops when a row between the start and the hovered row is more than one token, or when the hovered row is blank.
  • Both stop rules only skip rows that the existing forward walk would reject, so the links that get detected don't change. The rules stay in src/shared, so desktop and mobile still share them.

Why

Micro-benchmark with @xterm/headless on a ~2000-row buffer of box-drawn tables, averaged per provideLinks call:

before after
URL provider, tables with URLs (80/120/200 cols) 1306–2103µs 36–79µs
URL provider, tables without URLs 197–230µs 32–40µs
Framed-table scan only, tables with URLs 1640–3175µs 17–33µs
Edge-wrapped scan only 100–340µs 4–14µs

How often xterm calls providers (Linkifier.ts): once per mouse move to a new cell. During a scroll, it re-asks every provider on every rendered frame only while a link is under the pointer (onRenderedViewportChange, lines 301–321). So on URL-dense tables, scrolling paid about 2ms per frame in this provider alone. Caching results across calls was not needed once the scan is bounded.

Where this came from

Not the cause of #35439: profiling that report showed the scroll lag comes from the body:has() blur rule added in #33799 (a93e31a, v1.4.243), already fixed by #34932 in v1.4.244. With the pointer on plain text the link providers do no work while scrolling. This PR only trims hover/scroll cost when a link sits under the pointer over URL-dense tables.

Linked Issue

Refs #35439

Visual Proof

N/A: performance-only change with no visual or interaction difference.

Testing

  • Existing link suites: pnpm test on the link, URL and wrapped-terminal test files passed (53 files / 630 tests, and 57 files / 603 tests).

  • New test in src/shared/hard-wrapped-terminal-http-links.test.ts caps the scan at a table border. It fails on the old code and passes now.

  • pnpm check:changed --maxWorkers=2: 20 checks passed.

  • Platforms: macOS, unit tests and benchmark only. This is pure string logic shared by desktop and mobile, with no platform or SSH-specific behavior.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The 10s expiry on "missing" results in terminal-path-exists-cache.ts is unchanged. Hovering a missing path costs at most one host round trip per path every 10s, which is acceptable for SSH and remote use.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

…tinue a URL

Framed (hard-wrapped) detection walked back up to 2048 rows per hovered line,
building column maps for every URL row; edge-wrapped walked ~54 rows at 80 cols.
Stop once a later row cannot be a continuation (borders, prose, blank rows).
Table-heavy buffer: provideLinks 1.3-2.1ms -> 36-79us per call.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e47be477-f434-4890-8862-7030268d3a7c
Commits

Reviewing files that changed from the base of the PR and between 1279d5f and ff4c9a0.

Files selected for processing: 4
  • src/renderer/src/components/terminal-pane/edge-wrapped-terminal-http-links.test.ts
  • src/shared/edge-wrapped-terminal-http-links.ts
  • src/shared/hard-wrapped-terminal-http-links.test.ts
  • src/shared/hard-wrapped-terminal-http-links.ts

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

Walkthrough

Backward candidate scanning for edge-wrapped links now stops when preceding rows are absent or do not meet continuation rules. Scanning for hard-wrapped links now stops when a row is missing or does not meet framed-continuation criteria. Tests assert that prose and periodic borders limit the number of distinct rows accessed.

Priority: Normal

Merge Risk: Minimal · up to ff4c9

The bounded scans preserve valid link candidates while reducing unnecessary row access; no merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary performance change: stopping terminal HTTP-link backward scans at rows that cannot continue a URL.
Description check Passed The description is detailed and mostly complete. It includes the ELI5, change summary, rationale, benchmarks, linked issue reference, visual-proof explanation, testing results, platform scope, and che…
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: Description check

Explanation

The description is detailed and mostly complete. It includes the ELI5, change summary, rationale, benchmarks, linked issue reference, visual-proof explanation, testing results, platform scope, and checklist. The linked issue uses "Refs #35439" instead of the template's requested issue-link format, but the issue reference is present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; the added test introduces no blocking issue.

Summary

This PR stops backward URL scans at rows that cannot continue a wrapped link.

  • Framed-table URL searches stop at rows that cannot continue the link.
  • Terminal-edge URL searches stop at rows that cannot continue the link.

Reviews (2) · Last reviewed commit: "test(terminal): pin the edge-wrapped HTT..." · Reviewed by Greptile

@nwparker
nwparker merged commit 6de2007 into main Oct 29, 2026
50 checks passed
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