feat(v2): add session groups with collapsible sidebar headers

Add group_name column to sessions table with ALTER TABLE migration,
setPaneGroup in layout store, grouped sidebar rendering with Svelte 5
snippets, and right-click to assign group via prompt dialog.
This commit is contained in:
Hibryda 2026-03-06 15:42:16 +01:00
parent f349f3bb14
commit 035d4186fa
5 changed files with 144 additions and 7 deletions

View file

@ -6,6 +6,7 @@ import {
touchSession,
saveLayout,
loadLayout,
updateSessionGroup,
type PersistedSession,
} from '../adapters/session-bridge';
@ -20,6 +21,7 @@ export interface Pane {
shell?: string;
cwd?: string;
args?: string[];
group?: string;
focused: boolean;
}
@ -39,6 +41,7 @@ function persistSession(pane: Pane): void {
shell: pane.shell,
cwd: pane.cwd,
args: pane.args,
group_name: pane.group ?? '',
created_at: now,
last_used_at: now,
};
@ -109,6 +112,14 @@ export function renamePaneTitle(id: string, title: string): void {
}
}
export function setPaneGroup(id: string, group: string): void {
const pane = panes.find(p => p.id === id);
if (pane) {
pane.group = group || undefined;
updateSessionGroup(id, group).catch(e => console.warn('Failed to update group:', e));
}
}
/** Restore panes and layout from SQLite on app startup */
export async function restoreFromDb(): Promise<void> {
if (initialized) return;
@ -135,6 +146,7 @@ export async function restoreFromDb(): Promise<void> {
shell: s.shell ?? undefined,
cwd: s.cwd ?? undefined,
args: s.args ?? undefined,
group: s.group_name || undefined,
focused: false,
});
}