Repository navigation
perf(terminal): stop HTTP link backward scans at rows that cannot continue a URL - #35767
Conversation
…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.
|
No actionable comments were generated in the recent review.
|
[Low impact] The PR appears safe to merge; the added test introduces no blocking issue. SummaryThis PR stops backward URL scans at rows that cannot continue a wrapped link.
Reviews (2) · Last reviewed commit: "test(terminal): pin the edge-wrapped HTT..." · Reviewed by Greptile |
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.src/shared, so desktop and mobile still share them.Why
Micro-benchmark with
@xterm/headlesson a ~2000-row buffer of box-drawn tables, averaged perprovideLinkscall: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
TERMINAL_HTTP_URL_MAX_HARD_WRAPPED_ROWS) backward walk itself predates both.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 teston 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.tscaps 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
Notes
The 10s expiry on "missing" results in
terminal-path-exists-cache.tsis 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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code