feat: wire Monaco editor to real file read/write

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-03 11:27:19 +08:00
co-authored by Claude
parent d587c94f50
commit 58aa6077d8
4 changed files with 182 additions and 44 deletions
+1 -16
View File
@@ -8,33 +8,18 @@ import { TerminalPanel } from "@/components/terminal/TerminalPanel";
import { FileExplorerPanel } from "@/components/workspace/FileExplorerPanel";
import { StatusBar } from "@/components/workspace/StatusBar";
import { WorkspaceSelector } from "@/components/workspace/WorkspaceSelector";
import { inferLanguage } from "@/lib/api/files";
import { useWorkspaceUiStore } from "@/lib/store/workspace-ui-store";
import type { MockFileNode } from "@/pages/workspace/mock-data";
interface WorkspaceShellProps {
workspaceId: string;
}
function fileNodeFromPath(path: string): MockFileNode {
const name = path.split("/").pop() ?? path;
return {
name,
path,
kind: "file",
language: inferLanguage(name),
};
}
export function WorkspaceShell({ workspaceId }: WorkspaceShellProps) {
const activeFilePath = useWorkspaceUiStore((s) => s.activeFilePath);
const sidebarCollapsed = useWorkspaceUiStore((s) => s.sidebarCollapsed);
const terminalVisible = useWorkspaceUiStore((s) => s.terminalVisible);
const toggleSidebar = useWorkspaceUiStore((s) => s.toggleSidebar);
const toggleTerminal = useWorkspaceUiStore((s) => s.toggleTerminal);
const activeFile = activeFilePath
? fileNodeFromPath(activeFilePath)
: undefined;
return (
<div className="flex h-full w-full flex-col bg-background text-foreground">
@@ -86,7 +71,7 @@ export function WorkspaceShell({ workspaceId }: WorkspaceShellProps) {
<PanelGroup direction="vertical">
{/* Editor */}
<Panel>
<EditorPanel file={activeFile} />
<EditorPanel workspaceId={workspaceId} path={activeFilePath || null} />
</Panel>
{/* Terminal panel */}