| 1 | type ComposerDraftKeyTab = { |
| 2 | id?: string; |
| 3 | scope?: string; |
| 4 | workspaceRoot?: string; |
| 5 | topicId?: string; |
| 6 | sessionPath?: string; |
| 7 | }; |
| 8 | |
| 9 | export function composerDraftKeyForTab(activeTab: ComposerDraftKeyTab | undefined, activeTabId?: string | null): string { |
| 10 | if (!activeTab) return activeTabId ?? ""; |
| 11 | const scope = activeTab.scope === "project" ? "project" : "global"; |
| 12 | const workspaceRoot = scope === "project" ? activeTab.workspaceRoot || "" : ""; |
| 13 | const topicId = activeTab.topicId || ""; |
| 14 | const sessionPath = activeTab.sessionPath || ""; |
| 15 | if (topicId) { |
| 16 | return ["session-topic", scope, workspaceRoot, topicId].join("\u0000"); |
| 17 | } |
| 18 | if (sessionPath) { |
| 19 | return ["session-path", scope, workspaceRoot, sessionPath].join("\u0000"); |
| 20 | } |
| 21 | return ["tab", activeTab.id || activeTabId || ""].join("\u0000"); |
| 22 | } |
| 23 |