fix(web): show toolbar and status bar when no workspace selected

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-03 16:00:58 +08:00
co-authored by Claude
parent 61e5ede650
commit 60524bad0e
2 changed files with 45 additions and 46 deletions
+45 -35
View File
@@ -19,7 +19,7 @@ import {
} from "@/lib/api/process"; } from "@/lib/api/process";
interface WorkspaceShellProps { interface WorkspaceShellProps {
workspaceId: string; workspaceId: string | null;
} }
export function WorkspaceShell({ workspaceId }: WorkspaceShellProps) { export function WorkspaceShell({ workspaceId }: WorkspaceShellProps) {
@@ -75,7 +75,7 @@ export function WorkspaceShell({ workspaceId }: WorkspaceShellProps) {
variant="ghost" variant="ghost"
size="sm" size="sm"
className="h-7 px-2 text-xs" className="h-7 px-2 text-xs"
onClick={() => start.mutate(workspaceId)} onClick={() => workspaceId && start.mutate(workspaceId)}
disabled={!workspaceId || statusUnknown || isRunning || start.isPending} disabled={!workspaceId || statusUnknown || isRunning || start.isPending}
> >
<Play className="size-4" aria-hidden="true" /> <Play className="size-4" aria-hidden="true" />
@@ -84,7 +84,7 @@ export function WorkspaceShell({ workspaceId }: WorkspaceShellProps) {
variant="ghost" variant="ghost"
size="sm" size="sm"
className="h-7 px-2 text-xs" className="h-7 px-2 text-xs"
onClick={() => stop.mutate(workspaceId)} onClick={() => workspaceId && stop.mutate(workspaceId)}
disabled={!workspaceId || statusUnknown || !isRunning || stop.isPending} disabled={!workspaceId || statusUnknown || !isRunning || stop.isPending}
> >
<Square className="size-4" aria-hidden="true" /> <Square className="size-4" aria-hidden="true" />
@@ -93,7 +93,7 @@ export function WorkspaceShell({ workspaceId }: WorkspaceShellProps) {
variant="ghost" variant="ghost"
size="sm" size="sm"
className="h-7 px-2 text-xs" className="h-7 px-2 text-xs"
onClick={() => restart.mutate(workspaceId)} onClick={() => workspaceId && restart.mutate(workspaceId)}
disabled={!workspaceId || statusUnknown || !isRunning || restart.isPending} disabled={!workspaceId || statusUnknown || !isRunning || restart.isPending}
> >
<RotateCw <RotateCw
@@ -110,39 +110,49 @@ export function WorkspaceShell({ workspaceId }: WorkspaceShellProps) {
</header> </header>
{/* Main layout */} {/* Main layout */}
<div className="flex min-h-0 flex-1"> {workspaceId ? (
<PanelGroup direction="horizontal" className="flex-1"> <div className="flex min-h-0 flex-1">
{/* Sidebar */} <PanelGroup direction="horizontal" className="flex-1">
{!sidebarCollapsed && ( {/* Sidebar */}
<> {!sidebarCollapsed && (
<Panel defaultSize={18} minSize={12} maxSize={30}> <>
<FileExplorerPanel workspaceId={workspaceId} /> <Panel defaultSize={18} minSize={12} maxSize={30}>
</Panel> <FileExplorerPanel workspaceId={workspaceId} />
<PanelResizeHandle className="w-1 bg-border transition-colors hover:bg-accent" /> </Panel>
</> <PanelResizeHandle className="w-1 bg-border transition-colors hover:bg-accent" />
)} </>
)}
{/* Main content area */} {/* Main content area */}
<Panel> <Panel>
<PanelGroup direction="vertical"> <PanelGroup direction="vertical">
{/* Editor */} {/* Editor */}
<Panel> <Panel>
<EditorPanel workspaceId={workspaceId} path={activeFilePath || null} /> <EditorPanel workspaceId={workspaceId} path={activeFilePath || null} />
</Panel> </Panel>
{/* Terminal panel */} {/* Terminal panel */}
{terminalVisible && ( {terminalVisible && (
<> <>
<PanelResizeHandle className="h-1 bg-border transition-colors hover:bg-accent" /> <PanelResizeHandle className="h-1 bg-border transition-colors hover:bg-accent" />
<Panel defaultSize={30} minSize={10} maxSize={70}> <Panel defaultSize={30} minSize={10} maxSize={70}>
<TerminalPanel workspaceId={workspaceId} /> <TerminalPanel workspaceId={workspaceId} />
</Panel> </Panel>
</> </>
)} )}
</PanelGroup> </PanelGroup>
</Panel> </Panel>
</PanelGroup> </PanelGroup>
</div> </div>
) : (
<main className="flex min-h-0 flex-1 items-center justify-center bg-background text-foreground">
<div className="text-center text-sm text-muted-foreground">
<p className="font-medium">No workspace selected</p>
<p className="mt-1">Select or create a workspace to get started.</p>
<p className="mt-1 text-xs">Use the workspace selector in the toolbar to choose one.</p>
</div>
</main>
)}
{/* Status bar */} {/* Status bar */}
<StatusBar activeFilePath={activeFilePath} workspaceId={workspaceId} /> <StatusBar activeFilePath={activeFilePath} workspaceId={workspaceId} />
-11
View File
@@ -12,16 +12,5 @@ export function WorkspacePage() {
useWorkspaces(); useWorkspaces();
useFileList(currentWorkspaceId ?? null, "."); useFileList(currentWorkspaceId ?? null, ".");
if (!currentWorkspaceId) {
return (
<main className="flex h-full w-full items-center justify-center bg-background text-foreground">
<div className="text-center text-sm text-muted-foreground">
<p className="font-medium">No workspace selected</p>
<p className="mt-1">Select or create a workspace to get started.</p>
</div>
</main>
);
}
return <WorkspaceShell workspaceId={currentWorkspaceId} />; return <WorkspaceShell workspaceId={currentWorkspaceId} />;
} }