The VS Code of video editing, built for agents.
TypeScript
Refactor agent chat components and update sidebar functionality
konstantin-paulus5166153c297e
diff --git a/apps/web/src/agent-chat/chat-panel.tsx b/apps/web/src/agent-chat/chat-panel.tsxindex c42e0b4f..b5618870 100644--- a/apps/web/src/agent-chat/chat-panel.tsx+++ b/apps/web/src/agent-chat/chat-panel.tsx@@ -136,9 +136,8 @@ export function ChatPanel() {};return (- <div class="flex h-full min-h-0 flex-col" data-right-sidebar>- {/* The inspector's first section draws a top border under its header; the same hairline here keeps the tabs aligned. */}- <div class="flex h-12 shrink-0 items-center border-b border-border px-4">+ <div class="flex flex-1 min-h-0 flex-col">+ <div class="flex h-12 shrink-0 items-center border-y border-border px-4"><SidebarTabs /><HeaderActionsprojectId={project.id()}diff --git a/apps/web/src/agent-chat/header-actions.tsx b/apps/web/src/agent-chat/header-actions.tsxindex 5f20d21b..cff40b6d 100644--- a/apps/web/src/agent-chat/header-actions.tsx+++ b/apps/web/src/agent-chat/header-actions.tsx@@ -16,10 +16,11 @@ type HeaderActionsProps = {onOpenChat(chatId: string): void;};-/** Plus (New chat) and history (Chat history), at the right of the header. */+/** History (Chat history) and plus (New chat), at the right of the header. */export function HeaderActions(props: HeaderActionsProps) {return (<div class="ml-auto flex items-center gap-1 relative z-30" style="-webkit-app-region: no-drag;">+ <HistoryMenu projectId={props.projectId} chatId={props.chatId} onOpen={props.onOpenChat} /><Tooltip placement="bottom"><TooltipTriggeras={Button}@@ -34,7 +35,6 @@ export function HeaderActions(props: HeaderActionsProps) {</TooltipTrigger><TooltipContent>New chat</TooltipContent></Tooltip>- <HistoryMenu projectId={props.projectId} chatId={props.chatId} onOpen={props.onOpenChat} /></div>);}diff --git a/apps/web/src/agent-chat/index.ts b/apps/web/src/agent-chat/index.tsindex eb1787bc..fa0573ae 100644--- a/apps/web/src/agent-chat/index.ts+++ b/apps/web/src/agent-chat/index.ts@@ -3,14 +3,14 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */// The chat panel, and the few things the rest of the app touches: the-// right sidebar and its tabs, the sidebar width, the model picker the home+// left sidebar's tabs and width, the model picker the home// view shares, the home-view handoff, and the attachment helpers.-export { RightSidebar } from "./right-sidebar";+export { ChatPanel } from "./chat-panel";export { SidebarTabs } from "./sidebar-tabs";export { ModelPicker, harnessIcon } from "./model-picker";export {- rightSidebarWidth,+ leftSidebarWidth,sidebarTab,setSidebarTab,startChat,@@ -18,7 +18,7 @@ export {storedModel,setStoredModel,ensureConnected,- EDITOR_SIDEBAR_WIDTH,+ ASSETS_SIDEBAR_WIDTH,CHAT_SIDEBAR_WIDTH,} from "./store";export {diff --git a/apps/web/src/agent-chat/right-sidebar.tsx b/apps/web/src/agent-chat/right-sidebar.tsxdeleted file mode 100644index 5f702b24..00000000--- a/apps/web/src/agent-chat/right-sidebar.tsx+++ /dev/null@@ -1,17 +0,0 @@-/* This Source Code Form is subject to the terms of the Mozilla Public- * License, v. 2.0. If a copy of the MPL was not distributed with this- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */--import { Show, type JSX } from "solid-js";--import { ChatPanel } from "./chat-panel";-import { sidebarTab } from "./store";--/** The right column: the editor's inspector, or the chat, by tab. */-export function RightSidebar(props: { editor: () => JSX.Element }) {- return (- <Show when={sidebarTab() === "chat"} fallback={props.editor()}>- <ChatPanel />- </Show>- );-}diff --git a/apps/web/src/agent-chat/sidebar-tabs.tsx b/apps/web/src/agent-chat/sidebar-tabs.tsxindex c73501c0..58dae079 100644--- a/apps/web/src/agent-chat/sidebar-tabs.tsx+++ b/apps/web/src/agent-chat/sidebar-tabs.tsx@@ -7,14 +7,14 @@ import { For } from "solid-js";import { setSidebarTab, sidebarTab, type SidebarTab } from "./store";const TABS: { id: SidebarTab; label: string }[] = [- { id: "editor", label: "Editor" },+ { id: "assets", label: "Assets" },{ id: "chat", label: "Chat" },];-/** "Editor Chat" as plain text labels, the unselected one muted. The choice persists. */+/** "Assets Chat" as plain text labels, the unselected one muted. The choice persists. */export function SidebarTabs() {return (- <div class="relative z-30 flex items-center gap-3" style="-webkit-app-region: no-drag;" role="tablist">+ <div class="relative z-30 flex items-center gap-4" style="-webkit-app-region: no-drag;" role="tablist"><For each={TABS}>{(tab) => (<buttondiff --git a/apps/web/src/agent-chat/store.ts b/apps/web/src/agent-chat/store.tsindex 79fde55a..167a033e 100644--- a/apps/web/src/agent-chat/store.ts+++ b/apps/web/src/agent-chat/store.ts@@ -35,7 +35,7 @@ import type { ProjectInfo } from "@/projects";import { attachmentFromPath, attachmentPaths, type Attachment } from "./attachments";import { client, hasHost } from "./connection";-export type SidebarTab = "editor" | "chat";+export type SidebarTab = "assets" | "chat";export type Draft = { text: string; attachments: Attachment[] };@@ -72,13 +72,13 @@ export { state as chatState };// --- settings that persist ---------------------------------------------const root = createRoot(() => {- const [tab, setTab] = createStoredSignal(settings.define<SidebarTab>("rightSidebar.tab", "editor"));+ const [tab, setTab] = createStoredSignal(settings.define<SidebarTab>("leftSidebar.tab", "assets"));const [model, setModel] = createStoredSignal(settings.define<ModelRef | null>("agentChat.model", null));const [active, setActive] = createStoredSignal(settings.define<Record<string, string>>("agentChat.active", {}));return { tab, setTab, model, setModel, active, setActive };});-/** Which tab the right sidebar shows; persists across sessions. */+/** Which tab the left sidebar shows; persists across sessions. */export const sidebarTab = root.tab;export const setSidebarTab = root.setTab;@@ -399,11 +399,11 @@ export const chatRoute = (project: ProjectInfo): string => projectRoute(project.export { attachmentPaths };-/** Sidebar width by tab: room for about 47 characters of 12 px text on the Chat tab. */-export const EDITOR_SIDEBAR_WIDTH = 264;-export const CHAT_SIDEBAR_WIDTH = 320;+/** Left sidebar width by tab: room for about 50 characters of 12 px text on the Chat tab. */+export const ASSETS_SIDEBAR_WIDTH = 264;+export const CHAT_SIDEBAR_WIDTH = 340;-export const rightSidebarWidth = (): number => (sidebarTab() === "chat" ? CHAT_SIDEBAR_WIDTH : EDITOR_SIDEBAR_WIDTH);+export const leftSidebarWidth = (): number => (sidebarTab() === "chat" ? CHAT_SIDEBAR_WIDTH : ASSETS_SIDEBAR_WIDTH);/** For the empty state: why nothing can be sent right now, or null. */export function blockedReason(): string | null {diff --git a/apps/web/src/components/sidebar-left/assets.tsx b/apps/web/src/components/sidebar-left/assets.tsxindex 825e9741..18a1cb16 100644--- a/apps/web/src/components/sidebar-left/assets.tsx+++ b/apps/web/src/components/sidebar-left/assets.tsx@@ -6,6 +6,7 @@ import { basename, dirname } from "@diffusionstudio/assets";import { usePromptInput } from "@/context/prompt-input";import { createDefaultConfig } from "@/components/genai/prompt-input";import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show } from "solid-js";+import { SidebarTabs } from "@/agent-chat";import { Button } from "../ui/button";import { Icon } from "../ui/icon";import {@@ -86,7 +87,6 @@ export function Assets() {return library()?.childrenOf(currentFolder()).folders ?? [];});- const panelTitle = createMemo(() => (currentFolder() ? basename(currentFolder()) : "Assets"));const itemCount = createMemo(() => visibleFolders().length + filteredPartials().length + filteredAssets().length);// Deep paths collapse like the breadcrumbs docs example:@@ -311,21 +311,8 @@ export function Assets() {onKeyDown={handleKeyDown}><div class="h-12 shrink-0 flex items-center gap-2 px-4 border-y border-border">- <div class="flex-1 min-w-0 flex items-center gap-0.5 text-[12px] leading-5 font-strong text-foreground">- <Show when={currentFolder() !== ""}>- <Button- size="icon"- variant="ghost"- aria-label="Go to parent folder"- onClick={handleGoToParent}- >- <Icon name="chevron-left" class="text-muted-foreground" />- </Button>- </Show>- <span class="truncate">- {panelTitle()}- <span class="ml-1 text-muted-foreground">({itemCount()})</span>- </span>+ <div class="flex-1 min-w-0 flex items-center">+ <SidebarTabs /></div><div class="flex items-center gap-1 shrink-0"><Show when={hasAssets()}>@@ -466,7 +453,7 @@ export function Assets() {type="text"value={query()}onInput={(e) => setQuery(e.currentTarget.value)}- placeholder="Search"+ placeholder={`Search in ${itemCount()} ${itemCount() === 1 ? "item" : "items"}`}class="w-full h-7 rounded-md bg-input pl-8 pr-0 text-xs text-foreground placeholder:text-muted-foreground outline-none focus-ring"/></div>diff --git a/apps/web/src/components/sidebar-left/sidebar-left.tsx b/apps/web/src/components/sidebar-left/sidebar-left.tsxindex b71c9db2..33416655 100644--- a/apps/web/src/components/sidebar-left/sidebar-left.tsx+++ b/apps/web/src/components/sidebar-left/sidebar-left.tsx@@ -3,6 +3,7 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { Assets } from "./assets";+import { ChatPanel, sidebarTab } from "@/agent-chat";import { useLayout } from "@/context/layout";import { useEditorApi } from "@/dapi";import { createSignal, Show } from "solid-js";@@ -18,7 +19,12 @@ export function SidebarLeft() {<div class="flex flex-col h-full overflow-hidden"><ElectronHeader /><ProjectHeader />- <Assets />+ <div classList={{ contents: sidebarTab() === "assets", hidden: sidebarTab() === "chat" }}>+ <Assets />+ </div>+ <Show when={sidebarTab() === "chat"}>+ <ChatPanel />+ </Show></div>);}diff --git a/apps/web/src/components/sidebar-right/inspector/inspector-header.tsx b/apps/web/src/components/sidebar-right/inspector/inspector-header.tsxindex 934d5711..3b00f62a 100644--- a/apps/web/src/components/sidebar-right/inspector/inspector-header.tsx+++ b/apps/web/src/components/sidebar-right/inspector/inspector-header.tsx@@ -12,7 +12,6 @@ import {DropdownMenuTrigger,} from "@/components/ui/dropdown-menu";import { Button } from "@/components/ui/button";-import { SidebarTabs } from "@/agent-chat";import { useWorld } from "@diffusionstudio/koota-solid";import { useCameraScale, zoomBy, zoomTo, zoomToFit } from "@/engine";@@ -26,7 +25,7 @@ export function InspectorHeader() {return (<div class="h-12 shrink-0 flex items-center px-4">- <SidebarTabs />+ <span class="text-[12px] leading-5 font-450 text-foreground">Editor</span><DropdownMenu placement="bottom-end"><DropdownMenuTrigger<typeof Button>as={(triggerProps) => (diff --git a/apps/web/src/pages/editor.tsx b/apps/web/src/pages/editor.tsxindex a5cbd386..18381309 100644--- a/apps/web/src/pages/editor.tsx+++ b/apps/web/src/pages/editor.tsx@@ -4,7 +4,7 @@import { Show, createMemo, createSignal, onMount } from "solid-js";import { Canvas } from "@/components/canvas";-import { RightSidebar, rightSidebarWidth } from "@/agent-chat";+import { leftSidebarWidth } from "@/agent-chat";import { Timeline, Layers } from "@/components/timeline";import { Soundboard, Inspector } from "@/components/sidebar-right";import { FloatingProjectHeader, SidebarLeft } from "@/components/sidebar-left";@@ -186,7 +186,7 @@ export function EditorPage() {});});- // The right column follows the sidebar's tab (264 px on Editor, 320 px on+ // The left column follows the sidebar's tab (264 px on Assets, 340 px on// Chat) and animates between the two — except on load, where the stored// tab is read before first paint and the transition only comes on after// the first frame. Toggling `uiVisible` changes the track count, which@@ -203,7 +203,7 @@ export function EditorPage() {const height = timelineMinimized() ? RULER_HEIGHT : timelineHeight();return {- 'grid-template-columns': `264px 1px 1fr 1px ${rightSidebarWidth()}px`,+ 'grid-template-columns': `${leftSidebarWidth()}px 1px 1fr 1px 264px`,'grid-template-rows': `1fr 1px ${height}px`,...(animateColumns() ? { transition: 'grid-template-columns 200ms ease-out' } : {}),};@@ -255,7 +255,7 @@ export function EditorPage() {<Canvas /><Show when={uiVisible()}><div class="bg-border-strong" />- <RightSidebar editor={() => <Inspector />} />+ <Inspector /></Show><Show when={uiVisible()}><div class="col-span-full bg-border-strong relative">