Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat/thread split columns (#1104)

Ruben Lütke1d79eee29a55
diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadColumns.test.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadColumns.test.tsx
new file mode 100644
index 0000000000..6265b09827
--- /dev/null
+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadColumns.test.tsx
@@ -0,0 +1,82 @@
+import { act, createEvent, fireEvent, render, screen } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { useIdeThreadsStore } from "@/store/ideThreads";
+import { ThreadColumns } from "./ThreadColumns";
+import { THREAD_DRAG_MIME, THREAD_PROJECT_DRAG_MIME, setDraggedThread, useThreadChat } from "./threadModel";
+
+// Each column shows which thread its own store would open; the real view is tested on its own.
+vi.mock("./ThreadView", () => ({
+ ThreadView: ({ column }: { column?: { sessionId: string } }) => {
+ const store = useThreadChat();
+ return <div data-testid="view" data-thread={column?.sessionId ?? "main"} data-store={String(Boolean(store))} />;
+ },
+}));
+
+/** A drag that carries a thread, the way a sidebar row starts one. */
+function threadDrag(sessionId: string, projectId: string) {
+ const data: Record<string, string> = { [THREAD_DRAG_MIME]: sessionId, [THREAD_PROJECT_DRAG_MIME]: projectId };
+ return {
+ types: Object.keys(data),
+ getData: (type: string) => data[type] ?? "",
+ setData: () => undefined,
+ dropEffect: "none",
+ effectAllowed: "move",
+ };
+}
+
+/** Lay the columns out 400px wide each, left to right; jsdom measures nothing. */
+function layOut() {
+ screen.getByTestId("thread-columns").querySelectorAll<HTMLElement>("[data-thread-column]").forEach((cell, index) => {
+ cell.getBoundingClientRect = () => ({ left: index * 400, right: index * 400 + 400, width: 400, top: 0, bottom: 800, height: 800, x: index * 400, y: 0, toJSON: () => ({}) });
+ });
+}
+
+function dropAt(sessionId: string, clientX: number) {
+ const box = screen.getByTestId("thread-columns");
+ setDraggedThread(sessionId);
+ const dataTransfer = threadDrag(sessionId, "p1");
+ // jsdom has no DragEvent: the pointer's x is set on the plain event by hand.
+ for (const kind of ["dragOver", "drop"] as const) {
+ const event = createEvent[kind](box, { dataTransfer });
+ Object.defineProperty(event, "clientX", { value: clientX });
+ fireEvent(box, event);
+ }
+}
+
+function renderColumns() {
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ return render(<QueryClientProvider client={client}><ThreadColumns onScreen /></QueryClientProvider>);
+}
+
+const shown = () => screen.getAllByTestId("view").map((view) => view.dataset.thread);
+
+describe("ThreadColumns", () => {
+ beforeEach(() => {
+ localStorage.clear();
+ useIdeThreadsStore.setState({ selection: { projectId: "p1", sessionId: "s1" }, split: [], mainAt: 0 });
+ });
+ afterEach(() => setDraggedThread(null));
+
+ it("opens a thread dropped on the right half next to the main one, and on the left half before it", () => {
+ renderColumns();
+ expect(shown()).toEqual(["main"]);
+ layOut();
+ act(() => dropAt("s2", 300));
+ expect(shown()).toEqual(["main", "s2"]);
+ layOut();
+ act(() => dropAt("s3", 100));
+ expect(shown()).toEqual(["s3", "main", "s2"]);
+ });
+
+ it("ignores a drop of the main column's own thread and closes side columns from their header", () => {
+ renderColumns();
+ layOut();
+ act(() => dropAt("s1", 300));
+ expect(shown()).toEqual(["main"]);
+ layOut();
+ act(() => dropAt("s2", 300));
+ fireEvent.click(screen.getByTestId("thread-column-close-s2"));
+ expect(shown()).toEqual(["main"]);
+ });
+});
diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadColumns.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadColumns.tsx
new file mode 100644
index 0000000000..c937263f94
--- /dev/null
+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadColumns.tsx
@@ -0,0 +1,165 @@
+import { useLayoutEffect, useMemo, useRef, useState, type DragEvent } from "react";
+import { X } from "lucide-react";
+import { fill, useT } from "@/i18n";
+import { useTeamThreads } from "@/lib/teamThreadsApi";
+import { cn } from "@/lib/utils";
+import { createAgentChatStore } from "@/store/agentChat";
+import { MAX_THREAD_COLUMNS, threadColumns, useIdeThreadsStore, type SplitThread, type ThreadColumn } from "@/store/ideThreads";
+import { ThreadView } from "./ThreadView";
+import {
+ THREAD_DRAG_MIME, THREAD_PROJECT_DRAG_MIME, ThreadChatContext, draggedThread, setDraggedThread, threadTitle, useThreadChatStore,
+} from "./threadModel";
+
+/** Where a dragged thread would land: over which column, and on which side of it. */
+interface DropSpot {
+ cell: number;
+ side: "left" | "right" | "all";
+}
+
+/**
+ * The thread layout's columns. The main one shows what the sidebar picked; a
+ * thread dragged from the sidebar onto it opens in its own column next to it,
+ * left or right of the column it is dropped on. Each side column has its own
+ * chat store, so every column holds its own live conversation and composer.
+ */
+export function ThreadColumns({ onScreen }: { onScreen: boolean }) {
+ const t = useT();
+ const split = useIdeThreadsStore((state) => state.split);
+ const mainAt = useIdeThreadsStore((state) => state.mainAt);
+ const selection = useIdeThreadsStore((state) => state.selection);
+ const placeColumn = useIdeThreadsStore((state) => state.placeColumn);
+ const columns = useMemo(() => threadColumns(split, mainAt), [split, mainAt]);
+ const [spot, setSpot] = useState<DropSpot | null>(null);
+ const box = useRef<HTMLDivElement | null>(null);
+ const multi = columns.length > 1;
+
+ const spotFor = (event: DragEvent<HTMLDivElement>): DropSpot | null => {
+ const dragged = draggedThread();
+ // The main column's own thread is on screen already.
+ if (dragged !== null && dragged === selection.sessionId) return null;
+ const cells = Array.from(box.current?.querySelectorAll<HTMLElement>(":scope > [data-thread-column]") ?? []);
+ const cell = cells.findIndex((element) => {
+ const rect = element.getBoundingClientRect();
+ return event.clientX >= rect.left && event.clientX < rect.right;
+ });
+ if (cell < 0) return null;
+ const moving = dragged !== null && split.some((thread) => thread.sessionId === dragged);
+ // Every column taken: a new thread replaces the one it is dropped on.
+ if (!moving && columns.length >= MAX_THREAD_COLUMNS) return { cell, side: "all" };
+ const rect = cells[cell].getBoundingClientRect();
+ return { cell, side: event.clientX < rect.left + rect.width / 2 ? "left" : "right" };
+ };
+
+ const isThreadDrag = (event: DragEvent<HTMLDivElement>) => event.dataTransfer.types.includes(THREAD_DRAG_MIME);
+
+ return <div ref={box} className="flex h-full min-h-0 overflow-x-auto" data-testid="thread-columns"
+ // Capture phase: the composer below takes dropped files, and must not see a thread.
+ onDragOverCapture={(event) => {
+ if (!isThreadDrag(event)) return;
+ event.preventDefault();
+ event.stopPropagation();
+ const next = spotFor(event);
+ event.dataTransfer.dropEffect = next ? "move" : "none";
+ setSpot((current) => (current?.cell === next?.cell && current?.side === next?.side ? current : next));
+ }}
+ onDragLeave={(event) => {
+ const next = event.relatedTarget as Node | null;
+ if (next && event.currentTarget.contains(next)) return;
+ setSpot(null);
+ }}
+ onDropCapture={(event) => {
+ if (!isThreadDrag(event)) return;
+ event.preventDefault();
+ event.stopPropagation();
+ const at = spotFor(event);
+ setSpot(null);
+ setDraggedThread(null);
+ const sessionId = event.dataTransfer.getData(THREAD_DRAG_MIME);
+ if (!at || !sessionId) return;
+ const projectId = event.dataTransfer.getData(THREAD_PROJECT_DRAG_MIME)
+ || split.find((thread) => thread.sessionId === sessionId)?.projectId || selection.projectId;
+ placeColumn({ sessionId, projectId }, at.side === "right" ? at.cell + 1 : at.cell, at.side === "all");
+ }}>
+ {columns.map((column, index) => <div key={column?.sessionId ?? "main"} data-thread-column
+ data-testid={column ? `thread-column-${column.sessionId}` : "thread-column-main"}
+ className={cn("relative flex h-full min-w-[300px] flex-1 basis-0 flex-col", index > 0 && "border-l border-border")}>
+ {multi && <ColumnHeader column={column} />}
+ <div className="min-h-0 flex-1">
+ {column ? <SideColumn thread={column} onScreen={onScreen} /> : <ThreadView onScreen={onScreen} />}
+ </div>
+ {spot?.cell === index && <div aria-hidden className={cn(
+ "pointer-events-none absolute inset-y-1 z-30 flex items-center justify-center rounded-lg border-2 border-primary/60 bg-primary/10",
+ spot.side === "left" && "left-1 w-1/2",
+ spot.side === "right" && "right-1 w-1/2",
+ spot.side === "all" && "inset-x-1",
+ )}>
+ <span className="rounded-md bg-background/90 px-2 py-1 text-xs text-foreground shadow-sm">
+ {t(spot.side === "all" ? "ide_threads.drop_replace" : "ide_threads.drop_side_by_side")}
+ </span>
+ </div>}
+ </div>)}
+ </div>;
+}
+
+/** A column's name and its close button, shown while more than one column is open. */
+function ColumnHeader({ column }: { column: ThreadColumn }) {
+ const t = useT();
+ const selection = useIdeThreadsStore((state) => state.selection);
+ const sessionId = column ? column.sessionId : selection.sessionId;
+ const session = useThreadChatStore((state) => (sessionId ? state.sessions.find((row) => row.session_id === sessionId) : undefined));
+ const teamTitle = useTeamThreads(Boolean(selection.team) && !column).data?.find((row) => row.team_id === selection.team)?.title;
+ const title = selection.team && !column ? teamTitle || t("team_threads.new") : threadTitle(session);
+ const close = () => {
+ const store = useIdeThreadsStore.getState();
+ if (column) store.closeColumn(column.sessionId);
+ else store.closeMainColumn();
+ };
+ return <div className="flex h-9 shrink-0 items-center gap-1 border-b border-border pl-3 pr-1"
+ // A side column's header drags it to another place among the columns.
+ draggable={Boolean(column)}
+ onDragStart={(event) => {
+ if (!column) return;
+ event.dataTransfer.setData(THREAD_DRAG_MIME, column.sessionId);
+ event.dataTransfer.setData(THREAD_PROJECT_DRAG_MIME, column.projectId);
+ event.dataTransfer.effectAllowed = "move";
+ setDraggedThread(column.sessionId);
+ }}
+ onDragEnd={() => setDraggedThread(null)}>
+ <span className={cn("min-w-0 flex-1 truncate text-sm", column ? "cursor-grab text-muted-foreground" : "text-foreground")} title={title}>{title}</span>
+ <button type="button" onClick={close} aria-label={fill(t("ide_threads.close_column"), { target: title })} title={t("common.close")}
+ data-testid={column ? `thread-column-close-${column.sessionId}` : "thread-column-close-main"}
+ className="flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ <X className="h-3.5 w-3.5" />
+ </button>
+ </div>;
+}
+
+/** A side column: its own chat store, so its conversation runs next to the main one's. */
+function SideColumn({ thread, onScreen }: { thread: SplitThread; onScreen: boolean }) {
+ const [store] = useState(() => {
+ const created = createAgentChatStore("agent", "threads-side");
+ const main = useThreadChatStore.getState();
+ const row = main.sessions.find((session) => session.session_id === thread.sessionId);
+ // The thread list paints the title and agent at once, before the socket's
+ // first frame; the draft already mirrors the thread, so the composer never
+ // "corrects" a model or effort it has not seen yet.
+ created.setState((state) => ({
+ sessions: main.sessions,
+ catalog: main.catalog,
+ draft: row
+ ? { ...state.draft, provider: row.provider, model: row.model, effort: row.effort, permissionMode: row.permission_mode, cwd: row.cwd }
+ : state.draft,
+ }));
+ return created;
+ });
+ // A layout effect: the thread is open before the composer's effects run, so
+ // none of them ever treats this column as a new thread's draft.
+ useLayoutEffect(() => {
+ const state = store.getState();
+ if (state.activeSessionId !== thread.sessionId || state.socketState === "idle") state.openSession(thread.sessionId);
+ return () => store.getState().disconnect();
+ }, [store, thread.sessionId]);
+ return <ThreadChatContext.Provider value={store}>
+ <ThreadView onScreen={onScreen} column={thread} />
+ </ThreadChatContext.Provider>;
+}
diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadComposer.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadComposer.tsx
index 5e7c00ca2e..8d41c1644e 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadComposer.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadComposer.tsx
@@ -15,7 +15,7 @@ import { cn } from "@/lib/utils";
import { effortLadder, snapEffort } from "@/lib/effortLadder";
import { AccessPicker, AgentModelPicker, EffortPicker, modelsOf } from "./ThreadPickers";
import { useRecalledMessages } from "./recalledMessages";
-import { rememberSeat, rememberedSeat, threadAgents, useThreadChatStore } from "./threadModel";
+import { rememberSeat, rememberedSeat, threadAgents, useThreadChat } from "./threadModel";
/** A message typed while the agent was still working, sent when it is free. */
interface QueuedMessage {
@@ -116,6 +116,7 @@ function ApprovalPanel({ timeline }: { timeline: Timeline }) {
function ApprovalCard({ pending, count }: { pending: PendingApproval; count: number }) {
const t = useT();
+ const chat = useThreadChat();
const [sending, setSending] = useState<ApprovalDecision | null>(null);
const [error, setError] = useState("");
const input = pending.input && typeof pending.input === "object" ? pending.input as Record<string, unknown> : {};
@@ -130,7 +131,7 @@ function ApprovalCard({ pending, count }: { pending: PendingApproval; count: num
setSending(decision);
setError("");
try {
- await useThreadChatStore.getState().decide(pending.approvalId, decision);
+ await chat.getState().decide(pending.approvalId, decision);
} catch (err) {
setError(err instanceof Error ? err.message : String(err));
setSending(null);
@@ -177,6 +178,7 @@ function waitingPlan(timeline: Timeline): TurnItem | null {
*/
function PlanPanel({ timeline, provider }: { timeline: Timeline; provider: ProviderOption | null }) {
const t = useT();
+ const chat = useThreadChat();
const turn = waitingPlan(timeline);
const [sending, setSending] = useState(false);
const [error, setError] = useState("");
@@ -187,7 +189,7 @@ function PlanPanel({ timeline, provider }: { timeline: Timeline; provider: Provi
setSending(true);
setError("");
try {
- await useThreadChatStore.getState().resolvePlan(turn.id, decision);
+ await chat.getState().resolvePlan(turn.id, decision);
} catch (err) {
setError(err instanceof Error ? err.message : String(err));
} finally {
@@ -218,6 +220,7 @@ function PlanPanel({ timeline, provider }: { timeline: Timeline; provider: Provi
function QuestionPanel({ timeline }: { timeline: Timeline }) {
const t = useT();
+ const chat = useThreadChat();
const open = openQuestion(timeline);
const [text, setText] = useState("");
const [error, setError] = useState("");
@@ -231,7 +234,7 @@ function QuestionPanel({ timeline }: { timeline: Timeline }) {
setSending(true);
setError("");
try {
- await useThreadChatStore.getState().answerQuestion(question.questionId, index, payload);
+ await chat.getState().answerQuestion(question.questionId, index, payload);
setText("");
} catch (err) {
setError(err instanceof Error ? err.message : String(err));
@@ -257,7 +260,7 @@ function QuestionPanel({ timeline }: { timeline: Timeline }) {
<form className="mt-2 flex gap-2" onSubmit={(event) => { event.preventDefault(); if (text.trim()) void answer({ text: text.trim() }); }}>
<input value={text} onChange={(event) => setText(event.target.value)} placeholder={t("ide_threads.own_answer")} disabled={sending}
className="min-w-0 flex-1 rounded-lg border border-input bg-background px-3 py-1.5 text-sm text-foreground outline-none focus:ring-2 focus:ring-ring" />
- <button type="button" disabled={sending} onClick={() => void useThreadChatStore.getState().skipQuestion(question.questionId).catch((err: unknown) => setError(err instanceof Error ? err.message : String(err)))}
+ <button type="button" disabled={sending} onClick={() => void chat.getState().skipQuestion(question.questionId).catch((err: unknown) => setError(err instanceof Error ? err.message : String(err)))}
className="rounded-lg px-3 py-1.5 text-sm text-muted-foreground hover:bg-secondary">{t("ide_threads.skip")}</button>
</form>
{error && <p role="alert" className="mt-1 text-xs text-destructive">{error}</p>}
@@ -298,15 +301,16 @@ export function ThreadComposer({
/** False while the IDE section is hidden: its keys belong to whatever is on screen. */
onScreen?: boolean;
}) {
- const draft = useThreadChatStore((state) => state.draft);
- const timeline = useThreadChatStore((state) => state.timeline);
- const activeSessionId = useThreadChatStore((state) => state.activeSessionId);
- const activeSession = useThreadChatStore((state) => state.activeSession);
- const catalog = useThreadChatStore((state) => state.catalog);
- const connections = useThreadChatStore((state) => state.connections);
- const liveModels = useThreadChatStore((state) => state.liveModels);
- const busy = useThreadChatStore((state) => state.busy);
- const lastError = useThreadChatStore((state) => state.lastError);
+ const chat = useThreadChat();
+ const draft = chat((state) => state.draft);
+ const timeline = chat((state) => state.timeline);
+ const activeSessionId = chat((state) => state.activeSessionId);
+ const activeSession = chat((state) => state.activeSession);
+ const catalog = chat((state) => state.catalog);
+ const connections = chat((state) => state.connections);
+ const liveModels = chat((state) => state.liveModels);
+ const busy = chat((state) => state.busy);
+ const lastError = chat((state) => state.lastError);
const [value, setValueState] = useState(() => drafts.get(threadKey) ?? "");
const [queue, setQueueState] = useState<QueuedMessage[]>(() => queues.get(threadKey) ?? []);
// After Stop the queue waits: the person halted the agent, it must not start the next job.
@@ -343,10 +347,10 @@ export function ThreadComposer({
if (providers.some((option) => option.id === draft.provider && option.connected)) return;
const seat = rememberedSeat();
const remembered = seat && providers.find((option) => option.id === seat.provider && option.connected);
- if (remembered && seat) { void useThreadChatStore.getState().setDraft(seat); return; }
+ if (remembered && seat) { void chat.getState().setDraft(seat); return; }
const first = providers.find((option) => option.connected) ?? providers[0];
- if (first && first.id !== draft.provider) void useThreadChatStore.getState().setDraft({ provider: first.id });
- }, [activeSessionId, providers, draft.provider]);
+ if (first && first.id !== draft.provider) void chat.getState().setDraft({ provider: first.id });
+ }, [chat, activeSessionId, providers, draft.provider]);
// A model change can leave the picked effort off that model's ladder (Opus
// 4.6 has no xhigh, Gemini 3.1 Pro no medium); fold it the way the backend
@@ -360,8 +364,8 @@ export function ThreadComposer({
const ladder = effortLadder(provider, modelsOf(provider, liveModels), draft.model);
if (!ladder.some(Boolean)) return;
const next = snapEffort(draft.effort, ladder, provider.default_effort);
- if (next !== draft.effort) void useThreadChatStore.getState().setDraft({ effort: next });
- }, [provider, liveModels, draft.model, draft.effort, activeSessionId, activeSession]);
+ if (next !== draft.effort) void chat.getState().setDraft({ effort: next });
+ }, [chat, provider, liveModels, draft.model, draft.effort, activeSessionId, activeSession]);
const setValue = useCallback((next: string) => {
setValueState(next);
@@ -397,7 +401,7 @@ export function ThreadComposer({
const files = useChatAttachments(
{ sessionId: activeSessionId, cwd: draft.cwd, provider: draft.provider, surface: "agent" },
(message) => setProblem(message),
- { owner: useThreadChatStore, key: threadKey },
+ { owner: chat, key: threadKey },
);
const triggers = useMemo(() => provider?.typeahead ?? [], [provider]);
const typeahead = useComposerTypeahead(textareaRef, value, setValue, {
@@ -408,7 +412,7 @@ export function ThreadComposer({
});
const dispatch = useCallback(async (text: string, attachments: ChatAttachment[]) => {
- const store = useThreadChatStore.getState();
+ const store = chat.getState();
if (!store.activeSessionId) {
setStarting(true);
try {
@@ -422,9 +426,9 @@ export function ThreadComposer({
setStarting(false);
}
}
- await useThreadChatStore.getState().send(text, attachments, [], onSessionCreated);
- return !useThreadChatStore.getState().lastError;
- }, [prepareDraft, onSessionCreated]);
+ await chat.getState().send(text, attachments, [], onSessionCreated);
+ return !chat.getState().lastError;
+ }, [chat, prepareDraft, onSessionCreated]);
// A queued message goes out the moment the agent is free again.
useEffect(() => {
@@ -466,10 +470,10 @@ export function ThreadComposer({
setQueue((current) => [...current, { id: ++queueId.current, text, attachments }]);
return;
}
- const before = useThreadChatStore.getState();
+ const before = chat.getState();
keepSent({ text, files: held, sentMs: Date.now(), sessionId: before.activeSessionId, afterSeq: before.timeline.lastSeq });
const sent = await dispatch(text, attachments);
- if (!sent && !useThreadChatStore.getState().activeSessionId) {
+ if (!sent && !chat.getState().activeSessionId) {
// Nothing was created: give the words back instead of losing them.
setValue(text);
}
@@ -485,7 +489,7 @@ export function ThreadComposer({
lastSent = null;
setPaused(true);
if (activeSessionId) useRecalledMessages.getState().hide(activeSessionId, asked.id);
- void useThreadChatStore.getState().cancel("thread-recall");
+ void chat.getState().cancel("thread-recall");
const current = drafts.get(threadKey) ?? "";
setValue(current.trim() ? `${text}\n${current}` : text);
files.restore(held);
@@ -517,9 +521,9 @@ export function ThreadComposer({
// A pick the person made is the seat every new thread starts on.
const pick = async (patch: Partial<Pick<ComposerDraft, "provider" | "model" | "effort" | "permissionMode">>) => {
- const store = useThreadChatStore.getState();
+ const store = chat.getState();
await store.setDraft(patch);
- rememberSeat(useThreadChatStore.getState().draft);
+ rememberSeat(chat.getState().draft);
};
const canSend = (value.trim().length > 0 || files.attachments.length > 0 || dictation.dictating) && files.analyzing === 0 && !starting;
@@ -562,7 +566,8 @@ export function ThreadComposer({
onPaste={files.onPaste}
className="block max-h-[40vh] min-h-[84px] w-full resize-none bg-transparent px-4 pb-2 pt-4 text-base leading-6 text-foreground outline-none placeholder:text-faint-foreground sm:px-5" />
<div className="flex min-w-0 items-center justify-between gap-2 px-3 pb-3 sm:px-4 sm:pb-4">
- <div className="-ms-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none]">
+ {/* The pickers keep their width: a narrow column (side by side) scrolls the row instead of stacking them. */}
+ <div className="-ms-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&>*]:shrink-0">
<AgentModelPicker providers={providers} liveModels={liveModels} draft={draft}
lockedProvider={started && activeSessionId ? draft.provider : null}
onPick={(nextProvider, model) => void pick(nextProvider !== draft.provider ? { provider: nextProvider, model } : { model })} />
@@ -576,7 +581,7 @@ export function ThreadComposer({
startLabel={t("chats_view.dictation_start")} stopLabel={t("chats_view.dictation_stop")} shape="round" />
{running && !canSend
? <button type="button" aria-label={t("ide_threads.stop_agent")} title={t("ide_threads.stop")} data-testid="thread-stop"
- onClick={() => { setPaused(true); void useThreadChatStore.getState().cancel("thread-stop-button"); }}
+ onClick={() => { setPaused(true); void chat.getState().cancel("thread-stop-button"); }}
className="flex h-8 w-8 items-center justify-center rounded-full bg-foreground text-background transition-transform duration-150 hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
<Square className="h-3 w-3 fill-current" />
</button>
diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTree.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTree.tsx
index ccb946bb47..5f65092c91 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTree.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadTree.tsx
@@ -1,5 +1,5 @@
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
-import { Archive, ArchiveRestore, Check, ChevronDown, ChevronRight, Folder, FolderOpen, Loader2, Mic, MoreHorizontal, Pencil, Plus, SquarePlus, Trash2, Users, X } from "lucide-react";
+import { Archive, ArchiveRestore, Check, ChevronDown, ChevronRight, Columns2, Folder, FolderOpen, Loader2, Mic, MoreHorizontal, Pencil, Plus, SquarePlus, Trash2, Users, X } from "lucide-react";
import { AgentMark } from "@/components/agentic/AgentMark";
import { patchAgentChatSession, type AgentChatSession } from "@/lib/agentChatApi";
import type { IdeProject } from "@/lib/agenticIdeApi";
@@ -8,20 +8,18 @@ import { fill, useT } from "@/i18n";
import { useRunLocale } from "@/components/runs/format";
import { useEventStore } from "@/store/events";
import { useIdeProjectsStore } from "@/store/ideProjects";
-import { TEAM_DRAFT, useIdeThreadsStore } from "@/store/ideThreads";
+import { MAX_THREAD_COLUMNS, TEAM_DRAFT, useIdeThreadsStore } from "@/store/ideThreads";
import { useTeamThreads, type TeamThreadRow } from "@/lib/teamThreadsApi";
import { openSubagentOf, useThreadSubagentsStore } from "@/store/threadSubagents";
import { ThreadMenuItem, ThreadMenuSeparator, ThreadPopover } from "./ThreadPopover";
import { SubagentFoldToggle, ThreadTreeSubagents } from "./ThreadTreeSubagents";
-import { arrangeThreads, moveThreadId, projectIdFor, shortAge, threadStatus, threadTitle, threadsByProject, useThreadChatStore, type ThreadStatus } from "./threadModel";
+import { THREAD_DRAG_MIME, THREAD_PROJECT_DRAG_MIME, arrangeThreads, moveThreadId, projectIdFor, setDraggedThread, shortAge, threadStatus, threadTitle, threadsByProject, useThreadChatStore, type ThreadStatus } from "./threadModel";
const EXPANSION_KEY = "jarvis.ide.threadExpansion.v1";
/** Threads a project shows before "Show more". */
const FOLDED_COUNT = 6;
/** How often the list asks for fresh session rows while it is on screen. */
const POLL_MS = 4000;
-/** What a dragged thread row carries, so only a thread row is a valid drop. */
-const THREAD_DRAG_MIME = "application/x-jarvis-thread";
function readExpansion(): Record<string, boolean> {
try {
@@ -84,6 +82,8 @@ export function ThreadTree() {
const archiveThread = useIdeThreadsStore((state) => state.archiveThread);
const restoreThread = useIdeThreadsStore((state) => state.restoreThread);
const setThreadOrder = useIdeThreadsStore((state) => state.setThreadOrder);
+ const split = useIdeThreadsStore((state) => state.split);
+ const placeColumn = useIdeThreadsStore((state) => state.placeColumn);
const [expansion, setExpansion] = useState(readExpansion);
const [showAll, setShowAll] = useState<Record<string, boolean>>({});
const [renaming, setRenaming] = useState<{ sessionId: string; title: string } | null>(null);
@@ -157,7 +157,7 @@ export function ThreadTree() {
if (next.some((id, index) => id !== ids[index])) setThreadOrder(projectId, next);
};
- const clearDrag = () => { setDragged(null); setDropTarget(null); };
+ const clearDrag = () => { setDragged(null); setDropTarget(null); setDraggedThread(null); };
const remove = async (sessionId: string) => {
setConfirmDelete(null);
@@ -264,8 +264,11 @@ export function ThreadTree() {
return <Fragment key={session.session_id}><div data-testid={`thread-row-${session.session_id}`}
draggable
onDragStart={(event) => {
+ // Within the list it reorders; dropped on the thread view it opens side by side.
event.dataTransfer.setData(THREAD_DRAG_MIME, session.session_id);
+ event.dataTransfer.setData(THREAD_PROJECT_DRAG_MIME, project.id);
event.dataTransfer.effectAllowed = "move";
+ setDraggedThread(session.session_id);
setDragged({ sessionId: session.session_id, projectId: project.id });
}}
onDragEnd={clearDrag}
@@ -412,6 +415,10 @@ export function ThreadTree() {
const menuArchived = menuSession !== null && menuSession.session_id in archived;
// A thread that is working or waiting for an answer stays in view: archived, nobody would see it ask.
const menuBusy = Boolean(menuSession?.running) || Boolean(menuSession?.pending_approvals?.length);
+ // "Open side by side": not for the thread the main column shows, nor when every column is taken.
+ const menuInMain = menuSession !== null && selection.sessionId === menuSession.session_id;
+ const menuInSide = menuSession !== null && split.some((thread) => thread.sessionId === menuSession.session_id);
+ const columnsFull = split.length + 1 >= MAX_THREAD_COLUMNS;
return <div data-testid="ide-thread-tree" className="flex-1 px-2 pb-3 pt-2">
<div className="flex h-8 items-center justify-between gap-2 pl-2 pr-1 text-[15px] font-semibold text-foreground">
@@ -446,6 +453,9 @@ export function ThreadTree() {
: <div role="menu">
<ThreadMenuItem icon={<Pencil className="h-3.5 w-3.5" />} label={t("ide_threads.rename")}
onSelect={() => { setRenaming({ sessionId: menuSession.session_id, title: threadTitle(menuSession) }); setMenu(null); }} />
+ <ThreadMenuItem icon={<Columns2 className="h-3.5 w-3.5" />} label={t("ide_threads.open_side_by_side")}
+ disabled={menuInMain || menuInSide || columnsFull}
+ onSelect={() => { placeColumn({ sessionId: menuSession.session_id, projectId: menu.projectId }, split.length + 1); setMenu(null); }} />
<ThreadMenuItem icon={<SquarePlus className="h-3.5 w-3.5" />} label={t("ide_threads.new_thread_here")}
onSelect={() => { newThread(menu.projectId); setMenu(null); }} />
{menuArchived
diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx
index 9061499653..068496b713 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx
@@ -6,7 +6,7 @@ import type { AgentChatSession } from "@/lib/agentChatApi";
import { useEventStore } from "@/store/events";
import { fill, translate, useT } from "@/i18n";
import { useIdeProjectsStore } from "@/store/ideProjects";
-import { useIdeThreadsStore } from "@/store/ideThreads";
+import { useIdeThreadsStore, type SplitThread, type ThreadSelection } from "@/store/ideThreads";
import { useThreadTerminalsStore } from "@/store/threadTerminals";
import { openSubagentOf, useThreadSubagentsStore, type SubagentRow } from "@/store/threadSubagents";
import { ThreadBranchBar, type ThreadCheckout } from "./ThreadBranchBar";
@@ -17,7 +17,7 @@ import { ThreadTimeline } from "./ThreadTimeline";
import { OpenSubagent, SubagentHeader, SubagentSwitcher } from "./ThreadSubagents";
import { useRecalledMessages, withoutRecalled } from "./recalledMessages";
import { fetchDiscoveredAgents, listSubagents, mergeDiscovered, subagentPath, subagentTurn, type DiscoveredAgent } from "./subagents";
-import { projectIdFor, rememberedSeat, useThreadChatStore } from "./threadModel";
+import { projectIdFor, rememberedSeat, useThreadChat, useThreadChatStore } from "./threadModel";
import { TeamThreadView } from "./team/TeamThreadView";
/**
@@ -28,23 +28,36 @@ import { TeamThreadView } from "./team/TeamThreadView";
* opens the thread picked in the sidebar, or a draft in a project whose first
* message starts the thread — in the project's checkout or a fresh worktree.
*/
-export function ThreadView({ onScreen }: { onScreen: boolean }) {
+export function ThreadView({ onScreen, column }: {
+ onScreen: boolean;
+ /** A side column's thread; absent for the main column, which shows what the sidebar picked. */
+ column?: SplitThread;
+}) {
const t = useT();
+ // The main column's store, or the side column's own (from its provider).
+ const chatStore = useThreadChat();
const pushToast = useEventStore((state) => state.pushToast);
const projects = useIdeProjectsStore((state) => state.projects);
const activeWorkspaceId = useIdeProjectsStore((state) => state.activeWorkspaceId);
const connectProject = useIdeProjectsStore((state) => state.connectProject);
- const selection = useIdeThreadsStore((state) => state.selection);
+ const picked = useIdeThreadsStore((state) => state.selection);
+ const selection = useMemo<ThreadSelection>(
+ () => (column ? { projectId: column.projectId, sessionId: column.sessionId } : picked),
+ [column?.projectId, column?.sessionId, picked],
+ );
const projectOf = useIdeThreadsStore((state) => state.projectOf);
- const focusNonce = useIdeThreadsStore((state) => state.focusNonce);
+ const sidebarFocus = useIdeThreadsStore((state) => state.focusNonce);
+ // A side column never takes the focus a sidebar click asks for.
+ const focusNonce = column ? 0 : sidebarFocus;
+ // The thread list is the sidebar's, kept fresh there; a side column's own store holds one thread.
const sessions = useThreadChatStore((state) => state.sessions);
- const activeSessionId = useThreadChatStore((state) => state.activeSessionId);
- const activeSession = useThreadChatStore((state) => state.activeSession);
- const timeline = useThreadChatStore((state) => state.timeline);
+ const activeSessionId = chatStore((state) => state.activeSessionId);
+ const activeSession = chatStore((state) => state.activeSession);
+ const timeline = chatStore((state) => state.timeline);
const recalled = useRecalledMessages((state) => (activeSessionId ? state.bySession[activeSessionId] : undefined));
- const draft = useThreadChatStore((state) => state.draft);
- const catalog = useThreadChatStore((state) => state.catalog);
- const lastError = useThreadChatStore((state) => state.lastError);
+ const draft = chatStore((state) => state.draft);
+ const catalog = chatStore((state) => state.catalog);
+ const lastError = chatStore((state) => state.lastError);
const [checkout, setCheckout] = useState<ThreadCheckout>("current");
const [base, setBase] = useState("");
const [projectMenu, setProjectMenu] = useState(false);
@@ -79,14 +92,14 @@ export function ThreadView({ onScreen }: { onScreen: boolean }) {
}, [originatingProject]);
// The terminal drawer and its caption toggle open shells in this folder.
- useEffect(() => { useThreadTerminalsStore.getState().setFolder(folder); }, [folder]);
+ useEffect(() => { if (!column) useThreadTerminalsStore.getState().setFolder(folder); }, [column, folder]);
// Keep the store on what the sidebar picked. A draft's first message
// creates its session: that is this project's thread now — unless the
// person moved on while it was being created; then it only remembers where
// it belongs, and the thread they picked is what shows.
useEffect(() => {
- const store = useThreadChatStore.getState();
+ const store = chatStore.getState();
const threads = useIdeThreadsStore.getState();
const pending = startingIn.current;
const created = pending && store.activeSessionId && store.activeSessionId !== selection.sessionId ? store.activeSessionId : null;
@@ -109,7 +122,7 @@ export function ThreadView({ onScreen }: { onScreen: boolean }) {
// The agents are listed the moment the view opens, not when a menu is.
useEffect(() => {
- const store = useThreadChatStore.getState();
+ const store = chatStore.getState();
if (!store.catalog || store.catalogStale) void store.loadCatalog();
}, []);
@@ -120,23 +133,23 @@ export function ThreadView({ onScreen }: { onScreen: boolean }) {
setCheckout("current");
setBase("");
// Never picked here yet: the seat of the newest thread is the last choice made.
- const store = useThreadChatStore.getState();
+ const store = chatStore.getState();
const cli = new Set((store.catalog?.providers ?? []).filter((row) => row.agent).map((row) => row.id));
const newest = [...store.sessions].filter((row) => cli.has(row.provider)).sort((x, y) => y.created_ms - x.created_ms)[0];
const seat = rememberedSeat() ?? (newest
? { provider: newest.provider, model: newest.model, effort: newest.effort, permissionMode: newest.permission_mode }
: null);
- const draftNow = useThreadChatStore.getState().draft;
+ const draftNow = chatStore.getState().draft;
if (seat && (seat.provider !== draftNow.provider || seat.model !== draftNow.model
|| seat.effort !== draftNow.effort || seat.permissionMode !== draftNow.permissionMode)) {
- void useThreadChatStore.getState().setDraft(seat);
+ void chatStore.getState().setDraft(seat);
}
}, [isDraft, selection.projectId, sessions.length > 0, Boolean(catalog)]);
// A draft runs in its project's folder.
useEffect(() => {
if (!isDraft || !project || activeSessionId || startingIn.current) return;
- if (useThreadChatStore.getState().draft.cwd !== project.path) void useThreadChatStore.getState().setDraft({ cwd: project.path });
+ if (chatStore.getState().draft.cwd !== project.path) void chatStore.getState().setDraft({ cwd: project.path });
}, [isDraft, project, activeSessionId, draft.cwd]);
// Keep the open thread marked as read.
diff --git a/dodaios/ui/web/frontend/src/components/agentic/threads/threadModel.ts b/dodaios/ui/web/frontend/src/components/agentic/threads/threadModel.ts
index 3e3c9275b8..5f3f71f439 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/threads/threadModel.ts
+++ b/dodaios/ui/web/frontend/src/components/agentic/threads/threadModel.ts
@@ -1,3 +1,4 @@
+import { createContext, useContext } from "react";
import type { AgentChatSession } from "@/lib/agentChatApi";
import type { IdeProject } from "@/lib/agenticIdeApi";
import { createAgentChatStore, type ProviderOption } from "@/store/agentChat";
@@ -15,6 +16,40 @@ import { fill, translate } from "@/i18n";
/** The IDE threads' chat store — one socket, one draft, one session list. */
export const useThreadChatStore = createAgentChatStore("agent", "threads");
+/** A thread chat store: the main one, or a side column's own. */
+export type ThreadChatStore = typeof useThreadChatStore;
+
+/**
+ * The store a thread view and its composer talk to. The main column uses the
+ * default; every side column provides its own, so each holds its own socket
+ * and conversation while they sit next to each other.
+ */
+export const ThreadChatContext = createContext<ThreadChatStore>(useThreadChatStore);
+
+export function useThreadChat(): ThreadChatStore {
+ return useContext(ThreadChatContext);
+}
+
+/** What a dragged thread row carries: its session id, so only a thread is a valid drop. */
+export const THREAD_DRAG_MIME = "application/x-jarvis-thread";
+/** The dragged thread's project, carried next to its session id. */
+export const THREAD_PROJECT_DRAG_MIME = "application/x-jarvis-thread-project";
+
+/**
+ * The thread being dragged right now. A drag's data can only be read on the
+ * drop, but the thread columns must know during the drag whether it is
+ * already on screen, so the row says it here too.
+ */
+let draggedThreadId: string | null = null;
+
+export function setDraggedThread(sessionId: string | null): void {
+ draggedThreadId = sessionId;
+}
+
+export function draggedThread(): string | null {
+ return draggedThreadId;
+}
+
/** How a row in the thread list reads at a glance. */
export type ThreadStatus = "approval" | "running" | "unseen" | "idle";
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/de.json b/dodaios/ui/web/frontend/src/i18n/locales/de.json
index 03bcdf1e12..0ec3a94e1a 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/de.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/de.json
@@ -10365,7 +10365,11 @@
"send_message": "Nachricht senden",
"queue_title": "Einreihen, bis der Agent fertig ist",
"copy_message": "Nachricht kopieren",
- "scroll_newest": "Zur neuesten Nachricht scrollen"
+ "scroll_newest": "Zur neuesten Nachricht scrollen",
+ "open_side_by_side": "Daneben öffnen",
+ "drop_side_by_side": "Loslassen, um daneben zu öffnen",
+ "drop_replace": "Loslassen, um diesen Thread zu ersetzen",
+ "close_column": "{target} schließen"
},
"ide_view": {
"split_right": "Rechts",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/en.json b/dodaios/ui/web/frontend/src/i18n/locales/en.json
index 4e2cf3a400..141912c4ed 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/en.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/en.json
@@ -10365,7 +10365,11 @@
"send_message": "Send message",
"queue_title": "Queue for when the agent is done",
"copy_message": "Copy message",
- "scroll_newest": "Scroll to the newest message"
+ "scroll_newest": "Scroll to the newest message",
+ "open_side_by_side": "Open side by side",
+ "drop_side_by_side": "Drop to open side by side",
+ "drop_replace": "Drop to replace this thread",
+ "close_column": "Close {target}"
},
"ide_view": {
"split_right": "Right",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/es.json b/dodaios/ui/web/frontend/src/i18n/locales/es.json
index de20134cfe..9afea5f42b 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/es.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/es.json
@@ -10365,7 +10365,11 @@
"send_message": "Enviar mensaje",
"queue_title": "Poner en cola para cuando el agente termine",
"copy_message": "Copiar mensaje",
- "scroll_newest": "Ir al mensaje más reciente"
+ "scroll_newest": "Ir al mensaje más reciente",
+ "open_side_by_side": "Abrir al lado",
+ "drop_side_by_side": "Suelta para abrirlo al lado",
+ "drop_replace": "Suelta para reemplazar este hilo",
+ "close_column": "Cerrar {target}"
},
"ide_view": {
"split_right": "Derecha",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/pt.json b/dodaios/ui/web/frontend/src/i18n/locales/pt.json
index c622d2a7e5..229ab1faee 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/pt.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/pt.json
@@ -10365,7 +10365,11 @@
"send_message": "Enviar mensagem",
"queue_title": "Pôr em fila para quando o agente terminar",
"copy_message": "Copiar mensagem",
- "scroll_newest": "Ir para a mensagem mais recente"
+ "scroll_newest": "Ir para a mensagem mais recente",
+ "open_side_by_side": "Abrir ao lado",
+ "drop_side_by_side": "Largue para abrir ao lado",
+ "drop_replace": "Largue para substituir este thread",
+ "close_column": "Fechar {target}"
},
"ide_view": {
"split_right": "Direita",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/zh.json b/dodaios/ui/web/frontend/src/i18n/locales/zh.json
index 59524e692b..c1d4d269af 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/zh.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/zh.json
@@ -10365,7 +10365,11 @@
"send_message": "发送消息",
"queue_title": "排队,待智能体完成后发送",
"copy_message": "复制消息",
- "scroll_newest": "滚动到最新消息"
+ "scroll_newest": "滚动到最新消息",
+ "open_side_by_side": "并排打开",
+ "drop_side_by_side": "松开以并排打开",
+ "drop_replace": "松开以替换此线程",
+ "close_column": "关闭 {target}"
},
"ide_view": {
"split_right": "右侧",
diff --git a/dodaios/ui/web/frontend/src/store/ideThreads.test.ts b/dodaios/ui/web/frontend/src/store/ideThreads.test.ts
index 1fff694126..878b2cb99b 100644
--- a/dodaios/ui/web/frontend/src/store/ideThreads.test.ts
+++ b/dodaios/ui/web/frontend/src/store/ideThreads.test.ts
@@ -1,10 +1,10 @@
import { beforeEach, describe, expect, it } from "vitest";
-import { useIdeThreadsStore } from "./ideThreads";
+import { MAX_THREAD_COLUMNS, threadColumns, useIdeThreadsStore } from "./ideThreads";
describe("ideThreads store", () => {
beforeEach(() => {
localStorage.clear();
- useIdeThreadsStore.setState({ layout: "grid", selection: { projectId: "", sessionId: null }, projectOf: {}, seen: {}, focusNonce: 0, beforeTeamDraft: null });
+ useIdeThreadsStore.setState({ layout: "grid", selection: { projectId: "", sessionId: null }, projectOf: {}, seen: {}, focusNonce: 0, beforeTeamDraft: null, split: [], mainAt: 0 });
});
it("leaves the team start form for what was open before it", () => {
@@ -62,4 +62,74 @@ describe("ideThreads store", () => {
expect(state.seen).toEqual({});
expect(state.selection).toEqual({ projectId: "p1", sessionId: null });
});
+
+ describe("side-by-side columns", () => {
+ const ids = () => {
+ const { split, mainAt } = useIdeThreadsStore.getState();
+ return threadColumns(split, mainAt).map((column) => column?.sessionId ?? "main");
+ };
+
+ it("opens a dropped thread left or right of a column and keeps it across a reload", () => {
+ const store = useIdeThreadsStore.getState();
+ store.openThread("s1", "p1");
+ store.placeColumn({ sessionId: "s2", projectId: "p1" }, 1);
+ store.placeColumn({ sessionId: "s3", projectId: "p1" }, 0);
+ expect(ids()).toEqual(["s3", "main", "s2"]);
+ expect(JSON.parse(localStorage.getItem("jarvis.agenticIde.threadSplit.v1") ?? "null")).toEqual({
+ split: [{ sessionId: "s3", projectId: "p1" }, { sessionId: "s2", projectId: "p1" }], mainAt: 1,
+ });
+ });
+
+ it("moves a thread that already has a column and ignores the main column's own thread", () => {
+ const store = useIdeThreadsStore.getState();
+ store.openThread("s1", "p1");
+ store.placeColumn({ sessionId: "s2", projectId: "p1" }, 1);
+ store.placeColumn({ sessionId: "s3", projectId: "p1" }, 2);
+ store.placeColumn({ sessionId: "s3", projectId: "p1" }, 0);
+ expect(ids()).toEqual(["s3", "main", "s2"]);
+ store.placeColumn({ sessionId: "s1", projectId: "p1" }, 0);
+ expect(ids()).toEqual(["s3", "main", "s2"]);
+ });
+
+ it("never opens more columns than fit; a full row replaces the column dropped on", () => {
+ const store = useIdeThreadsStore.getState();
+ store.openThread("s0", "p1");
+ for (let index = 1; index < MAX_THREAD_COLUMNS + 2; index += 1) store.placeColumn({ sessionId: `s${index}`, projectId: "p1" }, index);
+ expect(ids()).toHaveLength(MAX_THREAD_COLUMNS);
+ store.placeColumn({ sessionId: "x", projectId: "p1" }, 1, true);
+ expect(ids()).toEqual(["main", "x", "s2", "s3"]);
+ // Dropped on the main column, it opens there.
+ store.placeColumn({ sessionId: "y", projectId: "p1" }, 0, true);
+ expect(useIdeThreadsStore.getState().selection.sessionId).toBe("y");
+ });
+
+ it("closes columns; a thread picked for the main column or archived leaves its side column", () => {
+ const store = useIdeThreadsStore.getState();
+ store.openThread("s1", "p1");
+ store.placeColumn({ sessionId: "s2", projectId: "p1" }, 1);
+ store.placeColumn({ sessionId: "s3", projectId: "p1" }, 2);
+ store.placeColumn({ sessionId: "s4", projectId: "p1" }, 3);
+ store.openThread("s2", "p1");
+ expect(ids()).toEqual(["main", "s3", "s4"]);
+ store.archiveThread("s4");
+ expect(ids()).toEqual(["main", "s3"]);
+ store.closeColumn("s3");
+ expect(ids()).toEqual(["main"]);
+ });
+
+ it("closing the main column hands it to the thread next to it", () => {
+ const store = useIdeThreadsStore.getState();
+ store.openThread("s1", "p1");
+ store.placeColumn({ sessionId: "s2", projectId: "p1" }, 0);
+ store.placeColumn({ sessionId: "s3", projectId: "p2" }, 2);
+ store.closeMainColumn();
+ expect(useIdeThreadsStore.getState().selection).toEqual({ projectId: "p2", sessionId: "s3" });
+ expect(ids()).toEqual(["s2", "main"]);
+ store.closeMainColumn();
+ expect(useIdeThreadsStore.getState().selection.sessionId).toBe("s2");
+ expect(ids()).toEqual(["main"]);
+ store.closeMainColumn(); // nothing beside it: stays
+ expect(useIdeThreadsStore.getState().selection.sessionId).toBe("s2");
+ });
+ });
});
diff --git a/dodaios/ui/web/frontend/src/store/ideThreads.ts b/dodaios/ui/web/frontend/src/store/ideThreads.ts
index 2d72b2d956..c9c53edfaf 100644
--- a/dodaios/ui/web/frontend/src/store/ideThreads.ts
+++ b/dodaios/ui/web/frontend/src/store/ideThreads.ts
@@ -40,12 +40,36 @@ export interface ThreadSelection {
/** `ThreadSelection.team` of a team thread that has not started yet. */
export const TEAM_DRAFT = "new";
+/** A thread open in a side column next to the main one. */
+export interface SplitThread {
+ sessionId: string;
+ projectId: string;
+}
+
+/** How many threads can sit side by side, the main column included. */
+export const MAX_THREAD_COLUMNS = 4;
+
+/** One column of the thread layout: the main one (`null`) or a side thread. */
+export type ThreadColumn = SplitThread | null;
+
+/** The columns left to right: the side threads with the main one at `mainAt`. */
+export function threadColumns(split: readonly SplitThread[], mainAt: number): ThreadColumn[] {
+ const at = Math.max(0, Math.min(mainAt, split.length));
+ return [...split.slice(0, at), null, ...split.slice(at)];
+}
+
+function fromColumns(columns: readonly ThreadColumn[]): { split: SplitThread[]; mainAt: number } {
+ const mainAt = Math.max(0, columns.indexOf(null));
+ return { split: columns.filter((column): column is SplitThread => column !== null), mainAt };
+}
+
const LAYOUT_KEY = "jarvis.agenticIde.layout.v1";
const SELECTION_KEY = "jarvis.agenticIde.threadSelection.v1";
const PROJECT_OF_KEY = "jarvis.agenticIde.threadProjects.v1";
const SEEN_KEY = "jarvis.agenticIde.threadSeen.v1";
const ARCHIVED_KEY = "jarvis.agenticIde.threadArchived.v1";
const ORDER_KEY = "jarvis.agenticIde.threadOrder.v1";
+const SPLIT_KEY = "jarvis.agenticIde.threadSplit.v1";
/** Bounds on the two maps kept in storage — oldest entries go first. */
const MAX_REMEMBERED = 400;
/**
@@ -106,6 +130,21 @@ const parseOrder = (raw: unknown): Record<string, string[]> | null => {
return out;
};
+const parseSplit = (raw: unknown): { split: SplitThread[]; mainAt: number } | null => {
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
+ const row = raw as Record<string, unknown>;
+ const split: SplitThread[] = [];
+ for (const entry of Array.isArray(row.split) ? row.split : []) {
+ if (!entry || typeof entry !== "object") continue;
+ const { sessionId, projectId } = entry as Record<string, unknown>;
+ if (typeof sessionId !== "string" || !sessionId || split.some((thread) => thread.sessionId === sessionId)) continue;
+ split.push({ sessionId, projectId: typeof projectId === "string" ? projectId : "" });
+ if (split.length >= MAX_THREAD_COLUMNS - 1) break;
+ }
+ const mainAt = typeof row.mainAt === "number" && Number.isInteger(row.mainAt) ? Math.max(0, Math.min(row.mainAt, split.length)) : 0;
+ return { split, mainAt };
+};
+
/** Drop the oldest keys once a map outgrows `limit` (insertion order). */
function bounded<T>(map: Record<string, T>, limit = MAX_REMEMBERED): Record<string, T> {
const keys = Object.keys(map);
@@ -137,6 +176,10 @@ interface IdeThreadsState {
focusNonce: number;
/** What was on screen before the team start form opened; its cancel goes back there. */
beforeTeamDraft: ThreadSelection | null;
+ /** Threads open side by side with the main one, left to right. */
+ split: SplitThread[];
+ /** Where the main column sits among the side ones: 0 is the far left. */
+ mainAt: number;
setLayout: (layout: IdeLayout) => void;
/** Open an existing thread. */
@@ -164,6 +207,24 @@ interface IdeThreadsState {
restoreThread: (sessionId: string) => void;
/** Keep a project's threads in this order. */
setThreadOrder: (projectId: string, sessionIds: readonly string[]) => void;
+ /**
+ * Show a thread in its own column at `index` among all columns, the main one
+ * included. A thread already in a side column moves there; `replace` swaps
+ * out the column at `index` instead (on the main column it opens there).
+ */
+ placeColumn: (thread: SplitThread, index: number, replace?: boolean) => void;
+ /** Close a side column. */
+ closeColumn: (sessionId: string) => void;
+ /** Close the main column: the side thread next to it takes its place. */
+ closeMainColumn: () => void;
+}
+
+/** The side columns without `sessionId`; the same state when it had none. */
+function withoutSplit(state: Pick<IdeThreadsState, "split" | "mainAt">, sessionId: string | null): Pick<IdeThreadsState, "split" | "mainAt"> {
+ if (!sessionId || !state.split.some((thread) => thread.sessionId === sessionId)) return { split: state.split, mainAt: state.mainAt };
+ const next = fromColumns(threadColumns(state.split, state.mainAt).filter((column) => column?.sessionId !== sessionId));
+ write(SPLIT_KEY, next);
+ return next;
}
export const useIdeThreadsStore = create<IdeThreadsState>((set, get) => ({
@@ -175,6 +236,7 @@ export const useIdeThreadsStore = create<IdeThreadsState>((set, get) => ({
order: read(ORDER_KEY, parseOrder, {}),
focusNonce: 0,
beforeTeamDraft: null,
+ ...read(SPLIT_KEY, parseSplit, { split: [], mainAt: 0 }),
setLayout: (layout) => {
if (get().layout === layout) return;
@@ -184,7 +246,8 @@ export const useIdeThreadsStore = create<IdeThreadsState>((set, get) => ({
openThread: (sessionId, projectId) => {
const selection = { projectId, sessionId };
write(SELECTION_KEY, selection);
- set({ selection });
+ // A thread shows in one column only: picked for the main one, it leaves its side column.
+ set({ selection, ...withoutSplit(get(), sessionId) });
},
newThread: (projectId) => {
const selection = { projectId, sessionId: null };
@@ -212,14 +275,14 @@ export const useIdeThreadsStore = create<IdeThreadsState>((set, get) => ({
openMemberThread: (sessionId, projectId, teamId) => {
const selection = { projectId, sessionId, fromTeam: teamId };
write(SELECTION_KEY, selection);
- set({ selection });
+ set({ selection, ...withoutSplit(get(), sessionId) });
},
adoptThread: (sessionId, projectId) => {
const selection = { projectId, sessionId };
const projectOf = projectId ? bounded({ ...get().projectOf, [sessionId]: projectId }) : get().projectOf;
write(SELECTION_KEY, selection);
write(PROJECT_OF_KEY, projectOf);
- set({ selection, projectOf });
+ set({ selection, projectOf, ...withoutSplit(get(), sessionId) });
},
rememberProject: (sessionId, projectId) => {
const projectOf = bounded({ ...get().projectOf, [sessionId]: projectId });
@@ -246,7 +309,7 @@ export const useIdeThreadsStore = create<IdeThreadsState>((set, get) => ({
? { projectId: get().selection.projectId, sessionId: null }
: get().selection;
write(SELECTION_KEY, selection);
- set({ projectOf, seen, archived, order, selection });
+ set({ projectOf, seen, archived, order, selection, ...withoutSplit(get(), sessionId) });
},
archiveThread: (sessionId) => {
const { [sessionId]: _previous, ...rest } = get().archived;
@@ -259,7 +322,7 @@ export const useIdeThreadsStore = create<IdeThreadsState>((set, get) => ({
? { projectId: get().selection.projectId, sessionId: null }
: get().selection;
write(SELECTION_KEY, selection);
- set({ archived, order, selection });
+ set({ archived, order, selection, ...withoutSplit(get(), sessionId) });
},
restoreThread: (sessionId) => {
if (!(sessionId in get().archived)) return;
@@ -272,4 +335,42 @@ export const useIdeThreadsStore = create<IdeThreadsState>((set, get) => ({
write(ORDER_KEY, order);
set({ order });
},
+ placeColumn: (thread, index, replace = false) => {
+ const state = get();
+ // The main column's thread is already on screen.
+ if (thread.sessionId === state.selection.sessionId) return;
+ const columns = threadColumns(state.split, state.mainAt);
+ const from = columns.findIndex((column) => column?.sessionId === thread.sessionId);
+ let at = Math.max(0, Math.min(index, columns.length));
+ // A thread already in a column only moves; replacing is for a new one when every column is taken.
+ if (replace && from < 0) {
+ const slot = Math.min(at, columns.length - 1);
+ if (columns[slot] === null) {
+ get().openThread(thread.sessionId, thread.projectId);
+ return;
+ }
+ columns.splice(slot, 1, thread);
+ } else {
+ if (from >= 0) {
+ columns.splice(from, 1);
+ if (from < at) at -= 1;
+ } else if (columns.length >= MAX_THREAD_COLUMNS) {
+ return;
+ }
+ columns.splice(at, 0, thread);
+ }
+ const next = fromColumns(columns);
+ write(SPLIT_KEY, next);
+ set(next);
+ },
+ closeColumn: (sessionId) => {
+ set(withoutSplit(get(), sessionId));
+ },
+ closeMainColumn: () => {
+ const { split, mainAt } = get();
+ if (split.length === 0) return;
+ // The neighbour on the right moves in, else the one on the left.
+ const heir = split[mainAt] ?? split[mainAt - 1];
+ get().openThread(heir.sessionId, heir.projectId);
+ },
}));
diff --git a/dodaios/ui/web/frontend/src/views/AgenticIdeView.tsx b/dodaios/ui/web/frontend/src/views/AgenticIdeView.tsx
index dccc85d58e..d19f1d61d1 100644
--- a/dodaios/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/dodaios/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -31,7 +31,7 @@ import { useIdeProjectsStore } from "@/store/ideProjects";
import { useIdeSidePanelStore } from "@/store/ideSidePanel";
import { useIdeSkillsStore } from "@/store/ideSkills";
import { useIdeThreadsStore } from "@/store/ideThreads";
-import { ThreadView } from "@/components/agentic/threads/ThreadView";
+import { ThreadColumns } from "@/components/agentic/threads/ThreadColumns";
import { ThreadTerminalDrawer } from "@/components/agentic/threads/ThreadTerminalDrawer";
import { CodeEditorStage } from "@/components/agentic/editor/CodeEditorStage";
import { useCodeEditorStore } from "@/store/codeEditor";
@@ -587,7 +587,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
{/* The thread over its terminal drawer. The drawer stays mounted in the
grid too, so its shells keep running while the layout switches. */}
<div className={cn("h-full min-h-0 flex-col", threads ? "flex" : "hidden")}>
- {threads && <div className="min-h-0 flex-1"><ThreadView onScreen={onScreen && !editorShown} /></div>}
+ {threads && <div className="min-h-0 flex-1"><ThreadColumns onScreen={onScreen && !editorShown} /></div>}
<ThreadTerminalDrawer onScreen={onScreen && threads && !editorShown && !panelCoversGrid} />
</div>
{/* The grid stays mounted behind the threads: its terminals keep running