diff --git a/src/lib/components/chat/ChatTabs.svelte b/src/lib/components/chat/ChatTabs.svelte index 7c55627290..8c3122f611 100644 --- a/src/lib/components/chat/ChatTabs.svelte +++ b/src/lib/components/chat/ChatTabs.svelte @@ -5,6 +5,7 @@ let fileGitDiffModes: Record = {}; let fileGitHideWhitespace: Record = {}; import { onMount, onDestroy, tick, getContext } from 'svelte'; + import { v4 as uuidv4 } from 'uuid'; import Sortable from 'sortablejs'; import { beforeNavigate, goto } from '$app/navigation'; import { @@ -276,7 +277,7 @@ let number = 1; while (tabs.tabs.some((tab) => tab.untitled && tab.label === `Untitled-${number}`)) number++; openPanel({ - id: crypto.randomUUID(), + id: uuidv4(), kind: 'file', label: `Untitled-${number}`, terminalId: selectedConnection.selector, @@ -296,7 +297,7 @@ const initialPrompt = pending?.parentId === chatId ? pending.prompt : ''; if (pending?.parentId === chatId) sideChatRequest.set(null); openPanel({ - id: crypto.randomUUID(), + id: uuidv4(), kind, label: `${view.label} ${sideChatNumber}`, sideChatNumber, @@ -418,7 +419,7 @@ let id = existing; if (!id) { focusGroup(groupId); - id = crypto.randomUUID(); + id = uuidv4(); tabs = openTab(tabs, { id, kind: 'side', label: $i18n.t('Chat'), chatId: savedId }); } tabs = bounds.edge @@ -466,7 +467,7 @@ terminalNumber++; } openPanel({ - id: crypto.randomUUID(), + id: uuidv4(), kind: 'terminal', label: `${$i18n.t('Terminal')} ${terminalNumber}`, terminalNumber, @@ -518,7 +519,7 @@ ? `${connection.baseUrl}/chats/${encodeURIComponent(chatId)}` : connection?.baseUrl); openPanel({ - id: crypto.randomUUID(), + id: uuidv4(), kind: 'browser', label: port ? `localhost:${port}` : $i18n.t('Browser'), path: url, diff --git a/src/lib/components/chat/ChatTabs/tabs.ts b/src/lib/components/chat/ChatTabs/tabs.ts index c5f47ec9ea..f5a5a81e25 100644 --- a/src/lib/components/chat/ChatTabs/tabs.ts +++ b/src/lib/components/chat/ChatTabs/tabs.ts @@ -1,3 +1,4 @@ +import { v4 as uuidv4 } from 'uuid'; import type { TerminalContext } from '$lib/types'; import type { TerminalConnection } from '$lib/apis/terminal'; @@ -221,7 +222,7 @@ export function splitTab( if (!source || !state.groups.some((group) => group.id === groupId)) return state; if (source.id === groupId && source.tabIds.length === 1) return state; const next = removeFromGroup(state, id); - const newGroup: PanelGroup = { id: crypto.randomUUID(), tabIds: [id], activeId: id }; + const newGroup: PanelGroup = { id: uuidv4(), tabIds: [id], activeId: id }; const replace = (layout: PanelLayout): PanelLayout => { if (layout.type === 'group') { if (layout.groupId !== groupId) return layout; @@ -229,7 +230,7 @@ export function splitTab( const before = edge === 'left' || edge === 'top'; return { type: 'split', - id: crypto.randomUUID(), + id: uuidv4(), direction: edge === 'left' || edge === 'right' ? 'horizontal' : 'vertical', ratio: 0.5, first: before ? leaf : layout,