Conversation
Avoid carrying APC cursor markers across selection slices and strip all remaining markers before terminal output. Closes earendil-works#9257 Closes earendil-works#9332
Keep marker cleanup at the slicing and cursor extraction boundaries, and document why APC state must not carry across slices.
4bc8f73 to
b82f251
Compare
gaoanze888
left a comment
There was a problem hiding this comment.
There is still a cursor-marker output leak outside the selected line. extractCursorPosition() scans only the visible viewport and returns immediately after finding the bottommost marked line; the patch removes duplicates only from that one line. Any marker on another visible line, or above the viewport during a full render, remains in lines and is passed to the terminal writer.
I reproduced this at exact head b82f251 with a TuiMainScreen whose 2-row terminal renders three lines: offscreen + marker, visible-a + marker, and visible-b + marker. The bottom marker determines the cursor and is removed, but terminal.writes.join("") still contains CURSOR_MARKER; the focused node:test fails on that assertion. This is the same output-boundary invariant the PR intends to guarantee, not just a synthetic duplicate on the selected line.
Please preserve the first valid visible marker for cursor positioning, but strip CURSOR_MARKER from every non-image rendered line before terminal output, and add coverage for markers on multiple lines / above the visible viewport. (The first commit appears to have had broader cleanup and an offscreen regression before the narrowing follow-up removed them.)
dfcbc56 to
f2e059b
Compare
|
@gaoanze888 Addressed in Cursor detection is unchanged: The new regression uses a 2-row terminal with three marked lines: one above the viewport, one upper visible marker at column 1, and one bottom visible marker at column 9. It verifies that:
I also rechecked the original issue paths: same-line duplicates are stripped while the first marker remains the cursor source (#9257), Verification:
The current GitHub CI failure is in the unrelated This comment is AI-generated by Trae CLI. |
gaoanze888
left a comment
There was a problem hiding this comment.
Verified the fix at exact head f2e059b. Cursor selection still uses the bottommost valid visible marker, while applyLineResets() now strips markers from every non-image rendered line at the terminal-output boundary. The new 3-line/2-row regression covers both another visible marker and one above the viewport, preserves their content, emits no marker bytes, and still positions the cursor from the bottom marker. The full @earendil-works/pi-tui suite passes locally. The GitHub failure is the unrelated packages/ai/src/api/google-shared.ts exhaustiveness error also tracked by #9570, not this TUI change.
Summary
Fix cursor-marker leakage across the full-screen selection and terminal rendering paths.
sliceWithWidth()does not replay them into later selection slices.This combines the duplicate-marker cleanup reported in #9257 with the upstream selection-slicing cause identified in #9332. The
sliceWithWidth()root cause and Ghostty behavior were identified by @Andy8647 in #9332. The duplicate-marker cleanup direction was also independently proposed by @bluefateludi in #9257.Closes #9257
Closes #9332
Test Plan
sliceWithWidth()regression test fails before the fix because later slices containCURSOR_MARKER.npm test --workspace @earendil-works/pi-tuitsgo -p packages/tui/tsconfig.build.json --noEmitbiome check --error-on-warningson the five changed filesThe current GitHub Actions failure occurs in the unrelated
packages/ai/src/api/google-shared.tsbuild onFinishReason.TOO_MANY_TOOL_CALLS; currentmainfails on the same error. Thepi-tuibuild, complete package test suite, type check, and changed-file formatting checks pass.This PR was prepared with AI assistance and reviewed by me.