Repository navigation
test(terminal): a drag in the copy regression waits for its own viewport position - #573
Conversation
…ort position A release that arrives before the press's GET /api/pane/scroll answer copies the visible text natively and never calls navigator.clipboard.write, so the recorder saw no write and the plain drag step failed under load (#551). Each press now waits until its scroll read was asked for and none is open.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe terminal copy regression script now tracks ChangesTerminal copy drag synchronization
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to The drag regression now waits for the scroll-position request before continuing. No merge-blocking issue was identified. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
devswha
left a comment
There was a problem hiding this comment.
Independent review (merge-own lane).
Classification: test-only fix for a flaky required check (#551). It merges because the "Integration and browser" check is required on main, so a race in it blocks every PR.
What I checked:
- Diff:
scripts/terminal-copy-regression.tswrapswindow.fetchin the init script and countsGET .../pane/scrollreads as asked and open. A press waits until its own read was asked and none is open. The product reads the position throughgetJson(src/lib/api.ts:111), which always callsresponse.json(), so the counter closes every read. A non-OK answer closes at once. A read that never answers makeswaitForFunctiontime out loudly rather than pass. The threewaitForTimeout(200)guesses after a press are replaced by the same wait. - Root cause matches
PaneTerminal.tsx: a release before the scroll answer copies the visible text natively and returns before the async clipboard write, so the recorder saw[]. - No product code changed, and there is no CHANGELOG entry, matching earlier test-only PRs.
What I ran, on head 7b343b1 in a separate worktree:
bun run check fast: 1699 pass, 0 fail.bun run buildthenbun run check run bun scripts/ui-regression.ts: every step passed, including the three terminal-copy steps ("plain drag copies...", "a selecting drag scrolls herdr...", "drag copy starts in the gesture...").- Fast checks and Integration and browser are green on this head, the branch is up to date with
main, and there are no review threads. CodeRabbit had no actionable comments.
Change
scripts/terminal-copy-regression.tsraced the page in its drag steps (#551).A press in the desktop terminal asks herdr where the pane's viewport sits (
GET /api/pane/scroll). A release that comes before that answer has no history row to map the selection to. It still copies the visible text with the native copy (PaneTerminal.tsxcopySelection,document.execCommand("copy")), shows "copied to clipboard", and returns before it reserves the asyncnavigator.clipboard.write(onMouseUp,if (!range) return). The script's recorder counts onlynavigator.clipboard.write/writeText, so under load (a slow scroll answer)clipboardGesture.writesstayed[]and the assertion at line 86 failed. The clipboard and the banner were already right. This matches the CI failure in #551.The product behaves as intended: copying the visible text when the position is not known yet is the documented fallback. So the fix is in the test. Each press now waits for its own scroll position instead of racing it: the init script counts the
/pane/scrollreads the page asked for and the ones still open, and a press waits until its read was asked for and none is open, so an answer to an earlier press cannot stand in for it. The three steps that guessed withwaitForTimeout(200)("the viewport position arrives") use the same wait.Fixes #551
Validation
On a herdr of the run's own (
bun run check run), with a scratch runner that runscheckTerminalCopyalone and can holdGET /api/pane/scroll(not committed):drag copy must begin inside mouseup,+ []).first selection response held), because a double-click's late answer released the next press; counting asked and open reads fixed that.bun run check fast: passed (1699 pass, 4 skip, 0 fail), run before the final wait change; it does not coverscripts/, which the runs above exercise.No CHANGELOG entry: the change is test-only and nothing a user notices.