🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(fleet): re-sync running topics each time the Observation tab opens (#15922)
Arvin Xu69dedc4eeb9c
diff --git a/apps/server/src/routers/lambda/__tests__/integration/aiAgent/serverCallAgent.integration.test.ts b/apps/server/src/routers/lambda/__tests__/integration/aiAgent/serverCallAgent.integration.test.tsindex 0f4fd0dec6c..f28866c7076 100644--- a/apps/server/src/routers/lambda/__tests__/integration/aiAgent/serverCallAgent.integration.test.ts+++ b/apps/server/src/routers/lambda/__tests__/integration/aiAgent/serverCallAgent.integration.test.ts@@ -199,7 +199,12 @@ beforeEach(async () => {parentAgentId = insertedAgents[0].id;targetAgentId = insertedAgents[1].id;- mockResponsesCreate = vi.spyOn(OpenAI.Responses.prototype, 'create');+ // `create` is overloaded (streaming / non-streaming); its precise spy type+ // isn't assignable to the generic MockInstance fallback, so widen via unknown.+ mockResponsesCreate = vi.spyOn(+ OpenAI.Responses.prototype,+ 'create',+ ) as unknown as typeof mockResponsesCreate;});afterEach(async () => {diff --git a/locales/en-US/electron.json b/locales/en-US/electron.jsonindex a2db2676c76..0a4aab9d9e7 100644--- a/locales/en-US/electron.json+++ b/locales/en-US/electron.json@@ -3,18 +3,24 @@"fleet.allShown": "All running tasks are shown","fleet.backToHome": "Back to home","fleet.closeColumn": "Close column",+ "fleet.collapseReply": "Collapse","fleet.createTask": "Create task",+ "fleet.dragHint": "Drag to reorder","fleet.empty": "No tasks open","fleet.emptyDesc": "Pick a running task on the left, or use + to add a column.","fleet.noRunningTasks": "No running tasks","fleet.openInChat": "Open in chat",+ "fleet.pin": "Pin column","fleet.reply": "Reply",- "fleet.runningTasks": "Running Tasks",+ "fleet.rows.one": "Single row",+ "fleet.rows.two": "Two rows",+ "fleet.runningBoard": "Running Board","fleet.status.idle": "Idle","fleet.status.paused": "Paused","fleet.status.running": "Running","fleet.status.scheduled": "Scheduled","fleet.tooltip": "View all agents side by side",+ "fleet.unpin": "Unpin column","gateway.description": "Description","gateway.descriptionPlaceholder": "Optional","gateway.deviceName": "Device Name",diff --git a/locales/en-US/topic.json b/locales/en-US/topic.jsonindex d7164984fbd..cc68520fd95 100644--- a/locales/en-US/topic.json+++ b/locales/en-US/topic.json@@ -143,6 +143,7 @@"management.status.archived": "Archived","management.status.completed": "Completed","management.status.failed": "Failed",+ "management.status.idle": "Idle","management.status.paused": "Paused","management.status.running": "Running","management.status.waitingForHuman": "Awaiting input",diff --git a/locales/zh-CN/electron.json b/locales/zh-CN/electron.jsonindex ffc424ee73c..530daf4b02b 100644--- a/locales/zh-CN/electron.json+++ b/locales/zh-CN/electron.json@@ -3,18 +3,24 @@"fleet.allShown": "所有运行中的任务都已展示","fleet.backToHome": "返回首页","fleet.closeColumn": "关闭此列",+ "fleet.collapseReply": "收起","fleet.createTask": "创建任务",+ "fleet.dragHint": "拖动以调整位置","fleet.empty": "暂无打开的任务","fleet.emptyDesc": "从左侧选择一个运行中的任务,或点击 + 添加一列。","fleet.noRunningTasks": "暂无运行中的任务","fleet.openInChat": "在对话中打开",+ "fleet.pin": "固定此列","fleet.reply": "回复",- "fleet.runningTasks": "运行中的任务",+ "fleet.rows.one": "单排",+ "fleet.rows.two": "双排",+ "fleet.runningBoard": "运行看板","fleet.status.idle": "空闲","fleet.status.paused": "已暂停","fleet.status.running": "运行中","fleet.status.scheduled": "已排期","fleet.tooltip": "并排查看所有助手",+ "fleet.unpin": "取消固定","gateway.description": "描述","gateway.descriptionPlaceholder": "可选","gateway.deviceName": "设备名称",diff --git a/locales/zh-CN/topic.json b/locales/zh-CN/topic.jsonindex 9c8b0125140..f21c877d29f 100644--- a/locales/zh-CN/topic.json+++ b/locales/zh-CN/topic.json@@ -143,6 +143,7 @@"management.status.archived": "已归档","management.status.completed": "已完成","management.status.failed": "已失败",+ "management.status.idle": "空闲中","management.status.paused": "已暂停","management.status.running": "运行中","management.status.waitingForHuman": "等待响应",diff --git a/packages/locales/src/default/electron.ts b/packages/locales/src/default/electron.tsindex fed78176c37..695586f8a83 100644--- a/packages/locales/src/default/electron.ts+++ b/packages/locales/src/default/electron.ts@@ -36,16 +36,22 @@ export default {'fleet.allShown': 'All running tasks are shown','fleet.backToHome': 'Back to home','fleet.closeColumn': 'Close column',+ 'fleet.collapseReply': 'Collapse',+ 'fleet.dragHint': 'Drag to reorder','fleet.empty': 'No tasks open','fleet.emptyDesc': 'Pick a running task on the left, or use + to add a column.','fleet.noRunningTasks': 'No running tasks','fleet.openInChat': 'Open in chat',- 'fleet.runningTasks': 'Running Tasks',+ 'fleet.pin': 'Pin column',+ 'fleet.rows.one': 'Single row',+ 'fleet.rows.two': 'Two rows',+ 'fleet.runningBoard': 'Running Board','fleet.status.idle': 'Idle','fleet.status.paused': 'Paused','fleet.status.running': 'Running','fleet.status.scheduled': 'Scheduled','fleet.tooltip': 'View all agents side by side',+ 'fleet.unpin': 'Unpin column','notification.finishChatGeneration': 'AI message generation completed','tab.closeCurrentTab': 'Close Tab','tab.closeLeftTabs': 'Close Tabs to the Left',diff --git a/packages/locales/src/default/topic.ts b/packages/locales/src/default/topic.tsindex 6d58a5eebb4..386367fcb9e 100644--- a/packages/locales/src/default/topic.ts+++ b/packages/locales/src/default/topic.ts@@ -158,6 +158,7 @@ export default {'management.status.archived': 'Archived','management.status.completed': 'Completed','management.status.failed': 'Failed',+ 'management.status.idle': 'Idle','management.status.paused': 'Paused','management.status.running': 'Running','management.status.waitingForHuman': 'Awaiting input',diff --git a/src/features/AgentTopicManager/StatusDot.tsx b/src/features/AgentTopicManager/StatusDot.tsxindex f19ab864c93..27159adf3e0 100644--- a/src/features/AgentTopicManager/StatusDot.tsx+++ b/src/features/AgentTopicManager/StatusDot.tsx@@ -12,18 +12,21 @@ const STATUS_COLOR: Record<string, string> = {archived: cssVar.colorWarning,completed: cssVar.colorTextQuaternary,failed: cssVar.colorError,+ idle: cssVar.colorTextQuaternary,paused: cssVar.colorInfo,running: cssVar.colorWarning,waitingForHuman: cssVar.colorInfo,};interface StatusDotProps {- status: string;+ status: string | undefined;}-const StatusDot = memo<StatusDotProps>(({ status }) => {+const StatusDot = memo<StatusDotProps>(({ status: rawStatus }) => {const { t } = useTranslation('topic');const { isDarkMode } = useTheme();+ // No status (e.g. a topic that dropped out of the running set) reads as idle.+ const status = rawStatus || 'idle';const color = STATUS_COLOR[status] ?? cssVar.colorTextQuaternary;const labelKey = `management.status.${status}` as const;diff --git a/src/features/Conversation/ChatList/index.tsx b/src/features/Conversation/ChatList/index.tsxindex 9c1857bce7b..8b46d98f732 100644--- a/src/features/Conversation/ChatList/index.tsx+++ b/src/features/Conversation/ChatList/index.tsx@@ -6,11 +6,12 @@ import { memo, useCallback, useMemo } from 'react';import { useFetchAgentDocuments } from '@/hooks/useFetchAgentDocuments';import { useFetchTopicMemories } from '@/hooks/useFetchMemoryForTopic';import { useFetchNotebookDocuments } from '@/hooks/useFetchNotebookDocuments';+import { useAgentStore } from '@/store/agent';import { useChatStore } from '@/store/chat';import { operationSelectors } from '@/store/chat/selectors';import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';import { useUserStore } from '@/store/user';-import { settingsSelectors } from '@/store/user/selectors';+import { authSelectors, settingsSelectors } from '@/store/user/selectors';import WideScreenContainer from '../../WideScreenContainer';import SkeletonList from '../components/SkeletonList';@@ -110,6 +111,18 @@ const ChatList = memo<ChatListProps>(topicId: canShowAgentSignalReceipts ? context.topicId : undefined,});+ // Ensure this conversation's agent config (meta) is loaded into the agent+ // store, so message author titles resolve via useAgentMeta instead of+ // falling back to "Untitled Agent". Route-level layouts already init the+ // active agent, but secondary mounts never do — each Fleet column shows a+ // different agent, and the share page mounts an arbitrary author's agent;+ // without this they render "未命名助理".+ // Idempotent: SWR dedupes against any route-level init by the same key,+ // and is gated on isLogin (no fetch for anonymous share viewers).+ const isLogin = useUserStore(authSelectors.isLogin);+ const useFetchAgentConfig = useAgentStore((s) => s.useFetchAgentConfig);+ useFetchAgentConfig(isLogin, context.agentId);+// Fetch conversation context data when a conversation is visible (skip for share pages)useFetchAgentDocuments(isSharePage ? undefined : activeAgentId);useFetchNotebookDocuments(isSharePage ? undefined : context.topicId!);diff --git a/src/features/Fleet/AddColumnButton.tsx b/src/features/Fleet/AddColumnButton.tsxindex 2676d5f3389..1e054b0a0df 100644--- a/src/features/Fleet/AddColumnButton.tsx+++ b/src/features/Fleet/AddColumnButton.tsx@@ -18,12 +18,11 @@ const styles = createStaticStyles(({ css, cssVar }) => ({display: flex;flex: none;- align-items: flex-start;+ align-items: center;justify-content: center;width: 52px;height: 100%;- padding-block-start: 12px;color: ${cssVar.colorTextTertiary};@@ -35,12 +34,19 @@ const styles = createStaticStyles(({ css, cssVar }) => ({`,}));+interface AddColumnButtonProps {+ /** Splice the new column right after this key (a band's "+" adds to its row). */+ insertAfterKey?: string;+ /** Band index to drop the new column into (a band's "+" passes its own row). */+ row?: number;+}+/**- * Trailing "+" at the right edge of the board. Opens an agent picker; selecting- * an agent creates a fresh topic for it and opens it as a new column ready to- * receive messages.+ * Trailing "+" at the end of a band. Opens an agent picker; selecting an agent+ * creates a fresh topic for it and opens it as a new column ready to receive+ * messages. In multi-band mode each band carries its own, adding into that row.*/-const AddColumnButton = memo(() => {+const AddColumnButton = memo<AddColumnButtonProps>(({ insertAfterKey, row }) => {const { t } = useTranslation(['electron', 'topic']);const addColumn = useFleetStore((s) => s.addColumn);@@ -49,14 +55,18 @@ const AddColumnButton = memo(() => {const title = t('defaultTitle', { ns: 'topic' });const topicId = await topicService.createTopic({ messages: [], sessionId: agentId, title });const key = fleetColumnKey(agentId, topicId);- addColumn({ agentId, fallbackTitle: title, key, threadId: null, topicId });+ addColumn(+ { agentId, fallbackTitle: title, key, threadId: null, topicId },+ insertAfterKey,+ row,+ );requestAnimationFrame(() => {document.querySelector(`[data-fleet-col="${CSS.escape(key)}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'end' });});},- [addColumn, t],+ [addColumn, insertAfterKey, row, t],);return (diff --git a/src/features/Fleet/AgentColumn.tsx b/src/features/Fleet/AgentColumn.tsxindex 54ce3743b5e..36669bfecf8 100644--- a/src/features/Fleet/AgentColumn.tsx+++ b/src/features/Fleet/AgentColumn.tsx@@ -5,12 +5,15 @@ import { CSS } from '@dnd-kit/utilities';import { ActionIcon, Avatar, Button, DropdownMenu, Flexbox, Icon, Text } from '@lobehub/ui';import { createStaticStyles, cssVar, cx } from 'antd-style';import {+ ChevronDownIcon,FolderIcon,GitBranchIcon,GripVertical,MessageCirclePlus,MessageSquareIcon,MoreHorizontalIcon,+ MoveIcon,+ PinIcon,XIcon,} from 'lucide-react';import { memo, useCallback, useMemo, useState } from 'react';@@ -49,15 +52,26 @@ const styles = createStaticStyles(({ css, cssVar }) => ({height: 100%;border-inline-end: 1px solid ${cssVar.colorBorderSecondary};`,- dragging: css`- z-index: 2;+ dragPreview: css`+ cursor: grabbing;++ overflow: hidden;++ width: 100%;+ height: 100%;+ border-radius: 8px;- /* opaque while dragging so it doesn't show columns underneath */background: ${cssVar.colorBgContainer};box-shadow:inset 0 0 0 1px ${cssVar.colorBorder},${cssVar.boxShadowSecondary};`,+ dragPreviewBody: css`+ flex: 1;+ padding: 16px;+ color: ${cssVar.colorTextQuaternary};+ text-align: center;+ `,grip: css`cursor: grab;flex: none;@@ -84,6 +98,31 @@ const styles = createStaticStyles(({ css, cssVar }) => ({padding-inline: 12px;border-block-start: 1px solid ${cssVar.colorBorderSecondary};`,+ replyClose: css`+ pointer-events: none;++ position: absolute;+ z-index: 11;+ inset-block-end: 100%;+ inset-inline-start: 12px;++ /* sit just above the input's top edge */+ overflow: hidden;++ margin-block-end: 4px;+ border-radius: ${cssVar.borderRadius};++ /* opaque chip so the conversation behind never bleeds through the button */+ background: ${cssVar.colorBgContainer};++ button {+ pointer-events: auto;+ }+ `,+ replyOpen: css`+ position: relative;+ flex: none;+ `,resize: css`cursor: col-resize;@@ -150,6 +189,57 @@ const WorkingDirRow = memo<{ workingDirectory: string }>(({ workingDirectory })WorkingDirRow.displayName = 'FleetWorkingDirRow';+/**+ * Lightweight drag visual rendered into the DragOverlay portal — the column+ * header on a lifted card with a centered "moving" hint instead of the live+ * conversation, so dragging stays cheap and isn't clipped by a band's overflow.+ */+export const ColumnDragPreview = memo<{+ column: FleetColumn;+ status: ChatTopicStatus | undefined;+}>(({ column, status }) => {+ const { t } = useTranslation('electron');+ const meta = useAgentDisplayMeta(column.agentId);++ return (+ <Flexbox className={styles.dragPreview}>+ <Flexbox className={styles.header} gap={4}>+ <Flexbox horizontal align={'center'} gap={6}>+ <span className={styles.grip}>+ <GripVertical size={16} />+ </span>+ <Text ellipsis style={{ flex: 1, fontWeight: 600 }}>+ {column.fallbackTitle}+ </Text>+ </Flexbox>+ <Flexbox horizontal align={'center'} gap={6} paddingInline={'22px 0'}>+ <Avatar+ emojiScaleWithBackground+ avatar={meta?.avatar}+ background={meta?.backgroundColor}+ shape={'square'}+ size={16}+ />+ <Text ellipsis fontSize={12} style={{ flex: 1 }} type={'secondary'}>+ {meta?.title}+ </Text>+ <StatusDot status={status} />+ </Flexbox>+ {column.workingDirectory ? (+ <WorkingDirRow workingDirectory={column.workingDirectory} />+ ) : null}+ </Flexbox>+ {/* Centered hint so the lifted card reads as a column being moved, not loading */}+ <Flexbox align={'center'} className={styles.dragPreviewBody} gap={8} justify={'center'}>+ <Icon icon={MoveIcon} size={22} />+ <Text style={{ color: cssVar.colorTextTertiary, fontSize: 13 }}>{t('fleet.dragHint')}</Text>+ </Flexbox>+ </Flexbox>+ );+});++ColumnDragPreview.displayName = 'FleetColumnDragPreview';+interface AgentColumnProps {column: FleetColumn;status: ChatTopicStatus | undefined;@@ -164,6 +254,8 @@ const AgentColumn = memo<AgentColumnProps>(({ column, status }) => {const storedWidth = useFleetStore((s) => s.widths[column.key]);const setWidth = useFleetStore((s) => s.setWidth);const removeColumn = useFleetStore((s) => s.removeColumn);+ const togglePin = useFleetStore((s) => s.togglePin);+ const isPinned = useFleetStore((s) => s.pinnedKeys.includes(column.key));const [dragWidth, setDragWidth] = useState<number | null>(null);const [replyOpen, setReplyOpen] = useState(false);const width = dragWidth ?? storedWidth ?? DEFAULT_COLUMN_WIDTH;@@ -199,12 +291,16 @@ const AgentColumn = memo<AgentColumnProps>(({ column, status }) => {return (<Flexbox- className={cx(styles.column, isDragging && styles.dragging)}+ className={styles.column}data-fleet-col={column.key}ref={setNodeRef}style={{+ // While dragging, the source becomes an invisible gap slot — the moving+ // visual is the portaled DragOverlay (ColumnDragPreview), so it escapes+ // each band's overflow clipping and any z-index stacking.flex: `0 0 ${width}px`,- transform: CSS.Translate.toString(transform),+ opacity: isDragging ? 0 : undefined,+ transform: isDragging ? undefined : CSS.Translate.toString(transform),transition,width,}}@@ -219,6 +315,13 @@ const AgentColumn = memo<AgentColumnProps>(({ column, status }) => {{column.fallbackTitle}</Text><Flexbox horizontal align={'center'} gap={2} style={{ flex: 'none' }}>+ <ActionIcon+ active={isPinned}+ icon={PinIcon}+ size={'small'}+ title={isPinned ? t('fleet.unpin') : t('fleet.pin')}+ onClick={() => togglePin(column.key)}+ /><DropdownMenuplacement={'bottomRight'}items={[@@ -251,7 +354,7 @@ const AgentColumn = memo<AgentColumnProps>(({ column, status }) => {<Text ellipsis fontSize={12} style={{ flex: 1 }} type={'secondary'}>{meta?.title}</Text>- <StatusDot status={status ?? 'running'} />+ <StatusDot status={status} /></Flexbox>{column.workingDirectory ? (<WorkingDirRow workingDirectory={column.workingDirectory} />@@ -271,8 +374,20 @@ const AgentColumn = memo<AgentColumnProps>(({ column, status }) => {><ChatList disableActionsBar /><OpStatusTray />- {replyOpen ? (- <ChatInput skipScrollMarginWithList isConfigLoading={messages === undefined} />+ {messages === undefined ? null : replyOpen ? (+ <Flexbox className={styles.replyOpen}>+ <Flexbox horizontal className={styles.replyClose}>+ <Button+ icon={ChevronDownIcon}+ size={'small'}+ type={'text'}+ onClick={() => setReplyOpen(false)}+ >+ {t('fleet.collapseReply')}+ </Button>+ </Flexbox>+ <ChatInput isConfigLoading={false} />+ </Flexbox>) : (<Flexbox className={styles.replyBar}><Buttondiff --git a/src/features/Fleet/ColumnsBoard.tsx b/src/features/Fleet/ColumnsBoard.tsxindex 66e256778d7..a45a556eb41 100644--- a/src/features/Fleet/ColumnsBoard.tsx+++ b/src/features/Fleet/ColumnsBoard.tsx@@ -1,27 +1,49 @@'use client';import {+ closestCenter,DndContext,type DragEndEvent,+ DragOverlay,+ type DragStartEvent,type Modifier,PointerSensor,useSensor,useSensors,} from '@dnd-kit/core';-import { arrayMove, horizontalListSortingStrategy, SortableContext } from '@dnd-kit/sortable';+import {+ arrayMove,+ horizontalListSortingStrategy,+ rectSortingStrategy,+ SortableContext,+} from '@dnd-kit/sortable';import { Flexbox, Icon, Text } from '@lobehub/ui';import { createStaticStyles } from 'antd-style';import { LayersIcon } from 'lucide-react';-import { memo, useCallback } from 'react';+import { memo, useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import { type ChatTopicStatus } from '@/types/topic';import AddColumnButton from './AddColumnButton';-import AgentColumn from './AgentColumn';+import AgentColumn, { ColumnDragPreview } from './AgentColumn';import { useFleetStore } from './store';+import { type FleetColumn } from './types';++const styles = createStaticStyles(({ css, cssVar }) => ({+ band: css`+ overflow: auto hidden;+ display: flex;+ flex: 1 1 0;+ align-items: stretch;++ /* each band scrolls horizontally on its own; min-height:0 lets it shrink */+ min-height: 0;-const styles = createStaticStyles(({ css }) => ({+ &:not(:last-child) {+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};+ }+ `,board: css`overflow-x: auto;display: flex;@@ -30,11 +52,32 @@ const styles = createStaticStyles(({ css }) => ({height: 100%;`,+ boardVertical: css`+ display: flex;+ flex: 1;+ flex-direction: column;+ height: 100%;+ `,}));-// Reorder is horizontal-only — lock the drag transform to the X axis.+// Single-row reorder is horizontal-only — lock the drag transform to the X axis.+// Multi-band mode must allow vertical movement so a column can cross bands.const restrictToHorizontalAxis: Modifier = ({ transform }) => ({ ...transform, y: 0 });+/** Group columns into `rows` bands by their persisted per-column row assignment. */+const groupIntoBands = (+ columns: FleetColumn[],+ rows: number,+ rowByKey: Record<string, number>,+): FleetColumn[][] => {+ const bands: FleetColumn[][] = Array.from({ length: rows }, () => []);+ for (const column of columns) {+ const row = Math.min(rows - 1, Math.max(0, rowByKey[column.key] ?? 0));+ bands[row].push(column);+ }+ return bands;+};+interface ColumnsBoardProps {statusByColumnKey: Record<string, ChatTopicStatus | undefined>;}@@ -42,31 +85,69 @@ interface ColumnsBoardProps {const ColumnsBoard = memo<ColumnsBoardProps>(({ statusByColumnKey }) => {const { t } = useTranslation('electron');const columns = useFleetStore((s) => s.columns);- const reorderColumns = useFleetStore((s) => s.reorderColumns);+ const rows = useFleetStore((s) => s.rows);+ const rowByKey = useFleetStore((s) => s.rowByKey);const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));- const handleDragEnd = useCallback(- (event: DragEndEvent) => {- const { active, over } = event;- if (!over || active.id === over.id) return;- const keys = useFleetStore.getState().columns.map((c) => c.key);- const from = keys.indexOf(active.id as string);- const to = keys.indexOf(over.id as string);- if (from < 0 || to < 0) return;- reorderColumns(arrayMove(keys, from, to));- },- [reorderColumns],+ const [activeKey, setActiveKey] = useState<string | null>(null);++ const handleDragStart = useCallback((event: DragStartEvent) => {+ setActiveKey(event.active.id as string);+ }, []);++ const handleDragEnd = useCallback((event: DragEndEvent) => {+ setActiveKey(null);+ const { active, over } = event;+ if (!over || active.id === over.id) return;+ const activeId = active.id as string;+ const overId = over.id as string;+ const state = useFleetStore.getState();+ // Multi-row: assign the dragged column to the dropped-on column's band and+ // splice it at that slot. Only this column moves, so other bands never+ // reflow — a cross-row drag inserts in place instead of wrapping the board.+ if (state.rows > 1) {+ state.moveColumn(activeId, overId, state.rowByKey[overId] ?? 0);+ return;+ }+ const keys = state.columns.map((c) => c.key);+ const from = keys.indexOf(activeId);+ const to = keys.indexOf(overId);+ if (from < 0 || to < 0) return;+ state.reorderColumns(arrayMove(keys, from, to));+ }, []);++ const handleDragCancel = useCallback(() => setActiveKey(null), []);++ const activeColumn = activeKey ? columns.find((c) => c.key === activeKey) : null;++ const isMultiBand = rows > 1 && columns.length > 0;++ const bands = useMemo(+ () => (isMultiBand ? groupIntoBands(columns, rows, rowByKey) : null),+ [isMultiBand, columns, rows, rowByKey],);- return (- <DndContext modifiers={[restrictToHorizontalAxis]} sensors={sensors} onDragEnd={handleDragEnd}>+ const renderColumn = (column: FleetColumn) => (+ <AgentColumn column={column} key={column.key} status={statusByColumnKey[column.key]} />+ );++ let content: React.ReactNode;+ if (bands) {+ content = (+ <div className={styles.boardVertical}>+ {bands.map((band, bandIndex) => (+ <div className={styles.band} key={`band-${bandIndex}`}>+ {band.map(renderColumn)}+ <AddColumnButton insertAfterKey={band.at(-1)?.key} row={bandIndex} />+ </div>+ ))}+ </div>+ );+ } else {+ content = (<div className={styles.board}>- <SortableContext items={columns.map((c) => c.key)} strategy={horizontalListSortingStrategy}>- {columns.map((column) => (- <AgentColumn column={column} key={column.key} status={statusByColumnKey[column.key]} />- ))}- </SortableContext>+ {columns.map(renderColumn)}{columns.length === 0 ? (<Flexbox align={'center'} flex={1} gap={8} justify={'center'}><Icon@@ -82,6 +163,29 @@ const ColumnsBoard = memo<ColumnsBoardProps>(({ statusByColumnKey }) => {) : null}<AddColumnButton /></div>+ );+ }++ return (+ <DndContext+ collisionDetection={isMultiBand ? closestCenter : undefined}+ modifiers={isMultiBand ? undefined : [restrictToHorizontalAxis]}+ sensors={sensors}+ onDragCancel={handleDragCancel}+ onDragEnd={handleDragEnd}+ onDragStart={handleDragStart}+ >+ <SortableContext+ items={columns.map((c) => c.key)}+ strategy={isMultiBand ? rectSortingStrategy : horizontalListSortingStrategy}+ >+ {content}+ </SortableContext>+ <DragOverlay>+ {activeColumn ? (+ <ColumnDragPreview column={activeColumn} status={statusByColumnKey[activeColumn.key]} />+ ) : null}+ </DragOverlay></DndContext>);});diff --git a/src/features/Fleet/RowsSwitcher.tsx b/src/features/Fleet/RowsSwitcher.tsxnew file mode 100644index 00000000000..f7d80a1e336--- /dev/null+++ b/src/features/Fleet/RowsSwitcher.tsx@@ -0,0 +1,44 @@+'use client';++import { ActionIcon, Flexbox } from '@lobehub/ui';+import { RectangleHorizontalIcon, Rows2Icon } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { useFleetStore } from './store';+import { type FleetRows } from './types';++const OPTIONS: { icon: typeof Rows2Icon; titleKey: string; value: FleetRows }[] = [+ { icon: RectangleHorizontalIcon, titleKey: 'fleet.rows.one', value: 1 },+ { icon: Rows2Icon, titleKey: 'fleet.rows.two', value: 2 },+];++/**+ * Compact 1 / 2 / 3 toggle for how many horizontal bands the board stacks+ * columns into. Lives in the sidebar header; the choice is persisted by the+ * store.+ */+const RowsSwitcher = memo(() => {+ const { t } = useTranslation('electron');+ const rows = useFleetStore((s) => s.rows);+ const setRows = useFleetStore((s) => s.setRows);++ return (+ <Flexbox horizontal align={'center'} gap={2}>+ {OPTIONS.map(({ value, icon, titleKey }) => (+ <ActionIcon+ active={rows === value}+ icon={icon}+ key={value}+ size={'small'}+ title={t(titleKey as 'fleet.rows.one')}+ onClick={() => setRows(value)}+ />+ ))}+ </Flexbox>+ );+});++RowsSwitcher.displayName = 'FleetRowsSwitcher';++export default RowsSwitcher;diff --git a/src/features/Fleet/RunningTaskSidebar.tsx b/src/features/Fleet/RunningTaskSidebar.tsxindex 30b605a9c30..9451bd6585d 100644--- a/src/features/Fleet/RunningTaskSidebar.tsx+++ b/src/features/Fleet/RunningTaskSidebar.tsx@@ -1,27 +1,28 @@'use client';-import { ActionIcon, Avatar, Flexbox, Text } from '@lobehub/ui';-import { createStaticStyles } from 'antd-style';+import { formatElapsedClockTime } from '@lobechat/utils';+import { Avatar, Button, Flexbox, Tag, Text } from '@lobehub/ui';+import { createStaticStyles, cssVar, useTheme } from 'antd-style';import { PlusIcon } from 'lucide-react';-import { memo, useCallback } from 'react';+import { memo, useCallback, useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';+import RingLoadingIcon from '@/components/RingLoading';import { createTaskModal } from '@/features/AgentTasks/CreateTaskModal';import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';import StatusDot from '@/features/AgentTopicManager/StatusDot';import { NavPanelPortal } from '@/features/NavPanel';import SideBarHeaderLayout from '@/features/NavPanel/SideBarHeaderLayout';import SideBarLayout from '@/features/NavPanel/SideBarLayout';+import { useChatStore } from '@/store/chat';+import { operationSelectors } from '@/store/chat/selectors';import { type ChatTopicStatus } from '@/types/topic';+import RowsSwitcher from './RowsSwitcher';import { useFleetStore } from './store';import { type FleetColumn } from './types';const styles = createStaticStyles(({ css, cssVar }) => ({- count: css`- font-size: 13px;- color: ${cssVar.colorTextTertiary};- `,empty: css`padding-block: 24px;padding-inline: 16px;@@ -41,6 +42,63 @@ const styles = createStaticStyles(({ css, cssVar }) => ({`,}));+/** Live elapsed clock since `startedAt`, re-rendering once per second. */+const useElapsedClock = (startedAt: number | undefined) => {+ const [now, setNow] = useState(() => Date.now());+ useEffect(() => {+ if (!startedAt) return;+ setNow(Date.now());+ const id = setInterval(() => setNow(Date.now()), 1000);+ return () => clearInterval(id);+ }, [startedAt]);+ return startedAt ? formatElapsedClockTime(now - startedAt) : null;+};++interface RunningStatusProps {+ agentId: string;+ status: ChatTopicStatus | undefined;+ topicId: string | null;+}++/**+ * Running indicator: the same spinning ring used across topic rows, paired with+ * a live elapsed-time readout (replaces the static "running" label so the row+ * conveys how long the task has been working). The elapsed baseline is the+ * running operation's start time (same selector the sidebar topic row uses),+ * not the topic's createdAt. Falls back to the shared StatusDot when no running+ * operation is loaded for this context.+ */+const RunningStatus = memo<RunningStatusProps>(({ agentId, status, topicId }) => {+ const { isDarkMode } = useTheme();+ const startedAt = useChatStore(+ operationSelectors.getAgentRuntimeStartTimeByContext({ agentId, topicId }),+ );+ const elapsed = useElapsedClock(startedAt);++ if (!elapsed) return <StatusDot status={status} />;++ const ringColor = isDarkMode+ ? cssVar.colorWarningBorder+ : `color-mix(in srgb, ${cssVar.colorWarning} 45%, transparent)`;++ return (+ <Flexbox horizontal align={'center'} gap={6} style={{ flex: 'none' }}>+ <RingLoadingIcon ringColor={ringColor} size={10} style={{ color: cssVar.colorWarning }} />+ <span+ style={{+ color: cssVar.colorTextSecondary,+ fontSize: 11,+ fontVariantNumeric: 'tabular-nums',+ }}+ >+ {elapsed}+ </span>+ </Flexbox>+ );+});++RunningStatus.displayName = 'FleetRunningStatus';+interface SidebarTaskItemProps {column: FleetColumn;onActivate: (column: FleetColumn) => void;@@ -76,7 +134,7 @@ const SidebarTaskItem = memo<SidebarTaskItemProps>(({ column, status, onActivate<Text ellipsis fontSize={12} style={{ flex: 1 }} type={'secondary'}>{meta?.title}</Text>- <StatusDot status={status ?? 'running'} />+ <RunningStatus agentId={column.agentId} status={status} topicId={column.topicId} /></Flexbox></Flexbox></Flexbox>@@ -93,9 +151,9 @@ interface RunningTaskSidebarProps {/*** Fleet's left navigation. Portals into the global NavPanel so the running-topic* list *replaces* the standard nav rail while the Fleet view is active. The- * top bar (`SideBarHeaderLayout`) carries the back-to-home action; the body- * offers a "create task" entry plus the running-topic list. Clicking an item- * opens (or re-opens) its column on the board.+ * top bar (`SideBarHeaderLayout`) carries the back-to-home action and open-column+ * count; the body leads with a "create task" action above the running-topic+ * list. Clicking an item opens (or re-opens) its column.*/const RunningTaskSidebar = memo<RunningTaskSidebarProps>(({ columns, statusByColumnKey }) => {const { t } = useTranslation('electron');@@ -120,37 +178,36 @@ const RunningTaskSidebar = memo<RunningTaskSidebarProps>(({ columns, statusByColconst header = (<SideBarHeaderLayoutbackTo={'/'}- left={t('fleet.runningTasks')}+ right={<RowsSwitcher />}showTogglePanelButton={false}- right={- <Flexbox horizontal align={'center'} gap={6}>- <ActionIcon- icon={PlusIcon}- size={'small'}- title={t('fleet.createTask')}- onClick={handleCreateTask}- />- <span className={styles.count}>{columns.length}</span>+ left={+ <Flexbox horizontal align={'center'} gap={8}>+ {t('fleet.runningBoard')}+ {columns.length > 0 && <Tag style={{ margin: 0 }}>{columns.length}</Tag>}</Flexbox>}/>);- const body =- columns.length === 0 ? (- <div className={styles.empty}>{t('fleet.noRunningTasks')}</div>- ) : (- <Flexbox gap={2} paddingBlock={'4px 12px'} paddingInline={8}>- {columns.map((column) => (+ const body = (+ <Flexbox gap={2} paddingBlock={'8px 12px'} paddingInline={8}>+ <Button block icon={PlusIcon} onClick={handleCreateTask}>+ {t('fleet.createTask')}+ </Button>+ {columns.length === 0 ? (+ <div className={styles.empty}>{t('fleet.noRunningTasks')}</div>+ ) : (+ columns.map((column) => (<SidebarTaskItemcolumn={column}key={column.key}status={statusByColumnKey[column.key]}onActivate={handleActivate}/>- ))}- </Flexbox>- );+ ))+ )}+ </Flexbox>+ );return (<NavPanelPortal navKey={'fleet'}>diff --git a/src/features/Fleet/index.tsx b/src/features/Fleet/index.tsxindex f1002751d96..da3d3de2df3 100644--- a/src/features/Fleet/index.tsx+++ b/src/features/Fleet/index.tsx@@ -22,14 +22,16 @@ const FleetView = memo(() => {useFetchAgentList();const { columns, isInit, statusByColumnKey } = useRunningTopics();- const seedColumns = useFleetStore((s) => s.seedColumns);+ const syncRunningColumns = useFleetStore((s) => s.syncRunningColumns);- // Default: show all currently-running topics, one column each. Seeds once- // per app load (the store re-seeds on reload since columns aren't persisted).+ // Reconcile the live running set into the board whenever it changes (initial+ // load, focus refetch, a topic starting/stopping). The store appends only —+ // new running topics pop in, columns you've pinned or closed are untouched,+ // and a column you closed while it's still running won't immediately re-add.useEffect(() => {- if (isInit) seedColumns(columns);- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [isInit]);+ if (!isInit) return;+ syncRunningColumns(columns);+ }, [isInit, columns, syncRunningColumns]);return (<Flexbox flex={1} height={'100%'} style={{ overflow: 'hidden' }} width={'100%'}>diff --git a/src/features/Fleet/store.test.ts b/src/features/Fleet/store.test.tsindex 391b1a15f3e..83aef489b39 100644--- a/src/features/Fleet/store.test.ts+++ b/src/features/Fleet/store.test.ts@@ -12,22 +12,11 @@ const col = (key: string): FleetColumn => ({});beforeEach(() => {- useFleetStore.setState({ columns: [], seeded: false, widths: {} });+ useFleetStore.setState({ columns: [], dismissedKeys: [], rowByKey: {}, rows: 1, widths: {} });localStorage.clear();});describe('fleet store', () => {- it('seedColumns seeds once, then no-ops', () => {- const { seedColumns } = useFleetStore.getState();- seedColumns([col('a'), col('b')]);- expect(useFleetStore.getState().columns.map((c) => c.key)).toEqual(['a', 'b']);- expect(useFleetStore.getState().seeded).toBe(true);-- // second seed is ignored — user customisations within a session win- seedColumns([col('c')]);- expect(useFleetStore.getState().columns.map((c) => c.key)).toEqual(['a', 'b']);- });-it('addColumn appends and dedupes by key', () => {const s = useFleetStore.getState();s.addColumn(col('a'));@@ -42,6 +31,50 @@ describe('fleet store', () => {expect(useFleetStore.getState().columns.map((c) => c.key)).toEqual(['a', 'c']);});+ it('removeColumn marks the key dismissed so it is not auto re-added', () => {+ useFleetStore.setState({ columns: [col('a')] });+ useFleetStore.getState().removeColumn('a');+ expect(useFleetStore.getState().dismissedKeys).toEqual(['a']);+ });++ it('addColumn clears a prior dismissal so a re-pinned column sticks', () => {+ useFleetStore.setState({ columns: [], dismissedKeys: ['a'] });+ useFleetStore.getState().addColumn(col('a'));+ expect(useFleetStore.getState().columns.map((c) => c.key)).toEqual(['a']);+ expect(useFleetStore.getState().dismissedKeys).toEqual([]);+ });++ describe('syncRunningColumns', () => {+ it('appends newly-running columns the board does not have yet', () => {+ useFleetStore.setState({ columns: [col('a')] });+ useFleetStore.getState().syncRunningColumns([col('a'), col('b')]);+ expect(useFleetStore.getState().columns.map((c) => c.key)).toEqual(['a', 'b']);+ });++ it('never reorders or removes existing columns (manual pins preserved)', () => {+ useFleetStore.setState({ columns: [col('manual'), col('a')] });+ // 'manual' is not in the running set, 'b' is new.+ useFleetStore.getState().syncRunningColumns([col('a'), col('b')]);+ expect(useFleetStore.getState().columns.map((c) => c.key)).toEqual(['manual', 'a', 'b']);+ });++ it('does not re-add a column the user closed while it is still running', () => {+ useFleetStore.setState({ columns: [col('a')] });+ useFleetStore.getState().removeColumn('a'); // close while running+ useFleetStore.getState().syncRunningColumns([col('a')]); // still running+ expect(useFleetStore.getState().columns).toEqual([]);+ expect(useFleetStore.getState().dismissedKeys).toEqual(['a']);+ });++ it('clears dismissal once the topic stops, so a fresh run re-surfaces it', () => {+ useFleetStore.setState({ columns: [], dismissedKeys: ['a'] });+ useFleetStore.getState().syncRunningColumns([]); // 'a' no longer running+ expect(useFleetStore.getState().dismissedKeys).toEqual([]);+ useFleetStore.getState().syncRunningColumns([col('a')]); // runs again+ expect(useFleetStore.getState().columns.map((c) => c.key)).toEqual(['a']);+ });+ });+it('reorderColumns applies the given key order (drag-and-drop result)', () => {useFleetStore.setState({ columns: [col('a'), col('b'), col('c')] });useFleetStore.getState().reorderColumns(['c', 'a', 'b']);@@ -54,6 +87,42 @@ describe('fleet store', () => {expect(useFleetStore.getState().columns.map((c) => c.key)).toEqual(['b', 'a', 'c']);});+ describe('multi-row bands', () => {+ it('setRows spreads columns evenly across the new band count', () => {+ useFleetStore.setState({ columns: [col('a'), col('b'), col('c'), col('d')] });+ useFleetStore.getState().setRows(2);+ expect(useFleetStore.getState().rows).toBe(2);+ expect(useFleetStore.getState().rowByKey).toEqual({ a: 0, b: 0, c: 1, d: 1 });+ });++ it('setRows gives the leading band the spare when columns are odd', () => {+ useFleetStore.setState({ columns: [col('a'), col('b'), col('c')] });+ useFleetStore.getState().setRows(2); // 3 cols / 2 rows → 2,1+ expect(useFleetStore.getState().rowByKey).toEqual({ a: 0, b: 0, c: 1 });+ });++ it('moveColumn re-bands only the dragged column — other bands never reflow', () => {+ useFleetStore.setState({+ columns: [col('a'), col('b'), col('c'), col('d')],+ rowByKey: { a: 0, b: 0, c: 1, d: 1 },+ rows: 2,+ });+ // Drag 'a' (row 0) onto 'c' (row 1): 'a' joins row 1 at c's slot.+ useFleetStore.getState().moveColumn('a', 'c', 1);+ const s = useFleetStore.getState();+ // c and d stay in row 1 (no wrap); only 'a' changed band.+ expect(s.rowByKey).toEqual({ a: 1, b: 0, c: 1, d: 1 });+ // Flat order: 'a' spliced to c's index → b, a, c, d.+ expect(s.columns.map((c) => c.key)).toEqual(['b', 'a', 'c', 'd']);+ });++ it('moveColumn clamps the target band to the current row count', () => {+ useFleetStore.setState({ columns: [col('a'), col('b')], rowByKey: { a: 0, b: 1 }, rows: 2 });+ useFleetStore.getState().moveColumn('a', null, 5); // out-of-range row+ expect(useFleetStore.getState().rowByKey.a).toBe(1);+ });+ });+// localStorage persistence is covered end-to-end (reload restores width);// here we only assert the in-state width bookkeeping.it('setWidth records a per-column width', () => {diff --git a/src/features/Fleet/store.ts b/src/features/Fleet/store.tsindex 9ff3b2acce8..5b0846729ab 100644--- a/src/features/Fleet/store.ts+++ b/src/features/Fleet/store.ts@@ -1,33 +1,127 @@import { create } from 'zustand';import { persist } from 'zustand/middleware';-import { type FleetColumn } from './types';+import { type FleetColumn, type FleetRows } from './types';++const clampRow = (row: number, rows: number) => Math.min(rows - 1, Math.max(0, row));++/** Even contiguous spread of keys across `rows` bands (first bands get the spare). */+const distributeRows = (keys: string[], rows: number): Record<string, number> => {+ const base = Math.floor(keys.length / rows);+ const remainder = keys.length % rows;+ const rowByKey: Record<string, number> = {};+ let cursor = 0;+ for (let band = 0; band < rows; band += 1) {+ const size = base + (band < remainder ? 1 : 0);+ for (let i = 0; i < size; i += 1) rowByKey[keys[cursor++]] = band;+ }+ return rowByKey;+};interface FleetState {- /** Append a column to the right; no-op if its key is already open. */- addColumn: (column: FleetColumn) => void;- /** Ordered list of open columns. Ephemeral — re-seeded from running tasks per load. */+ /**+ * Pin a column to the board (trailing "+" or a sidebar click). Dedupes by+ * key and clears any prior dismissal so a re-pinned topic sticks. Pass+ * `afterKey` to splice the new column right after an existing one (used by a+ * band's "+" so the column lands in that row instead of at the very end), and+ * `row` to assign its band (defaults to the least-full row for balance).+ */+ addColumn: (column: FleetColumn, afterKey?: string, row?: number) => void;+ /**+ * Ordered list of open columns. Persisted: manual pins and auto-added running+ * topics both live here and stay until the user closes them.+ */columns: FleetColumn[];+ /**+ * Running keys the user explicitly closed. Suppresses auto re-add while the+ * topic is still running; cleared once it stops (see syncRunningColumns).+ */+ dismissedKeys: string[];+ /**+ * Move a column to row `toRow` at the position of `overKey` (the multi-row+ * drag result): set its band assignment and splice it next to `overKey` in+ * the flat order. Every other column's band stays put, so a cross-row drag+ * inserts at the drop spot without reflowing/wrapping the rest of the board.+ */+ moveColumn: (activeKey: string, overKey: string | null, toRow: number) => void;+ /** Keys the user explicitly pinned — a deliberate "keep this column" marker. */+ pinnedKeys: string[];removeColumn: (key: string) => void;- /** Reorder columns to match the given key order (from drag-and-drop). */+ /** Reorder columns to match the given key order (from single-row drag). */reorderColumns: (orderedKeys: string[]) => void;- /** Seed the default column set once per app load. No-op after the first seed. */- seedColumns: (columns: FleetColumn[]) => void;- seeded: boolean;+ /**+ * Per-column band assignment (which row a column lives in). Drives multi-row+ * grouping; persisted so the arrangement survives reloads.+ */+ rowByKey: Record<string, number>;+ /**+ * How many horizontal bands (rows) the board is split into. 1 = the classic+ * single-row layout; 2/3 stack columns into vertical tiers, each an+ * independently horizontal-scrolling band that splits the height evenly.+ */+ rows: FleetRows;+ setRows: (rows: FleetRows) => void;setWidth: (key: string, width: number) => void;+ /**+ * Reconcile the live running set into the board: append any running topic+ * that isn't already shown and wasn't dismissed while running. Never removes+ * or reorders existing columns, so manual pins and ordering are preserved.+ */+ syncRunningColumns: (running: FleetColumn[]) => void;+ /** Toggle a column's pinned state. */+ togglePin: (key: string) => void;/** Per-column widths, persisted so each column remembers its size. */widths: Record<string, number>;}export const useFleetStore = create<FleetState>()(persist(- (set, get) => ({- addColumn: (column) => {- if (get().columns.some((c) => c.key === column.key)) return;- set((s) => ({ columns: [...s.columns, column] }));- },+ (set) => ({+ addColumn: (column, afterKey, row) =>+ set((s) => {+ const dismissedKeys = s.dismissedKeys.filter((k) => k !== column.key);+ if (s.columns.some((c) => c.key === column.key)) return { dismissedKeys };+ // Assign a band: the caller's row (a band's "+"), else the least-full+ // row so auto-added running topics spread out instead of piling up.+ const counts = Array.from({ length: s.rows }, () => 0);+ for (const c of s.columns) counts[clampRow(s.rowByKey[c.key] ?? 0, s.rows)] += 1;+ const targetRow =+ row === undefined ? counts.indexOf(Math.min(...counts)) : clampRow(row, s.rows);+ const rowByKey = { ...s.rowByKey, [column.key]: targetRow };+ const at = afterKey ? s.columns.findIndex((c) => c.key === afterKey) : -1;+ if (at < 0) return { columns: [...s.columns, column], dismissedKeys, rowByKey };+ const columns = [...s.columns];+ columns.splice(at + 1, 0, column);+ return { columns, dismissedKeys, rowByKey };+ }),columns: [],- removeColumn: (key) => set((s) => ({ columns: s.columns.filter((c) => c.key !== key) })),+ dismissedKeys: [],+ moveColumn: (activeKey, overKey, toRow) =>+ set((s) => {+ const rowByKey = { ...s.rowByKey, [activeKey]: clampRow(toRow, s.rows) };+ if (!overKey || overKey === activeKey) return { rowByKey };+ const from = s.columns.findIndex((c) => c.key === activeKey);+ if (from < 0) return { rowByKey };+ const columns = [...s.columns];+ const [moved] = columns.splice(from, 1);+ // Re-find the target after removal so the splice lands at over's slot.+ const to = columns.findIndex((c) => c.key === overKey);+ columns.splice(to < 0 ? columns.length : to, 0, moved);+ return { columns, rowByKey };+ }),+ pinnedKeys: [],+ removeColumn: (key) =>+ set((s) => {+ const { [key]: _removed, ...rowByKey } = s.rowByKey;+ return {+ columns: s.columns.filter((c) => c.key !== key),+ dismissedKeys: s.dismissedKeys.includes(key)+ ? s.dismissedKeys+ : [...s.dismissedKeys, key],+ pinnedKeys: s.pinnedKeys.filter((k) => k !== key),+ rowByKey,+ };+ }),reorderColumns: (orderedKeys) =>set((s) => {const byKey = new Map(s.columns.map((c) => [c.key, c]));@@ -39,19 +133,65 @@ export const useFleetStore = create<FleetState>()(for (const c of s.columns) if (!seen.has(c.key)) next.push(c);return { columns: next };}),- seedColumns: (columns) => {- if (get().seeded) return;- set({ columns, seeded: true });- },- seeded: false,+ rowByKey: {},+ rows: 1,+ // Changing the band count is a deliberate relayout — re-spread all columns+ // evenly across the new row count (preserving flat order).+ setRows: (rows) =>+ set((s) => ({+ rowByKey: distributeRows(+ s.columns.map((c) => c.key),+ rows,+ ),+ rows,+ })),setWidth: (key, width) => set((s) => ({ widths: { ...s.widths, [key]: width } })),+ togglePin: (key) =>+ set((s) => ({+ pinnedKeys: s.pinnedKeys.includes(key)+ ? s.pinnedKeys.filter((k) => k !== key)+ : [...s.pinnedKeys, key],+ })),+ syncRunningColumns: (running) =>+ set((s) => {+ const runningKeys = new Set(running.map((c) => c.key));+ // A dismissal only holds while the topic keeps running; once it stops+ // we drop it so a fresh run re-surfaces the column.+ const dismissedKeys = s.dismissedKeys.filter((k) => runningKeys.has(k));+ const dismissed = new Set(dismissedKeys);+ const existing = new Set(s.columns.map((c) => c.key));+ const additions = running.filter((c) => !existing.has(c.key) && !dismissed.has(c.key));+ const dismissedChanged = dismissedKeys.length !== s.dismissedKeys.length;+ if (additions.length === 0 && !dismissedChanged) return {};+ // Spread each new topic into the least-full band so auto-adds balance.+ const counts = Array.from({ length: s.rows }, () => 0);+ for (const c of s.columns) counts[clampRow(s.rowByKey[c.key] ?? 0, s.rows)] += 1;+ const rowByKey = { ...s.rowByKey };+ for (const c of additions) {+ const band = counts.indexOf(Math.min(...counts));+ rowByKey[c.key] = band;+ counts[band] += 1;+ }+ return {+ columns: additions.length > 0 ? [...s.columns, ...additions] : s.columns,+ dismissedKeys: dismissedChanged ? dismissedKeys : s.dismissedKeys,+ rowByKey: additions.length > 0 ? rowByKey : s.rowByKey,+ };+ }),widths: {},}),{- // Only widths persist across reloads; the column set re-seeds from- // the live running-task list each time the view loads.+ // Columns, dismissals, and widths all persist so the board (manual pins ++ // running topics you've kept) and each column's size survive reloads.name: 'LOBE_FLEET_VIEW',- partialize: (s) => ({ widths: s.widths }),+ partialize: (s) => ({+ columns: s.columns,+ dismissedKeys: s.dismissedKeys,+ pinnedKeys: s.pinnedKeys,+ rowByKey: s.rowByKey,+ rows: s.rows,+ widths: s.widths,+ }),},),);diff --git a/src/features/Fleet/types.ts b/src/features/Fleet/types.tsindex 38c75e70382..6dfb5e331ca 100644--- a/src/features/Fleet/types.ts+++ b/src/features/Fleet/types.ts@@ -18,6 +18,9 @@ export interface FleetColumn {workingDirectory?: string | null;}+/** Number of horizontal bands the board stacks columns into (vertical tiers). */+export type FleetRows = 1 | 2;+/** Stable, content-derived key so a given agent+topic always maps to one column. */export const fleetColumnKey = (agentId: string, topicId: string | null | undefined) =>`${agentId}::${topicId ?? 'default'}`;diff --git a/src/features/Fleet/useRunningTopics.ts b/src/features/Fleet/useRunningTopics.tsindex e51cbbe7faf..fb5a052214a 100644--- a/src/features/Fleet/useRunningTopics.ts+++ b/src/features/Fleet/useRunningTopics.ts@@ -1,6 +1,7 @@import { useMemo } from 'react';import { useClientDataSWR } from '@/libs/swr';+import { fleetKeys } from '@/libs/swr/keys';import { topicService } from '@/services/topic';import { type ChatTopic, type ChatTopicStatus } from '@/types/topic';@@ -32,8 +33,13 @@ const toColumn = (topic: RunningTopic): FleetColumn | null => {* (sidebar / column badge).*/export const useRunningTopics = () => {- const { data, isLoading } = useClientDataSWR('fleet-running-topics', () =>- topicService.queryTopics({ statuses: RUNNING_STATUSES }),+ const { data, isLoading } = useClientDataSWR(+ fleetKeys.runningTopics(),+ () => topicService.queryTopics({ statuses: RUNNING_STATUSES }),+ // The board is a live overview — refetch on focus almost immediately+ // (default throttle is 5min) so newly-running topics show up the instant+ // the user looks at it.+ { focusThrottleInterval: 1000 },);const running = useMemo(() => (data ?? []) as RunningTopic[], [data]);diff --git a/src/libs/swr/keys.ts b/src/libs/swr/keys.tsindex b244623a21c..f039bb6b2b7 100644--- a/src/libs/swr/keys.ts+++ b/src/libs/swr/keys.ts@@ -78,6 +78,12 @@ export const topicKeys = {]),};+// ---- fleet (Observation Mode board) -------------------------------------+export const fleetKeys = {+ /** Account-wide set of actively-running topics powering the Observation board. */+ runningTopics: def('fleet:runningTopics', () => ['fleet:runningTopics']),+};+// ---- agent --------------------------------------------------------------export const agentKeys = {/** Sidebar agent list. */@@ -822,6 +828,7 @@ export const swrKeys = {eval: evalKeys,favorite: favoriteKeys,file: fileKeys,+ fleet: fleetKeys,fork: forkKeys,gateway: gatewayKeys,global: globalKeys,