Harden observe leave-restore tests against duplicate rows - #372
Merged
TheGreatAxios merged 1 commit intoAug 7, 2026
Merged
Conversation
The parent-restore assertion only checked streamLog.length was at least as long as before entering observe, and used .some() to find expected rows rather than counting them, so a row silently appended twice would not fail the test. Assert exact counts instead, and add a multi-cycle enter/observe/leave regression that checks the parent transcript for duplicated rows across repeated observe sessions.
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.
Summary
CL-4869 tracked a stale "Back to parent session" link and duplicated
tool/command lines left behind after leaving a sub-agent observe
session. Investigating this against the live TUI turned up something
more important than a rendering bug: PR #298 (and the combo PR #312
that superseded it) fixed this only in
src/tui/app.tsxand its Inkcomponent tree — code with zero importers anywhere in the codebase.
The actual shipping entrypoint (
src/tui/runner.ts->src/index.ts)renders through
src/tui-opentui/shell.tsinstead, andpackage.jsoncarries no
ink/reactdependency at all. Those merged fixes neverreached the live TUI.
Auditing the live
shell.tsobserve machinery directly:tui-opentui.leaveSubagentObserveclears the observe chrome (setChromeZones)and restores the parent stream by reassignment, not append.
appendStreamRowroutes to the parent snapshot only while observingand never paints;
appendObserveStreamRowis a no-op when notobserving. There is no code path that writes a row to both logs.
So the live behavior was already correct, but the regression test
covering it used
.some()lookups and a>=length check, whichwould not have caught a row silently duplicated on leave. This change
tightens that test to exact row counts and adds a multi-cycle
enter/observe/leave regression.
Verification
bun run typecheckbun run test(full suite, 4038 pass / 0 fail)bun test ./src ./tests ./evals --randomize --seed 42observe, append a child row, leave) and confirmed by eye: no stale
"Back to parent session" text at any point, the observe chrome line
disappears on leave, and the parent transcript shows the row
appended while away plus exactly one "left observe" row with no
duplicates:
Closes CL-4869