Repository navigation
[PIR #1917] Carry cursor visibility in the terminal attach snapshot (Spec 1658 M2 double cursor) - #1934
Merged
Conversation
addon-serialize does not write DECTCEM, so a viewer attach re-showed a cursor the app had hidden. Under ConPTY that cursor is parked at the end of the last row: the second cursor of Spec 1658 M2.
… unreadable-field fallback
…seeded-mirror limits
amrmelsayed
added a commit
that referenced
this pull request
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PIR Review: Two cursors in the architect terminal on Windows (Spec 1658 M2)
Fixes #1917
Summary
On native Windows the dashboard terminal showed claude's own drawn cursor and a second block
cursor. Neither suspect in the issue was the cause: the ConPTY stream hides the cursor correctly
and xterm.js honours it. The cause was Tower's viewer-attach snapshot.
SessionScreen.serialize()uses
@xterm/addon-serialize, which does not write cursor visibility (DECTCEM), so every dashboardattach (opening it, a reload, a tab switch, a reconnect) re-showed a cursor claude had hidden.
Under ConPTY that cursor is parked at the end of the last row, away from claude's drawn cursor. On
macOS it sits on claude's cursor, which hid the same bug there.
serialize()now appends?25lor?25hfrom the mirror's own state.Why it came and went: three things had to be true at once. Claude had to be drawing its own
cursor; that mode comes and goes and its trigger is still unknown (M15). The dashboard had to
attach while it was in that mode. And on Windows the hidden cursor had to be parked away from
claude's. The stray cursor followed ConPTY's repaints (the end of the last row when idle, just past
the last cell drawn while typing). It stayed until claude next toggled visibility, because ConPTY
only emits DECTCEM when visibility changes.
Files Changed
packages/codev/src/terminal/session-screen.ts(+27 / -1)packages/codev/src/terminal/__tests__/session-screen-serialize.test.ts(+81 / -0)codev/reviews/1658-windows-native-non-wsl-support.md(+13 / -0): the M2 entry records the causecodev/resources/arch.md(+1 / -1)codev/resources/lessons-learned.md(+2 / -0)codev/plans/1917-terminal-two-cursors-in-the-ar.md(+130 / -0)codev/reviews/1917-terminal-two-cursors-in-the-ar.md(this file)codev/state/pir-1917_thread.md(+46 / -0)codev/projects/1917-terminal-two-cursors-in-the-ar/status.yaml(porch)Commits
ac5acbf5f[PIR terminal: two cursors in the architect terminal on Windows (Spec 1658 finding M2) #1917] Plan draft9512d4b7e[PIR terminal: two cursors in the architect terminal on Windows (Spec 1658 finding M2) #1917] Carry cursor visibility in the attach snapshot743d7a857[PIR terminal: two cursors in the architect terminal on Windows (Spec 1658 finding M2) #1917] Record the M2 cause in the 1658 review; builder thread43b0aa855[PIR terminal: two cursors in the architect terminal on Windows (Spec 1658 finding M2) #1917] Thread: Tower incident, holding at the tests checkd604e1b6e[PIR terminal: two cursors in the architect terminal on Windows (Spec 1658 finding M2) #1917] Thread: rebase onto Fix #1922: full suite on native Windows no longer stops the live Tower; fix EPERM at its cause #1926, tests-check timeout, orphan shellpersmain(5bce03080,c6c534051), both without conflictsTest Results
buildcheck)packages/codevsuite: ✓ pass (porchtestscheck, 131.6s, on the merged head; the liveTower, PID 39120, was the same before and after)
session-screen-serialize.test.ts. The ConPTY ghost-idle, macOS ghost andreused-client tests fail when the append is disabled and pass with it. The other two pin the
private field and check that a visible cursor stays visible. Two more, added after the
consultation, cover the empty-snapshot canary and the
undefinedfallback.main: session-screen*, pty-session-replay-snapshot,attach-replay, pty-terminal-type, render-gate, spec-1658-conpty-gate-replay: 161/161.
dispatch: https://github.com/cluesmith/codev/actions/runs/44263468954
dev-approval.Architecture Updates
COLD
codev/resources/arch.md: one sentence added to the PIR #1354 "Viewer attach serves themirror's serialized snapshot" paragraph. It says the addon does not serialize DECTCEM, that
serialize()appends it from the mirror, and that anything else a viewer must see after areconnect has to be checked against what the addon serializes. Nothing goes in the HOT tier:
this is subsystem detail, not a cross-cutting rule.
Lessons Learned Updates
COLD
codev/resources/lessons-learned.md, Debugging and Root Cause Analysis: a symptom seen onone platform can come from a platform-neutral bug that another platform masks. Trace the state
hop by hop on a captured stream before blaming the platform layer, and check what a serializer
drops, not only what it round-trips (the #1354 round-trip suite compared cells and cursor
position, so a lost mode was invisible to it).
Things to Look At During PR Review
Consultation (single pass): codex APPROVE, claude COMMENT, gemini skipped (agy CLI not installed). How each of claude's points was handled:
empty-snapshotdesync canary had become unreachable (an empty screen serialized to�[?25h). Fixed:serialize()passes an empty addon payload through untouched. The new test fails without the guard.Co-Authored-Bytrailer might survive on the plan commit. Already resolved: the commit was rewritten without it on the architect's order, andgit log <merge-base>..HEADshows no attribution trailer. The thread line the reviewer read predated that.undefinedfallback was untested. Fixed: a getter-spy test asserts that the snapshot is the plain addon output.arch.md; pre-existing and narrow (cursor-hiding apps are almost always alt-screen, which takes the snapshot route).Private field.
cursorHiddenreadsterm._core.coreService.isCursorHidden, because@xterm/headless6.0 has no public visibility field. If the field is missing it returnsundefinedandserialize()falls back to the old output. A test pins the field, so anupgrade that removes it fails CI. I rejected the alternative, a public parser hook on
CSI ? h/l, because it would duplicate the emulator's state and every reset path (RIS,DECSTR, multi-parameter DECSET).
?25his always sent for a visible cursor. The dashboard writes the replay into itsexisting xterm instance on reconnect, so a hidden state from before the disconnect could
otherwise survive. It changes nothing for a fresh terminal (visible is the default).
POSIX. Live rendering is untouched. After a reconnect, a hidden cursor now stays hidden on
macOS and Linux too. For claude's software cursor the screen looks the same (claude's cell is
still drawn). For full-screen apps that hide the cursor (vim, less) a stray cursor no longer
appears after a reconnect.
Not addressed: cursor style (DECSCUSR) is also not serialized. Nothing has been seen to depend on it.
Still unknown: what makes claude switch into drawing its own cursor (M15). It no longer
matters for M2, which this PR fixes whichever mode claude is in.
Process note. At 00:19Z on 2026-11-18 a local full-suite run from this worktree stopped the
live Tower (attributed to
launchers.windows.test.ts; Fix #1922: full suite on native Windows no longer stops the live Tower; fix EPERM at its cause #1926 added a guard). Two test-orphanshellpers from this worktree's
distare still running, left alone on the architect's order:PID 20476 (
bash -c "node dev-server.cjs"in~/.agent-farm/test-workspaces/codev-1658-p6-EOuHsQ/ws)and PID 41076 (
cmd.exe /d /q /k "echo MARK-1658-A"). Details are in the thread.How to Test Locally
afx dev pir-1917suggestion), reload the dashboard and switch tabs away and back: one cursor each time, idle
and while typing. If claude shows only the plain dim hint, there was one cursor before the
fix too, so this check proves nothing; the ghost-idle unit test covers that case.
npx vitest run src/terminal/__tests__/session-screen-serializeinpackages/codev.Flaky Tests
Under full-suite load on the owner's Windows machine, before #1926:
cold-tier-materialization(2) and
update.testbootstrap-docs hint (4) failed on EPERM removing their temp dirs, andbugfix-1691-tower-start-surface-refusalfailed on its "No output was captured" assertion.One run also failed
agy-auth-cache"keeps spawning per call when the cache is disabled"(EPERM). The first Windows CI run's Node 22 job hit
Worker exited unexpectedlywith every testpassing, and passed on re-run. These are tracked in #1923 and #1926. None reproduced on the
merged head.