sessions: fix duplicate session in list when new session is opened while another is active (#314913)
sessions: fix duplicate session in list when new session opened while another is active When a new CLI session was created and the user opened another session before the new one fully graduated: 1. SessionAdded notification from the agent host arrived before _pendingSession was set, so _sessionCache already contained the committed session when the skeleton was added as _pendingSession. getSessions() then returned both, causing the duplicate row. 2. SessionsManagementService.onDidReplaceSession only fired _onDidChangeSessions when the active session was the 'from' session. If the user had navigated away, no refresh event fired and the SessionsList kept showing the duplicate indefinitely. Fix: - Clear _pendingSession before firing _onDidReplaceSession so any synchronous listener that calls getSessions() sees only the committed session (the finally block still clears it on the failure path). - Always fire _onDidChangeSessions in onDidReplaceSession; only the active-session reassignment remains conditional. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
D
Don Jayamanne committed
24ae24bb0e98a262e048f9f6477e858fe51649a9
Parent: 702d855
Committed by GitHub <noreply@github.com>
on 5/7/2026, 6:49:55 AM