This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-11 18:34:25 -05:00
1 parent d21bb55800
commit 2b8bcdc595
6 files changed
+102 -14

No files matched your search

@@ -1387,7 +1387,7 @@
: null}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<button
class="group flex items-center gap-1 w-full h-7 rounded-lg text-left transition-colors duration-75
class="group flex items-center gap-1 w-full h-7 pr-2 rounded-lg text-left transition-colors duration-75
{isSelected
? 'bg-blue-50 dark:bg-blue-500/10'
: isDragTarget
@@ -1395,7 +1395,6 @@
? 'bg-blue-100 dark:bg-blue-500/20'
: 'bg-blue-50/60 dark:bg-blue-500/8'
: 'hover:bg-gray-100 dark:hover:bg-white/4'}"
style="padding-left: {8 + entry.depth * 16}px; padding-right: 0.5rem;"
onclick={(e) => handleClick(e, entry, i)}
oncontextmenu={(e) => onContextMenu(e, entry)}
draggable="true"
@@ -1408,7 +1407,7 @@
{#if entry.type === 'directory'}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<span
class="flex items-center justify-center w-4 shrink-0 text-gray-400 dark:text-gray-600 hover:text-gray-600 dark:hover:text-gray-400 cursor-pointer"
class="flex h-full shrink-0 cursor-pointer items-center text-gray-400 hover:text-gray-600 dark:text-gray-600 dark:hover:text-gray-400"
role="button"
tabindex="-1"
onclick={(e) => {
@@ -1422,13 +1421,25 @@
}
}}
>
<Icon
name={expandedDirs.has(entry.path) ? 'chevron-down' : 'chevron-right'}
size={10}
/>
<span class="w-2 shrink-0"></span>
{#each Array(entry.depth) as _}
<span class="w-4 shrink-0"></span>
{/each}
<span class="flex w-4 shrink-0 items-center justify-center">
<Icon
name={expandedDirs.has(entry.path) ? 'chevron-down' : 'chevron-right'}
size={10}
/>
</span>
</span>
{:else}
<span class="w-4 shrink-0"></span>
<span class="flex shrink-0">
<span class="w-2 shrink-0"></span>
{#each Array(entry.depth) as _}
<span class="w-4 shrink-0"></span>
{/each}
<span class="w-4 shrink-0"></span>
</span>
{/if}
<span
class="flex items-center justify-center w-4 shrink-0 {entry.type === 'directory'
@@ -138,7 +138,6 @@
}
function handleContextMenu(e: MouseEvent, tab: Tab) {
if (home) return;
if (!isWideScreen) return;
e.preventDefault();
contextMenu = { tab, x: e.clientX, y: e.clientY };
+11 -1
View File
@@ -357,6 +357,16 @@ export const activeTab = derived(activeGroup, ($g) =>
$g ? ($g.tabs.find((t) => t.id === $g.activeTabId) ?? null) : null
);
export const activeHomeGroup = derived(
homeState,
($state) =>
$state.groups.find((group) => group.id === $state.activeGroupId) ?? $state.groups[0] ?? null
);
export const activeHomeTab = derived(activeHomeGroup, ($group) =>
$group ? ($group.tabs.find((tab) => tab.id === $group.activeTabId) ?? null) : null
);
export const splitActive = derived(currentWorkspace, ($ws) => ($ws?.groups.length ?? 0) > 1);
// ── Compat aliases for old split-pane API ──────────────────────
@@ -1514,7 +1524,7 @@ export function moveTabToGroup(tabId: string, fromGroupId: string, toGroupId: st
}
export function moveHomeTabToGroup(tabId: string, fromGroupId: string, toGroupId: string): void {
homeState.update((state) => moveTabToGroupInState(state, tabId, fromGroupId, toGroupId, false));
homeState.update((state) => moveTabToGroupInState(state, tabId, fromGroupId, toGroupId, true));
}
function moveTabToNewSplitInState<T extends SplitEditorState>(
+22 -2
View File
@@ -245,7 +245,16 @@ export function executeAction(
toggleVoiceMemo?: () => void;
}
): boolean {
const dispatchHomeAction = (detail: 'newChat' | 'newTerminal' | 'newBrowser') => {
const dispatchHomeAction = (
detail:
| 'newChat'
| 'newTerminal'
| 'newBrowser'
| 'closeTab'
| 'nextTab'
| 'prevTab'
| 'toggleSplit'
) => {
if (typeof window !== 'undefined')
window.dispatchEvent(new CustomEvent('cptr:home-action', { detail }));
};
@@ -271,6 +280,10 @@ export function executeAction(
return true;
case 'closeTab': {
if (!get(currentWorkspace)) {
dispatchHomeAction('closeTab');
return true;
}
const group = get(activeGroup);
if (!group) return false;
const tab = group.tabs.find((t) => t.id === group.activeTabId);
@@ -282,6 +295,10 @@ export function executeAction(
case 'nextTab':
case 'prevTab': {
if (!get(currentWorkspace)) {
dispatchHomeAction(action);
return true;
}
const g = get(activeGroup);
if (!g || g.tabs.length < 2) return true;
const visibleTabs = g.tabs.filter((t) => t.type !== 'git');
@@ -307,7 +324,10 @@ export function executeAction(
case 'toggleSplit': {
const ws = get(currentWorkspace);
if (!ws) return false;
if (!ws) {
dispatchHomeAction('toggleSplit');
return true;
}
if (get(splitActive)) {
const otherGroup = ws.groups.find((g) => g.id !== ws.activeGroupId);
if (otherGroup) closeGroup(otherGroup.id);
+2 -1
View File
@@ -16,6 +16,7 @@
import { Toaster, toast } from 'svelte-sonner';
import {
activeTab,
activeHomeTab,
currentWorkspace,
stateLoaded,
initState,
@@ -460,7 +461,7 @@
<GitBar />
{/if}
{#if $activeTab?.type === 'terminal'}
{#if $activeTab?.type === 'terminal' || (!$currentWorkspace && $activeHomeTab?.type === 'terminal')}
<ShortcutBar />
{/if}
</div>
+48 -1
View File
@@ -95,6 +95,24 @@
updateHomeTabs(groupId, () => ({ tabs, activeTabId: group.activeTabId }));
}
function cycleHomeTab(direction: 1 | -1) {
const group = activeHomeGroup;
if (!group || group.tabs.length < 2) return;
const currentIndex = group.tabs.findIndex((tab) => tab.id === group.activeTabId);
if (currentIndex === -1) return;
const nextIndex = (currentIndex + direction + group.tabs.length) % group.tabs.length;
updateHomeTabs(group.id, (tabs) => ({ tabs, activeTabId: tabs[nextIndex].id }));
}
function toggleHomeSplit() {
if ($homeState.groups.length > 1) {
const group = $homeState.groups.find((item) => item.id !== $homeState.activeGroupId);
if (group) closeHomeGroup(group.id);
} else {
splitHomeTab();
}
}
function openHomeChat(chatId?: string, groupId = $homeState.activeGroupId) {
const group = $homeState.groups.find((item) => item.id === groupId);
if (!group) return;
@@ -530,13 +548,42 @@
if (typeof window === 'undefined') return;
const handleHomeAction = (event: Event) => {
if ($currentWorkspace) return;
switch ((event as CustomEvent<'newChat' | 'newTerminal' | 'newBrowser'>).detail) {
switch (
(
event as CustomEvent<
| 'newChat'
| 'newTerminal'
| 'newBrowser'
| 'closeTab'
| 'nextTab'
| 'prevTab'
| 'toggleSplit'
>
).detail
) {
case 'newChat':
openHomeChat();
break;
case 'newBrowser':
void openHomeBrowser();
break;
case 'closeTab':
if (
activeHomeGroup &&
!activeHomeGroup.tabs.find((tab) => tab.id === activeHomeGroup.activeTabId)?.permanent
) {
closeHomeTab(activeHomeGroup.activeTabId, activeHomeGroup.id);
}
break;
case 'nextTab':
cycleHomeTab(1);
break;
case 'prevTab':
cycleHomeTab(-1);
break;
case 'toggleSplit':
toggleHomeSplit();
break;
default:
void openHomeTerminal();
}