- {todoItems.map((todo) => (
-
-
-
- {todo.text}
+
+
}
+ header={
+
+
+ Updated Todos
+
+
+ {completed}/{todoItems.length}
- ))}
-
+ }
+ hasExpandableContent={todoItems.length > 0}
+ isExpanded={isExpanded}
+ onToggle={() => setIsExpanded((prev) => !prev)}
+ >
+
+ {todoItems.map((todo, idx) => {
+ const s = resolveStatus(todo);
+ return (
+
+
+
+ {todo.text}
+
+
+ );
+ })}
+
+
);
}
diff --git a/apps/web/components/task/chat/tiptap-helpers.ts b/apps/web/components/task/chat/tiptap-helpers.ts
index e8ecd27f7b..352a3620a9 100644
--- a/apps/web/components/task/chat/tiptap-helpers.ts
+++ b/apps/web/components/task/chat/tiptap-helpers.ts
@@ -120,10 +120,10 @@ export function parseCodeFences(text: string): FenceSegment[] {
// ── Paste handler ───────────────────────────────────────────────────
-function extractImageFiles(items: DataTransferItemList): File[] {
+function extractFiles(items: DataTransferItemList): File[] {
const files: File[] = [];
for (const item of items) {
- if (item.type.startsWith("image/")) {
+ if (item.kind === "file") {
const file = item.getAsFile();
if (file) files.push(file);
}
@@ -167,13 +167,13 @@ export function handleEditorPaste(
event: ClipboardEvent,
onImagePasteRef: React.RefObject<((files: File[]) => void) | undefined>,
): boolean {
- // 1. Image paste
+ // 1. File paste (images and other files)
const items = event.clipboardData?.items;
if (items) {
- const imageFiles = extractImageFiles(items);
- if (imageFiles.length > 0) {
+ const files = extractFiles(items);
+ if (files.length > 0) {
event.preventDefault();
- onImagePasteRef.current?.(imageFiles);
+ onImagePasteRef.current?.(files);
return true;
}
}
diff --git a/apps/web/components/task/chat/todo-indicator.tsx b/apps/web/components/task/chat/todo-indicator.tsx
new file mode 100644
index 0000000000..1d51d269c2
--- /dev/null
+++ b/apps/web/components/task/chat/todo-indicator.tsx
@@ -0,0 +1,92 @@
+"use client";
+
+import { IconCheck, IconCircle, IconCircleFilled, IconListCheck, IconX } from "@tabler/icons-react";
+import { HoverCard, HoverCardTrigger, HoverCardContent } from "@kandev/ui/hover-card";
+import { cn } from "@/lib/utils";
+
+type TodoDisplayItem = {
+ text: string;
+ done?: boolean;
+ status?: "pending" | "in_progress" | "completed" | "failed";
+};
+
+type TodoIndicatorProps = {
+ todos: TodoDisplayItem[];
+};
+
+function resolveStatus(todo: TodoDisplayItem): "pending" | "in_progress" | "completed" | "failed" {
+ if (todo.status) return todo.status;
+ return todo.done ? "completed" : "pending";
+}
+
+function StatusIcon({ status, className }: { status: string; className?: string }) {
+ switch (status) {
+ case "completed":
+ return
;
+ case "in_progress":
+ return
;
+ case "failed":
+ return
;
+ default:
+ return
;
+ }
+}
+
+export function TodoIndicator({ todos }: TodoIndicatorProps) {
+ if (!todos.length) return null;
+
+ const completed = todos.filter((t) => resolveStatus(t) === "completed").length;
+ const allComplete = completed === todos.length;
+ const progress = Math.round((completed / todos.length) * 100);
+
+ return (
+
+
+
+
+
+
+ Todos
+
+ {completed}/{todos.length} completed
+
+
+
+
+ {todos.map((todo, idx) => {
+ const s = resolveStatus(todo);
+ return (
+
+
+
+ {todo.text}
+
+
+ );
+ })}
+
+
+
+ );
+}
+
+export { StatusIcon, resolveStatus };
+export type { TodoDisplayItem };
diff --git a/apps/web/components/task/chat/todo-summary.tsx b/apps/web/components/task/chat/todo-summary.tsx
deleted file mode 100644
index 8c3698f56b..0000000000
--- a/apps/web/components/task/chat/todo-summary.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-"use client";
-
-import { IconCheck, IconChevronDown } from "@tabler/icons-react";
-import { cn } from "@/lib/utils";
-
-type TodoItem = {
- text: string;
- done?: boolean;
-};
-
-type TodoSummaryProps = {
- todos: TodoItem[];
-};
-
-export function TodoSummary({ todos }: TodoSummaryProps) {
- if (!todos.length) return null;
-
- const completed = todos.filter((todo) => todo.done).length;
-
- return (
-
-
- Todos ({todos.length})
-
-
-
- {todos.map((todo) => (
-
- {todo.done ? (
-
- ) : (
-
- )}
-
- {todo.text}
-
-
- ))}
-
-
- {completed} of {todos.length} completed
-
-
- );
-}
diff --git a/apps/web/components/task/chat/use-chat-input-container.ts b/apps/web/components/task/chat/use-chat-input-container.ts
index b9df9c4d88..d4309a89c6 100644
--- a/apps/web/components/task/chat/use-chat-input-container.ts
+++ b/apps/web/components/task/chat/use-chat-input-container.ts
@@ -26,7 +26,6 @@ type UseChatInputContainerParams = {
onClarificationResolved: (() => void) | undefined;
pendingCommentsByFile: Record
| undefined;
hasContextComments: boolean;
- todoItems: { text: string; done?: boolean }[];
showRequestChangesTooltip: boolean;
onRequestChangesTooltipDismiss: (() => void) | undefined;
onSubmit: (
@@ -78,7 +77,6 @@ function computeDerivedState(params: {
pendingClarification: Message | null | undefined;
onClarificationResolved: (() => void) | undefined;
pendingCommentsByFile: Record | undefined;
- todoItems: { text: string }[];
allItemsLength: number;
isInputFocused: boolean;
placeholder: string | undefined;
@@ -91,8 +89,7 @@ function computeDerivedState(params: {
const hasPendingComments = !!(
params.pendingCommentsByFile && Object.keys(params.pendingCommentsByFile).length > 0
);
- const hasTodos = params.todoItems.length > 0;
- const hasContextZone = hasTodos || params.allItemsLength > 0;
+ const hasContextZone = params.allItemsLength > 0;
const showFocusHint = !params.isInputFocused && !hasClarification && !hasPendingComments;
const inputPlaceholder = getInputPlaceholder(
params.placeholder,
@@ -104,7 +101,6 @@ function computeDerivedState(params: {
isDisabled,
hasClarification,
hasPendingComments,
- hasTodos,
hasContextZone,
showFocusHint,
inputPlaceholder,
@@ -126,7 +122,6 @@ export function useChatInputContainer(params: UseChatInputContainerParams) {
pendingClarification,
onClarificationResolved,
pendingCommentsByFile,
- todoItems,
showRequestChangesTooltip,
onRequestChangesTooltipDismiss,
onSubmit,
@@ -142,17 +137,17 @@ export function useChatInputContainer(params: UseChatInputContainerParams) {
sessionId ?? undefined,
getContentElement,
);
- const { value, inputRef, handleImagePaste, handleChange, handleSubmit, allItems } =
- useChatInputState({
- sessionId,
- isSending,
- contextItems,
- pendingCommentsByFile,
- hasContextComments: params.hasContextComments,
- showRequestChangesTooltip,
- onRequestChangesTooltipDismiss,
- onSubmit,
- });
+ const fileInputRef = useRef(null);
+ const { value, inputRef, addFiles, handleChange, handleSubmit, allItems } = useChatInputState({
+ sessionId,
+ isSending,
+ contextItems,
+ pendingCommentsByFile,
+ hasContextComments: params.hasContextComments,
+ showRequestChangesTooltip,
+ onRequestChangesTooltipDismiss,
+ onSubmit,
+ });
useEffect(() => {
tiptapRef.current = inputRef.current;
@@ -192,7 +187,6 @@ export function useChatInputContainer(params: UseChatInputContainerParams) {
pendingClarification,
onClarificationResolved,
pendingCommentsByFile,
- todoItems,
allItemsLength: allItems.length,
isInputFocused,
placeholder,
@@ -212,7 +206,8 @@ export function useChatInputContainer(params: UseChatInputContainerParams) {
resizeHandleProps,
value,
inputRef,
- handleImagePaste,
+ addFiles,
+ fileInputRef,
handleChange: handleChangeWithAutoExpand,
handleSubmitWithReset,
handleAgentCommand,
diff --git a/apps/web/components/task/chat/use-chat-input-state.ts b/apps/web/components/task/chat/use-chat-input-state.ts
index 92d6d01435..f7082be03f 100644
--- a/apps/web/components/task/chat/use-chat-input-state.ts
+++ b/apps/web/components/task/chat/use-chat-input-state.ts
@@ -8,13 +8,13 @@ import {
restoreAttachmentPreview,
} from "@/lib/local-storage";
import {
- processImageFile,
+ processFile,
formatBytes,
- MAX_IMAGES,
+ MAX_FILES,
MAX_TOTAL_SIZE,
- type ImageAttachment,
-} from "./image-attachment-preview";
-import type { ContextItem, ImageContextItem } from "@/lib/types/context";
+ type FileAttachment,
+} from "./file-attachment";
+import type { ContextItem, ImageContextItem, FileAttachmentContextItem } from "@/lib/types/context";
import type { ContextFile } from "@/lib/state/context-files-store";
import type { DiffComment } from "@/lib/diff/types";
import type { MessageAttachment } from "./chat-input-container";
@@ -47,12 +47,12 @@ function collectComments(
return allComments;
}
-function toMessageAttachments(attachments: ImageAttachment[]): MessageAttachment[] {
- return attachments.map((att) => ({
- type: "image" as const,
- data: att.data,
- mime_type: att.mimeType,
- }));
+function toMessageAttachments(attachments: FileAttachment[]): MessageAttachment[] {
+ return attachments.map((att) =>
+ att.isImage
+ ? { type: "image" as const, data: att.data, mime_type: att.mimeType }
+ : { type: "resource" as const, data: att.data, mime_type: att.mimeType, name: att.fileName },
+ );
}
function clearDraft(sessionId: string | null) {
@@ -63,7 +63,7 @@ function clearDraft(sessionId: string | null) {
}
function useAttachments(sessionId: string | null) {
- const [attachments, setAttachments] = useState(() =>
+ const [attachments, setAttachments] = useState(() =>
sessionId ? getChatDraftAttachments(sessionId).map(restoreAttachmentPreview) : [],
);
const attachmentsRef = useRef(attachments);
@@ -75,20 +75,20 @@ function useAttachments(sessionId: string | null) {
setChatDraftAttachments(sessionId, attachments);
}, [attachments, sessionId]);
- const handleImagePaste = useCallback(
+ const addFiles = useCallback(
async (files: File[]) => {
- if (attachments.length >= MAX_IMAGES) {
- console.warn(`Maximum ${MAX_IMAGES} images allowed`);
+ if (attachments.length >= MAX_FILES) {
+ console.warn(`Maximum ${MAX_FILES} files allowed`);
return;
}
const currentTotalSize = attachments.reduce((sum, att) => sum + att.size, 0);
for (const file of files) {
- if (attachments.length >= MAX_IMAGES) break;
+ if (attachments.length >= MAX_FILES) break;
if (currentTotalSize + file.size > MAX_TOTAL_SIZE) {
console.warn("Total attachment size limit exceeded");
break;
}
- const attachment = await processImageFile(file);
+ const attachment = await processFile(file);
if (attachment) setAttachments((prev) => [...prev, attachment]);
}
},
@@ -104,7 +104,7 @@ function useAttachments(sessionId: string | null) {
attachmentsRef,
prevSessionIdRef,
setAttachments,
- handleImagePaste,
+ addFiles,
handleRemoveAttachment,
};
}
@@ -130,7 +130,7 @@ export function useChatInputState({
attachmentsRef,
prevSessionIdRef,
setAttachments,
- handleImagePaste,
+ addFiles,
handleRemoveAttachment,
} = useAttachments(sessionId);
@@ -188,15 +188,26 @@ export function useChatInputState({
);
const allItems = useMemo((): ContextItem[] => {
- const imageItems: ImageContextItem[] = attachments.map((att) => ({
- kind: "image" as const,
- id: `image:${att.id}`,
- label: `Image (${formatBytes(att.size)})`,
- attachment: att,
- onRemove: () => handleRemoveAttachment(att.id),
- }));
- return [...contextItems, ...imageItems];
+ const attachmentItems: (ImageContextItem | FileAttachmentContextItem)[] = attachments.map(
+ (att) =>
+ att.isImage
+ ? ({
+ kind: "image" as const,
+ id: `image:${att.id}`,
+ label: `Image (${formatBytes(att.size)})`,
+ attachment: att,
+ onRemove: () => handleRemoveAttachment(att.id),
+ } as ImageContextItem)
+ : ({
+ kind: "file-attachment" as const,
+ id: `file:${att.id}`,
+ label: att.fileName,
+ attachment: att,
+ onRemove: () => handleRemoveAttachment(att.id),
+ } as FileAttachmentContextItem),
+ );
+ return [...contextItems, ...attachmentItems];
}, [contextItems, attachments, handleRemoveAttachment]);
- return { value, attachments, inputRef, handleImagePaste, handleChange, handleSubmit, allItems };
+ return { value, attachments, inputRef, addFiles, handleChange, handleSubmit, allItems };
}
diff --git a/apps/web/components/task/chat/use-chat-panel-state.ts b/apps/web/components/task/chat/use-chat-panel-state.ts
index 1e30285246..1c8f3e20ce 100644
--- a/apps/web/components/task/chat/use-chat-panel-state.ts
+++ b/apps/web/components/task/chat/use-chat-panel-state.ts
@@ -422,6 +422,27 @@ function useSessionData(
};
}
+type TodoStatus = "pending" | "in_progress" | "completed" | "failed";
+
+function useSessionTodoItems(
+ resolvedSessionId: string | null,
+ messageTodos: Array<{ text: string; done?: boolean }>,
+) {
+ const storeTodos = useAppStore((s) =>
+ resolvedSessionId ? s.sessionTodos.bySessionId[resolvedSessionId] : undefined,
+ );
+ return useMemo(() => {
+ if (storeTodos && storeTodos.length > 0) {
+ return storeTodos.map((e: { description: string; status: string }) => ({
+ text: e.description,
+ done: e.status === "completed",
+ status: e.status as TodoStatus,
+ }));
+ }
+ return messageTodos;
+ }, [storeTodos, messageTodos]);
+}
+
export type UseChatPanelStateOptions = {
sessionId: string | null;
onOpenFile?: (path: string) => void;
@@ -515,6 +536,8 @@ export function useChatPanelState({
onOpenFileAtLine,
});
+ const todoItems = useSessionTodoItems(resolvedSessionId, sessionData.todoItems);
+
return {
...sessionState,
...planMode,
@@ -527,5 +550,6 @@ export function useChatPanelState({
planModeAvailable,
mcpServers,
prompts,
+ todoItems,
};
}
diff --git a/apps/web/components/task/config-options-display.tsx b/apps/web/components/task/config-options-display.tsx
new file mode 100644
index 0000000000..e270f91a4c
--- /dev/null
+++ b/apps/web/components/task/config-options-display.tsx
@@ -0,0 +1,49 @@
+"use client";
+
+import { memo } from "react";
+import { IconSettings } from "@tabler/icons-react";
+import { Button } from "@kandev/ui/button";
+import { Popover, PopoverContent, PopoverTrigger } from "@kandev/ui/popover";
+import { useAppStore } from "@/components/state-provider";
+
+type ConfigOptionsDisplayProps = {
+ sessionId: string | null;
+};
+
+export const ConfigOptionsDisplay = memo(function ConfigOptionsDisplay({
+ sessionId,
+}: ConfigOptionsDisplayProps) {
+ const configOptions = useAppStore((state) => {
+ if (!sessionId) return undefined;
+ return state.sessionModels.bySessionId[sessionId]?.configOptions;
+ });
+
+ if (!sessionId || !configOptions || configOptions.length === 0) {
+ return null;
+ }
+
+ return (
+
+
+
+
+
+
+
Config Options
+ {configOptions.map((option) => (
+
+ {option.name}
+ {option.currentValue}
+
+ ))}
+
+
+
+ );
+});
diff --git a/apps/web/components/task/dockview-header-actions.tsx b/apps/web/components/task/dockview-header-actions.tsx
index c403e94d67..3c223d1ed2 100644
--- a/apps/web/components/task/dockview-header-actions.tsx
+++ b/apps/web/components/task/dockview-header-actions.tsx
@@ -349,16 +349,16 @@ function RightTopGroupActions() {
function SessionModeBadge() {
const activeSessionId = useAppStore((state) => state.tasks.activeSessionId);
- const modeId = useAppStore((state) => {
+ const modeState = useAppStore((state) => {
if (!activeSessionId) return null;
return state.sessionMode.bySessionId[activeSessionId] ?? null;
});
- if (!modeId) return null;
+ if (!modeState?.currentModeId) return null;
return (
- {modeId}
+ {modeState.currentModeId}
);
}
diff --git a/apps/web/components/task/mode-selector.tsx b/apps/web/components/task/mode-selector.tsx
new file mode 100644
index 0000000000..fd0a976233
--- /dev/null
+++ b/apps/web/components/task/mode-selector.tsx
@@ -0,0 +1,78 @@
+"use client";
+
+import { memo, useCallback } from "react";
+import { IconChevronDown } from "@tabler/icons-react";
+import { Button } from "@kandev/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@kandev/ui/dropdown-menu";
+import { useAppStore } from "@/components/state-provider";
+import { setSessionMode } from "@/lib/api/domains/session-api";
+
+type ModeSelectorProps = {
+ sessionId: string | null;
+};
+
+export const ModeSelector = memo(function ModeSelector({ sessionId }: ModeSelectorProps) {
+ const modeState = useAppStore((state) =>
+ sessionId ? state.sessionMode.bySessionId[sessionId] : undefined,
+ );
+
+ const handleModeChange = useCallback(
+ async (modeId: string) => {
+ if (!sessionId) return;
+ try {
+ await setSessionMode(sessionId, modeId);
+ } catch (err) {
+ console.error("[ModeSelector] set-mode API failed:", err);
+ }
+ },
+ [sessionId],
+ );
+
+ if (
+ !sessionId ||
+ !modeState ||
+ !modeState.availableModes ||
+ modeState.availableModes.length <= 1
+ ) {
+ return null;
+ }
+
+ const currentMode = modeState.availableModes.find((m) => m.id === modeState.currentModeId);
+ const displayName = currentMode?.name || modeState.currentModeId || "Mode";
+
+ return (
+
+
+
+
+
+ {modeState.availableModes.map((mode) => (
+ handleModeChange(mode.id)}
+ className={mode.id === modeState.currentModeId ? "bg-muted" : ""}
+ >
+
+
{mode.name}
+ {mode.description && (
+
{mode.description}
+ )}
+
+
+ ))}
+
+
+ );
+});
diff --git a/apps/web/components/task/model-selector.tsx b/apps/web/components/task/model-selector.tsx
index 25c323ddc5..44b16a4306 100644
--- a/apps/web/components/task/model-selector.tsx
+++ b/apps/web/components/task/model-selector.tsx
@@ -1,18 +1,13 @@
"use client";
-import { memo } from "react";
-import { IconChevronDown } from "@tabler/icons-react";
-import { Button } from "@kandev/ui/button";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@kandev/ui/dropdown-menu";
+import { memo, useCallback, useMemo } from "react";
import { useAppStore } from "@/components/state-provider";
+import { Combobox, type ComboboxOption } from "@/components/combobox";
import { useAvailableAgents } from "@/hooks/domains/settings/use-available-agents";
import { useSettingsData } from "@/hooks/domains/settings/use-settings-data";
import type { Agent, AgentProfile, AvailableAgent } from "@/lib/types/http";
+import { setSessionModel } from "@/lib/api/domains/session-api";
+import type { SessionModelEntry } from "@/lib/state/slices/session-runtime/types";
type ModelSelectorProps = {
sessionId: string | null;
@@ -24,6 +19,8 @@ type ModelOption = {
provider: string;
context_window: number;
is_default: boolean;
+ description?: string;
+ usageMultiplier?: string;
};
function resolveSnapshotModel(snapshot: unknown): string | null {
@@ -32,7 +29,7 @@ function resolveSnapshotModel(snapshot: unknown): string | null {
return typeof model === "string" && model ? model : null;
}
-function resolveAvailableModels(
+function resolveStaticModels(
agents: Agent[],
profileId: string | null | undefined,
availableAgents: AvailableAgent[],
@@ -42,11 +39,28 @@ function resolveAvailableModels(
const profile = agent.profiles.find((p: AgentProfile) => p.id === profileId);
if (!profile) continue;
const available = availableAgents.find((a: AvailableAgent) => a.name === agent.name);
- return available?.model_config?.available_models ?? [];
+ const models = available?.model_config?.available_models ?? [];
+ // Static models don't include description — use model ID as subtitle when it differs from name
+ return models.map((m) => ({
+ ...m,
+ description: m.id !== m.name ? m.id : undefined,
+ }));
}
return [];
}
+function sessionModelsToOptions(models: SessionModelEntry[]): ModelOption[] {
+ return models.map((m) => ({
+ id: m.modelId,
+ name: m.name,
+ provider: "",
+ context_window: 0,
+ is_default: false,
+ description: m.description,
+ usageMultiplier: m.usageMultiplier,
+ }));
+}
+
function buildModelOptions(
availableModels: ModelOption[],
currentModel: string | null,
@@ -64,7 +78,8 @@ function buildModelOptions(
return options;
}
-export const ModelSelector = memo(function ModelSelector({ sessionId }: ModelSelectorProps) {
+/** Resolves available models and current model from store state. */
+function useModelSelectorState(sessionId: string | null) {
useSettingsData(true);
const settingsAgents = useAppStore((state) => state.settingsAgents.items);
@@ -72,50 +87,89 @@ export const ModelSelector = memo(function ModelSelector({ sessionId }: ModelSel
const activeModels = useAppStore((state) => state.activeModel.bySessionId);
const setActiveModel = useAppStore((state) => state.setActiveModel);
const { items: availableAgents } = useAvailableAgents();
+ const sessionModelsData = useAppStore((state) =>
+ sessionId ? state.sessionModels.bySessionId[sessionId] : undefined,
+ );
const session = sessionId ? (taskSessions[sessionId] ?? null) : null;
const snapshotModel = resolveSnapshotModel(session?.agent_profile_snapshot);
- const availableModels = resolveAvailableModels(
- settingsAgents as Agent[],
- session?.agent_profile_id,
- availableAgents,
- );
+
+ // Prefer dynamic ACP session models when available, fall back to static registry models
+ const availableModels = sessionModelsData?.models?.length
+ ? sessionModelsToOptions(sessionModelsData.models)
+ : resolveStaticModels(settingsAgents as Agent[], session?.agent_profile_id, availableAgents);
+
const activeModel = sessionId ? activeModels[sessionId] || null : null;
- const currentModel = activeModel || snapshotModel;
+ const acpCurrentModel = sessionModelsData?.currentModelId || null;
+ const currentModel = activeModel || acpCurrentModel || snapshotModel;
const modelOptions = buildModelOptions(availableModels, currentModel);
- const handleModelChange = (modelId: string) => {
- if (!sessionId) return;
- setActiveModel(sessionId, modelId);
+ const handleModelChange = useCallback(
+ (sid: string, modelId: string) => {
+ setActiveModel(sid, modelId);
+ setSessionModel(sid, modelId).catch((err) => {
+ console.error("[ModelSelector] set-model API failed:", err);
+ });
+ },
+ [setActiveModel],
+ );
+
+ return { currentModel, modelOptions, handleModelChange };
+}
+
+function modelToComboboxOption(model: ModelOption): ComboboxOption {
+ return {
+ value: model.id,
+ label: model.name,
+ description: model.description,
+ renderLabel: () => (
+ <>
+
+
{model.name}
+ {model.description && (
+
+ {model.description}
+
+ )}
+
+ {model.usageMultiplier && (
+ {model.usageMultiplier}
+ )}
+ >
+ ),
};
+}
+
+export const ModelSelector = memo(function ModelSelector({ sessionId }: ModelSelectorProps) {
+ const { currentModel, modelOptions, handleModelChange } = useModelSelectorState(sessionId);
+
+ const comboboxOptions = useMemo(() => modelOptions.map(modelToComboboxOption), [modelOptions]);
+
+ const onValueChange = useCallback(
+ (value: string) => {
+ // Don't allow deselecting — always keep a model selected
+ if (!value || !sessionId) return;
+ handleModelChange(sessionId, value);
+ },
+ [sessionId, handleModelChange],
+ );
if (!sessionId || !currentModel) return null;
- const displayName = modelOptions.find((m) => m.id === currentModel)?.name || currentModel;
-
return (
-
-
-
-
-
- {modelOptions.map((model) => (
- handleModelChange(model.id)}
- className={model.id === currentModel ? "bg-accent" : ""}
- >
- {model.name}
-
- ))}
-
-
+ 5}
+ triggerClassName="h-7 gap-1 px-2 text-xs w-auto hover:bg-muted/40 whitespace-nowrap"
+ className="min-w-[280px]"
+ plainTrigger
+ popoverSide="top"
+ popoverAlign="end"
+ />
);
});
diff --git a/apps/web/hooks/use-message-handler.ts b/apps/web/hooks/use-message-handler.ts
index 4499eaf6ec..78a60ec744 100644
--- a/apps/web/hooks/use-message-handler.ts
+++ b/apps/web/hooks/use-message-handler.ts
@@ -172,6 +172,7 @@ export function useMessageHandler({
type: att.type,
data: att.data,
mime_type: att.mime_type,
+ name: att.name,
}));
await queue(taskId, finalMessage, modelToSend, planModeEnabled, queueAttachments);
return;
diff --git a/apps/web/lib/api/domains/session-api.ts b/apps/web/lib/api/domains/session-api.ts
index 4d5a6e66fa..7e6329cbbc 100644
--- a/apps/web/lib/api/domains/session-api.ts
+++ b/apps/web/lib/api/domains/session-api.ts
@@ -58,6 +58,24 @@ export async function openSessionFolder(sessionId: string, options?: ApiRequestO
});
}
+export async function setSessionMode(sessionId: string, modeId: string) {
+ return fetchJson<{ ok: boolean }>(`/api/v1/task-sessions/${sessionId}/set-mode`, {
+ init: { method: "POST", body: JSON.stringify({ mode_id: modeId }) },
+ });
+}
+
+export async function setSessionModel(sessionId: string, modelId: string) {
+ return fetchJson<{ ok: boolean }>(`/api/v1/task-sessions/${sessionId}/set-model`, {
+ init: { method: "POST", body: JSON.stringify({ model_id: modelId }) },
+ });
+}
+
+export async function authenticateSession(sessionId: string, methodId: string) {
+ return fetchJson<{ ok: boolean }>(`/api/v1/task-sessions/${sessionId}/authenticate`, {
+ init: { method: "POST", body: JSON.stringify({ method_id: methodId }) },
+ });
+}
+
export { launchSession, type LaunchSessionResponse } from "@/lib/services/session-launch-service";
export {
buildPRPrepareRequest,
diff --git a/apps/web/lib/local-storage.ts b/apps/web/lib/local-storage.ts
index 5f343fe735..2d19c0519f 100644
--- a/apps/web/lib/local-storage.ts
+++ b/apps/web/lib/local-storage.ts
@@ -490,14 +490,14 @@ const CHAT_DRAFT_CONTENT_KEY = "kandev.chatDraft.content";
const CHAT_DRAFT_ATTACHMENTS_KEY = "kandev.chatDraft.attachments";
const CHAT_INPUT_HEIGHT_KEY = "kandev.chatInput.height";
-/** Stored attachment — same as ImageAttachment but without `preview` (reconstructed on load) */
-type StoredImageAttachment = {
+/** Stored attachment — same as FileAttachment but without `preview` (reconstructed on load) */
+type StoredFileAttachment = {
id: string;
data: string;
mimeType: string;
+ fileName: string;
size: number;
- width: number;
- height: number;
+ isImage: boolean;
};
export function getChatDraftText(sessionId: string): string {
@@ -525,8 +525,8 @@ export function setChatDraftContent(sessionId: string, content: unknown): void {
}
}
-export function getChatDraftAttachments(sessionId: string): StoredImageAttachment[] {
- return getSessionStorage(
+export function getChatDraftAttachments(sessionId: string): StoredFileAttachment[] {
+ return getSessionStorage(
`${CHAT_DRAFT_ATTACHMENTS_KEY}.${sessionId}`,
[],
);
@@ -538,24 +538,24 @@ export function setChatDraftAttachments(
id: string;
data: string;
mimeType: string;
+ fileName: string;
size: number;
- width: number;
- height: number;
+ isImage: boolean;
preview?: string;
}>,
): void {
if (attachments.length === 0) {
removeSessionStorage(`${CHAT_DRAFT_ATTACHMENTS_KEY}.${sessionId}`);
} else {
- // Strip `preview` to halve storage cost — reconstructed on load
- const stored: StoredImageAttachment[] = attachments.map(
- ({ id, data, mimeType, size, width, height }) => ({
+ // Strip `preview` to halve storage cost — reconstructed on load for images
+ const stored: StoredFileAttachment[] = attachments.map(
+ ({ id, data, mimeType, fileName, size, isImage }) => ({
id,
data,
mimeType,
+ fileName,
size,
- width,
- height,
+ isImage,
}),
);
setSessionStorage(`${CHAT_DRAFT_ATTACHMENTS_KEY}.${sessionId}`, stored);
@@ -563,12 +563,15 @@ export function setChatDraftAttachments(
}
/**
- * Reconstruct the `preview` data URL from stored attachment data.
+ * Reconstruct the `preview` data URL from stored attachment data (images only).
*/
export function restoreAttachmentPreview(
- att: StoredImageAttachment,
-): StoredImageAttachment & { preview: string } {
- return { ...att, preview: `data:${att.mimeType};base64,${att.data}` };
+ att: StoredFileAttachment,
+): StoredFileAttachment & { preview?: string } {
+ if (att.isImage) {
+ return { ...att, preview: `data:${att.mimeType};base64,${att.data}` };
+ }
+ return att;
}
export function getChatInputHeight(sessionId: string): number | null {
diff --git a/apps/web/lib/state/slices/session-runtime/session-runtime-slice.ts b/apps/web/lib/state/slices/session-runtime/session-runtime-slice.ts
index a6f8ae5ce2..5e4ba6ef6c 100644
--- a/apps/web/lib/state/slices/session-runtime/session-runtime-slice.ts
+++ b/apps/web/lib/state/slices/session-runtime/session-runtime-slice.ts
@@ -82,6 +82,10 @@ export const defaultSessionRuntimeState: SessionRuntimeSliceState = {
agents: { agents: [] },
availableCommands: { bySessionId: {} },
sessionMode: { bySessionId: {} },
+ agentCapabilities: { bySessionId: {} },
+ sessionModels: { bySessionId: {} },
+ promptUsage: { bySessionId: {} },
+ sessionTodos: { bySessionId: {} },
userShells: { bySessionId: {}, loading: {}, loaded: {} },
prepareProgress: { bySessionId: {} },
};
@@ -228,13 +232,33 @@ export const createSessionRuntimeSlice: StateCreator<
set((draft) => {
delete draft.availableCommands.bySessionId[sessionId];
}),
- setSessionMode: (sessionId, modeId) =>
+ setSessionMode: (sessionId, modeId, availableModes) =>
set((draft) => {
- draft.sessionMode.bySessionId[sessionId] = modeId;
+ const existing = draft.sessionMode.bySessionId[sessionId];
+ draft.sessionMode.bySessionId[sessionId] = {
+ currentModeId: modeId,
+ availableModes: availableModes ?? existing?.availableModes ?? [],
+ };
}),
clearSessionMode: (sessionId) =>
set((draft) => {
delete draft.sessionMode.bySessionId[sessionId];
}),
+ setAgentCapabilities: (sessionId, caps) =>
+ set((draft) => {
+ draft.agentCapabilities.bySessionId[sessionId] = caps;
+ }),
+ setSessionModels: (sessionId, data) =>
+ set((draft) => {
+ draft.sessionModels.bySessionId[sessionId] = data;
+ }),
+ setPromptUsage: (sessionId, usage) =>
+ set((draft) => {
+ draft.promptUsage.bySessionId[sessionId] = usage;
+ }),
+ setSessionTodos: (sessionId, entries) =>
+ set((draft) => {
+ draft.sessionTodos.bySessionId[sessionId] = entries;
+ }),
...buildUserShellActions(set),
});
diff --git a/apps/web/lib/state/slices/session-runtime/types.ts b/apps/web/lib/state/slices/session-runtime/types.ts
index ed0684013b..3a4c41477b 100644
--- a/apps/web/lib/state/slices/session-runtime/types.ts
+++ b/apps/web/lib/state/slices/session-runtime/types.ts
@@ -123,8 +123,79 @@ export type AvailableCommandsState = {
bySessionId: Record;
};
+export type SessionModeEntry = {
+ id: string;
+ name: string;
+ description?: string;
+};
+
export type SessionModeState = {
- bySessionId: Record;
+ bySessionId: Record<
+ string,
+ {
+ currentModeId: string;
+ availableModes: SessionModeEntry[];
+ }
+ >;
+};
+
+export type AuthMethodEntry = {
+ id: string;
+ name: string;
+ description?: string;
+ terminalAuth?: { command: string; args?: string[]; label?: string };
+ meta?: Record;
+};
+
+export type SessionModelEntry = {
+ modelId: string;
+ name: string;
+ description?: string;
+ usageMultiplier?: string;
+ meta?: Record;
+};
+
+export type ConfigOptionEntry = {
+ type: string;
+ id: string;
+ name: string;
+ currentValue: string;
+ category?: string;
+ options?: { value: string; name: string }[];
+};
+
+export type AgentCapabilitiesEntry = {
+ supportsImage: boolean;
+ supportsAudio: boolean;
+ supportsEmbeddedContext: boolean;
+ authMethods: AuthMethodEntry[];
+};
+
+export type PromptUsageEntry = {
+ inputTokens: number;
+ outputTokens: number;
+ cachedReadTokens?: number;
+ cachedWriteTokens?: number;
+ totalTokens: number;
+};
+
+export type AgentCapabilitiesState = {
+ bySessionId: Record;
+};
+
+export type SessionModelsState = {
+ bySessionId: Record<
+ string,
+ {
+ currentModelId: string;
+ models: SessionModelEntry[];
+ configOptions: ConfigOptionEntry[];
+ }
+ >;
+};
+
+export type PromptUsageState = {
+ bySessionId: Record;
};
export type UserShellInfo = {
@@ -163,6 +234,16 @@ export type PrepareProgressState = {
bySessionId: Record;
};
+export type TodoEntry = {
+ description: string;
+ status: "pending" | "in_progress" | "completed" | "failed";
+ priority?: string;
+};
+
+export type SessionTodosState = {
+ bySessionId: Record;
+};
+
export type SessionRuntimeSliceState = {
terminal: TerminalState;
shell: ShellState;
@@ -173,6 +254,10 @@ export type SessionRuntimeSliceState = {
agents: AgentState;
availableCommands: AvailableCommandsState;
sessionMode: SessionModeState;
+ agentCapabilities: AgentCapabilitiesState;
+ sessionModels: SessionModelsState;
+ promptUsage: PromptUsageState;
+ sessionTodos: SessionTodosState;
userShells: UserShellsState;
prepareProgress: PrepareProgressState;
};
@@ -201,8 +286,23 @@ export type SessionRuntimeSliceActions = {
setAvailableCommands: (sessionId: string, commands: AvailableCommand[]) => void;
clearAvailableCommands: (sessionId: string) => void;
// Session mode actions
- setSessionMode: (sessionId: string, modeId: string) => void;
+ setSessionMode: (sessionId: string, modeId: string, availableModes?: SessionModeEntry[]) => void;
clearSessionMode: (sessionId: string) => void;
+ // Agent capabilities actions
+ setAgentCapabilities: (sessionId: string, caps: AgentCapabilitiesEntry) => void;
+ // Session models actions
+ setSessionModels: (
+ sessionId: string,
+ data: {
+ currentModelId: string;
+ models: SessionModelEntry[];
+ configOptions: ConfigOptionEntry[];
+ },
+ ) => void;
+ // Prompt usage actions
+ setPromptUsage: (sessionId: string, usage: PromptUsageEntry) => void;
+ // Session todos actions
+ setSessionTodos: (sessionId: string, entries: TodoEntry[]) => void;
// User shells actions
setUserShells: (sessionId: string, shells: UserShellInfo[]) => void;
setUserShellsLoading: (sessionId: string, loading: boolean) => void;
diff --git a/apps/web/lib/state/store.ts b/apps/web/lib/state/store.ts
index df602a68b0..f36b0bae57 100644
--- a/apps/web/lib/state/store.ts
+++ b/apps/web/lib/state/store.ts
@@ -55,6 +55,16 @@ import {
type PreviewDevicePreset,
type ConnectionState,
} from "./slices";
+import type {
+ AvailableCommand,
+ SessionModeEntry,
+ AgentCapabilitiesEntry,
+ SessionModelEntry,
+ ConfigOptionEntry,
+ PromptUsageEntry,
+ TodoEntry,
+ UserShellInfo,
+} from "./slices/session-runtime/types";
// Re-export all types from slices for backwards compatibility
export type {
@@ -172,6 +182,10 @@ export type AppState = {
sessionMode: (typeof defaultSessionRuntimeState)["sessionMode"];
userShells: (typeof defaultSessionRuntimeState)["userShells"];
prepareProgress: (typeof defaultSessionRuntimeState)["prepareProgress"];
+ sessionTodos: (typeof defaultSessionRuntimeState)["sessionTodos"];
+ agentCapabilities: (typeof defaultSessionRuntimeState)["agentCapabilities"];
+ sessionModels: (typeof defaultSessionRuntimeState)["sessionModels"];
+ promptUsage: (typeof defaultSessionRuntimeState)["promptUsage"];
// GitHub slice
githubStatus: (typeof defaultGitHubState)["githubStatus"];
@@ -353,24 +367,30 @@ export type AppState = {
setQueueLoading: (sessionId: string, loading: boolean) => void;
clearQueueStatus: (sessionId: string) => void;
// Available commands actions
- setAvailableCommands: (
- sessionId: string,
- commands: import("./slices/session-runtime/types").AvailableCommand[],
- ) => void;
+ setAvailableCommands: (sessionId: string, commands: AvailableCommand[]) => void;
clearAvailableCommands: (sessionId: string) => void;
// Session mode actions
- setSessionMode: (sessionId: string, modeId: string) => void;
+ setSessionMode: (sessionId: string, modeId: string, availableModes?: SessionModeEntry[]) => void;
clearSessionMode: (sessionId: string) => void;
+ // Agent capabilities actions
+ setAgentCapabilities: (sessionId: string, caps: AgentCapabilitiesEntry) => void;
+ // Session models actions
+ setSessionModels: (
+ sessionId: string,
+ data: {
+ currentModelId: string;
+ models: SessionModelEntry[];
+ configOptions: ConfigOptionEntry[];
+ },
+ ) => void;
+ // Prompt usage actions
+ setPromptUsage: (sessionId: string, usage: PromptUsageEntry) => void;
+ // Session todos actions
+ setSessionTodos: (sessionId: string, entries: TodoEntry[]) => void;
// User shells actions
- setUserShells: (
- sessionId: string,
- shells: import("./slices/session-runtime/types").UserShellInfo[],
- ) => void;
+ setUserShells: (sessionId: string, shells: UserShellInfo[]) => void;
setUserShellsLoading: (sessionId: string, loading: boolean) => void;
- addUserShell: (
- sessionId: string,
- shell: import("./slices/session-runtime/types").UserShellInfo,
- ) => void;
+ addUserShell: (sessionId: string, shell: UserShellInfo) => void;
removeUserShell: (sessionId: string, terminalId: string) => void;
};
@@ -418,6 +438,10 @@ const defaultState = {
sessionMode: defaultSessionRuntimeState.sessionMode,
userShells: defaultSessionRuntimeState.userShells,
prepareProgress: defaultSessionRuntimeState.prepareProgress,
+ sessionTodos: defaultSessionRuntimeState.sessionTodos,
+ agentCapabilities: defaultSessionRuntimeState.agentCapabilities,
+ sessionModels: defaultSessionRuntimeState.sessionModels,
+ promptUsage: defaultSessionRuntimeState.promptUsage,
githubStatus: defaultGitHubState.githubStatus,
taskPRs: defaultGitHubState.taskPRs,
prWatches: defaultGitHubState.prWatches,
@@ -488,6 +512,10 @@ function mergeInitialState(initialState?: Partial): typeof defaultStat
sessionMode: { ...defaultState.sessionMode, ...initialState.sessionMode },
userShells: { ...defaultState.userShells, ...initialState.userShells },
prepareProgress: { ...defaultState.prepareProgress, ...initialState.prepareProgress },
+ sessionTodos: { ...defaultState.sessionTodos, ...initialState.sessionTodos },
+ agentCapabilities: { ...defaultState.agentCapabilities, ...initialState.agentCapabilities },
+ sessionModels: { ...defaultState.sessionModels, ...initialState.sessionModels },
+ promptUsage: { ...defaultState.promptUsage, ...initialState.promptUsage },
githubStatus: { ...defaultState.githubStatus, ...initialState.githubStatus },
taskPRs: { ...defaultState.taskPRs, ...initialState.taskPRs },
prWatches: { ...defaultState.prWatches, ...initialState.prWatches },
@@ -567,6 +595,10 @@ export function createAppStore(initialState?: Partial) {
sessionMode: merged.sessionMode,
userShells: merged.userShells,
prepareProgress: merged.prepareProgress,
+ sessionTodos: merged.sessionTodos,
+ agentCapabilities: merged.agentCapabilities,
+ sessionModels: merged.sessionModels,
+ promptUsage: merged.promptUsage,
githubStatus: merged.githubStatus,
taskPRs: merged.taskPRs,
prWatches: merged.prWatches,
diff --git a/apps/web/lib/types/backend.ts b/apps/web/lib/types/backend.ts
index a516feceed..444caf709d 100644
--- a/apps/web/lib/types/backend.ts
+++ b/apps/web/lib/types/backend.ts
@@ -33,6 +33,10 @@ export type BackendMessageType =
| "session.turn.completed"
| "session.available_commands"
| "session.mode_changed"
+ | "session.agent_capabilities"
+ | "session.models_updated"
+ | "session.todos_updated"
+ | "session.prompt_usage"
| "executor.created"
| "executor.updated"
| "executor.deleted"
@@ -76,6 +80,13 @@ import type {
import type { SecretListItem } from "@/lib/types/http-secrets";
import type { GitEventPayload } from "@/lib/types/git-events";
import type { TaskPR } from "@/lib/types/github";
+import type { FileChangeNotificationPayload } from "./workspace-files";
+import type {
+ AgentCapabilitiesPayload,
+ SessionModelsPayload,
+ SessionPromptUsagePayload,
+ SessionTodosPayload,
+} from "./session-runtime-payloads";
export type KanbanUpdatePayload = {
workflowId: string;
@@ -416,9 +427,24 @@ export type SessionModeChangedPayload = {
session_id: string;
agent_id: string;
current_mode_id: string;
+ available_modes?: {
+ id: string;
+ name: string;
+ description?: string;
+ }[];
timestamp?: string;
};
+// Session runtime payload types (extracted to reduce file size)
+export {
+ type AuthMethodInfoPayload,
+ type AgentCapabilitiesPayload,
+ type SessionModelInfoPayload,
+ type ConfigOptionPayload,
+ type SessionModelsPayload,
+ type SessionTodosPayload,
+} from "./session-runtime-payloads";
+
export type TaskPlanEventPayload = {
id: string;
task_id: string;
@@ -491,6 +517,13 @@ export type BackendMessageMap = {
AvailableCommandsPayload
>;
"session.mode_changed": BackendMessage<"session.mode_changed", SessionModeChangedPayload>;
+ "session.agent_capabilities": BackendMessage<
+ "session.agent_capabilities",
+ AgentCapabilitiesPayload
+ >;
+ "session.models_updated": BackendMessage<"session.models_updated", SessionModelsPayload>;
+ "session.todos_updated": BackendMessage<"session.todos_updated", SessionTodosPayload>;
+ "session.prompt_usage": BackendMessage<"session.prompt_usage", SessionPromptUsagePayload>;
"executor.created": BackendMessage<"executor.created", ExecutorPayload>;
"executor.updated": BackendMessage<"executor.updated", ExecutorPayload>;
"executor.deleted": BackendMessage<"executor.deleted", ExecutorPayload>;
@@ -526,74 +559,14 @@ export type BackendMessageMap = {
"github.task_pr.updated": BackendMessage<"github.task_pr.updated", TaskPR>;
};
-// Workspace file types
-export type FileTreeNode = {
- name: string;
- path: string;
- is_dir: boolean;
- size?: number;
- children?: FileTreeNode[];
-};
-
-export type FileTreeResponse = {
- request_id?: string;
- root: FileTreeNode;
- error?: string;
-};
-
-export type FileContentResponse = {
- request_id?: string;
- path: string;
- content: string;
- size: number;
- is_binary?: boolean;
- resolved_path?: string;
- error?: string;
-};
-
-export type FileSearchResponse = {
- files: string[];
- error?: string;
-};
-
-// Single file change event (used within batched notifications)
-export type FileChangeEvent = {
- timestamp: string;
- path: string;
- operation: "create" | "write" | "remove" | "rename" | "chmod" | "refresh";
- session_id: string;
- task_id: string;
- agent_id: string;
-};
-
-// Batched file change notification payload (multiple changes batched for efficiency)
-export type FileChangeNotificationPayload = {
- session_id: string;
- changes: FileChangeEvent[];
-};
-
-// Open file tab for file viewer
-export type OpenFileTab = {
- path: string;
- name: string;
- content: string;
- originalContent: string; // For diff generation
- originalHash: string; // SHA256 for conflict detection
- isDirty: boolean; // Has unsaved changes
- isBinary?: boolean; // Binary file (content is base64-encoded)
-};
-
-// File extension to color mapping for file type indicators
-export const FILE_EXTENSION_COLORS: Record = {
- ts: "bg-blue-500",
- tsx: "bg-blue-400",
- js: "bg-yellow-500",
- jsx: "bg-yellow-400",
- go: "bg-cyan-500",
- py: "bg-green-500",
- rs: "bg-orange-500",
- json: "bg-amber-400",
- css: "bg-purple-500",
- html: "bg-red-500",
- md: "bg-gray-400",
-};
+// Workspace file types (extracted to reduce file size)
+export {
+ type FileTreeNode,
+ type FileTreeResponse,
+ type FileContentResponse,
+ type FileSearchResponse,
+ type FileChangeEvent,
+ type FileChangeNotificationPayload,
+ type OpenFileTab,
+ FILE_EXTENSION_COLORS,
+} from "./workspace-files";
diff --git a/apps/web/lib/types/context.ts b/apps/web/lib/types/context.ts
index d706d22761..c6391dcb39 100644
--- a/apps/web/lib/types/context.ts
+++ b/apps/web/lib/types/context.ts
@@ -1,5 +1,5 @@
import type { DiffComment, PlanComment, PRFeedbackComment } from "@/lib/state/slices/comments";
-import type { ImageAttachment } from "@/components/task/chat/image-attachment-preview";
+import type { FileAttachment } from "@/components/task/chat/file-attachment";
type ContextItemBase = {
id: string;
@@ -43,7 +43,12 @@ export type PlanCommentContextItem = ContextItemBase & {
export type ImageContextItem = ContextItemBase & {
kind: "image";
- attachment: ImageAttachment;
+ attachment: FileAttachment;
+};
+
+export type FileAttachmentContextItem = ContextItemBase & {
+ kind: "file-attachment";
+ attachment: FileAttachment;
};
export type PRFeedbackContextItem = ContextItemBase & {
@@ -59,6 +64,7 @@ export type ContextItem =
| CommentContextItem
| PlanCommentContextItem
| ImageContextItem
+ | FileAttachmentContextItem
| PRFeedbackContextItem;
export type ContextItemKind = ContextItem["kind"];
diff --git a/apps/web/lib/types/session-runtime-payloads.ts b/apps/web/lib/types/session-runtime-payloads.ts
new file mode 100644
index 0000000000..007f201f54
--- /dev/null
+++ b/apps/web/lib/types/session-runtime-payloads.ts
@@ -0,0 +1,75 @@
+export type AuthMethodInfoPayload = {
+ id: string;
+ name: string;
+ description?: string;
+ terminal_auth?: {
+ command: string;
+ args?: string[];
+ label?: string;
+ };
+ meta?: Record;
+};
+
+export type AgentCapabilitiesPayload = {
+ task_id: string;
+ session_id: string;
+ agent_id: string;
+ supports_image: boolean;
+ supports_audio: boolean;
+ supports_embedded_context: boolean;
+ auth_methods: AuthMethodInfoPayload[];
+ timestamp: string;
+};
+
+export type SessionModelInfoPayload = {
+ model_id: string;
+ name: string;
+ description?: string;
+ usage_multiplier?: string;
+ meta?: Record;
+};
+
+export type ConfigOptionPayload = {
+ type: string;
+ id: string;
+ name: string;
+ current_value: string;
+ category?: string;
+ options?: { value: string; name: string }[];
+};
+
+export type SessionModelsPayload = {
+ task_id: string;
+ session_id: string;
+ agent_id: string;
+ current_model_id: string;
+ models: SessionModelInfoPayload[];
+ config_options: ConfigOptionPayload[];
+ timestamp: string;
+};
+
+export type SessionPromptUsagePayload = {
+ task_id: string;
+ session_id: string;
+ agent_id: string;
+ usage: {
+ input_tokens: number;
+ output_tokens: number;
+ cached_read_tokens?: number;
+ cached_write_tokens?: number;
+ total_tokens: number;
+ };
+ timestamp: string;
+};
+
+export type SessionTodosPayload = {
+ task_id: string;
+ session_id: string;
+ agent_id: string;
+ entries: Array<{
+ description: string;
+ status: string;
+ priority: string;
+ }>;
+ timestamp: string;
+};
diff --git a/apps/web/lib/types/workspace-files.ts b/apps/web/lib/types/workspace-files.ts
new file mode 100644
index 0000000000..6bb4e2d562
--- /dev/null
+++ b/apps/web/lib/types/workspace-files.ts
@@ -0,0 +1,66 @@
+export type FileTreeNode = {
+ name: string;
+ path: string;
+ is_dir: boolean;
+ size?: number;
+ children?: FileTreeNode[];
+};
+
+export type FileTreeResponse = {
+ request_id?: string;
+ root: FileTreeNode;
+ error?: string;
+};
+
+export type FileContentResponse = {
+ request_id?: string;
+ path: string;
+ content: string;
+ size: number;
+ is_binary?: boolean;
+ resolved_path?: string;
+ error?: string;
+};
+
+export type FileSearchResponse = {
+ files: string[];
+ error?: string;
+};
+
+export type FileChangeEvent = {
+ timestamp: string;
+ path: string;
+ operation: "create" | "write" | "remove" | "rename" | "chmod" | "refresh";
+ session_id: string;
+ task_id: string;
+ agent_id: string;
+};
+
+export type FileChangeNotificationPayload = {
+ session_id: string;
+ changes: FileChangeEvent[];
+};
+
+export type OpenFileTab = {
+ path: string;
+ name: string;
+ content: string;
+ originalContent: string;
+ originalHash: string;
+ isDirty: boolean;
+ isBinary?: boolean;
+};
+
+export const FILE_EXTENSION_COLORS: Record = {
+ ts: "bg-blue-500",
+ tsx: "bg-blue-400",
+ js: "bg-yellow-500",
+ jsx: "bg-yellow-400",
+ go: "bg-cyan-500",
+ py: "bg-green-500",
+ rs: "bg-orange-500",
+ json: "bg-amber-400",
+ css: "bg-purple-500",
+ html: "bg-red-500",
+ md: "bg-gray-400",
+};
diff --git a/apps/web/lib/ws/handlers/agent-capabilities.ts b/apps/web/lib/ws/handlers/agent-capabilities.ts
new file mode 100644
index 0000000000..1ec152cb2a
--- /dev/null
+++ b/apps/web/lib/ws/handlers/agent-capabilities.ts
@@ -0,0 +1,33 @@
+import type { StoreApi } from "zustand";
+import type { AppState } from "@/lib/state/store";
+import type { WsHandlers } from "@/lib/ws/handlers/types";
+import type { AgentCapabilitiesPayload } from "@/lib/types/backend";
+
+export function registerAgentCapabilitiesHandlers(store: StoreApi): WsHandlers {
+ return {
+ "session.agent_capabilities": (message) => {
+ const payload = message.payload as AgentCapabilitiesPayload | undefined;
+ if (!payload?.session_id) {
+ return;
+ }
+ store.getState().setAgentCapabilities(payload.session_id, {
+ supportsImage: payload.supports_image,
+ supportsAudio: payload.supports_audio,
+ supportsEmbeddedContext: payload.supports_embedded_context,
+ authMethods: (payload.auth_methods ?? []).map((m) => ({
+ id: m.id,
+ name: m.name,
+ description: m.description,
+ terminalAuth: m.terminal_auth
+ ? {
+ command: m.terminal_auth.command,
+ args: m.terminal_auth.args,
+ label: m.terminal_auth.label,
+ }
+ : undefined,
+ meta: m.meta,
+ })),
+ });
+ },
+ };
+}
diff --git a/apps/web/lib/ws/handlers/prompt-usage.ts b/apps/web/lib/ws/handlers/prompt-usage.ts
new file mode 100644
index 0000000000..2051a52107
--- /dev/null
+++ b/apps/web/lib/ws/handlers/prompt-usage.ts
@@ -0,0 +1,22 @@
+import type { StoreApi } from "zustand";
+import type { AppState } from "@/lib/state/store";
+import type { WsHandlers } from "@/lib/ws/handlers/types";
+import type { SessionPromptUsagePayload } from "@/lib/types/session-runtime-payloads";
+
+export function registerPromptUsageHandlers(store: StoreApi): WsHandlers {
+ return {
+ "session.prompt_usage": (message) => {
+ const payload = message.payload as SessionPromptUsagePayload | undefined;
+ if (!payload?.session_id || !payload?.usage) {
+ return;
+ }
+ store.getState().setPromptUsage(payload.session_id, {
+ inputTokens: payload.usage.input_tokens,
+ outputTokens: payload.usage.output_tokens,
+ cachedReadTokens: payload.usage.cached_read_tokens,
+ cachedWriteTokens: payload.usage.cached_write_tokens,
+ totalTokens: payload.usage.total_tokens,
+ });
+ },
+ };
+}
diff --git a/apps/web/lib/ws/handlers/session-mode.ts b/apps/web/lib/ws/handlers/session-mode.ts
index fd5df74bc7..39ec219260 100644
--- a/apps/web/lib/ws/handlers/session-mode.ts
+++ b/apps/web/lib/ws/handlers/session-mode.ts
@@ -1,22 +1,29 @@
import type { StoreApi } from "zustand";
import type { AppState } from "@/lib/state/store";
import type { WsHandlers } from "@/lib/ws/handlers/types";
+import type { SessionModeChangedPayload } from "@/lib/types/backend";
export function registerSessionModeHandlers(store: StoreApi): WsHandlers {
return {
"session.mode_changed": (message) => {
- const payload = message.payload;
+ const payload = message.payload as SessionModeChangedPayload | undefined;
if (!payload?.session_id) {
return;
}
- const sessionId = payload.session_id as string;
+ const sessionId = payload.session_id;
// Empty current_mode_id means the agent exited its special mode
- const modeId = (payload.current_mode_id as string) || "";
+ const modeId = payload.current_mode_id || "";
+ const availableModes = payload.available_modes?.map((m) => ({
+ id: m.id,
+ name: m.name,
+ description: m.description,
+ }));
if (modeId) {
- store.getState().setSessionMode(sessionId, modeId);
+ store.getState().setSessionMode(sessionId, modeId, availableModes);
} else {
- store.getState().clearSessionMode(sessionId);
+ // Keep availableModes so the UI still knows what modes exist
+ store.getState().setSessionMode(sessionId, "", availableModes);
}
},
};
diff --git a/apps/web/lib/ws/handlers/session-models.ts b/apps/web/lib/ws/handlers/session-models.ts
new file mode 100644
index 0000000000..30637dc3c7
--- /dev/null
+++ b/apps/web/lib/ws/handlers/session-models.ts
@@ -0,0 +1,33 @@
+import type { StoreApi } from "zustand";
+import type { AppState } from "@/lib/state/store";
+import type { WsHandlers } from "@/lib/ws/handlers/types";
+import type { SessionModelsPayload } from "@/lib/types/backend";
+
+export function registerSessionModelsHandlers(store: StoreApi): WsHandlers {
+ return {
+ "session.models_updated": (message) => {
+ const payload = message.payload as SessionModelsPayload | undefined;
+ if (!payload?.session_id) {
+ return;
+ }
+ store.getState().setSessionModels(payload.session_id, {
+ currentModelId: payload.current_model_id,
+ models: (payload.models ?? []).map((m) => ({
+ modelId: m.model_id,
+ name: m.name,
+ description: m.description,
+ usageMultiplier: m.usage_multiplier,
+ meta: m.meta,
+ })),
+ configOptions: (payload.config_options ?? []).map((o) => ({
+ type: o.type,
+ id: o.id,
+ name: o.name,
+ currentValue: o.current_value,
+ category: o.category,
+ options: o.options,
+ })),
+ });
+ },
+ };
+}
diff --git a/apps/web/lib/ws/handlers/session-todos.ts b/apps/web/lib/ws/handlers/session-todos.ts
new file mode 100644
index 0000000000..f17835809f
--- /dev/null
+++ b/apps/web/lib/ws/handlers/session-todos.ts
@@ -0,0 +1,26 @@
+import type { StoreApi } from "zustand";
+import type { AppState } from "@/lib/state/store";
+import type { WsHandlers } from "@/lib/ws/handlers/types";
+import type { SessionTodosPayload } from "@/lib/types/backend";
+import type { TodoEntry } from "@/lib/state/slices/session-runtime/types";
+
+export function registerSessionTodosHandlers(store: StoreApi): WsHandlers {
+ return {
+ "session.todos_updated": (message) => {
+ const payload = message.payload as SessionTodosPayload | undefined;
+ if (!payload?.session_id) {
+ return;
+ }
+ store.getState().setSessionTodos(
+ payload.session_id,
+ (payload.entries ?? []).map(
+ (e): TodoEntry => ({
+ description: e.description,
+ status: e.status as TodoEntry["status"],
+ priority: e.priority,
+ }),
+ ),
+ );
+ },
+ };
+}
diff --git a/apps/web/lib/ws/router.ts b/apps/web/lib/ws/router.ts
index 823d8ef8e7..778d42ed67 100644
--- a/apps/web/lib/ws/router.ts
+++ b/apps/web/lib/ws/router.ts
@@ -4,6 +4,10 @@ import { registerAgentsHandlers } from "@/lib/ws/handlers/agents";
import { registerTaskSessionHandlers } from "@/lib/ws/handlers/agent-session";
import { registerAvailableCommandsHandlers } from "@/lib/ws/handlers/available-commands";
import { registerSessionModeHandlers } from "@/lib/ws/handlers/session-mode";
+import { registerAgentCapabilitiesHandlers } from "@/lib/ws/handlers/agent-capabilities";
+import { registerSessionModelsHandlers } from "@/lib/ws/handlers/session-models";
+import { registerSessionTodosHandlers } from "@/lib/ws/handlers/session-todos";
+import { registerPromptUsageHandlers } from "@/lib/ws/handlers/prompt-usage";
import { registerWorkflowsHandlers } from "@/lib/ws/handlers/workflows";
import { registerMessagesHandlers } from "@/lib/ws/handlers/messages";
@@ -39,6 +43,10 @@ export function registerWsHandlers(store: StoreApi) {
...registerTaskSessionHandlers(store),
...registerAvailableCommandsHandlers(store),
...registerSessionModeHandlers(store),
+ ...registerAgentCapabilitiesHandlers(store),
+ ...registerSessionModelsHandlers(store),
+ ...registerSessionTodosHandlers(store),
+ ...registerPromptUsageHandlers(store),
...registerUsersHandlers(store),
...registerTerminalsHandlers(store),
...registerDiffsHandlers(store),