summaryrefslogtreecommitdiffhomepage
path: root/src/features/tabs/tab-groups.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-10-24 18:05:30 +0900
committerAdam Malczewski <[email protected]>2026-10-24 18:05:30 +0900
commitdaefad66bdf8dee132d701a3b43ce0d227dde241 (patch)
tree424ac806b3822247c0b835ee38ffabdf87f5016e /src/features/tabs/tab-groups.ts
parentc8b2fb49835bde2f85d99a91b313e6a01ce1359c (diff)
parent0ba54b4455cb560cf7a82baf71b31ed129cfc29b (diff)
downloaddispatch-web-daefad66bdf8dee132d701a3b43ce0d227dde241.tar.gz
dispatch-web-daefad66bdf8dee132d701a3b43ce0d227dde241.zip
Merge branch 'feature/close-tab-cascade-subagents' into dev
Diffstat (limited to 'src/features/tabs/tab-groups.ts')
-rw-r--r--src/features/tabs/tab-groups.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/features/tabs/tab-groups.ts b/src/features/tabs/tab-groups.ts
index c7406d8..ff3ddd4 100644
--- a/src/features/tabs/tab-groups.ts
+++ b/src/features/tabs/tab-groups.ts
@@ -104,6 +104,22 @@ export function groupDescendants(tabs: readonly Tab[], conversationId: string):
}
/**
+ * The tabs removed by a CASCADING close of `conversationId` (the user chose
+ * "also close its subagents"): the tab itself first, then its transitive
+ * visible-group descendants in tab order. ONE decision covers the whole
+ * subtree — closing never re-prompts per level. A single-element result (the
+ * tab alone) means the tab has no subagents and closes without a prompt.
+ */
+export function cascadeCloseIds(tabs: readonly Tab[], conversationId: string): string[] {
+ const descendants = groupDescendants(tabs, conversationId);
+ const ids = [conversationId];
+ for (const tab of tabs) {
+ if (descendants.has(tab.conversationId)) ids.push(tab.conversationId);
+ }
+ return ids;
+}
+
+/**
* The tabs `conversationId` may be moved under (the "Add to group" menu):
* every other tab EXCEPT itself, its descendants (that would form a cycle),
* and its current visible group parent (already there). Tab order preserved.