diff --git a/cptr/frontend/src/lib/components/Sidebar.svelte b/cptr/frontend/src/lib/components/Sidebar.svelte index 8a39498..31b1a58 100644 --- a/cptr/frontend/src/lib/components/Sidebar.svelte +++ b/cptr/frontend/src/lib/components/Sidebar.svelte @@ -1,148 +1,18 @@ {#if $sidebarOpen} @@ -278,269 +77,17 @@ onpointerdown={startResize} ondblclick={() => sidebarWidth.set(220)} > - -
- { - e.preventDefault(); - goto('/'); - if (typeof window !== 'undefined' && window.innerWidth < 768) sidebarOpen.set(false); - }}>Computer logoComputer - -
- - -
- -
- - - {#if $chatEnabled} -
- { - e.preventDefault(); - goto('/automations'); - if (typeof window !== 'undefined' && window.innerWidth < 768) sidebarOpen.set(false); - }} - > - - {$t('automations.title')} - -
- {/if} - - -
- {$t('sidebar.workspaces')} - -
- - -
- {#each $workspaceList as ws (ws.path)} - {@const isExpanded = expandedWorkspaces.has(ws.path)} - {@const chats = wsChatsCache.get(ws.path)} - {@const isLoading = wsChatsLoading.has(ws.path)} -
-
- handleWorkspaceClick(e, ws.path)} - > - - {#if $chatEnabled} - { - e.stopPropagation(); - e.preventDefault(); - toggleWorkspaceExpand(ws.path); - }} - aria-label={isExpanded ? $t('sidebar.collapse') : $t('sidebar.addWorkspace')} - > - - - - - - {:else} - - {/if} - {ws.name} - - openWsMenu(e, ws.path)} - aria-label={$t('sidebar.workspaceOptions')} - > - - - {#if $chatEnabled} - handleNewChat(ws.path)} - aria-label={$t('bar.newChat')} - use:tooltip={$t('bar.newChat')} - > - - - {/if} -
- - - {#if $chatEnabled && isExpanded} -
- {#if isLoading && !chats} -
- - - -
- {:else if chats && chats.length > 0} - {#each chats as chat (chat.id)} - handleSidebarChatClick(chat.id, ws.path, chat.title)} - /> - {/each} - - {:else if chats} - - {/if} -
- {/if} -
- {/each} - - {#if $workspaceList.length === 0} -
-

{$t('sidebar.noWorkspaces')}

-
- {/if} -
- - -
- - {/if} - -
+ + + (showPicker = true)} /> + {/if} -{#if showMenu && menuButtonEl} - { - settingsTab = 'account'; - showMenu = false; - showSettings = true; - } - } - ] - : []), - ...($session ? [{ divider: true, label: '', onclick: () => {} }] : []), - { - label: $t('sidebar.settings'), - icon: 'settings', - shortcut: formatChord($keybindings.openSettings), - onclick: openSettings - }, - { - label: $t('system.infoTitle'), - icon: 'info', - onclick: openSystemInfo - }, - { divider: true, label: '', onclick: () => {} }, - { label: $t('sidebar.logOut'), icon: 'log-out', onclick: logout } - ]} - onclose={() => (showMenu = false)} - /> -{/if} - {#if showPicker} (showPicker = false)} /> {/if} -{#if wsMenuPath && wsMenuAnchor} - handleRemoveWorkspace(wsMenuPath!) - } - ]} - onclose={closeWsMenu} - /> -{/if} - {#if showSettings} diff --git a/cptr/frontend/src/lib/components/SidebarFooter.svelte b/cptr/frontend/src/lib/components/SidebarFooter.svelte new file mode 100644 index 0000000..cd06a6e --- /dev/null +++ b/cptr/frontend/src/lib/components/SidebarFooter.svelte @@ -0,0 +1,87 @@ + + +
+ + {/if} + +
+ +{#if showMenu && menuButtonEl} + openSettings('account') + } + ] + : []), + ...($session ? [{ divider: true, label: '', onclick: () => {} }] : []), + { + label: $t('sidebar.settings'), + icon: 'settings', + shortcut: formatChord($keybindings.openSettings), + onclick: () => openSettings() + }, + { + label: $t('system.infoTitle'), + icon: 'info', + onclick: openSystemInfo + }, + { divider: true, label: '', onclick: () => {} }, + { label: $t('sidebar.logOut'), icon: 'log-out', onclick: clearSession } + ]} + onclose={() => (showMenu = false)} + /> +{/if} diff --git a/cptr/frontend/src/lib/components/SidebarHeader.svelte b/cptr/frontend/src/lib/components/SidebarHeader.svelte new file mode 100644 index 0000000..465ac53 --- /dev/null +++ b/cptr/frontend/src/lib/components/SidebarHeader.svelte @@ -0,0 +1,32 @@ + + +
+ Computer logoComputer + +
diff --git a/cptr/frontend/src/lib/components/SidebarNav.svelte b/cptr/frontend/src/lib/components/SidebarNav.svelte new file mode 100644 index 0000000..e8d1145 --- /dev/null +++ b/cptr/frontend/src/lib/components/SidebarNav.svelte @@ -0,0 +1,48 @@ + + +
+ +
+ +{#if $chatEnabled} + +{/if} diff --git a/cptr/frontend/src/lib/components/SidebarWorkspaceList.svelte b/cptr/frontend/src/lib/components/SidebarWorkspaceList.svelte new file mode 100644 index 0000000..98d3a23 --- /dev/null +++ b/cptr/frontend/src/lib/components/SidebarWorkspaceList.svelte @@ -0,0 +1,426 @@ + + +
+ {$t('sidebar.workspaces')} + +
+ +
+ {#each $workspaceList as ws (ws.path)} + {@const isExpanded = expandedWorkspaces.has(ws.path)} + {@const chats = wsChatsCache.get(ws.path)} + {@const isLoading = wsChatsLoading.has(ws.path)} +
+
+ openWorkspace(e, ws.path)} + > + {#if $chatEnabled} + { + e.stopPropagation(); + e.preventDefault(); + toggleWorkspaceExpand(ws.path); + }} + aria-label={isExpanded ? $t('sidebar.collapse') : $t('sidebar.addWorkspace')} + > + + + + + + {:else} + + {/if} + {ws.name} + + openWsMenu(e, ws.path)} + aria-label={$t('sidebar.workspaceOptions')} + > + + + {#if $chatEnabled} + newChat(ws.path)} + aria-label={$t('bar.newChat')} + use:tooltip={$t('bar.newChat')} + > + + + {/if} +
+ + {#if $chatEnabled && isExpanded} +
+ {#if isLoading && !chats} +
+ + + +
+ {:else if chats && chats.length > 0} + {#each chats as chat (chat.id)} + openChat(chat.id, ws.path)} + onmenu={(e) => openChatMenu(e, chat.id, ws.path)} + /> + {/each} + + {/if} +
+ {/if} +
+ {/each} + + {#if $workspaceList.length === 0} +
+

{$t('sidebar.noWorkspaces')}

+
+ {/if} +
+ +{#if wsMenuPath && wsMenuAnchor} + handleRemoveWorkspace(wsMenuPath!) + } + ]} + onclose={closeWsMenu} + /> +{/if} + +{#if chatMenu} + +{/if} + +