fix(native-chat): tolerate missing layout state

This commit is contained in:
Jinjing
2026-07-13 07:12:15 -07:00
parent 6f1899ba79
commit cd7ef80d24
2 changed files with 7 additions and 1 deletions
@@ -146,6 +146,10 @@ describe('selectTabAgentTypesByTabId', () => {
).toEqual({ 'tab-1': 'claude' })
})
it('treats a missing layout map as no unsafe split evidence during hydration', () => {
expect(selectNativeChatTabWideFallbackUnsafeTabsById()).toEqual({})
})
it('resolves the active leaf through nested splits and ignores expanded siblings', () => {
const layout: TerminalLayoutSnapshot = {
root: {
@@ -64,8 +64,10 @@ export function selectTabAgentTypesByTabId(
}
export function selectNativeChatTabWideFallbackUnsafeTabsById(
terminalLayoutsByTabId: Record<string, TerminalLayoutSnapshot>
terminalLayoutsByTabId: Record<string, TerminalLayoutSnapshot> = {}
): Record<string, true> {
// Why: legacy and hydrating store shapes may not expose layout state yet;
// absence carries no unsafe split evidence and must not crash tab rendering.
const unsafeTabs: Record<string, true> = {}
for (const [tabId, layout] of Object.entries(terminalLayoutsByTabId)) {
if (!isNativeChatTabWideFallbackSafe(layout)) {