mirror of
https://github.com/open-webui/computer.git
synced 2026-11-23 14:10:45 -05:00
refac
This commit is contained in:
1 parent
7da8f114cf
commit
f44b620fd7
5 files changed
+481
-41
No files matched your search
@@ -18,6 +18,7 @@
|
||||
import DirectoryPicker from './DirectoryPicker.svelte';
|
||||
import DropdownMenu from './DropdownMenu.svelte';
|
||||
import SettingsModal from './SettingsModal.svelte';
|
||||
import SystemInfoModal from './SystemInfoModal.svelte';
|
||||
|
||||
import { tooltip } from '$lib/tooltip';
|
||||
import { session, clearSession } from '$lib/session';
|
||||
@@ -34,6 +35,7 @@
|
||||
let showPicker = $state(false);
|
||||
let showMenu = $state(false);
|
||||
let showSettings = $state(false);
|
||||
let showSystemInfo = $state(false);
|
||||
let settingsTab = $state<string>('general');
|
||||
let wsMenuPath = $state<string | null>(null);
|
||||
let wsMenuAnchor = $state<HTMLElement | null>(null);
|
||||
@@ -214,6 +216,11 @@
|
||||
showSettings = true;
|
||||
}
|
||||
|
||||
function openSystemInfo() {
|
||||
showMenu = false;
|
||||
showSystemInfo = true;
|
||||
}
|
||||
|
||||
function logout() {
|
||||
clearSession();
|
||||
}
|
||||
@@ -503,6 +510,11 @@
|
||||
shortcut: formatChord($keybindings.openSettings),
|
||||
onclick: openSettings
|
||||
},
|
||||
{
|
||||
label: 'System info',
|
||||
icon: 'info',
|
||||
onclick: openSystemInfo
|
||||
},
|
||||
{ divider: true, label: '', onclick: () => {} },
|
||||
{ label: $t('sidebar.logOut'), icon: 'log-out', onclick: logout }
|
||||
]}
|
||||
@@ -538,6 +550,10 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showSystemInfo}
|
||||
<SystemInfoModal onclose={() => (showSystemInfo = false)} />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
@reference "../../app.css";
|
||||
|
||||
|
||||
@@ -28,9 +28,10 @@
|
||||
interface Props {
|
||||
system: SystemInfo;
|
||||
processes?: Process[];
|
||||
defaultOpen?: boolean;
|
||||
}
|
||||
|
||||
let { system: sys, processes = [] }: Props = $props();
|
||||
let { system: sys, processes = [], defaultOpen = false }: Props = $props();
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
if (bytes < 1073741824) return `${(bytes / 1048576).toFixed(0)} MB`;
|
||||
@@ -64,7 +65,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<Collapsible title={$t('system.title')} {summary}>
|
||||
<Collapsible title={$t('system.title')} {summary} open={defaultOpen}>
|
||||
<div class="flex flex-col gap-3">
|
||||
{#if sys.cpu_usage != null}
|
||||
<div>
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import Modal from './Modal.svelte';
|
||||
import SystemInfo from './SystemInfo.svelte';
|
||||
import Spinner from './common/Spinner.svelte';
|
||||
import { getWelcome } from '$lib/apis/state';
|
||||
|
||||
interface Props {
|
||||
onclose: () => void;
|
||||
}
|
||||
|
||||
let { onclose }: Props = $props();
|
||||
|
||||
let loading = $state(true);
|
||||
let welcomeData = $state<{
|
||||
hostname?: string;
|
||||
system?: {
|
||||
os: string;
|
||||
arch: string;
|
||||
python: string;
|
||||
cpu_count: number;
|
||||
memory_total?: number;
|
||||
memory_available?: number;
|
||||
disk_total?: number;
|
||||
disk_used?: number;
|
||||
disk_free?: number;
|
||||
uptime_seconds?: number;
|
||||
load_avg?: number[];
|
||||
cpu_usage?: number;
|
||||
network?: { name: string; ip: string }[];
|
||||
};
|
||||
processes?: { pid: number; cpu: number; mem: number; name: string }[];
|
||||
} | null>(null);
|
||||
|
||||
onMount(() => {
|
||||
getWelcome()
|
||||
.then((data) => {
|
||||
welcomeData = data as typeof welcomeData;
|
||||
})
|
||||
.catch(() => {
|
||||
welcomeData = null;
|
||||
})
|
||||
.finally(() => {
|
||||
loading = false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<Modal {onclose} class="w-full max-w-[420px] mx-4">
|
||||
<div class="px-4 py-3.5">
|
||||
<div class="mb-3 flex items-baseline justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white">System info</h2>
|
||||
{#if welcomeData?.hostname}
|
||||
<p class="mt-0.5 truncate font-mono text-[11px] text-gray-400 dark:text-gray-600">
|
||||
{welcomeData.hostname}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if loading}
|
||||
<div class="flex h-28 items-center justify-center">
|
||||
<Spinner size={18} />
|
||||
</div>
|
||||
{:else if welcomeData?.system}
|
||||
<SystemInfo system={welcomeData.system} processes={welcomeData.processes ?? []} defaultOpen />
|
||||
{:else}
|
||||
<div class="py-8 text-center text-xs text-gray-400 dark:text-gray-600">
|
||||
System info unavailable
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</Modal>
|
||||
@@ -0,0 +1,193 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
activeWorkspace,
|
||||
setActiveTab,
|
||||
gitReviewOpen,
|
||||
openPreviewTab,
|
||||
type Tab
|
||||
} from '$lib/stores';
|
||||
import { systemEvents } from '$lib/stores/systemEvents.svelte';
|
||||
import { gitStatusStore } from '$lib/stores/gitStatus.svelte';
|
||||
import Icon from './Icon.svelte';
|
||||
|
||||
interface Props {
|
||||
onclose: () => void;
|
||||
}
|
||||
|
||||
let { onclose }: Props = $props();
|
||||
|
||||
const tabs = $derived($activeWorkspace?.groups.flatMap((group) => group.tabs) ?? []);
|
||||
const nonFileTabs = $derived(
|
||||
tabs.filter(
|
||||
(tab) => ['terminal', 'chat', 'preview', 'file'].includes(tab.type) && !tab.permanent
|
||||
)
|
||||
);
|
||||
const terminalTabs = $derived(tabs.filter((tab) => tab.type === 'terminal'));
|
||||
const chatTabs = $derived(tabs.filter((tab) => tab.type === 'chat'));
|
||||
const previewTabs = $derived(tabs.filter((tab) => tab.type === 'preview' && tab.port));
|
||||
const gitStatus = $derived(gitStatusStore.status);
|
||||
const changedFiles = $derived(gitStatus?.files?.length ?? 0);
|
||||
const livePorts = $derived(
|
||||
systemEvents.ports.filter((port) =>
|
||||
tabs.some((tab) => tab.type === 'terminal' && tab.sessionId === port.session_id)
|
||||
)
|
||||
);
|
||||
const hasResumeItems = $derived(
|
||||
terminalTabs.length > 0 ||
|
||||
chatTabs.length > 0 ||
|
||||
previewTabs.length > 0 ||
|
||||
livePorts.length > 0 ||
|
||||
changedFiles > 0 ||
|
||||
nonFileTabs.length > 1
|
||||
);
|
||||
|
||||
function activateTab(tab: Tab) {
|
||||
const group = $activeWorkspace?.groups.find((g) => g.tabs.some((t) => t.id === tab.id));
|
||||
if (!group) return;
|
||||
setActiveTab(tab.id, group.id);
|
||||
onclose();
|
||||
}
|
||||
|
||||
function openGit() {
|
||||
gitReviewOpen.set(true);
|
||||
onclose();
|
||||
}
|
||||
|
||||
function openPort(port: number) {
|
||||
openPreviewTab(port);
|
||||
onclose();
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if hasResumeItems}
|
||||
<section class="resume-sheet md:hidden" aria-label="Workspace resume">
|
||||
<div class="mb-1.5 flex items-baseline justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<h2 class="truncate text-xs font-medium text-gray-800 dark:text-gray-200">
|
||||
{$activeWorkspace?.name}
|
||||
</h2>
|
||||
<p class="truncate font-mono text-[10px] text-gray-400 dark:text-gray-600">
|
||||
{$activeWorkspace?.path}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"
|
||||
onclick={onclose}
|
||||
aria-label="Dismiss resume"
|
||||
>
|
||||
<Icon name="xmark" size={11} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="space-y-px">
|
||||
{#if changedFiles > 0}
|
||||
<button class="resume-row" onclick={openGit}>
|
||||
<Icon name="git-diff" size={14} />
|
||||
<span class="min-w-0 flex-1 truncate">{changedFiles} changed files</span>
|
||||
<span class="resume-meta">{gitStatus?.branch}</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#each livePorts as port (port.port)}
|
||||
<button class="resume-row" onclick={() => openPort(port.port)}>
|
||||
<Icon name="monitor" size={14} />
|
||||
<span class="min-w-0 flex-1 truncate">localhost:{port.port}</span>
|
||||
<span class="resume-meta">{port.process}</span>
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
{#each terminalTabs as tab (tab.id)}
|
||||
<button class="resume-row" onclick={() => activateTab(tab)}>
|
||||
<Icon name="terminal" size={14} />
|
||||
<span class="min-w-0 flex-1 truncate">{tab.label || 'Terminal'}</span>
|
||||
<span class="resume-meta">{tab.sessionId ? 'running' : 'starting'}</span>
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
{#each chatTabs as tab (tab.id)}
|
||||
<button class="resume-row" onclick={() => activateTab(tab)}>
|
||||
<Icon name="chat-bubble" size={14} />
|
||||
<span class="min-w-0 flex-1 truncate">{tab.label || 'Chat'}</span>
|
||||
<span class="resume-meta">chat</span>
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
{#each previewTabs as tab (tab.id)}
|
||||
<button class="resume-row" onclick={() => activateTab(tab)}>
|
||||
<Icon name="monitor" size={14} />
|
||||
<span class="min-w-0 flex-1 truncate">{tab.label || `localhost:${tab.port}`}</span>
|
||||
<span class="resume-meta">preview</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
@reference "../../app.css";
|
||||
|
||||
.resume-sheet {
|
||||
position: fixed;
|
||||
left: 8px;
|
||||
right: 8px;
|
||||
bottom: calc(8px + env(safe-area-inset-bottom, 0px));
|
||||
z-index: 90;
|
||||
max-height: min(44dvh, 280px);
|
||||
overflow-y: auto;
|
||||
border: 1px solid var(--color-gray-200);
|
||||
border-radius: 12px;
|
||||
background: white;
|
||||
padding: 7px;
|
||||
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
:global(.dark) .resume-sheet {
|
||||
border-color: rgba(255, 255, 255, 0.08);
|
||||
background: #050505;
|
||||
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
.resume-row {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
border-radius: 7px;
|
||||
padding: 5px 6px;
|
||||
text-align: left;
|
||||
font-size: 11px;
|
||||
color: var(--color-gray-700);
|
||||
transition:
|
||||
background 0.1s,
|
||||
color 0.1s;
|
||||
}
|
||||
|
||||
.resume-row:hover {
|
||||
background: var(--color-gray-100);
|
||||
color: var(--color-gray-950);
|
||||
}
|
||||
|
||||
:global(.dark) .resume-row {
|
||||
color: var(--color-gray-300);
|
||||
}
|
||||
|
||||
:global(.dark) .resume-row:hover {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.resume-meta {
|
||||
min-width: 0;
|
||||
max-width: 42%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 9px;
|
||||
color: var(--color-gray-400);
|
||||
}
|
||||
|
||||
:global(.dark) .resume-meta {
|
||||
color: var(--color-gray-600);
|
||||
}
|
||||
</style>
|
||||
@@ -20,12 +20,13 @@
|
||||
showSearch,
|
||||
pwaPreferences
|
||||
} from '$lib/stores';
|
||||
import type { Tab, EditorGroup } from '$lib/stores';
|
||||
import type { Tab, EditorGroup, WorkspaceState } from '$lib/stores';
|
||||
import { t } from '$lib/i18n';
|
||||
import { get } from 'svelte/store';
|
||||
import { getWelcome } from '$lib/apis/state';
|
||||
import { getWelcome, getWorkspaceState } from '$lib/apis/state';
|
||||
import { createSession } from '$lib/apis/terminal';
|
||||
import { createEntry, writeFile, uploadFiles as uploadFilesApi } from '$lib/apis/files';
|
||||
import { getChats, type ChatInfo } from '$lib/apis/chat';
|
||||
import { deleteSharePayload, getSharePayload } from '$lib/intents/payloadStore';
|
||||
import type { LaunchIntent, ShareBehavior, SharePayload } from '$lib/intents/types';
|
||||
import FileBrowser from '$lib/components/FileBrowser.svelte';
|
||||
@@ -38,7 +39,7 @@
|
||||
import GroupTabBar from '$lib/components/GroupTabBar.svelte';
|
||||
import Icon from '$lib/components/Icon.svelte';
|
||||
import WorkspacePicker from '$lib/components/WorkspacePicker.svelte';
|
||||
import SystemInfo from '$lib/components/SystemInfo.svelte';
|
||||
import WorkspaceResumeSheet from '$lib/components/WorkspaceResumeSheet.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { isSupportedWorkspacePath } from '$lib/utils/paths';
|
||||
|
||||
@@ -46,6 +47,7 @@
|
||||
let pendingIntent = $state<LaunchIntent | null>(null);
|
||||
let folderPickerIntent = $state<LaunchIntent | null>(null);
|
||||
let folderPickerWorkspace = $state<string | null>(null);
|
||||
let dismissedResumePath = $state<string | null>(null);
|
||||
const INTENT_URL_KEYS = [
|
||||
'intent',
|
||||
'chatId',
|
||||
@@ -392,6 +394,21 @@
|
||||
recent: { name: string; path: string }[];
|
||||
} | null>(null);
|
||||
|
||||
type WorkspaceResume = {
|
||||
path: string;
|
||||
tabs: Tab[];
|
||||
terminalCount: number;
|
||||
previewPorts: number[];
|
||||
chatCount: number;
|
||||
fileCount: number;
|
||||
recentChats: ChatInfo[];
|
||||
activeChatCount: number;
|
||||
activeLabels: string[];
|
||||
};
|
||||
|
||||
let workspaceResumes = $state<Map<string, WorkspaceResume>>(new Map());
|
||||
let resumeLoadSeq = 0;
|
||||
|
||||
// Fetch welcome data whenever no workspace is active
|
||||
$effect(() => {
|
||||
if (!$currentWorkspace) {
|
||||
@@ -403,6 +420,74 @@
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if ($currentWorkspace || !welcomeData) return;
|
||||
const paths = [
|
||||
...(welcomeData.recent ?? []).map((item) => item.path),
|
||||
...(welcomeData.suggestions ?? []).map((item) => item.path)
|
||||
]
|
||||
.filter((path, index, all) => path && all.indexOf(path) === index)
|
||||
.slice(0, 8);
|
||||
loadWorkspaceResumes(paths);
|
||||
});
|
||||
|
||||
async function loadWorkspaceResumes(paths: string[]) {
|
||||
const seq = ++resumeLoadSeq;
|
||||
if (!paths.length) {
|
||||
workspaceResumes = new Map();
|
||||
return;
|
||||
}
|
||||
const entries = await Promise.all(
|
||||
paths.map(async (path) => {
|
||||
try {
|
||||
const [state, chatsData] = await Promise.all([
|
||||
getWorkspaceState(path).catch(() => null),
|
||||
getChats(path, 3, 0, 'updated_at', 'desc').catch(() => null)
|
||||
]);
|
||||
if (!state) return null;
|
||||
return [
|
||||
path,
|
||||
buildWorkspaceResume(path, state as unknown as WorkspaceState, chatsData?.chats ?? [])
|
||||
] as const;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
);
|
||||
if (seq !== resumeLoadSeq) return;
|
||||
workspaceResumes = new Map(
|
||||
entries.filter((entry): entry is [string, WorkspaceResume] => !!entry)
|
||||
);
|
||||
}
|
||||
|
||||
function buildWorkspaceResume(
|
||||
path: string,
|
||||
state: WorkspaceState,
|
||||
recentChats: ChatInfo[]
|
||||
): WorkspaceResume {
|
||||
const tabs = (state.groups ?? []).flatMap((group) => group.tabs ?? []);
|
||||
const previewPorts = tabs
|
||||
.filter((tab) => tab.type === 'preview' && tab.port)
|
||||
.map((tab) => tab.port!)
|
||||
.filter((port, index, all) => all.indexOf(port) === index);
|
||||
const activeLabels = tabs
|
||||
.filter((tab) => !tab.permanent && ['terminal', 'chat', 'preview', 'file'].includes(tab.type))
|
||||
.slice(0, 3)
|
||||
.map((tab) => tab.label);
|
||||
|
||||
return {
|
||||
path,
|
||||
tabs,
|
||||
terminalCount: tabs.filter((tab) => tab.type === 'terminal').length,
|
||||
previewPorts,
|
||||
chatCount: tabs.filter((tab) => tab.type === 'chat').length,
|
||||
fileCount: tabs.filter((tab) => tab.type === 'file').length,
|
||||
recentChats,
|
||||
activeChatCount: recentChats.filter((chat) => chat.is_active).length,
|
||||
activeLabels
|
||||
};
|
||||
}
|
||||
|
||||
// Lazy-init terminal sessions for any group's active tab
|
||||
let initingTerminal = $state(false);
|
||||
$effect(() => {
|
||||
@@ -454,6 +539,28 @@
|
||||
return path;
|
||||
}
|
||||
|
||||
function resumeSignals(resume: WorkspaceResume | undefined): string[] {
|
||||
if (!resume) return [];
|
||||
const signals: string[] = [];
|
||||
if (resume.terminalCount) signals.push(`${resume.terminalCount} term`);
|
||||
if (resume.previewPorts.length)
|
||||
signals.push(resume.previewPorts.map((port) => `:${port}`).join(', '));
|
||||
if (resume.fileCount)
|
||||
signals.push(`${resume.fileCount} file${resume.fileCount === 1 ? '' : 's'}`);
|
||||
if (resume.chatCount || resume.activeChatCount) {
|
||||
signals.push(
|
||||
resume.activeChatCount ? `${resume.activeChatCount} active` : `${resume.chatCount} chat`
|
||||
);
|
||||
}
|
||||
return signals;
|
||||
}
|
||||
|
||||
function workspaceItems() {
|
||||
const recent = welcomeData?.recent ?? [];
|
||||
if (recent.length) return recent.slice(0, 6);
|
||||
return (welcomeData?.suggestions ?? []).slice(0, 6);
|
||||
}
|
||||
|
||||
// ── Draggable divider ──────────────────────────────────────────
|
||||
|
||||
let isDragging = $state(false);
|
||||
@@ -495,6 +602,10 @@
|
||||
return () => window.removeEventListener('resize', onResize);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!$currentWorkspace) dismissedResumePath = null;
|
||||
});
|
||||
|
||||
const allGroups = $derived($currentWorkspace?.groups ?? []);
|
||||
const splitDirection = $derived($currentWorkspace?.splitDirection ?? 'horizontal');
|
||||
const splitRatio = $derived($currentWorkspace?.splitRatio ?? 0.5);
|
||||
@@ -579,40 +690,31 @@
|
||||
</script>
|
||||
|
||||
{#if !$currentWorkspace}
|
||||
<div class="flex items-center justify-center h-full p-6 overflow-y-auto">
|
||||
<div class="flex h-full items-center justify-center overflow-y-auto p-6">
|
||||
<div class="w-full max-w-md">
|
||||
<!-- Header -->
|
||||
<div class="mb-4">
|
||||
<div class="mb-5">
|
||||
<div class="flex items-baseline gap-2">
|
||||
<h1 class="text-lg font-semibold tracking-tight text-gray-900 dark:text-white">cptr</h1>
|
||||
{#if $appVersion}
|
||||
<button
|
||||
onclick={() => showChangelog.set(true)}
|
||||
class="text-[11px] text-gray-400 dark:text-gray-600 hover:text-gray-500 dark:hover:text-gray-400 font-mono hover:underline cursor-pointer"
|
||||
class="cursor-pointer font-mono text-[11px] text-gray-400 hover:text-gray-500 hover:underline dark:text-gray-600 dark:hover:text-gray-400"
|
||||
>
|
||||
v{$appVersion}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{#if welcomeData?.hostname}
|
||||
<p class="text-xs text-gray-400 dark:text-gray-600 mt-0.5 font-mono">
|
||||
<p class="mt-0.5 font-mono text-xs text-gray-400 dark:text-gray-600">
|
||||
{welcomeData.hostname}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- System -->
|
||||
{#if welcomeData?.system}
|
||||
<div class="mb-6">
|
||||
<SystemInfo system={welcomeData.system} processes={welcomeData.processes} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Start -->
|
||||
<div class="mb-6">
|
||||
<h2 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('home.start')}</h2>
|
||||
<h2 class="mb-2 text-xs text-gray-400 dark:text-gray-600">{$t('home.start')}</h2>
|
||||
<button
|
||||
class="flex items-center gap-2 text-[13px] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100"
|
||||
class="flex items-center gap-2 text-[13px] text-gray-600 transition-colors duration-100 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"
|
||||
onclick={() => (showPicker = true)}
|
||||
>
|
||||
<Icon name="folder" size={15} strokeWidth={1.3} />
|
||||
@@ -620,44 +722,94 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Recent -->
|
||||
{#if welcomeData?.recent?.length}
|
||||
{#if workspaceItems().length}
|
||||
<div class="mb-6">
|
||||
<h2 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('home.recent')}</h2>
|
||||
<h2 class="mb-2 text-xs text-gray-400 dark:text-gray-600">
|
||||
{welcomeData?.recent?.length ? $t('home.recent') : $t('home.folders')}
|
||||
</h2>
|
||||
<div class="flex flex-col">
|
||||
{#each welcomeData.recent.slice(0, 5) as item}
|
||||
{#each workspaceItems() as item}
|
||||
{@const resume = workspaceResumes.get(item.path)}
|
||||
{@const signals = resumeSignals(resume)}
|
||||
<button
|
||||
class="flex items-center gap-3 py-1.5 group text-left transition-colors duration-100"
|
||||
class="group flex w-full min-w-0 items-start gap-2 py-1.5 text-left transition-colors duration-100"
|
||||
onclick={() => quickOpen(item.path)}
|
||||
>
|
||||
<span
|
||||
class="text-[13px] text-gray-700 dark:text-gray-300 group-hover:text-gray-900 dark:group-hover:text-white"
|
||||
>{item.name}</span
|
||||
>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-600 font-mono"
|
||||
>{shortenPath(item.path)}</span
|
||||
>
|
||||
<Icon
|
||||
name="folder"
|
||||
size={14}
|
||||
strokeWidth={1.3}
|
||||
class="mt-[3px] shrink-0 text-gray-400 dark:text-gray-600"
|
||||
/>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="flex min-w-0 items-baseline gap-2">
|
||||
<span
|
||||
class="truncate text-[13px] text-gray-700 group-hover:text-gray-900 dark:text-gray-300 dark:group-hover:text-white"
|
||||
>
|
||||
{item.name}
|
||||
</span>
|
||||
<span class="truncate font-mono text-[11px] text-gray-400 dark:text-gray-600">
|
||||
{shortenPath(item.path)}
|
||||
</span>
|
||||
</span>
|
||||
{#if signals.length}
|
||||
<span
|
||||
class="mt-0.5 block truncate font-mono text-[10px] text-gray-400 dark:text-gray-600"
|
||||
>
|
||||
{signals.join(' ')}
|
||||
</span>
|
||||
{:else if resume?.activeLabels.length}
|
||||
<span
|
||||
class="mt-0.5 block truncate text-[11px] text-gray-400 dark:text-gray-600"
|
||||
>
|
||||
{resume.activeLabels.join(' · ')}
|
||||
</span>
|
||||
{/if}
|
||||
{#if resume?.recentChats[0]?.is_active}
|
||||
<span
|
||||
class="mt-0.5 block truncate text-[11px] text-gray-400 dark:text-gray-600"
|
||||
>
|
||||
active
|
||||
{resume.recentChats[0].title}
|
||||
</span>
|
||||
{/if}
|
||||
</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="mb-6">
|
||||
<h2 class="mb-2 text-xs text-gray-400 dark:text-gray-600">{$t('home.recent')}</h2>
|
||||
<button
|
||||
class="flex items-center gap-2 text-[13px] text-gray-500 transition-colors duration-100 hover:text-gray-900 dark:text-gray-500 dark:hover:text-white"
|
||||
onclick={() => (showPicker = true)}
|
||||
>
|
||||
<Icon name="folder" size={14} strokeWidth={1.3} />
|
||||
No workspaces yet
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Suggestions -->
|
||||
{#if welcomeData?.suggestions?.length}
|
||||
{#if welcomeData?.suggestions?.length && welcomeData?.recent?.length}
|
||||
<div>
|
||||
<h2 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('home.folders')}</h2>
|
||||
<h2 class="mb-2 text-xs text-gray-400 dark:text-gray-600">{$t('home.folders')}</h2>
|
||||
<div class="flex flex-col">
|
||||
{#each welcomeData.suggestions.slice(0, 5) as item}
|
||||
<button
|
||||
class="flex items-center gap-2 py-1.5 text-[13px] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100"
|
||||
class="flex min-w-0 items-center gap-2 py-1.5 text-left text-[13px] text-gray-600 transition-colors duration-100 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"
|
||||
onclick={() => quickOpen(item.path)}
|
||||
>
|
||||
<Icon name="folder" size={14} strokeWidth={1.3} />
|
||||
<span>{item.name}</span>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-600 font-mono"
|
||||
>{shortenPath(item.path)}</span
|
||||
>
|
||||
<Icon
|
||||
name="folder"
|
||||
size={14}
|
||||
strokeWidth={1.3}
|
||||
class="shrink-0 text-gray-400 dark:text-gray-600"
|
||||
/>
|
||||
<span class="truncate">{item.name}</span>
|
||||
<span class="truncate font-mono text-[11px] text-gray-400 dark:text-gray-600">
|
||||
{shortenPath(item.path)}
|
||||
</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -767,6 +919,10 @@
|
||||
<div class="split-drop-zone split-drop-bottom"></div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if dismissedResumePath !== $currentWorkspace.path}
|
||||
<WorkspaceResumeSheet onclose={() => (dismissedResumePath = $currentWorkspace?.path ?? null)} />
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if pendingIntent}
|
||||
|
||||
Reference in new issue
Block a user