fix: preserve structured tabs during activation

This commit is contained in:
Brennan Benson
2026-08-11 01:20:30 -07:00
parent 03d5373071
commit 0cf5179487
2 changed files with 78 additions and 1 deletions
@@ -2194,6 +2194,83 @@ describe('TabsSlice', () => {
})
})
it('keeps a structured session activation target during worktree reconciliation', () => {
const groupId = 'g-structured'
store.setState({
unifiedTabsByWorktree: {
[WT]: [
{
id: 'terminal-1',
entityId: 'terminal-1',
groupId,
worktreeId: WT,
contentType: 'terminal',
label: 'Terminal 1',
customLabel: null,
color: null,
sortOrder: 0,
createdAt: 1
},
{
id: 'structured-session-1',
entityId: 'session-1',
groupId,
worktreeId: WT,
contentType: 'agent-session',
label: 'Codex Chat',
customLabel: null,
color: null,
sortOrder: 1,
createdAt: 2,
agentSessionAgent: 'codex'
}
]
},
groupsByWorktree: {
[WT]: [
{
id: groupId,
worktreeId: WT,
activeTabId: 'structured-session-1',
tabOrder: ['terminal-1', 'structured-session-1']
}
]
},
activeGroupIdByWorktree: { [WT]: groupId },
tabsByWorktree: {
[WT]: [
{
id: 'terminal-1',
ptyId: 'pty-1',
worktreeId: WT,
title: 'Terminal 1',
customTitle: null,
color: null,
sortOrder: 0,
createdAt: 1
}
]
},
ptyIdsByTabId: { 'terminal-1': ['pty-1'] }
})
const result = store.getState().reconcileWorktreeTabModel(WT)
const state = store.getState()
expect(result).toEqual({
renderableTabCount: 2,
activeRenderableTabId: 'structured-session-1'
})
expect(state.unifiedTabsByWorktree[WT].map((tab) => tab.id)).toEqual([
'terminal-1',
'structured-session-1'
])
expect(state.groupsByWorktree[WT][0]).toMatchObject({
activeTabId: 'structured-session-1',
tabOrder: ['terminal-1', 'structured-session-1']
})
})
it('collapses empty split groups when reconciliation drops a stale tab', () => {
const terminalGroupId = 'g-terminal'
const staleGroupId = 'g-stale'
+1 -1
View File
@@ -714,7 +714,7 @@ export function projectWorktreeTabModelReconciliation(
if (tab.contentType === 'browser') {
return liveBrowserIds.has(tab.entityId)
}
if (tab.contentType === 'simulator') {
if (tab.contentType === 'simulator' || tab.contentType === 'agent-session') {
return true
}
return liveEditorIds.has(tab.entityId)