Repository navigation
Bound search preview memory and stop canceled SSH scans - #25303
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (11)
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Bounded search preview retention —
clampLineContextnow shifts the window off a split surrogate, clips via the reusedsliceAtCodeUnitLimit, derivesdisplayStart/displayMatchLengthfrom the real window, and routes the retained snippet through the existingownRetainedStringso a ~500-char preview can no longer pin a megabyte source line. - Single preview-length constant —
MAX_LINE_CONTENT_LENGTHrelocated totext-search-match-accumulator.tsand re-exported fromtext-search.ts. - Relay listing cancellation —
runPassOncerefuses to start the broader pass after settlement, the launch-failure diagnosis continuation checkspassDone || done, the abort signal is forwarded intoclassifyRigrepLaunchFailure(so a runningrg --versionprobe is killed and pending cwd checks bail), an unexpected diagnosis rejection is caught, and the always-discarded stderr pipe is dropped. - Session reader consolidation — the redundant first-byte object-root scan is replaced by
assembler.current === record.
The new tests are genuine regression guards: the retention fixture retains ~32 MiB without ownership, the between-passes test spawns a second rg without the guard, the diagnosis tests hang or probe without the signal/guard, and the unicode tests assert exact columns and display slices against real bundled rg.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

ELI5
Long search results can keep far more memory alive than their tiny previews suggest, and canceling Quick Open over SSH can still start another scan. This bounds retained preview text and stops abandoned listing work.
What Changed
Why
Reuse the existing string and cancellation mechanisms instead of introducing a cache, dependency patch, or another parser. Legacy remote fallbacks and session readers still have active callers and remain necessary.
Measurements on macOS arm64, Node 24.20.0, against this branch's main base; serial counterbalanced timings and fresh-process memory checks:
Copying trades bounded allocation for predictable retention: 2,000 matches sharing one short line retain about 2.16 MiB instead of 0.38 MiB. The small dense ingestion case takes 0.7 → 1.4 ms, and its fresh-process peak RSS rises about 6.7 MiB. Long ASCII result peak RSS rises about 4 MiB despite lower retained heap. This is a memory-lifetime fix, not a general speed claim.
Linked Issue
Follow-up to #25156 and #25202.
Visual Proof
N/A — this changes shared result preparation and subprocess lifecycle, without renderer changes. Real bundled-binary tests verify intact Unicode preview text, highlight ranges, and unchanged navigation coordinates; no rendered-app validation was performed.
Testing
341 tests passed, 2 platform-specific tests skipped across 32 focused suites, covering real bundled search output, dense results, forced-GC retention, session contracts, remote lifecycle, Windows path handling, and listing cancellation. The new cancellation regressions were shown to fail before the fixes.
pnpm tc,pnpm run check:code-quality:changed, andpnpm run build:relaypassed. Relay bundles built for all six targets; native Windows process-tree binaries are absent locally, so packaging/native Windows execution remains a CI check. Local tests and measurements ran on macOS; no live Windows, WSL, or SSH host validation is claimed.Review
Adversarial sub-agent review before implementation and again on the fixes covered byte offsets, Unicode clipping, stream assembly, cancellation races, and memory ownership. Review found the Git fallback highlight intersection and diagnostic cancellation gaps; both now have regressions.
Agent skill upstream boundary
Notes
No dependency changes or patches. No wire format changes. Shared preview handling applies to native and remote searches, including folder workspaces. Cancellation stays on the execution host.
Checklist