d8bf76dfd6
AgentSession.switchSession() eagerly called buildDisplaySessionContext() before setSessionFile, walking the previous session's branch and expanding every compaction entry's snapcompact archive and openaiRemoteCompaction replacementHistory into messages. For huge pre-fix sessions that materialized GBs of data and OOMed in-TUI /resume even after the streaming loader fix. The snapshot is only needed for same-session reloads, where #didSessionMessagesChange compares the pre/post message arrays to detect rollback edits. Different-session switches skip the call entirely; the error-recovery path rebuilds the previous context on demand from the restored state so MCP-selection restoration still has its inputs. Added a regression test (test/agent-session-switch-prev-context.test.ts) that spies on sessionManager.buildSessionContext across switchSession and asserts the expected call count and target file per branch. Fixes #3846