Skip to content

Harden observe leave-restore tests against duplicate rows - #372

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-4869-stale-back-to-parent-session-link-persists-in-the-main
Aug 7, 2026
Merged

Harden observe leave-restore tests against duplicate rows#372
TheGreatAxios merged 1 commit into
mainfrom
cl-4869-stale-back-to-parent-session-link-persists-in-the-main

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

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.tsx and its Ink
component 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.ts instead, and package.json
carries no ink/react dependency at all. Those merged fixes never
reached the live TUI.

Auditing the live shell.ts observe machinery directly:

  • No "Back to parent session" string exists anywhere in tui-opentui.
    leaveSubagentObserve clears the observe chrome (setChromeZones)
    and restores the parent stream by reassignment, not append.
  • appendStreamRow routes to the parent snapshot only while observing
    and never paints; appendObserveStreamRow is a no-op when not
    observing. 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, which
would 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 typecheck
  • bun run test (full suite, 4038 pass / 0 fail)
  • bun test ./src ./tests ./evals --randomize --seed 42
  • Rendered real frames through the OpenTUI test harness (enter
    observe, 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:
=== DURING OBSERVE ===
   observe: explore — map callers
  observe     Viewing explore: map callers
  ✓   shell       grep -rn callers src/

=== PARENT AFTER LEAVE ===
  ▍ run the tests
  parent still working
  observe     left observe (explore)

Closes CL-4869

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.
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

CL-4869

@TheGreatAxios
TheGreatAxios merged commit 7735180 into main Aug 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant