summaryrefslogtreecommitdiffhomepage
path: root/src/features/tabs/tabs.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-21 22:54:00 +0900
committerAdam Malczewski <[email protected]>2026-06-21 22:54:00 +0900
commita8de5b2b9bec07a5ed5df54b859fa6ff5f98406f (patch)
tree54ffa30ec7b6fcef6d95f0da914381316d0d62c8 /src/features/tabs/tabs.ts
parent6c61fb52494b5a11f96b7ec814b625d61a67399c (diff)
downloaddispatch-web-a8de5b2b9bec07a5ed5df54b859fa6ff5f98406f.tar.gz
dispatch-web-a8de5b2b9bec07a5ed5df54b859fa6ff5f98406f.zip
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.
Diffstat (limited to 'src/features/tabs/tabs.ts')
-rw-r--r--src/features/tabs/tabs.ts11
1 files changed, 11 insertions, 0 deletions
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 };
}