feat(v3): convert Settings from tab to collapsible side drawer

Settings is now a right-side drawer (32em width, semi-transparent
backdrop) instead of a full-page tab. GlobalTabBar has 3 tabs
(Sessions/Docs/Context) + gear icon toggle. WorkspaceTab type
reduced to 'sessions' | 'docs' | 'context'. Close via Escape,
click-outside, or close button. Alt+1..3 for tabs, Ctrl+, toggles
drawer.
This commit is contained in:
Hibryda 2026-03-07 23:48:03 +01:00
parent b1b34f8195
commit 3776a3ba65
4 changed files with 180 additions and 34 deletions

View file

@ -25,10 +25,15 @@
let detachedConfig = getDetachedConfig(); let detachedConfig = getDetachedConfig();
let paletteOpen = $state(false); let paletteOpen = $state(false);
let settingsOpen = $state(false);
let loaded = $state(false); let loaded = $state(false);
let activeTab = $derived(getActiveTab()); let activeTab = $derived(getActiveTab());
function toggleSettings() {
settingsOpen = !settingsOpen;
}
onMount(() => { onMount(() => {
initTheme(); initTheme();
startAgentDispatcher(); startAgentDispatcher();
@ -45,10 +50,10 @@
return; return;
} }
// Alt+1..4 — switch workspace tab // Alt+1..3 — switch workspace tab
if (e.altKey && !e.ctrlKey && e.key >= '1' && e.key <= '4') { if (e.altKey && !e.ctrlKey && e.key >= '1' && e.key <= '3') {
e.preventDefault(); e.preventDefault();
const tabs = ['sessions', 'docs', 'context', 'settings'] as const; const tabs = ['sessions', 'docs', 'context'] as const;
setActiveTab(tabs[parseInt(e.key) - 1]); setActiveTab(tabs[parseInt(e.key) - 1]);
return; return;
} }
@ -64,10 +69,17 @@
return; return;
} }
// Ctrl+, — settings tab // Ctrl+, — toggle settings drawer
if (e.ctrlKey && e.key === ',') { if (e.ctrlKey && e.key === ',') {
e.preventDefault(); e.preventDefault();
setActiveTab('settings'); toggleSettings();
return;
}
// Escape — close settings drawer
if (e.key === 'Escape' && settingsOpen) {
e.preventDefault();
settingsOpen = false;
return; return;
} }
} }
@ -99,19 +111,36 @@
</div> </div>
{:else if loaded} {:else if loaded}
<div class="app-shell"> <div class="app-shell">
<GlobalTabBar /> <GlobalTabBar {settingsOpen} ontoggleSettings={toggleSettings} />
<main class="tab-content"> <div class="content-area">
{#if activeTab === 'sessions'} <main class="tab-content">
<ProjectGrid /> {#if activeTab === 'sessions'}
{:else if activeTab === 'docs'} <ProjectGrid />
<DocsTab /> {:else if activeTab === 'docs'}
{:else if activeTab === 'context'} <DocsTab />
<ContextTab /> {:else if activeTab === 'context'}
{:else if activeTab === 'settings'} <ContextTab />
<SettingsTab /> {/if}
</main>
{#if settingsOpen}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div class="drawer-backdrop" onclick={() => settingsOpen = false}></div>
<aside class="settings-drawer">
<div class="drawer-header">
<h2>Settings</h2>
<button class="drawer-close" onclick={() => settingsOpen = false} title="Close (Esc)">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
<path d="M2 2l10 10M12 2L2 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
</button>
</div>
<SettingsTab />
</aside>
{/if} {/if}
</main> </div>
<StatusBar /> <StatusBar />
</div> </div>
@ -137,11 +166,74 @@
overflow: hidden; overflow: hidden;
} }
.tab-content { .content-area {
flex: 1; flex: 1;
position: relative;
overflow: hidden; overflow: hidden;
} }
.tab-content {
height: 100%;
overflow: hidden;
}
.drawer-backdrop {
position: absolute;
inset: 0;
background: rgba(0, 0, 0, 0.3);
z-index: 50;
}
.settings-drawer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 32em;
max-width: 90%;
background: var(--ctp-base);
border-left: 1px solid var(--ctp-surface1);
box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
z-index: 51;
display: flex;
flex-direction: column;
overflow: hidden;
}
.drawer-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 16px;
border-bottom: 1px solid var(--ctp-surface0);
flex-shrink: 0;
}
.drawer-header h2 {
font-size: 0.9rem;
font-weight: 600;
color: var(--ctp-text);
margin: 0;
}
.drawer-close {
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
background: transparent;
border: none;
border-radius: 4px;
color: var(--ctp-subtext0);
cursor: pointer;
}
.drawer-close:hover {
color: var(--ctp-text);
background: var(--ctp-surface0);
}
.loading { .loading {
display: flex; display: flex;
align-items: center; align-items: center;

View file

@ -1,37 +1,67 @@
<script lang="ts"> <script lang="ts">
import { getActiveTab, setActiveTab, type WorkspaceTab } from '../../stores/workspace.svelte'; import { getActiveTab, setActiveTab, type WorkspaceTab } from '../../stores/workspace.svelte';
interface Props {
settingsOpen?: boolean;
ontoggleSettings?: () => void;
}
let { settingsOpen = false, ontoggleSettings }: Props = $props();
const tabs: { id: WorkspaceTab; label: string; shortcut: string }[] = [ const tabs: { id: WorkspaceTab; label: string; shortcut: string }[] = [
{ id: 'sessions', label: 'Sessions', shortcut: 'Alt+1' }, { id: 'sessions', label: 'Sessions', shortcut: 'Alt+1' },
{ id: 'docs', label: 'Docs', shortcut: 'Alt+2' }, { id: 'docs', label: 'Docs', shortcut: 'Alt+2' },
{ id: 'context', label: 'Context', shortcut: 'Alt+3' }, { id: 'context', label: 'Context', shortcut: 'Alt+3' },
{ id: 'settings', label: 'Settings', shortcut: 'Alt+4' },
]; ];
</script> </script>
<nav class="global-tab-bar"> <nav class="global-tab-bar">
{#each tabs as tab} <div class="tabs">
<button {#each tabs as tab}
class="tab-btn" <button
class:active={getActiveTab() === tab.id} class="tab-btn"
onclick={() => setActiveTab(tab.id)} class:active={getActiveTab() === tab.id}
title={tab.shortcut} onclick={() => setActiveTab(tab.id)}
> title={tab.shortcut}
{tab.label} >
</button> {tab.label}
{/each} </button>
{/each}
</div>
<button
class="settings-toggle"
class:active={settingsOpen}
onclick={ontoggleSettings}
title="Settings (Ctrl+,)"
>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
<path
d="M6.5 1L6.2 2.7a5 5 0 0 0-1.2.7L3.4 2.8 1.9 5.4l1.3 1.2a5 5 0 0 0 0 1.4L1.9 9.2l1.5 2.6 1.6-.6a5 5 0 0 0 1.2.7L6.5 14h3l.3-1.7a5 5 0 0 0 1.2-.7l1.6.6 1.5-2.6-1.3-1.2a5 5 0 0 0 0-1.4l1.3-1.2-1.5-2.6-1.6.6a5 5 0 0 0-1.2-.7L9.5 1h-3zM8 5.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5z"
stroke="currentColor"
stroke-width="1.2"
stroke-linejoin="round"
fill="none"
/>
</svg>
</button>
</nav> </nav>
<style> <style>
.global-tab-bar { .global-tab-bar {
display: flex; display: flex;
gap: 2px; align-items: center;
padding: 4px 8px; padding: 4px 8px;
background: var(--ctp-mantle); background: var(--ctp-mantle);
border-bottom: 1px solid var(--ctp-surface0); border-bottom: 1px solid var(--ctp-surface0);
flex-shrink: 0; flex-shrink: 0;
} }
.tabs {
display: flex;
gap: 2px;
flex: 1;
}
.tab-btn { .tab-btn {
padding: 4px 14px; padding: 4px 14px;
background: transparent; background: transparent;
@ -53,4 +83,29 @@
background: var(--ctp-base); background: var(--ctp-base);
border-bottom: 2px solid var(--ctp-blue); border-bottom: 2px solid var(--ctp-blue);
} }
.settings-toggle {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
background: transparent;
border: none;
border-radius: 4px;
color: var(--ctp-subtext0);
cursor: pointer;
transition: color 0.15s, background 0.15s;
flex-shrink: 0;
}
.settings-toggle:hover {
color: var(--ctp-text);
background: var(--ctp-surface0);
}
.settings-toggle.active {
color: var(--ctp-blue);
background: var(--ctp-surface0);
}
</style> </style>

View file

@ -478,14 +478,13 @@
<style> <style>
.settings-tab { .settings-tab {
padding: 16px 24px; padding: 12px 16px;
overflow-y: auto; overflow-y: auto;
height: 100%; flex: 1;
max-width: 560px;
} }
h2 { h2 {
font-size: 0.85rem; font-size: 0.8rem;
font-weight: 600; font-weight: 600;
color: var(--ctp-text); color: var(--ctp-text);
margin: 0 0 10px; margin: 0 0 10px;

View file

@ -2,7 +2,7 @@ import { loadGroups, saveGroups, getCliGroup } from '../adapters/groups-bridge';
import type { GroupsFile, GroupConfig, ProjectConfig } from '../types/groups'; import type { GroupsFile, GroupConfig, ProjectConfig } from '../types/groups';
import { clearAllAgentSessions } from '../stores/agents.svelte'; import { clearAllAgentSessions } from '../stores/agents.svelte';
export type WorkspaceTab = 'sessions' | 'docs' | 'context' | 'settings'; export type WorkspaceTab = 'sessions' | 'docs' | 'context';
export interface TerminalTab { export interface TerminalTab {
id: string; id: string;