PR #603 (S1011 fix for #600) removed 9 unit tests targeting
SwitchToAgentSession, recordPastAgentSessionID, and KnownAgentSessionIDs —
production functions that the PR kept. The production code never lost
those behaviors, but the test coverage dropped by 9. QA review
(msg-20260607-4iaibz/2ocb88) flagged this as a P1 blocker on the merge.
Restore the 9 tests verbatim from commit 4e61c8f5 (which sat on the
pre-rebase base of #603) so the merge of #603 into main does not lose
the regression coverage for the legacy-session-preservation invariant
that #603 was built on top of.
- TestSwitchToAgentSession_PreservesOldSession
- TestSwitchToAgentSession_ReusesExisting
- TestPastAgentSessionIDs_ClearPreservesHistory
- TestPastAgentSessionIDs_ReplacePreservesHistory
- TestPastAgentSessionIDs_NoDuplicates
- TestPastAgentSessionIDs_ContinueSentinelNotRecorded
- TestKnownAgentSessionIDs_IncludesPast
- TestKnownAgentSessionIDs_ReproducesNewCommandBug
- TestKnownAgentSessionIDs_ResetAllSessionsBug
Cherry-picked from 3392323b (PR #603 branch) which itself restores the
tests byte-for-byte from 4e61c8f5:core/session_test.go. This PR re-applies
the same 9-test diff onto current main (5e2f3b9e) so coverage restoration
can land via a separate review path while the original PR #603 stays
merged at cafc802a.
Refs #600, #603
Co-existence verified: the 9 new tests live alongside the existing
TestPruneDuplicateSessions_* tests in core/session_test.go and exercise
the same package-level helpers (NewSessionManager, Session,
SetAgentSessionID, SwitchToAgentSession, KnownAgentSessionIDs,
filterOwnedSessions, AgentSessionInfo).
No production code touched. No changes to the S1011 fix at
core/session.go:878, sort.SliceStable at :879, /prune subcommand,
PruneDuplicateSessions, --empty/--merge flags, or
TestPruneDuplicateSessions_NoMergeKeepsBothWithHistory.
go test -count=1 -tags no_web ./core/ → ok (39 existing + 9 restored = 48 tests in core/session_test.go)
go vet -tags no_web ./core/... → clean
Co-authored-by: Claude <noreply@anthropic.com>