This commit is contained in:
Timothy Jaeryang Baek committed 2026-06-06 09:36:26 +01:00
1 parent e7a8ade634
commit 697888f247
11 files changed
+541 -59

No files matched your search

@@ -12,6 +12,8 @@
image?: string;
/** Optional check mark on the right when active. */
check?: boolean;
/** Optional keyboard shortcut hint displayed as a single pill on the right. */
shortcut?: string;
}
interface Props {
@@ -139,6 +141,9 @@
<Icon name={item.icon} size={14} />
{/if}
<span class="flex-1 text-left truncate">{item.label}</span>
{#if item.shortcut}
<kbd class="ml-auto shrink-0 inline-flex items-center h-[18px] px-[5px] rounded-full text-[9px] font-medium leading-none bg-[#e8e8e8] text-[#555] dark:bg-[#1e1e1e] dark:text-[#999]">{item.shortcut}</kbd>
{/if}
{#if item.check && item.active}
<svg class="w-3 h-3 shrink-0 text-gray-400 dark:text-gray-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12" />
@@ -22,6 +22,7 @@
} from '$lib/stores';
import { openChatTab } from '$lib/stores';
import { chatEnabled, streamingChatTabs } from '$lib/stores/chat';
import { keybindings, formatChord } from '$lib/stores/keybindings';
import Icon from './Icon.svelte';
import DropdownMenu from './DropdownMenu.svelte';
import { tooltip } from '$lib/tooltip';
@@ -129,16 +130,19 @@
{
label: $t('bar.newFile'),
icon: 'page',
shortcut: formatChord($keybindings.newFile),
onclick: () => { openUntitledFileTab(group.id); },
},
...($chatEnabled ? [{
label: $t('bar.newChat'),
icon: 'chat-bubble',
shortcut: formatChord($keybindings.newChat),
onclick: () => { openChatTab(undefined, group.id); },
}] : []),
{
label: $t('bar.newTerminal'),
icon: 'terminal',
shortcut: formatChord($keybindings.newTerminal),
onclick: () => { openTerminalTab(group.id); },
},
]);
@@ -24,7 +24,7 @@
>
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="bg-white dark:bg-[#0a0a0a] dark:border dark:border-white/8 rounded-3xl overflow-hidden shadow-2xl p-0.5 {className}"
class="bg-white dark:bg-[#0a0a0a] dark:border dark:border-white/8 rounded-3xl overflow-hidden shadow-2xl {className}"
onmousedown={(e) => e.stopPropagation()}
onkeydown={() => {}}
>
@@ -1,6 +1,7 @@
<script lang="ts">
import { activeWorkspace, openFileTab } from '$lib/stores';
import { searchFiles } from '$lib/apis/files';
import Modal from './Modal.svelte';
import Icon from './Icon.svelte';
import { t } from '$lib/i18n';
@@ -53,9 +54,7 @@
}
function handleKeydown(e: KeyboardEvent) {
if (e.key === 'Escape') {
onclose();
} else if (e.key === 'ArrowDown') {
if (e.key === 'ArrowDown') {
e.preventDefault();
selectedIndex = Math.min(selectedIndex + 1, results.length - 1);
} else if (e.key === 'ArrowUp') {
@@ -76,39 +75,38 @@
<svelte:window onkeydown={handleKeydown} />
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div class="fixed inset-0 bg-black/50 z-[100] flex items-start justify-center pt-[15vh] max-md:pt-0 max-md:items-stretch" onclick={onclose} onkeydown={() => {}}>
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div class="w-full max-w-[520px] bg-white dark:bg-[#111] dark:border dark:border-white/8 rounded-3xl max-md:rounded-none overflow-hidden shadow-2xl max-h-[400px] max-md:max-h-dvh flex flex-col" onclick={(e) => e.stopPropagation()} onkeydown={() => {}}>
<div class="flex items-center px-4 py-3 gap-2.5 border-b border-gray-200 dark:border-white/6">
<Icon name="search" size={16} class="text-gray-400 shrink-0" />
<input
bind:this={inputEl}
type="text"
class="flex-1 border-none outline-none bg-transparent text-sm text-gray-900 dark:text-white font-sans placeholder:text-gray-400"
placeholder={$t('quickOpen.searchFiles')}
bind:value={query}
/>
<span class="text-[10px] font-mono font-medium px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/6 text-gray-400 shrink-0">ESC</span>
</div>
{#if results.length > 0}
<div class="overflow-y-auto p-1">
{#each results as r, i (r.path)}
<button
class="flex items-center gap-2 w-full px-3 py-2 rounded-md text-left text-gray-400 transition-colors duration-75
{i === selectedIndex ? 'bg-gray-100 dark:bg-white/6' : ''}"
onclick={() => selectResult(r)}
onmouseenter={() => selectedIndex = i}
>
<Icon name={r.type === 'directory' ? 'folder' : 'empty-page'} size={14} />
<span class="text-[13px] font-medium text-gray-800 dark:text-gray-200 shrink-0">{r.name}</span>
<span class="text-[11px] text-gray-400 overflow-hidden text-ellipsis whitespace-nowrap">{relativePath(r.path)}</span>
</button>
{/each}
</div>
{:else if query && !loading}
<div class="p-6 text-center text-sm text-gray-400">{$t('quickOpen.noFiles')}</div>
{/if}
<Modal {onclose} class="w-full max-w-[520px] mx-4 max-md:mx-0 max-md:rounded-none max-h-[400px] max-md:max-h-dvh flex flex-col mb-[6vh] max-md:mb-0">
<div class="flex items-center px-4 py-2.5 gap-2.5 border-b border-gray-200 dark:border-white/6">
<Icon name="search" size={14} class="text-gray-400 shrink-0" />
<input
bind:this={inputEl}
type="text"
class="flex-1 border-none outline-none bg-transparent text-xs text-gray-900 dark:text-white font-sans placeholder:text-gray-400"
placeholder={$t('quickOpen.searchFiles')}
bind:value={query}
/>
<span class="text-[10px] font-mono font-medium px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/6 text-gray-400 shrink-0">ESC</span>
</div>
</div>
{#if results.length > 0}
<div class="overflow-y-auto p-1.5">
{#each results as r, i (r.path)}
<button
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-left transition-colors duration-75
{i === selectedIndex
? 'bg-gray-200/50 text-gray-900 dark:bg-white/6 dark:text-white'
: 'text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/4'}"
onclick={() => selectResult(r)}
onmouseenter={() => selectedIndex = i}
>
<Icon name={r.type === 'directory' ? 'folder' : 'empty-page'} size={14} class="shrink-0 text-gray-400" />
<span class="text-xs font-medium shrink-0">{r.name}</span>
<span class="text-[11px] text-gray-400 overflow-hidden text-ellipsis whitespace-nowrap">{relativePath(r.path)}</span>
</button>
{/each}
</div>
{:else if query && !loading}
<div class="p-6 text-center text-xs text-gray-400">{$t('quickOpen.noFiles')}</div>
{/if}
</Modal>
@@ -0,0 +1,180 @@
<script lang="ts">
import { keybindings, ACTION_IDS, ACTION_LABELS, DEFAULT_KEYBINDINGS, formatChord, eventToChord, resetKeybindings } from '$lib/stores/keybindings';
import type { ActionId } from '$lib/stores/keybindings';
/** Action descriptions for the second line. */
const ACTION_DESCRIPTIONS: Record<ActionId, string> = {
newFile: 'Open a new untitled file',
newTerminal: 'Open a new terminal session',
newChat: 'Start a new AI chat',
closeTab: 'Close the active tab',
nextTab: 'Switch to the next tab',
prevTab: 'Switch to the previous tab',
quickOpen: 'Search and open files quickly',
openSettings: 'Open the settings panel',
toggleSplit: 'Toggle split editor view',
toggleSidebar: 'Show or hide the sidebar',
};
let recordingAction = $state<ActionId | null>(null);
function startRecording(actionId: ActionId) {
recordingAction = actionId;
}
function cancelRecording() {
recordingAction = null;
}
function handleKeydown(e: KeyboardEvent) {
if (!recordingAction) return;
e.preventDefault();
e.stopPropagation();
const chord = eventToChord(e);
if (!chord) return; // Pure modifier press, keep waiting
if (chord === 'ESCAPE') {
cancelRecording();
return;
}
// Save it
keybindings.update((current) => ({
...current,
[recordingAction!]: chord,
}));
recordingAction = null;
}
function clearBinding(actionId: ActionId) {
keybindings.update((current) => ({
...current,
[actionId]: '',
}));
}
/** Check if a chord is used by another action. */
function getConflict(actionId: ActionId, chord: string): ActionId | null {
if (!chord) return null;
for (const id of ACTION_IDS) {
if (id !== actionId && $keybindings[id] === chord) return id;
}
return null;
}
</script>
<svelte:window onkeydown={handleKeydown} />
<div class="flex flex-col min-h-full">
<div class="flex items-center justify-between mb-3">
<h2 class="text-sm font-medium text-gray-900 dark:text-white">Keyboard Shortcuts</h2>
<button
class="text-[10px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-100"
onclick={resetKeybindings}
>Reset defaults</button>
</div>
<!-- Column headers -->
<div class="flex items-center gap-2 mb-0.5 px-1">
<span class="flex-1 text-[10px] font-medium text-gray-400 dark:text-gray-600">Command</span>
<span class="w-[140px] text-[10px] font-medium text-gray-400 dark:text-gray-600 text-right">Keybinding</span>
</div>
<div class="flex flex-col">
{#each ACTION_IDS as actionId}
{@const chord = $keybindings[actionId]}
{@const isRecording = recordingAction === actionId}
{@const conflict = getConflict(actionId, chord)}
<div class="shortcut-row">
<div class="flex-1 min-w-0">
<div class="text-[11.5px] text-gray-700 dark:text-gray-300">{ACTION_LABELS[actionId]}</div>
<div class="text-[10px] text-gray-400 dark:text-gray-600 truncate leading-tight">{ACTION_DESCRIPTIONS[actionId]}</div>
</div>
<div class="w-[140px] flex items-center justify-end shrink-0">
{#if isRecording}
<span class="recording-indicator">Press keys…</span>
{:else if chord}
<button
class="key-pill cursor-pointer"
onclick={() => startRecording(actionId)}
title="Click to rebind"
>
{formatChord(chord)}
</button>
{:else}
<button
class="text-[10px] text-gray-500 dark:text-gray-600 cursor-pointer hover:text-gray-400 transition-colors duration-75"
onclick={() => startRecording(actionId)}
>Unassigned</button>
{/if}
{#if conflict}
<span class="text-[9px] text-amber-500 ml-1" title="Also bound to {ACTION_LABELS[conflict]}">!</span>
{/if}
</div>
</div>
{/each}
</div>
<p class="text-[10px] text-gray-400 dark:text-gray-600 mt-3">
Click a binding to rebind. Press <kbd class="kbd-inline">Esc</kbd> to cancel.
</p>
</div>
<style>
@reference "../../../app.css";
.shortcut-row {
@apply flex items-center gap-2 px-1 py-1.5;
border-bottom: 1px solid rgba(128, 128, 128, 0.04);
}
.shortcut-row:last-child {
border-bottom: none;
}
.key-pill {
display: inline-flex;
align-items: center;
justify-content: center;
height: 22px;
padding: 0 6px;
border-radius: 9999px;
font-size: 10px;
font-weight: 500;
line-height: 1;
background: #e8e8e8;
color: #555;
}
:global(.dark) .key-pill {
background: #1e1e1e;
color: #999;
}
.recording-indicator {
display: inline-flex;
align-items: center;
height: 18px;
padding: 0 8px;
border-radius: 4px;
font-size: 10px;
font-weight: 500;
background: rgba(59, 130, 246, 0.1);
color: rgba(59, 130, 246, 0.7);
animation: pulse-subtle 1.5s ease-in-out infinite;
}
@keyframes pulse-subtle {
0%, 100% { opacity: 1; }
50% { opacity: 0.6; }
}
.kbd-inline {
@apply inline px-0.5 py-px rounded text-[9px] font-mono bg-gray-100 dark:bg-white/6 text-gray-500;
}
</style>
@@ -3,17 +3,18 @@
import Modal from "./Modal.svelte";
import General from "./Settings/General.svelte";
import Account from "./Settings/Account.svelte";
import Keyboard from "./Settings/Keyboard.svelte";
import About from "./Settings/About.svelte";
import { t } from '$lib/i18n';
interface Props {
onclose: () => void;
initialTab?: 'general' | 'account' | 'about';
initialTab?: 'general' | 'keyboard' | 'account' | 'about';
}
let { onclose, initialTab = 'general' }: Props = $props();
let activeTab = $state<"general" | "account" | "about">(initialTab);
let activeTab = $state<"general" | "keyboard" | "account" | "about">(initialTab);
</script>
<Modal
@@ -31,7 +32,7 @@
<Icon name="chevron-left" size={12} />
<span>{$t('settings.back')}</span>
</button>
{#each [{ id: "general", label: $t('settings.general'), icon: "settings" }, { id: "account", label: $t('settings.account'), icon: "user" }, { id: "about", label: $t('settings.about'), icon: "info" }] as tab}
{#each [{ id: "general", label: $t('settings.general'), icon: "settings" }, { id: "keyboard", label: "Keyboard", icon: "terminal" }, { id: "account", label: $t('settings.account'), icon: "user" }, { id: "about", label: $t('settings.about'), icon: "info" }] as tab}
<button
class="flex items-center gap-1.5 h-7 px-2 md:w-full shrink-0 rounded-lg text-xs text-left transition-colors duration-75
{activeTab === tab.id
@@ -49,6 +50,8 @@
<div class="flex-1 overflow-y-auto min-h-0 p-4 md:px-5">
{#if activeTab === "general"}
<General />
{:else if activeTab === "keyboard"}
<Keyboard />
{:else if activeTab === "account"}
<Account />
{:else if activeTab === "about"}
@@ -178,7 +178,7 @@
if (!child) return;
const popupHeight = child.offsetHeight || 200;
child.style.position = 'fixed';
child.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - 320))}px`;
child.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - 340))}px`;
child.style.top = `${rect.top - popupHeight - 8}px`;
}
@@ -34,7 +34,7 @@
</script>
<div
class="fixed z-[200] w-56 max-h-40 overflow-y-auto rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5"
class="fixed z-50 w-64 max-h-40 overflow-y-auto rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5"
>
{#if items.length === 0}
<div class="px-3 py-2 text-xs text-gray-400 dark:text-gray-600">No files found</div>
+5
View File
@@ -27,6 +27,7 @@ import {
import { listSessions, createSession, deleteSession } from '$lib/apis/terminal';
import { changeLocale, i18next } from '$lib/i18n';
import { streamingChatTabs } from '$lib/stores/chat';
import { keybindings, loadKeybindings } from '$lib/stores/keybindings';
// ── Types ───────────────────────────────────────────────────────
@@ -71,6 +72,7 @@ export interface UserPreferences {
toolApprovalMode: ToolApprovalMode;
locale: string;
workspaceOrder?: string[]; // ordered paths for sidebar drag-reorder
keybindings?: Record<string, string>; // user-customised keyboard shortcuts
}
export type Theme = 'dark' | 'light' | 'system';
@@ -261,6 +263,7 @@ function persistPreferences(): void {
toolApprovalMode: get(toolApprovalMode),
locale: i18next.language,
workspaceOrder: get(workspaceOrder),
keybindings: get(keybindings),
};
savePreferences(prefs as unknown as Record<string, unknown>).catch(() => {});
}, 300);
@@ -276,6 +279,7 @@ function subscribeForPersistence() {
sidebarWidth.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
toolApprovalMode.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
workspaceOrder.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
keybindings.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
i18next.on('languageChanged', () => { if (get(stateLoaded)) persistPreferences(); });
}
@@ -296,6 +300,7 @@ export async function loadPreferences(): Promise<void> {
}
if (prefs.locale) changeLocale(prefs.locale as string);
if (Array.isArray(prefs.workspaceOrder)) workspaceOrder.set(prefs.workspaceOrder as string[]);
if (prefs.keybindings) loadKeybindings(prefs.keybindings as Record<string, string>);
} catch {
// First run, no preferences yet
}
+289
View File
@@ -0,0 +1,289 @@
/**
* Configurable keyboard shortcuts system.
*
* Every shortcut is user-configurable and persisted in preferences.
* Ships with conventional IDE defaults that avoid conflicting with
* browser-native shortcuts (Cmd+W, Cmd+T, Cmd+N, Cmd+1-9, Ctrl+Tab).
*
* Chord format: modifiers in fixed order + key, e.g. "Cmd+Shift+K"
* Modifier order: Cmd → Ctrl → Alt → Shift
* "Cmd" normalizes Meta (Mac) and Ctrl (Win/Linux) into one token.
*/
import { writable, get } from 'svelte/store';
import {
openUntitledFileTab,
openTerminalTab,
closeTab,
setActiveTab,
activeGroup,
currentWorkspace,
splitActive,
splitCurrentTab,
closeGroup,
sidebarOpen,
} from '$lib/stores';
import { openChatTab } from '$lib/stores';
// ── Action IDs ──────────────────────────────────────────────────
export const ACTION_IDS = [
'newFile',
'newTerminal',
'newChat',
'closeTab',
'nextTab',
'prevTab',
'quickOpen',
'openSettings',
'toggleSplit',
'toggleSidebar',
] as const;
export type ActionId = (typeof ACTION_IDS)[number];
// ── Human-readable labels ───────────────────────────────────────
export const ACTION_LABELS: Record<ActionId, string> = {
newFile: 'New File',
newTerminal: 'New Terminal',
newChat: 'New Chat',
closeTab: 'Close Tab',
nextTab: 'Next Tab',
prevTab: 'Previous Tab',
quickOpen: 'Quick Open',
openSettings: 'Open Settings',
toggleSplit: 'Toggle Split',
toggleSidebar: 'Toggle Sidebar',
};
// ── Default bindings (browser-safe) ─────────────────────────────
export const DEFAULT_KEYBINDINGS: Record<ActionId, string> = {
newFile: 'Cmd+N',
newTerminal: 'Ctrl+`',
newChat: 'Cmd+Shift+O',
closeTab: 'Cmd+W',
nextTab: 'Cmd+Shift+]',
prevTab: 'Cmd+Shift+[',
quickOpen: 'Cmd+K',
openSettings: 'Cmd+.',
toggleSplit: 'Cmd+\\',
toggleSidebar: 'Cmd+Shift+S',
};
// ── Store ───────────────────────────────────────────────────────
export type KeybindingsMap = Record<ActionId, string>;
export const keybindings = writable<KeybindingsMap>({ ...DEFAULT_KEYBINDINGS });
/** Load keybindings from saved preferences (partial map is OK). */
export function loadKeybindings(saved: Partial<Record<string, string>> | undefined): void {
if (!saved || typeof saved !== 'object') return;
keybindings.update((current) => {
const updated = { ...current };
for (const id of ACTION_IDS) {
if (typeof saved[id] === 'string' && saved[id]) {
updated[id] = saved[id]!;
}
}
return updated;
});
}
/** Reset all keybindings to defaults. */
export function resetKeybindings(): void {
keybindings.set({ ...DEFAULT_KEYBINDINGS });
}
// ── Chord normalisation ─────────────────────────────────────────
const IS_MAC = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.userAgent);
/**
* Convert a KeyboardEvent into a normalised chord string.
*
* On Mac: metaKey → "Cmd", ctrlKey stays as "Ctrl" (for Ctrl+` etc.)
* On Win/Linux: ctrlKey → "Cmd" (so "Cmd+K" means Ctrl+K there)
*
* Modifier order: Cmd → Ctrl → Alt → Shift → Key
*/
export function eventToChord(e: KeyboardEvent): string {
const parts: string[] = [];
if (IS_MAC) {
if (e.metaKey) parts.push('Cmd');
if (e.ctrlKey) parts.push('Ctrl');
} else {
// Windows/Linux: Ctrl acts as Cmd
if (e.ctrlKey) parts.push('Cmd');
}
if (e.altKey) parts.push('Alt');
if (e.shiftKey) parts.push('Shift');
// Normalise the key
let key = e.key;
// Skip pure modifier presses
if (['Meta', 'Control', 'Alt', 'Shift'].includes(key)) return '';
// Normalise common key names
if (key === ' ') key = 'Space';
if (key === 'Escape') key = 'Escape';
if (key.length === 1) key = key.toUpperCase();
// Bracket keys come through as the character when Shift is held
// but we want the base key name
if (key === '{') key = '[';
if (key === '}') key = ']';
parts.push(key);
return parts.join('+');
}
/**
* Format a chord string for display (e.g. "Cmd+Shift+N" → "⌘⇧N" on Mac).
*/
export function formatChord(chord: string): string {
if (!chord) return '';
const parts = chord.split('+');
const formatted = parts.map((part) => {
if (IS_MAC) {
switch (part) {
case 'Cmd': return '⌘';
case 'Ctrl': return '⌃';
case 'Alt': return '⌥';
case 'Shift': return '⇧';
default: return part;
}
}
return part;
});
// On Mac, join directly like Open WebUI; on Win/Linux use +
return IS_MAC ? formatted.join('') : formatted.join('+');
}
/**
* Split a chord into individual display tokens for rendering as separate pills.
* e.g. "Cmd+Shift+N" → ["⌘", "⇧", "N"] on Mac, ["Ctrl", "Shift", "N"] on Win.
*/
export function chordToDisplayParts(chord: string): string[] {
if (!chord) return [];
const parts = chord.split('+');
return parts.map((part) => {
if (IS_MAC) {
switch (part) {
case 'Cmd': return '⌘';
case 'Ctrl': return '⌃';
case 'Alt': return '⌥';
case 'Shift': return '⇧';
default: return part;
}
}
return part;
});
}
// ── Event matching ──────────────────────────────────────────────
/** Build a reverse lookup from chord → action. */
function buildReverseLookup(bindings: KeybindingsMap): Map<string, ActionId> {
const map = new Map<string, ActionId>();
for (const id of ACTION_IDS) {
const chord = bindings[id];
if (chord) map.set(chord, id);
}
return map;
}
/**
* Match a KeyboardEvent against current keybindings.
* Returns the matching ActionId or null.
*/
export function matchKeybinding(e: KeyboardEvent): ActionId | null {
const chord = eventToChord(e);
if (!chord) return null;
const lookup = buildReverseLookup(get(keybindings));
return lookup.get(chord) ?? null;
}
// ── Action executor ─────────────────────────────────────────────
/**
* Execute a keybinding action.
* Returns true if an action was executed, false if not
* (e.g. quickOpen is handled externally via callback).
*/
export function executeAction(
action: ActionId,
callbacks?: {
toggleQuickOpen?: () => void;
toggleSettings?: () => void;
}
): boolean {
switch (action) {
case 'newFile':
openUntitledFileTab();
return true;
case 'newTerminal':
openTerminalTab();
return true;
case 'newChat':
openChatTab();
return true;
case 'closeTab': {
const group = get(activeGroup);
if (!group) return false;
const tab = group.tabs.find((t) => t.id === group.activeTabId);
if (tab && !tab.permanent) {
closeTab(tab.id, group.id);
}
return true;
}
case 'nextTab':
case 'prevTab': {
const g = get(activeGroup);
if (!g || g.tabs.length < 2) return true;
const visibleTabs = g.tabs.filter((t) => t.type !== 'git');
const currentIdx = visibleTabs.findIndex((t) => t.id === g.activeTabId);
if (currentIdx === -1) return true;
const dir = action === 'nextTab' ? 1 : -1;
const nextIdx = (currentIdx + dir + visibleTabs.length) % visibleTabs.length;
setActiveTab(visibleTabs[nextIdx].id, g.id);
return true;
}
case 'quickOpen':
callbacks?.toggleQuickOpen?.();
return true;
case 'openSettings':
callbacks?.toggleSettings?.();
return true;
case 'toggleSplit': {
const ws = get(currentWorkspace);
if (!ws) return false;
if (get(splitActive)) {
const otherGroup = ws.groups.find((g) => g.id !== ws.activeGroupId);
if (otherGroup) closeGroup(otherGroup.id);
} else {
splitCurrentTab();
}
return true;
}
case 'toggleSidebar':
sidebarOpen.update((v) => !v);
return true;
default:
return false;
}
}
+13 -15
View File
@@ -8,9 +8,11 @@
import ShortcutBar from '$lib/components/ShortcutBar.svelte';
import GitBar from '$lib/components/GitBar.svelte';
import QuickOpen from '$lib/components/QuickOpen.svelte';
import SettingsModal from '$lib/components/SettingsModal.svelte';
import AuthScreen from '$lib/components/AuthScreen.svelte';
import { Toaster } from 'svelte-sonner';
import { activeTab, currentWorkspace, stateLoaded, initState, gitReviewOpen, isGitRepo, splitActive, splitCurrentTab, closeGroup } from '$lib/stores';
import { matchKeybinding, executeAction } from '$lib/stores/keybindings';
import { systemEvents } from '$lib/stores/systemEvents.svelte';
import { socketStore } from '$lib/stores/socket.svelte';
import { setSession } from '$lib/session';
@@ -21,6 +23,7 @@
let { children } = $props();
let showQuickOpen = $state(false);
let showSettings = $state(false);
let viewportHeight = $state('100dvh');
// Auth state
@@ -128,21 +131,13 @@
}
function handleKeydown(e: KeyboardEvent) {
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
e.preventDefault();
showQuickOpen = !showQuickOpen;
}
// Cmd/Ctrl+\ to toggle split view
if ((e.metaKey || e.ctrlKey) && e.key === '\\') {
e.preventDefault();
if ($splitActive && $currentWorkspace) {
// Close the non-active group
const otherGroup = $currentWorkspace.groups.find((g) => g.id !== $currentWorkspace!.activeGroupId);
if (otherGroup) closeGroup(otherGroup.id);
} else {
splitCurrentTab();
}
}
const action = matchKeybinding(e);
if (!action) return;
e.preventDefault();
executeAction(action, {
toggleQuickOpen: () => { showQuickOpen = !showQuickOpen; },
toggleSettings: () => { showSettings = !showSettings; },
});
}
// Connect system events when workspace is active
@@ -233,6 +228,9 @@
{#if showQuickOpen}
<QuickOpen onclose={() => showQuickOpen = false} />
{/if}
{#if showSettings}
<SettingsModal onclose={() => showSettings = false} />
{/if}
{:else}
<div class="flex items-center justify-center h-dvh bg-white dark:bg-black">
<div class="w-5 h-5 border-2 border-gray-300 border-t-gray-600 dark:border-gray-700 dark:border-t-gray-400 rounded-full animate-spin"></div>