+ {shown.map((item) => {
+ const active = item.id === activeId;
+ const count = active ? messageCount : item.messageCount;
+ return (
+
- ))}
+ {active && (
+
+
+ {t("assistant.sessions.current")}
+
+ )}
+
+ );
+ })}
{!shown.length && (
{query.trim()
diff --git a/src/canvas/AssistantPanel.tsx b/src/canvas/AssistantPanel.tsx
index 1adf4db51..0daad44b9 100644
--- a/src/canvas/AssistantPanel.tsx
+++ b/src/canvas/AssistantPanel.tsx
@@ -5,11 +5,17 @@ import { assistantModelSelection } from "./agentPreferences";
import { creationClient } from "../backend/creationClient.ts";
import { fingerprint } from "../backend/generation.ts";
import type { BackendModels } from "../backend/models";
+import type { Asset } from "../contracts/generated.ts";
import { loadReferenceCatalog } from "../backend/referenceCatalog.ts";
import "./assistant-panel.css";
import "./assistant-experience.css";
+import "./assistant-workspace.css";
import { AttachmentStrip, AttachmentHover } from "./AssistantMedia";
import { AssistantReply } from "./AssistantReply";
+import type { ProjectEditorTarget } from "./assistantResultEditors.ts";
+import { AssistantResultCard, AssistantTimelineResultCard } from "./AssistantResultCard";
+import { useAssistantResults } from "./useAssistantResults.ts";
+import { CreationAssetList } from "./CreationAssetList.tsx";
import { AssistantConversations } from "./AssistantConversations";
import { AgentPicker } from "./AgentPicker";
import { ModelPicker } from "./AssistantPickers";
@@ -26,6 +32,7 @@ import {
type ChatReferenceEditorHandle,
} from "./ChatReferenceEditor";
import { nodeReferenceAsset } from "./generationReferenceContent.ts";
+import { pinnedReferenceAsset } from "./pinnedReferenceAssets.ts";
import type { CanvasNode } from "./model";
import {
pendingCanvasReferences,
@@ -54,7 +61,7 @@ function kindOf(asset: ChatAsset) {
: "text";
}
-/** OpenDirector conversation tools in an OpenDirector floating canvas window. */
+/** Shared conversation and composer for chat creation and the canvas assistant. */
export function AssistantPanel({
documentId,
readOnly = false,
@@ -64,6 +71,7 @@ export function AssistantPanel({
visibleNodes,
selectedNodes,
open,
+ collapsible = true,
layout,
selectionRequest,
onClose,
@@ -72,6 +80,11 @@ export function AssistantPanel({
onAgentModel,
onOpenSettings,
onPrepareReferences,
+ onCreateProjectTimeline,
+ onOpenProjectTimeline,
+ onPreviewResult,
+ onViewResultOnCanvas,
+ onEditResult,
}: {
documentId: string;
readOnly?: boolean;
@@ -81,6 +94,7 @@ export function AssistantPanel({
visibleNodes: CanvasNode[];
selectedNodes: CanvasNode[];
open: boolean;
+ collapsible?: boolean;
layout: AssistantLayout;
selectionRequest: number;
onClose: () => void;
@@ -88,12 +102,18 @@ export function AssistantPanel({
/** Lets the canvas default new nodes to the model this dialog is using. */
onModelSelections?: (selections: ModelSelections) => void;
onAgentModel?: (projectId: string, selection: AssistantModelSelection | null) => void;
- onOpenSettings: () => void;
+ onOpenSettings: (kind: keyof ModelSelections) => void;
onPrepareReferences: () => Promise;
+ onCreateProjectTimeline: () => Promise;
+ onOpenProjectTimeline: (itemId: string) => Promise;
+ onPreviewResult: (asset: Asset) => void;
+ onEditResult: (target: ProjectEditorTarget, signal?: AbortSignal) => Promise;
+ onViewResultOnCanvas: (asset: Asset, itemId?: string | null) => Promise;
}) {
const t = useT();
const chat = useAssistantChat(documentId, catalog, onTurnEnd, t, open, readOnly);
const { value } = chat;
+ const { results, timelines, snapshot } = useAssistantResults(documentId, open && !collapsible, value.messages);
const [deepseekLabels, setDeepseekLabels] = useState>({});
const hasDeepseekMessages = value.messages.some((message) => message.runtime === "deepseek");
useEffect(() => {
@@ -114,6 +134,8 @@ export function AssistantPanel({
const uploads = useReferenceUploads(documentId);
const projectReferences = useProjectMentionAssets(documentId);
const editor = useRef(null);
+ const assetListAnchor = useRef(null);
+ const [projectAssetsOpen, setProjectAssetsOpen] = useState(false);
const [slashQuery, setSlashQuery] = useState(null);
const [dragOver, setDragOver] = useState(false);
const [mediaPreview, setMediaPreview] = useState<{assetId: string; anchor: DOMRect} | null>(null);
@@ -156,7 +178,7 @@ export function AssistantPanel({
const currentRuntime = chat.runtimes.find((item) => item.id === (value.runtime ?? "default"));
const missingAgentModel = needsAgentModel(chat.loaded, currentRuntime, !!chat.agent);
const referenceDisabled =
- !chat.loaded || chat.adding || checkingReferences || chat.sending;
+ readOnly || !chat.loaded || chat.adding || checkingReferences || chat.sending;
const sessionDisabledReason = readOnly ? t("canvas.workspace.preview.mode") : chat.changing
? t("assistant.sessions.disabled.switching")
: !chat.loaded
@@ -187,8 +209,27 @@ export function AssistantPanel({
chat.setContent(content, projectReferences.assets);
}, [projectReferences.assets]);
+ const previouslyOpen = useRef(open);
+ const openFocusTarget = useRef(null);
useEffect(() => {
- if (open && chat.loaded) editor.current?.focus();
+ if (open && !previouslyOpen.current) {
+ // A mode change can reveal chat while the user is still editing elsewhere.
+ openFocusTarget.current = collapsible ? document.activeElement : null;
+ }
+ previouslyOpen.current = open;
+ if (!open) {
+ openFocusTarget.current = null;
+ return;
+ }
+ if (!chat.loaded) return;
+ const active = document.activeElement;
+ // Loading a default-open chat must not dismiss a project menu or rename.
+ // An explicit open retains focus intent until the user chooses another control.
+ if (!active?.closest('[aria-modal="true"]') &&
+ (active === document.body || active?.closest("#canvas-assistant") ||
+ active === openFocusTarget.current))
+ editor.current?.focus();
+ openFocusTarget.current = null;
}, [open, chat.loaded, value.conversationId]);
const displayedAssets = [
...new Map(
@@ -232,7 +273,7 @@ export function AssistantPanel({
useEffect(() => {
if (nearBottom.current && log.current)
log.current.scrollTop = log.current.scrollHeight;
- }, [value.messages, open]);
+ }, [value.messages, open, results]);
useEffect(() => () => confirming.current?.abort(), [pending?.id]);
const confirmPending = async (end: number) => {
if (!pending || referenceDisabled || confirming.current) return;
@@ -317,6 +358,21 @@ export function AssistantPanel({
(assets) => editor.current?.insert(assets) ?? false,
);
+ function referenceResult(asset: Asset) {
+ const input = editor.current;
+ if (!input || referenceDisabled || chat.changing) return;
+ if (value.draftContent?.some((part) =>
+ part.type === "reference" && part.binding === "asset" &&
+ part.assetId === asset.id && part.fingerprint === asset.fingerprint
+ )) {
+ input.focus();
+ return;
+ }
+ // Insert beside a selection so clicking a result keeps any highlighted draft.
+ const end = input.caret().end;
+ input.insert([pinnedReferenceAsset(asset)], { start: end, end });
+ }
+
useEffect(() => {setMediaPreview(null);}, [documentId, value.conversationId, open]);
useEffect(() => {
const closePreview = () => setMediaPreview(null);
@@ -333,6 +389,17 @@ export function AssistantPanel({
}
const hoveredAsset = mediaPreview && displayedAssets.find(item => item.id === mediaPreview.assetId);
+ const projectAssetsButton = !collapsible && (
+
+
+
+ );
+
const latestUser = value.messages.at(-2);
const latestTrace = latestReply?.role === "assistant" && latestUser?.role === "user" &&
new URLSearchParams({
@@ -347,6 +414,8 @@ export function AssistantPanel({