From a8de5b2b9bec07a5ed5df54b859fa6ff5f98406f Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Sun, 21 Jun 2026 22:54:00 +0900 Subject: fix: conversation.open opens tab without auto-switching CLI --open should add the tab to the strip but leave the user on their current tab. Add openTab reducer (add without selecting) + use it in openConversation instead of createTab+selectTab. --- src/features/tabs/tabs.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/features/tabs/tabs.ts') diff --git a/src/features/tabs/tabs.ts b/src/features/tabs/tabs.ts index 61ae58e..3360d3f 100644 --- a/src/features/tabs/tabs.ts +++ b/src/features/tabs/tabs.ts @@ -27,6 +27,17 @@ export function createTab(state: TabsState, tab: Tab): TabsState { return { tabs, activeConversationId: tab.conversationId }; } +/** + * Add a tab WITHOUT switching the active conversation — used by the + * `conversation.open` WS broadcast (CLI `--open`): the tab appears in the + * strip but the user stays on their current tab. No-op if already open. + */ +export function openTab(state: TabsState, tab: Tab): TabsState { + const exists = state.tabs.some((t) => t.conversationId === tab.conversationId); + if (exists) return state; + return { tabs: [...state.tabs, tab], activeConversationId: state.activeConversationId }; +} + export function selectTab(state: TabsState, conversationId: string): TabsState { return { ...state, activeConversationId: conversationId }; } -- cgit v1.2.3