Two issues:
- The ACTIVE session's StepCount was NOT reset (still 1) — meaning the active session was not condensed
- The shadow branch was NOT deleted
The active session has StepCount=1 but only a session state file — it doesn't have actual content on the shadow branch (the setupSessionWithCheckpoint was only for the idle session). The ACTIVE session with StepCount=1 has hasNew check. Let me check what sessionHasNewContent returns for a session state that was manually created without actual content on the shadow branch.
The ACTIVE session was created manually (not through setupSessionWithCheckpoint), so it has no actual transcript data on the shadow branch. The hasNew check might return false because there's nothing new to condense, OR it might error out and fall through to hasNew = true.
Let me trace through the logic: the active session has StepCount: 1 but no actual data on the shadow branch. When sessionHasNewContent is called, it would try to read the shadow branch content and compare with what was previously condensed. Since there's no content on the shadow branch for this session, it would likely return false (no new content).
When hasNew is false for ActionCondense, it goes to the else branch: s.updateBaseCommitIfChanged(logCtx, state, newHead) — just updates BaseCommit without condensing. This means condensed stays false, and the session gets marked as an uncondensed active session, preserving the shadow branch.
This is actually correct behavior! The active session has no content to condense (it was just created with a manual state but has no actual shadow branch data). The test setup needs to be different — either the active session needs actual content, or we should accept that a content-less active session correctly preserves the branch.
Let me reconsider what this test is really about. The original test was about: "when you have two sessions on the same branch, one IDLE and one ACTIVE, the shadow branch should be preserved after PostCommit because the active session still needs it."
In the new model, if the active session has content, it gets condensed too and the branch CAN be deleted. If the active session has no content, it's not condensed and the branch is preserved (correct behavior — the idle session's data was condensed from the same branch).
Let me update the test to properly reflect the scenario: the active session has no new content, so it's not condensed, and the shadow branch is correctly preserved.