Repository navigation
[PIR #1920] Tower PTYs get TERM=xterm-256color; claude gate accepts the ASCII-fallback > marker - #1928
Merged
Conversation
node-pty sets TERM from its name option on POSIX only. On Windows an agent launched straight into ConPTY (the architect's bare claude) got only the TERM in Tower's inherited env, often none, and claude then drew its ASCII fallbacks, including a '>' composer marker the render gate did not match. Applied at the shellper first-spawn config, both relaunch SPAWN frames, and the non-shellper PtySession.spawn.
…arker Heals architects already running with the fallback screen (their env cannot change until claude relaunches). The pointer is followed by U+00A0 in fallback mode; '>' must be followed by a space or end the row. Codex keeps its pattern.
The recorder injected TERM itself, so no fixture showed the screen production architects drew. --bare-env records without it; four real captures of claude 2.1.327 (idle, draft, prefix-left, midturn) join the replay suite.
… the wrong screen
…CII-fallback marker; thread update
… boundary, correct review file list
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: Architect mail held with no-composer-marker on Windows
Fixes #1920
Summary
On native Windows, mail to the
mainarchitect was held withbusy:no-composer-markerafter a Tower restart, and the hold never cleared. The cause was the environment, not the gate's logic. node-pty setsTERMfrom itsnameoption only on POSIX, and architects launch as bareclaude, with Tower's env and noTERM. With no Unicode signal in its env on win32, claude draws itsfiguresASCII fallbacks: the composer marker becomes>followed by U+00A0 instead of❯, and the claude gate profile only matched❯/›.Builders never showed this, because Git Bash sets
TERM=xterm-256colorbeforeclaudestarts. The fix has two parts:TERM=xterm-256color, enforced at the spawn chokepoint. New sessions draw❯.Files Changed
codev/plans/1920-tower-mail-to-the-architect-he.md(+214 / -0)codev/projects/1920-tower-mail-to-the-architect-he/status.yaml(porch state)codev/resources/arch.md(+2 / -0)codev/reviews/1920-tower-mail-to-the-architect-he.md(this file)codev/resources/lessons-learned.md(+2 / -0)codev/state/pir-1920_thread.md(+23 / -0)packages/codev/scripts/spec-1658-conpty-capture.mts(+24 / -5)packages/codev/src/agent-farm/__tests__/fixtures/gate/README.md(+19 / -0)packages/codev/src/agent-farm/__tests__/fixtures/gate/claude-conpty-ghost-idle-ascii.replay.bin.gz(new, binary)packages/codev/src/agent-farm/__tests__/fixtures/gate/conpty/conpty-claude-ascii-draft.capture.jsonl.gz(new, binary)packages/codev/src/agent-farm/__tests__/fixtures/gate/conpty/conpty-claude-ascii-idle.capture.jsonl.gz(new, binary)packages/codev/src/agent-farm/__tests__/fixtures/gate/conpty/conpty-claude-ascii-midturn.capture.jsonl.gz(new, binary)packages/codev/src/agent-farm/__tests__/fixtures/gate/conpty/conpty-claude-ascii-prefix-left.capture.jsonl.gz(new, binary)packages/codev/src/agent-farm/__tests__/helpers/conpty-replay.ts(+6 / -0)packages/codev/src/agent-farm/__tests__/render-gate.test.ts(+76 / -0)packages/codev/src/agent-farm/__tests__/spec-1658-conpty-gate-replay.test.ts(+2 / -1)packages/codev/src/agent-farm/servers/gate-profiles.ts(+25 / -1)packages/codev/src/agent-farm/servers/render-gate.ts(+2 / -1)packages/codev/src/lib/agent-env.ts(+23 / -0)packages/codev/src/terminal/__tests__/pty-terminal-type.test.ts(+72 / -0)packages/codev/src/terminal/__tests__/session-manager-spawn-config.test.ts(+25 / -4)packages/codev/src/terminal/__tests__/session-manager.test.ts(+24 / -1)packages/codev/src/terminal/pty-session.ts(+6 / -3)packages/codev/src/terminal/session-manager.ts(+7 / -4)Commits
8d7b2451d[PIR tower: mail to the architect held with no-composer-marker after a Tower restart on Windows #1920] arch.md: TERM at the PTY spawn chokepoint and claude's ASCII-fallback marker; thread update6325afd3c[PIR tower: mail to the architect held with no-composer-marker after a Tower restart on Windows #1920] Thread: implement status and Tower-stop incident91258ee51[PIR tower: mail to the architect held with no-composer-marker after a Tower restart on Windows #1920] Lesson: a recorder that adds env production lacks records the wrong screen269eaf66a[PIR tower: mail to the architect held with no-composer-marker after a Tower restart on Windows #1920] Recorder --bare-env and ASCII-marker ConPTY capturesacd025292[PIR tower: mail to the architect held with no-composer-marker after a Tower restart on Windows #1920] Claude gate profile accepts claude's ASCII-fallback '>' markerf55f9d4ad[PIR tower: mail to the architect held with no-composer-marker after a Tower restart on Windows #1920] Give every Tower-launched PTY child TERM=xterm-256color8b30ce9b2[PIR tower: mail to the architect held with no-composer-marker after a Tower restart on Windows #1920] Plan draftchore(porch): 1920 …)Test Results
npm run build: ✓ passnpm test(fullpackages/codevsuite, on native Windows, after rebasing onto Fix #1922: full suite on native Windows no longer stops the live Tower; fix EPERM at its cause #1926): ✓ pass. It passed atporch done(134.4s) and again on theporch approvere-check (129.7s). The first attempt timed out at 300s because several builders were running the full suite at once; it passed once the runs were serialized.render-gate.test.ts: 10 cases in "claude's ASCII-fallback composer marker (Issue tower: mail to the architect held with no-composer-marker after a Tower restart on Windows #1920)":no-composer-markerunder the old pattern;>idle lines are clean;user-text;> …echo above the composer is clean;user-text;user-text;>>and>fooareno-composer-marker;>staysno-composer-marker.pty-terminal-type.test.ts: the helper, and the non-shellperPtySession.spawn(name andenv.TERM).session-manager*.test.ts: TERM at first spawn on win32 and linux, an inheritedxtermreplaced, and the crash and clean-exit relaunchSPAWNframes.spec-1658-conpty-gate-replay.test.ts: the four new real bare-env claude 2.1.327 captures (idle, draft, prefix-left, midturn) replay with the expected verdicts.Before the fix: a read-only viewer attach captured the held
mainarchitect's screen. It showed>+ U+00A0, which classifiesno-composer-markerunder the old profile andcleanunder the new one.Dev approval: the owner installed this build on their Windows machine and restarted Tower. Mail to
mainnow delivers. The backlog held asno-composer-markerdelivered on install:The 2026-11-02 cron (
dc384851) was superseded by the 00:00Z team-update row and did not deliver.Architecture Updates
COLD:
codev/resources/arch.md, "PTY Environment".TERMis now enforced at the spawn chokepoint bywithPtyTerminalType(), at four places:SPAWNframes;PtySession.spawn.The same entry explains why (node-pty sets
TERMon POSIX only), and that the claude gate profile accepts the ASCII-fallback marker while codex keeps the strict one. Nothing hot-tier: the mailbox and gate invariant inarch-critical.mdis unchanged.Lessons Learned Updates
COLD:
codev/resources/lessons-learned.md, Testing ([From #1920]). A fixture recorder that adds environment that production does not add records a screen that production never shows. Spec 1658's recorder setTERMitself, so every capture drew❯and the suite stayed green while real architects drew>. Record with the env the production launch path builds, and put any deviation behind a named switch (--bare-env).Not routed, but worth knowing:
launchers.windows.test.ts(before #1926) stopped the live Tower on port 4100 during a local full-suite run. #1926 added the guard.Things to Look At During PR Review
The ASCII ghost-cursor fixture is derived, not recorded.
claude-conpty-ghost-idle-ascii.replay.bin.gzis the real M15 capture with every❯replaced by>; no other byte changed. Six idle recordings of claude 2.1.327, with the bare env and the normal env, never drew the inverse software cursor, so the focused state could not be recorded live. It shows thatisGhostCursorCell's first-input-cell anchor holds with a one-column ASCII marker. It does not prove claude draws exactly that screen.The marker regex (
gate-profiles.ts,CLAUDE_COMPOSER_MARKER):>must be followed by a space, U+00A0, or end of line. Without that lookahead,>>,>fooor a quoted>line would read as a marker. The last-match-wins search plus the region-end rule requirement still bound the composer. A transcript> …echo above the composer is fine: the composer's own marker is the last match.TERM is overwritten, not defaulted. An inherited
xterm(mintty) fails claude's win32 Unicode check, and the PTY really isxterm-256color. The change is in shared code; on POSIX node-pty already set the same value fromname, so behaviour there is unchanged.No hold became a force-inject. The gate still requires a clean, bounded composer region; only the set of accepted marker glyphs grew.
Consultation (single pass): codex APPROVE, claude APPROVE, gemini COMMENT (lane skipped: agy CLI not installed). Claude noted three minors, all applied after the consultation: the NBSP test constant is now the escape
\u00a0(a literal could silently normalise to a space); theCLAUDE_COMPOSER_MARKERdoc names its known boundary (no agy-style cursor-row/palette anchor, so a single>item below the composer with a rule beneath it would read as an empty region; never observed); this file list was corrected. Claude also confirmed the chokepoint holds becausesession.options.envis wrapped at everyclient.spawnread, not at its writes.How to Test Locally
afx dev pir-1920afx send architect "…"to an idle architect reportsdelivered, notheld … no-composer-marker.❯(its env hasTERM=xterm-256color).npx vitest run src/agent-farm/__tests__/render-gate.test.ts src/agent-farm/__tests__/spec-1658-conpty-gate-replay.test.ts src/terminal/__tests__/session-manager.test.ts src/terminal/__tests__/session-manager-spawn-config.test.ts src/terminal/__tests__/pty-terminal-type.test.ts(frompackages/codev).Flaky Tests
packages/codev/src/__tests__/tower-lifecycle.windows.test.ts, "Phase 4 (b): started from inside a session job, Tower is created through CIM and survives the session teardown, with its shellper". Windows workflow run 44242152525, first attempt:Tower 3432 died with the session job (before teardown: inJob=False jobOpened=True procOpened=True ppid= created= …), and the CIM lookup returned null. The failed job passed on rerun. The same test failed on bugfix-1922's run 44237325105, before this branch's changes, withconnect ECONNREFUSED. Left running, not skipped.