Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Move chat history to either side of the conversation (#7294)
Abraham68a0e8870c6e
diff --git a/.changeset/chat-history-side.md b/.changeset/chat-history-side.mdnew file mode 100644index 000000000..e427037fb--- /dev/null+++ b/.changeset/chat-history-side.md@@ -0,0 +1,5 @@+---+'@inkeep/open-knowledge': patch+---++Move docked chat history to either side of the conversation: right-click an empty part of the Agents tab strip, or search the command palette. The Chat history button moves to the same side, and the desktop app keeps the choice for every project.diff --git a/docs/content/features/editor.mdx b/docs/content/features/editor.mdxindex d67baaa80..92422d7b0 100644--- a/docs/content/features/editor.mdx+++ b/docs/content/features/editor.mdx@@ -201,7 +201,7 @@ The Agents panel keeps its own open/closed memory: on the web it is remembered iThe Agents panel's **Chat history** button opens every conversation the project has, live and closed alike, in one list. Type in its search box to filter by conversation title; the rows group into **Today** and **Older** by the local date of their last activity, newest first. Selecting a row activates that conversation's tab, and renaming or deleting a conversation works from the row's own controls, with deletion still requiring you to close an open archived chat's tab first.-Which presentation you get when opening history follows the width of the chat pane rather than the window. A wide pane docks history beside the transcript: the tab strip stays visible and usable, and the list stays open after you pick a conversation, so you close it with `Esc` or by clicking **Chat history** again. If you narrow the pane while history is docked, history closes first so the active chat remains open. Opening history in a narrow pane covers the whole chat area instead, including the tab strip, which is inert until you leave history; widening the pane while history is open moves it into the docked position without closing it. The cover list closes as soon as you pick a conversation, and a **Back** button in its header dismisses it, as does `Esc`.+Which presentation you get when opening history follows the width of the chat pane rather than the window. A wide pane docks history beside the transcript, on the right unless you move it: right-click an empty part of the Agents tab strip and choose **Move chat history to the left** (or **to the right**), or search the command palette for the same command, and the **Chat history** button moves to the same end of the tab strip. The choice is remembered, in the desktop app for every project. While docked, the tab strip stays visible and usable, and the list stays open after you pick a conversation, so you close it with `Esc` or by clicking **Chat history** again. If you narrow the pane while history is docked, history closes first so the active chat remains open. Opening history in a narrow pane covers the whole chat area instead, including the tab strip, which is inert until you leave history; widening the pane while history is open moves it into the docked position without closing it. The cover list closes as soon as you pick a conversation, and a **Back** button in its header dismisses it, as does `Esc`.To report a problem with a chat in the desktop app, choose **Report a problem with this chat…** from the chat's **Settings** menu, which stays open for this even when the agent has no settings to adjust, for example after it failed to start. Unless you uncheck **This conversation**, the report carries the newest 4 MB of the chat's messages, tool calls, and their output, plus the chat's title, the project folder's path, the document it started from, and the agent and its settings, with known secrets scrubbed. Images and other binary content in the chat are replaced by a note of their type and size, while text files attached to a message are included. The review step tells you if the chat's messages couldn't be added, in which case the report goes without the conversation. If only the title, path, document, and agent details couldn't be read, the report carries the messages without them, and the review step doesn't mention it. See [what leaves your machine](../reference/what-open-knowledge-writes.mdx#what-leaves-your-machine) for everything else a report carries.diff --git a/packages/app/BUNDLE-SIZE.md b/packages/app/BUNDLE-SIZE.mdindex 2263ac7d3..a0c8b3d05 100644--- a/packages/app/BUNDLE-SIZE.md+++ b/packages/app/BUNDLE-SIZE.md@@ -119,3 +119,5 @@ Combined-chunks 9.15->9.16 MB for `@visimer/core` and `@visimer/dom` 1.x, whichCombined-chunks 9.16->9.17 MB for the quiet notice after a both-kept merge or a version moved to history (PRD-9735). Measured 9,157,371 B on main and 9,165,865 B with the notice, 8,494 B more: about 6.6 kB is its 14 new strings in each of the 13 locale catalogs, about 1.7 kB the notice strip, its data hook and the timeline row labels in the main bundle (481.29 kB against its 487 kB limit), and 0.15 kB the notice schema in the `schemas/api` chunk, which the app already imports through that narrow entry. No reclamation lever: the strings are the feature, and each reader downloads one catalog.Combined-chunks 9.17->9.18 MB for keeping the edited side of engine-less files, settings and skills (PRD-9771, #7203): the history and backup-folder notices in `DocChangeNotice`, the settings notices, the held-save message, and their new strings compiled into each of the 13 locale catalogs. Measured on one machine, `main` alone builds to 9,166,292 B and the branch to 9,175,290 B, so the branch adds 8,998 B and lands 5,290 B over the prior 9,170,000 B ceiling. The 10 kB ratchet to 9,180,000 B leaves 4,710 B of headroom over the branch build. No reclamation lever: the strings are the feature, and each reader downloads one catalog.++Combined-chunks 9.18->9.19 MB for moving docked chat history to either side of the conversation (#7294): the Agents strip's row menu with its Move chat history item, the palette's side-aware move commands, and their strings compiled into each of the 13 locale catalogs. Measured on one machine, `main` at `450b65e` alone builds to 9,178,809 B, 1,191 B under the 9,180,000 B ceiling, and the branch merged with it to 9,180,163 B, so the branch adds 1,354 B and lands 163 B over; the merge queue measured the same 9,180,163 B. The main app bundle went from 482.47 kB on `main` to 482.26 kB on the branch against its 487 kB limit, and CSS stayed at 8.36 kB against 59 kB, so the growth sits outside the main app bundle. The 10 kB ratchet to 9,190,000 B leaves 9,837 B of headroom over the branch build. No reclamation lever beyond the lazy-load levers above.diff --git a/packages/app/package.json b/packages/app/package.jsonindex cbea348d9..786ef408b 100644--- a/packages/app/package.json+++ b/packages/app/package.json@@ -68,7 +68,7 @@{"name": "all JS chunks combined (gzipped)","path": "dist/assets/*.js",- "limit": "9.18 MB",+ "limit": "9.19 MB","gzip": true,"running": false},diff --git a/packages/app/src/components/CommandPalette.tsx b/packages/app/src/components/CommandPalette.tsxindex 4cc5f9d9c..377f8535a 100644--- a/packages/app/src/components/CommandPalette.tsx+++ b/packages/app/src/components/CommandPalette.tsx@@ -103,7 +103,9 @@ import {import { emitLocalMenuAction } from '@/lib/local-menu-action-bus';import { isOverlayLayerOpen } from '@/lib/overlay-layers';import { revealEditor } from '@/lib/reveal-editor';+import { physicalSide, useChatHistorySide } from '@/lib/sidebar-side-store';import { useSingleFileMode } from '@/lib/single-file-mode';+import { useDocumentDirection } from '@/lib/use-document-direction';import { useWorkspace } from '@/lib/use-workspace';import { cn } from '@/lib/utils.ts';import { useViewMenuState } from '@/lib/view-menu-state-store';@@ -686,6 +688,7 @@ export function CommandPalette({ bridge = null, open, onOpenChange }: CommandPalpaletteMode.kind === 'tag-docs' && tagDocsStatus === 'success' && tagDocs.length === 0;const viewMenuState = useViewMenuState();+ const chatHistorySide = physicalSide(useChatHistorySide(), useDocumentDirection());const runMenuAction = (action: OkMenuAction) => {onOpenChange(false);emitLocalMenuAction(action, { launcherBorne: true });@@ -703,6 +706,7 @@ export function CommandPalette({ bridge = null, open, onOpenChange }: CommandPalactiveDocName,contextualTargetKind: projectContextualTargetKind(activeTarget),viewMenuState,+ chatHistorySide,emitMenuAction: runMenuAction,runAction,openExternalUrl,diff --git a/packages/app/src/components/DocPanelToggle.tsx b/packages/app/src/components/DocPanelToggle.tsxindex e6220ac1b..e6c010a9d 100644--- a/packages/app/src/components/DocPanelToggle.tsx+++ b/packages/app/src/components/DocPanelToggle.tsx@@ -3,9 +3,9 @@ import { PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen } from 'import { Button } from '@/components/ui/button.tsx';import { Kbd } from '@/components/ui/kbd';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';-import { physicalSide } from '@/lib/editor-sidebar-side-store';import { formatShortcut, formatShortcutLabel } from '@/lib/keyboard-shortcuts';import { isNoteWindow } from '@/lib/note-window-mode';+import { physicalSide } from '@/lib/sidebar-side-store';import { useDocumentDirection } from '@/lib/use-document-direction';import { cn } from '@/lib/utils';diff --git a/packages/app/src/components/EditorArea.dom.test.tsx b/packages/app/src/components/EditorArea.dom.test.tsxindex 2e89f42d5..ed4b89bd3 100644--- a/packages/app/src/components/EditorArea.dom.test.tsx+++ b/packages/app/src/components/EditorArea.dom.test.tsx@@ -10,7 +10,6 @@ import {} from 'react';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import { DEFAULT_DOCK_TREE, type DockNode, moveDockPane } from '@/lib/dock-tree';-import { swapEditorSidebars } from '@/lib/editor-sidebar-side-store';import {__resetPaneVisibilityStoreForTests,type PaneId,@@ -18,6 +17,7 @@ import {paneVisibilityStore,} from '@/lib/pane-visibility-store';import { SIDEBAR_PINS_KEY } from '@/lib/sidebar-pin-store';+import { swapEditorSidebars } from '@/lib/sidebar-side-store';import type { PanelTab } from './DocPanel';import type { SessionPlacements } from './EditorArea';import { FileListHostProvider } from './FileListHost';diff --git a/packages/app/src/components/EditorArea.tsx b/packages/app/src/components/EditorArea.tsxindex befb02817..1c427f392 100644--- a/packages/app/src/components/EditorArea.tsx+++ b/packages/app/src/components/EditorArea.tsx@@ -85,7 +85,6 @@ import { type DockLayout, dockPaneMinExtent, EMPTY_DOCK_LAYOUT } from '@/lib/docimport type { DockNode } from '@/lib/dock-tree';import { focusAwayFromHiddenEditor, focusWaitsForEditor } from '@/lib/editor-hidden-focus';import { type EditorSidebar, resolveEditorSidebarFit } from '@/lib/editor-sidebar-fit';-import { documentPanelSide, useFileSidebarSide } from '@/lib/editor-sidebar-side-store';import { matchesKeyboardShortcut } from '@/lib/keyboard-shortcuts';import { subscribeLocalMenuAction } from '@/lib/local-menu-action-bus';import { isNoteWindow } from '@/lib/note-window-mode';@@ -105,6 +104,7 @@ import {readPins,resolveEffectiveState,} from '@/lib/sidebar-pin-store';+import { documentPanelSide, useFileSidebarSide } from '@/lib/sidebar-side-store';import { closeTimelineDiff, useTimelineDiffView } from '@/lib/timeline-diff-store';import { EditorContentOnScreenContext } from '@/lib/use-editor-pane-on-screen';import { useSettingsRoute } from '@/lib/use-settings-route';diff --git a/packages/app/src/components/EditorSidebarsContextMenu.tsx b/packages/app/src/components/EditorSidebarsContextMenu.tsxindex 0d93c948c..29cabdf52 100644--- a/packages/app/src/components/EditorSidebarsContextMenu.tsx+++ b/packages/app/src/components/EditorSidebarsContextMenu.tsx@@ -7,7 +7,7 @@ import {ContextMenuItem,ContextMenuTrigger,} from '@/components/ui/context-menu';-import { swapEditorSidebars } from '@/lib/editor-sidebar-side-store';+import { swapEditorSidebars } from '@/lib/sidebar-side-store';export function EditorSidebarsContextMenu({ children }: { readonly children: ReactNode }) {const { t } = useLingui();diff --git a/packages/app/src/components/EditorWorkspace.dom.test.tsx b/packages/app/src/components/EditorWorkspace.dom.test.tsxindex 82557e41e..91ed5d756 100644--- a/packages/app/src/components/EditorWorkspace.dom.test.tsx+++ b/packages/app/src/components/EditorWorkspace.dom.test.tsx@@ -3,8 +3,8 @@ import type { ReactNode } from 'react';import { createPortal } from 'react-dom';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import type { EditorPaneState } from '@/editor/editor-panes';-import { swapEditorSidebars } from '@/lib/editor-sidebar-side-store';import { OK_SIDEBAR_DRAG_MIME, serializeSidebarDragPayload } from '@/lib/sidebar-drag';+import { swapEditorSidebars } from '@/lib/sidebar-side-store';import { renderLinguiTemplate } from '@/test-utils/lingui-mock';import {expectVisualClassTokens,diff --git a/packages/app/src/components/EditorWorkspace.tsx b/packages/app/src/components/EditorWorkspace.tsxindex aad9d4767..14869c530 100644--- a/packages/app/src/components/EditorWorkspace.tsx+++ b/packages/app/src/components/EditorWorkspace.tsx@@ -35,7 +35,6 @@ import {import { useDocumentContext } from '@/editor/DocumentContext';import type { EditorPaneState, PaneSide } from '@/editor/editor-panes';import { openSidebarDropPayload } from '@/editor/sidebar-drop';-import { useFileSidebarSide } from '@/lib/editor-sidebar-side-store';import {getNoteWindowDeletedDoc,subscribeNoteWindowDeleted,@@ -43,6 +42,7 @@ import {import { isNoteWindow } from '@/lib/note-window-mode';import { paneVisibilityStore } from '@/lib/pane-visibility-store';import { hasSidebarDragType, parseSidebarDragPayload } from '@/lib/sidebar-drag';+import { useFileSidebarSide } from '@/lib/sidebar-side-store';import { useSingleFileMode } from '@/lib/single-file-mode';import { cn } from '@/lib/utils';import { EditorTabs } from './EditorTabs';diff --git a/packages/app/src/components/FileListToggle.tsx b/packages/app/src/components/FileListToggle.tsxindex 7190180df..c3d5e393d 100644--- a/packages/app/src/components/FileListToggle.tsx+++ b/packages/app/src/components/FileListToggle.tsx@@ -3,8 +3,8 @@ import { Kbd } from '@/components/ui/kbd';import { Separator } from '@/components/ui/separator';import { SidebarTrigger, useSidebar } from '@/components/ui/sidebar';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';-import { physicalSide } from '@/lib/editor-sidebar-side-store';import { formatShortcut, formatShortcutLabel } from '@/lib/keyboard-shortcuts';+import { physicalSide } from '@/lib/sidebar-side-store';import { useDocumentDirection } from '@/lib/use-document-direction';import { cn } from '@/lib/utils';diff --git a/packages/app/src/components/FileSidebar.tsx b/packages/app/src/components/FileSidebar.tsxindex 5338b48a1..0f38b2cbd 100644--- a/packages/app/src/components/FileSidebar.tsx+++ b/packages/app/src/components/FileSidebar.tsx@@ -104,7 +104,6 @@ import {import { useSettingsLoadingReason } from '@/lib/config-context';import { useConfigContext } from '@/lib/config-provider';import { subscribeToCreateTopLevelFile } from '@/lib/create-file-events';-import { physicalSide, useFileSidebarSide } from '@/lib/editor-sidebar-side-store';import {buildSendToAiInputForActiveTarget,resolveActiveTargetAbsPath,@@ -123,6 +122,7 @@ import { revealInFileManagerLabel } from '@/lib/platform-labels';import { revealEditorBeforeActing } from '@/lib/reveal-editor';import { scheduleClipboardWrite } from '@/lib/share/clipboard-adapter';import { buildFolderShareInput, runShareAction } from '@/lib/share/run-share-action';+import { physicalSide, useFileSidebarSide } from '@/lib/sidebar-side-store';import { useStickyAgent } from '@/lib/unified-agent-store';import { useDocumentDirection } from '@/lib/use-document-direction';import { useWorkspace } from '@/lib/use-workspace';diff --git a/packages/app/src/components/SessionsHost.tsx b/packages/app/src/components/SessionsHost.tsxindex 5b8ea22ab..63cd2accc 100644--- a/packages/app/src/components/SessionsHost.tsx+++ b/packages/app/src/components/SessionsHost.tsx@@ -23,6 +23,7 @@ import {} from 'react';import { createPortal } from 'react-dom';import { toast } from 'sonner';+import { ChatHistorySideMenuItem } from '@/components/acp/ChatHistorySideMenuItem';import { RegisteredAgentIcon } from '@/components/acp/RegisteredAgentIcon';import {ThreadHistoryPanel,@@ -89,6 +90,7 @@ import type { NewSessionChoice } from '@/lib/new-session-choice';import { isOverlayLayerOpen } from '@/lib/overlay-layers';import { paneVisibilityStore } from '@/lib/pane-visibility-store';import { RESTORE_SETTLE_TIMEOUT_MS } from '@/lib/restore-settle-timeout';+import { useChatHistorySide } from '@/lib/sidebar-side-store';import { usePreferBareTerminal, writePreferBareTerminal } from '@/lib/terminal-new-tab-store';import {parseStickyCliId,@@ -525,6 +527,7 @@ export function SessionsHost({}, [hostEl, container]);const [historyOpen, setHistoryOpen] = useState(false);+ const chatHistorySide = useChatHistorySide();const { mode: historyMode, remeasure: remeasureHistoryMode } = useHistoryPresentationMode(container,hostThreads,@@ -2083,7 +2086,7 @@ export function SessionsHost({/>) : null;- const trailingControls = hostThreads ? (+ const historyToggle = hostThreads ? (<ThreadHistoryToggleopen={historyOpen}panelId={historyPanelId}@@ -2214,7 +2217,10 @@ export function SessionsHost({if (session != null) queueMicrotask(() => focusSession(session));}}newButton={newButton}- trailingControls={trailingControls}+ leadingControls={chatHistorySide === 'start' ? historyToggle : null}+ trailingControls={chatHistorySide === 'end' ? historyToggle : null}+ rowMenu={hostThreads ? <ChatHistorySideMenuItem side={chatHistorySide} /> : undefined}+ rowMenuFocusFallback={hostThreads ? historyToggleRef : undefined}onClose={closeSession}onRename={renameSession}onReorder={reorderSessions}@@ -2234,6 +2240,29 @@ export function SessionsHost({</TerminalTabStrip>);+ const historySurface = historyOpen ? (+ <div+ className={cn(+ 'z-20 h-full max-w-full bg-sidebar',+ historyMode === 'cover'+ ? 'absolute inset-0 w-full shadow-xl [-webkit-app-region:no-drag]'+ : cn(+ 'w-(--history-panel-width) shrink-0',+ chatHistorySide === 'start' ? 'border-e' : 'border-s',+ ),+ )}+ style={+ {+ '--history-panel-width': `${HISTORY_PANEL_WIDTH_PX}px`,+ } as CSSProperties+ }+ data-testid="agent-thread-history-surface"+ data-side={chatHistorySide}+ >+ {historyPanel}+ </div>+ ) : null;+const sessionViews = showStrip ? (hostThreads ? (<ThreadHistorySearchProvider scope={threadScope}>@@ -2241,6 +2270,7 @@ export function SessionsHost({className="relative flex h-full min-h-0 min-w-0 overflow-hidden"data-testid="agent-panel-layout">+ {chatHistorySide === 'start' ? historySurface : null}<divclassName="flex min-h-0 min-w-0 flex-1 flex-col"data-testid="agent-panel-session-surface"@@ -2248,24 +2278,7 @@ export function SessionsHost({>{sessionStrip}</div>- {historyOpen ? (- <div- className={cn(- 'z-20 h-full max-w-full bg-sidebar',- historyMode === 'cover'- ? 'absolute inset-0 w-full shadow-xl [-webkit-app-region:no-drag]'- : 'w-(--history-panel-width) shrink-0 border-s',- )}- style={- {- '--history-panel-width': `${HISTORY_PANEL_WIDTH_PX}px`,- } as CSSProperties- }- data-testid="agent-thread-history-surface"- >- {historyPanel}- </div>- ) : null}+ {chatHistorySide === 'end' ? historySurface : null}</div></ThreadHistorySearchProvider>) : (diff --git a/packages/app/src/components/TerminalTabStrip.dom.test.tsx b/packages/app/src/components/TerminalTabStrip.dom.test.tsxindex 52d7e4113..d2da45a9b 100644--- a/packages/app/src/components/TerminalTabStrip.dom.test.tsx+++ b/packages/app/src/components/TerminalTabStrip.dom.test.tsx@@ -1,7 +1,8 @@import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';import userEvent from '@testing-library/user-event';-import { useEffect } from 'react';+import { useEffect, useRef, useState } from 'react';import { afterEach, describe, expect, test, vi } from 'vitest';+import { ContextMenuItem } from '@/components/ui/context-menu';import { TooltipProvider } from '@/components/ui/tooltip';import {expectVisualClassTokens,@@ -73,6 +74,35 @@ function renderStrip(props?: {};}+function StripWithMovingControl() {+ const [atStart, setAtStart] = useState(false);+ const controlRef = useRef<HTMLButtonElement>(null);+ const control = (+ <button ref={controlRef} type="button" aria-label="Moving control">+ M+ </button>+ );+ return (+ <TooltipProvider>+ <TerminalTabStrip+ sessions={SESSIONS}+ activeSessionId="s1"+ onSelect={() => {}}+ onClose={() => {}}+ sessionKind="agent"+ leadingControls={atStart ? control : null}+ trailingControls={atStart ? null : control}+ rowMenu={+ <ContextMenuItem onSelect={() => setAtStart((current) => !current)}>+ Move the control+ </ContextMenuItem>+ }+ rowMenuFocusFallback={controlRef}+ />+ </TooltipProvider>+ );+}+describe('TerminalTabStrip', () => {afterEach(() => cleanup());@@ -415,6 +445,42 @@ describe('TerminalTabStrip', () => {expect(focusedTab).toBe(document.activeElement);});+ test('when a row menu action chosen from the keyboard moves the control that opened the menu, focus lands on that control in its new place', async () => {+ const user = userEvent.setup();+ render(<StripWithMovingControl />);+ const control = screen.getByRole('button', { name: 'Moving control' });+ act(() => control.focus());++ fireEvent.keyDown(control, { key: 'F10', shiftKey: true });+ expect(await screen.findByRole('menuitem', { name: 'Move the control' })).toBe(+ document.activeElement,+ );+ await user.keyboard('{Enter}');++ const moved = screen.getByRole('button', { name: 'Moving control' });+ expect(moved).not.toBe(control);+ await waitFor(() => expect(document.activeElement).toBe(moved));+ });++ test('while a tab is being renamed, right-click and the context-menu keys in the field keep the native text menu and leave the rename open', async () => {+ const user = userEvent.setup();+ const { onRename } = renderStrip({ edge: 'bottom', sessionKind: 'terminal' });+ await user.dblClick(screen.getByRole('tab', { name: 'Terminal 2' }));+ const input = screen.getByRole('textbox', { name: 'Rename Terminal 2' });++ expect(fireEvent.contextMenu(input)).toBe(true);+ expect(fireEvent.keyDown(input, { key: 'F10', shiftKey: true })).toBe(true);+ expect(fireEvent.keyDown(input, { key: 'ContextMenu' })).toBe(true);++ expect(screen.queryByRole('menu')).toBeNull();+ expect(input).toBe(document.activeElement);+ expect(onRename).not.toHaveBeenCalled();++ await user.keyboard('{Escape}');+ fireEvent.contextMenu(screen.getByRole('tablist', { name: 'Terminal sessions' }));+ expect(await screen.findByRole('menuitem', { name: 'Move to right panel' })).toBeDefined();+ });+test('the right Terminal header has a named 24px dock control that moves it bottom', async () => {const user = userEvent.setup();const { onPlacementChange } = renderStrip({ edge: 'right', sessionKind: 'terminal' });diff --git a/packages/app/src/components/TerminalTabStrip.tsx b/packages/app/src/components/TerminalTabStrip.tsxindex 4cf00c3d0..66e7c7fed 100644--- a/packages/app/src/components/TerminalTabStrip.tsx+++ b/packages/app/src/components/TerminalTabStrip.tsx@@ -9,7 +9,14 @@ import {} from '@dnd-kit/sortable';import { Trans, useLingui } from '@lingui/react/macro';import { PanelBottomIcon, PanelRightIcon, XIcon } from 'lucide-react';-import { type ReactElement, type ReactNode, useEffect, useRef, useState } from 'react';+import {+ type ReactElement,+ type ReactNode,+ type RefObject,+ useEffect,+ useRef,+ useState,+} from 'react';import { Button } from '@/components/ui/button';import {ContextMenu,@@ -79,22 +86,27 @@ export interface TerminalTabDescriptor {export type SessionPanelEdge = 'bottom' | 'right';type SessionKind = 'terminal' | 'agent';-function BottomTerminalPlacementMenu({+function StripRowMenu({children,- onMoveRight,+ items,+ disabled,+ focusFallback,}: {readonly children: ReactElement;- readonly onMoveRight?: () => void;+ readonly items: ReactNode;+ readonly disabled: boolean;+ readonly focusFallback?: RefObject<HTMLElement | null>;}) {const keyboardTriggerRef = useRef<HTMLElement | null>(null);- if (onMoveRight == null) return children;+ if (items == null) return children;return (<ContextMenu><ContextMenuTriggerasChild+ disabled={disabled}onKeyDown={(event) => {- if (!shouldOpenTabContextMenu(event)) return;+ if (disabled || !shouldOpenTabContextMenu(event)) return;event.preventDefault();keyboardTriggerRef.current =document.activeElement instanceof HTMLElement ? document.activeElement : null;@@ -113,18 +125,14 @@ function BottomTerminalPlacementMenu({</ContextMenuTrigger><ContextMenuContentonCloseAutoFocus={(event) => {- if (keyboardTriggerRef.current == null) return;+ const trigger = keyboardTriggerRef.current;+ if (trigger == null) return;event.preventDefault();- keyboardTriggerRef.current.focus();keyboardTriggerRef.current = null;+ (trigger.isConnected ? trigger : focusFallback?.current)?.focus();}}>- <ContextMenuGroup>- <ContextMenuItem onSelect={onMoveRight}>- <PanelRightIcon aria-hidden="true" />- <Trans>Move to right panel</Trans>- </ContextMenuItem>- </ContextMenuGroup>+ <ContextMenuGroup>{items}</ContextMenuGroup></ContextMenuContent></ContextMenu>);@@ -137,7 +145,10 @@ interface TerminalTabStripProps {readonly onSelect: (id: string) => void;readonly onTabActivate?: (id: string) => void;readonly newButton?: ReactNode;+ readonly leadingControls?: ReactNode;readonly trailingControls?: ReactNode;+ readonly rowMenu?: ReactNode;+ readonly rowMenuFocusFallback?: RefObject<HTMLElement | null>;readonly onClose: (id: string) => void;readonly onRename?: (id: string, label: string) => void;readonly onReorder?: (newOrderIds: readonly string[]) => void;@@ -156,7 +167,10 @@ export function TerminalTabStrip({onSelect,onTabActivate,newButton,+ leadingControls,trailingControls,+ rowMenu,+ rowMenuFocusFallback,onClose,onRename,onReorder,@@ -268,7 +282,20 @@ export function TerminalTabStrip({onValueChange={onSelect}className={cn('flex min-h-0 min-w-0 flex-1 flex-col', className)}>- <BottomTerminalPlacementMenu onMoveRight={onMoveRight}>+ <StripRowMenu+ items={+ onMoveRight != null ? (+ <ContextMenuItem onSelect={onMoveRight}>+ <PanelRightIcon aria-hidden="true" />+ <Trans>Move to right panel</Trans>+ </ContextMenuItem>+ ) : (+ rowMenu+ )+ }+ disabled={renamingId != null}+ focusFallback={rowMenuFocusFallback}+ ><divref={rowRef}data-terminal-tab-row=""@@ -282,6 +309,11 @@ export function TerminalTabStrip({'h-[62px] pr-[22px] pl-[calc(var(--ok-titlebar-reserve-left,1rem)+0.75rem)]',)}>+ {leadingControls != null ? (+ <div className={cn('shrink-0', windowDragRegion && '[-webkit-app-region:no-drag]')}>+ {leadingControls}+ </div>+ ) : null}<DndContextsensors={sensors}autoScroll={TAB_REORDER_AUTO_SCROLL}@@ -497,7 +529,7 @@ export function TerminalTabStrip({</Tooltip>) : null}</div>- </BottomTerminalPlacementMenu>+ </StripRowMenu>{children}</Tabs>);diff --git a/packages/app/src/components/acp/ChatHistorySideMenuItem.tsx b/packages/app/src/components/acp/ChatHistorySideMenuItem.tsxnew file mode 100644index 000000000..7511b40c6--- /dev/null+++ b/packages/app/src/components/acp/ChatHistorySideMenuItem.tsx@@ -0,0 +1,19 @@+import { useLingui } from '@lingui/react/macro';+import { PanelLeft, PanelRight } from 'lucide-react';+import { ContextMenuItem } from '@/components/ui/context-menu';+import { type LogicalSide, moveChatHistory, physicalSide } from '@/lib/sidebar-side-store';+import { useDocumentDirection } from '@/lib/use-document-direction';++export function ChatHistorySideMenuItem({ side }: { readonly side: LogicalSide }) {+ const { t } = useLingui();+ const onRight = physicalSide(side, useDocumentDirection()) === 'right';+ return (+ <ContextMenuItem+ data-move-chat-history=""+ onSelect={() => moveChatHistory(onRight ? 'left' : 'right')}+ >+ {onRight ? <PanelLeft aria-hidden="true" /> : <PanelRight aria-hidden="true" />}+ {onRight ? t`Move chat history to the left` : t`Move chat history to the right`}+ </ContextMenuItem>+ );+}diff --git a/packages/app/src/components/command-palette-chat-history-side.test.ts b/packages/app/src/components/command-palette-chat-history-side.test.tsnew file mode 100644index 000000000..288dbb8cf--- /dev/null+++ b/packages/app/src/components/command-palette-chat-history-side.test.ts@@ -0,0 +1,27 @@+import { describe, expect, test } from 'vitest';+import { PALETTE_COMMANDS, type PaletteCommandContext } from './command-palette-commands';++function offeredChatHistoryMoves(chatHistorySide: 'left' | 'right'): string[] {+ const ctx = {+ bridge: null,+ singleFile: false,+ activeDocName: null,+ viewMenuState: {},+ chatHistorySide,+ } as unknown as PaletteCommandContext;+ return PALETTE_COMMANDS.filter(+ (command) => command.id.startsWith('move-chat-history-') && command.available(ctx),+ ).map((command) => command.id);+}++describe('chat history side palette commands', () => {+ test.each([+ ['right', ['move-chat-history-left']],+ ['left', ['move-chat-history-right']],+ ] as const)(+ 'with chat history on the %s, the palette offers only the move to the other side',+ (side, offered) => {+ expect(offeredChatHistoryMoves(side)).toEqual(offered);+ },+ );+});diff --git a/packages/app/src/components/command-palette-commands.ts b/packages/app/src/components/command-palette-commands.tsindex 0cc027733..38748b944 100644--- a/packages/app/src/components/command-palette-commands.ts+++ b/packages/app/src/components/command-palette-commands.ts@@ -62,10 +62,10 @@ import { PANE_ICON } from '@/components/pane-icons';import { requestSkillsDockExpanded } from '@/components/skills-dock-expanded-store';import type { OkDesktopBridge, OkMenuAction } from '@/lib/desktop-bridge-types';import { requestDockPaneMove } from '@/lib/dock-move-requests';-import { swapEditorSidebars } from '@/lib/editor-sidebar-side-store';import { i18n } from '@/lib/i18n';import type { KeyboardShortcutId } from '@/lib/keyboard-shortcuts';import { openDocInNoteWindow } from '@/lib/open-note-window';+import { moveChatHistory, type PhysicalSide, swapEditorSidebars } from '@/lib/sidebar-side-store';import { openSettings } from '@/lib/use-settings-route';import type { ViewMenuState } from '@/lib/view-menu-state-store';@@ -98,6 +98,7 @@ export interface PaletteCommandContext {activeDocName: string | null;contextualTargetKind: ContextualTargetKind;viewMenuState: ViewMenuState;+ chatHistorySide: PhysicalSide;emitMenuAction(action: OkMenuAction): void;runAction(fn: () => Promise<void> | void, fallback?: string): void;openExternalUrl(url: string): void;@@ -164,6 +165,8 @@ const PALETTE_COMMAND_LABELS = {docPanelShow: msg`Show document panel`,docPanelHide: msg`Hide document panel`,swapEditorSidebars: msg`Swap file sidebar and document panel`,+ chatHistoryMoveLeft: msg`Move chat history to the left`,+ chatHistoryMoveRight: msg`Move chat history to the right`,editorShow: msg`Show Editor`,editorHide: msg`Hide Editor`,terminalShow: msg`Show Terminal`,@@ -274,6 +277,8 @@ const COMMAND_ICONS: Record<string, ComponentType<{ className?: string }>> = {'toggle-sidebar': PanelLeft,'toggle-doc-panel': PanelRight,'swap-editor-sidebars': ArrowLeftRight,+ 'move-chat-history-left': PanelLeft,+ 'move-chat-history-right': PanelRight,'toggle-terminal': PANE_ICON.terminal,'move-terminal': SquareTerminal,'toggle-agent-panel': PANE_ICON.agents,@@ -308,6 +313,14 @@ const COMMAND_DISPATCH: Record<string, (ctx: PaletteCommandContext) => void> = {ctx.closePalette();swapEditorSidebars();},+ 'move-chat-history-left': (ctx) => {+ ctx.closePalette();+ moveChatHistory('left');+ },+ 'move-chat-history-right': (ctx) => {+ ctx.closePalette();+ moveChatHistory('right');+ },'open-blob-run': (ctx) => ctx.openBlobRun(),'new-file': (ctx) => {ctx.closePalette();@@ -396,6 +409,13 @@ const COMMAND_DISPATCH: Record<string, (ctx: PaletteCommandContext) => void> = {'open-discord': (ctx) => ctx.openExternalUrl(OPEN_KNOWLEDGE_DISCORD_URL),};+const STATE_AVAILABILITY: Readonly<+ Partial<Record<string, (ctx: PaletteCommandContext) => boolean>>+> = {+ 'move-chat-history-left': (ctx) => ctx.chatHistorySide === 'right',+ 'move-chat-history-right': (ctx) => ctx.chatHistorySide === 'left',+};+function paletteCoreContext(ctx: PaletteCommandContext): CommandContext {return {host: ctx.bridge !== null ? 'desktop' : 'web',@@ -459,7 +479,9 @@ function toPaletteCommand(cmd: CommandIdentity): PaletteCommand {shortcutId: cmd.shortcutId as KeyboardShortcutId | undefined,shortcutDesktopOnly: cmd.shortcutDesktopOnly,checked: checkField ? (ctx) => ctx.viewMenuState[checkField] === true : undefined,- available: (ctx) => evaluateCommandAvailability(cmd.availability, paletteCoreContext(ctx)),+ available: (ctx) =>+ evaluateCommandAvailability(cmd.availability, paletteCoreContext(ctx)) &&+ (STATE_AVAILABILITY[cmd.id]?.(ctx) ?? true),dispatch: COMMAND_DISPATCH[cmd.id] ?? busDispatch(cmd),};}diff --git a/packages/app/src/lib/command-menu-parity.uncached.test.ts b/packages/app/src/lib/command-menu-parity.uncached.test.tsindex 93ae2b255..2e132216c 100644--- a/packages/app/src/lib/command-menu-parity.uncached.test.ts+++ b/packages/app/src/lib/command-menu-parity.uncached.test.ts@@ -536,6 +536,8 @@ describe('command identity registry (Phase 2b)', () => {'open-docs','open-discord','swap-editor-sidebars',+ 'move-chat-history-left',+ 'move-chat-history-right',...DOCK_MOVE_COMMANDS.map((command) => command.id),]);const missing = COMMAND_IDENTITIES.flatMap((cmd) =>diff --git a/packages/app/src/lib/editor-sidebar-side-store.ts b/packages/app/src/lib/editor-sidebar-side-store.tsdeleted file mode 100644index 57172026f..000000000--- a/packages/app/src/lib/editor-sidebar-side-store.ts+++ /dev/null@@ -1,93 +0,0 @@-import type { TextDirection } from '@inkeep/open-knowledge-core/i18n/direction';-import { useSyncExternalStore } from 'react';--export type EditorSidebarSide = 'start' | 'end';--// precedent #59: app-global by intent, a personal layout preference like the theme that follows the user into every project.-export const FILE_SIDEBAR_SIDE_KEY = 'ok-file-sidebar-side-v1';--export interface EditorSidebarSideStorage {- getItem(key: string): string | null;- setItem(key: string, value: string): void;-}--export interface EditorSidebarSideStore {- getSnapshot(): EditorSidebarSide;- set(side: EditorSidebarSide): void;- syncFromStorage(): void;- subscribe(listener: () => void): () => void;-}--export function createEditorSidebarSideStore(- key: string,- fallback: EditorSidebarSide,- storage: () => EditorSidebarSideStorage,-): EditorSidebarSideStore {- const other: EditorSidebarSide = fallback === 'start' ? 'end' : 'start';- const listeners = new Set<() => void>();- let side: EditorSidebarSide | null = null;- const read = (): EditorSidebarSide => {- try {- return storage().getItem(key) === other ? other : fallback;- } catch {- return fallback;- }- };- const notify = () => {- for (const listener of listeners) listener();- };- return {- getSnapshot() {- side ??= read();- return side;- },- set(next) {- side = next;- try {- storage().setItem(key, next);- } catch {}- notify();- },- syncFromStorage() {- side = read();- notify();- },- subscribe(listener) {- listeners.add(listener);- return () => listeners.delete(listener);- },- };-}--const fileSidebarSideStore = createEditorSidebarSideStore(- FILE_SIDEBAR_SIDE_KEY,- 'start',- () => localStorage,-);--if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {- window.addEventListener('storage', (event) => {- if (event.key === FILE_SIDEBAR_SIDE_KEY || event.key === null)- fileSidebarSideStore.syncFromStorage();- });-}--export function swapEditorSidebars(store: EditorSidebarSideStore = fileSidebarSideStore): void {- store.set(store.getSnapshot() === 'start' ? 'end' : 'start');-}--export function physicalSide(side: EditorSidebarSide, direction: TextDirection): 'left' | 'right' {- return (side === 'start') === (direction === 'ltr') ? 'left' : 'right';-}--export function documentPanelSide(fileSidebarSide: EditorSidebarSide): EditorSidebarSide {- return fileSidebarSide === 'start' ? 'end' : 'start';-}--export function useFileSidebarSide(): EditorSidebarSide {- return useSyncExternalStore(- fileSidebarSideStore.subscribe,- fileSidebarSideStore.getSnapshot,- () => 'start',- );-}diff --git a/packages/app/src/lib/editor-sidebar-side-store.test.ts b/packages/app/src/lib/sidebar-side-store.test.tssimilarity index 50%rename from packages/app/src/lib/editor-sidebar-side-store.test.tsrename to packages/app/src/lib/sidebar-side-store.test.tsindex 85707b8cf..dddda377d 100644--- a/packages/app/src/lib/editor-sidebar-side-store.test.ts+++ b/packages/app/src/lib/sidebar-side-store.test.ts@@ -1,14 +1,16 @@import { describe, expect, test } from 'vitest';import {- createEditorSidebarSideStore,+ CHAT_HISTORY_SIDE_KEY,+ createSidebarSideStore,documentPanelSide,- type EditorSidebarSideStorage,FILE_SIDEBAR_SIDE_KEY,+ moveChatHistory,physicalSide,+ type SidebarSideStorage,swapEditorSidebars,-} from './editor-sidebar-side-store.ts';+} from './sidebar-side-store.ts';-function memoryStorage(initial: Record<string, string> = {}): EditorSidebarSideStorage & {+function memoryStorage(initial: Record<string, string> = {}): SidebarSideStorage & {data: Map<string, string>;} {const data = new Map(Object.entries(initial));@@ -21,24 +23,28 @@ function memoryStorage(initial: Record<string, string> = {}): EditorSidebarSideS};}-function storeOver(storage: EditorSidebarSideStorage) {- return createEditorSidebarSideStore(FILE_SIDEBAR_SIDE_KEY, 'start', () => storage);+function fileSidebarOver(storage: SidebarSideStorage) {+ return createSidebarSideStore(FILE_SIDEBAR_SIDE_KEY, 'start', () => storage);+}++function chatHistoryOver(storage: SidebarSideStorage) {+ return createSidebarSideStore(CHAT_HISTORY_SIDE_KEY, 'end', () => storage);}describe('editor sidebar sides', () => {test('the file sidebar starts at the start edge and the document panel at the end', () => {- const side = storeOver(memoryStorage()).getSnapshot();+ const side = fileSidebarOver(memoryStorage()).getSnapshot();expect(side).toBe('start');expect(documentPanelSide(side)).toBe('end');});test('swapping puts the file sidebar at the end and saves it, and swapping again puts it back', () => {const storage = memoryStorage();- const store = storeOver(storage);+ const store = fileSidebarOver(storage);swapEditorSidebars(store);expect(store.getSnapshot()).toBe('end');expect(storage.data.get(FILE_SIDEBAR_SIDE_KEY)).toBe('end');- expect(storeOver(storage).getSnapshot()).toBe('end');+ expect(fileSidebarOver(storage).getSnapshot()).toBe('end');swapEditorSidebars(store);expect(store.getSnapshot()).toBe('start');});@@ -46,14 +52,14 @@ describe('editor sidebar sides', () => {test.each(['', 'left', 'END'])('a stored value %j that is not a side reads as the start',(value) => {- expect(storeOver(memoryStorage({ [FILE_SIDEBAR_SIDE_KEY]: value })).getSnapshot()).toBe(+ expect(fileSidebarOver(memoryStorage({ [FILE_SIDEBAR_SIDE_KEY]: value })).getSnapshot()).toBe('start',);},);test('storage that throws starts at the start edge, and a swap still takes effect for the session', () => {- const throwing: EditorSidebarSideStorage = {+ const throwing: SidebarSideStorage = {getItem: () => {throw new Error('blocked');},@@ -61,7 +67,7 @@ describe('editor sidebar sides', () => {throw new Error('blocked');},};- const store = storeOver(throwing);+ const store = fileSidebarOver(throwing);expect(store.getSnapshot()).toBe('start');swapEditorSidebars(store);expect(store.getSnapshot()).toBe('end');@@ -80,7 +86,7 @@ describe('editor sidebar sides', () => {test('a change saved by another window is picked up on reload and announced to subscribers', () => {const storage = memoryStorage();- const store = storeOver(storage);+ const store = fileSidebarOver(storage);expect(store.getSnapshot()).toBe('start');let announced = 0;const stop = store.subscribe(() => {@@ -94,3 +100,42 @@ describe('editor sidebar sides', () => {stop();});});++describe('chat history side', () => {+ test('chat history starts at the end edge and keeps the side it is moved to, apart from the file sidebar', () => {+ const storage = memoryStorage();+ const history = chatHistoryOver(storage);+ const files = fileSidebarOver(storage);+ expect(history.getSnapshot()).toBe('end');+ moveChatHistory('left', 'ltr', history);+ expect(storage.data.get(CHAT_HISTORY_SIDE_KEY)).toBe('start');+ expect(chatHistoryOver(storage).getSnapshot()).toBe('start');+ expect(files.getSnapshot()).toBe('start');+ swapEditorSidebars(files);+ expect(history.getSnapshot()).toBe('start');+ });++ test.each(['', 'left', 'START'])(+ 'a stored chat history value %j that is not a side reads as the end',+ (value) => {+ expect(chatHistoryOver(memoryStorage({ [CHAT_HISTORY_SIDE_KEY]: value })).getSnapshot()).toBe(+ 'end',+ );+ },+ );++ test.each([+ ['left', 'ltr', 'start'],+ ['right', 'ltr', 'end'],+ ['left', 'rtl', 'end'],+ ['right', 'rtl', 'start'],+ ] as const)(+ 'moving chat history to the %s of a %s document puts it at the %s edge',+ (physical, direction, side) => {+ const history = chatHistoryOver(memoryStorage());+ moveChatHistory(physical, direction, history);+ expect(history.getSnapshot()).toBe(side);+ expect(physicalSide(side, direction)).toBe(physical);+ },+ );+});diff --git a/packages/app/src/lib/sidebar-side-store.ts b/packages/app/src/lib/sidebar-side-store.tsnew file mode 100644index 000000000..b00b459f1--- /dev/null+++ b/packages/app/src/lib/sidebar-side-store.ts@@ -0,0 +1,119 @@+import type { TextDirection } from '@inkeep/open-knowledge-core/i18n/direction';+import { useSyncExternalStore } from 'react';+import { currentDocumentDirection } from './use-document-direction';++export type LogicalSide = 'start' | 'end';+export type PhysicalSide = 'left' | 'right';++// precedent #59: app-global by intent, personal layout preferences like the theme that follow the user into every project.+export const FILE_SIDEBAR_SIDE_KEY = 'ok-file-sidebar-side-v1';+export const CHAT_HISTORY_SIDE_KEY = 'ok-chat-history-side-v1';++export interface SidebarSideStorage {+ getItem(key: string): string | null;+ setItem(key: string, value: string): void;+}++export interface SidebarSideStore {+ getSnapshot(): LogicalSide;+ set(side: LogicalSide): void;+ syncFromStorage(): void;+ subscribe(listener: () => void): () => void;+}++export function createSidebarSideStore(+ key: string,+ fallback: LogicalSide,+ storage: () => SidebarSideStorage,+): SidebarSideStore {+ const other: LogicalSide = fallback === 'start' ? 'end' : 'start';+ const listeners = new Set<() => void>();+ let side: LogicalSide | null = null;+ const read = (): LogicalSide => {+ try {+ return storage().getItem(key) === other ? other : fallback;+ } catch {+ return fallback;+ }+ };+ const notify = () => {+ for (const listener of listeners) listener();+ };+ return {+ getSnapshot() {+ side ??= read();+ return side;+ },+ set(next) {+ side = next;+ try {+ storage().setItem(key, next);+ } catch {}+ notify();+ },+ syncFromStorage() {+ side = read();+ notify();+ },+ subscribe(listener) {+ listeners.add(listener);+ return () => listeners.delete(listener);+ },+ };+}++const fileSidebarSideStore = createSidebarSideStore(+ FILE_SIDEBAR_SIDE_KEY,+ 'start',+ () => localStorage,+);+const chatHistorySideStore = createSidebarSideStore(+ CHAT_HISTORY_SIDE_KEY,+ 'end',+ () => localStorage,+);++if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {+ window.addEventListener('storage', (event) => {+ if (event.key === FILE_SIDEBAR_SIDE_KEY || event.key === null)+ fileSidebarSideStore.syncFromStorage();+ if (event.key === CHAT_HISTORY_SIDE_KEY || event.key === null)+ chatHistorySideStore.syncFromStorage();+ });+}++export function swapEditorSidebars(store: SidebarSideStore = fileSidebarSideStore): void {+ store.set(store.getSnapshot() === 'start' ? 'end' : 'start');+}++export function moveChatHistory(+ physical: PhysicalSide,+ direction: TextDirection = currentDocumentDirection(),+ store: SidebarSideStore = chatHistorySideStore,+): void {+ store.set(physicalSide('start', direction) === physical ? 'start' : 'end');+}++export function physicalSide(side: LogicalSide, direction: TextDirection): PhysicalSide {+ return (side === 'start') === (direction === 'ltr') ? 'left' : 'right';+}++export function documentPanelSide(fileSidebarSide: LogicalSide): LogicalSide {+ return fileSidebarSide === 'start' ? 'end' : 'start';+}++export function useFileSidebarSide(): LogicalSide {+ return useSyncExternalStore(+ fileSidebarSideStore.subscribe,+ fileSidebarSideStore.getSnapshot,+ () => 'start',+ );+}++export function useChatHistorySide(): LogicalSide {+ return useSyncExternalStore(+ chatHistorySideStore.subscribe,+ chatHistorySideStore.getSnapshot,+ () => 'end',+ );+}diff --git a/packages/app/src/lib/use-document-direction.ts b/packages/app/src/lib/use-document-direction.tsindex b9f99a915..9b84e92c2 100644--- a/packages/app/src/lib/use-document-direction.ts+++ b/packages/app/src/lib/use-document-direction.ts@@ -7,7 +7,7 @@ function subscribeDocumentDirection(listener: () => void): () => void {return () => observer.disconnect();}-function currentDocumentDirection(): TextDirection {+export function currentDocumentDirection(): TextDirection {return document.documentElement.dir === 'rtl' ? 'rtl' : 'ltr';}diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.poindex d8ac2bd82..5c715399e 100644--- a/packages/app/src/locales/ar/messages.po+++ b/packages/app/src/locales/ar/messages.po@@ -6372,6 +6372,12 @@ msgstr "التنقل بين خلايا الجدول"msgid "Move block"msgstr "نقل الكتلة"+msgid "Move chat history to the left"+msgstr "نقل سجل الدردشة إلى اليسار"++msgid "Move chat history to the right"+msgstr "نقل سجل الدردشة إلى اليمين"+msgid "Move down"msgstr "تحريك لأسفل"diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.poindex 2148d6227..744442b71 100644--- a/packages/app/src/locales/bn/messages.po+++ b/packages/app/src/locales/bn/messages.po@@ -6368,6 +6368,12 @@ msgstr "টেবিলের ঘরগুলোর মধ্যে সরুনmsgid "Move block"msgstr "ব্লক সরান"+msgid "Move chat history to the left"+msgstr "চ্যাটের ইতিহাস বাঁ দিকে সরান"++msgid "Move chat history to the right"+msgstr "চ্যাটের ইতিহাস ডান দিকে সরান"+msgid "Move down"msgstr "নিচে সরান"diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.poindex c4c7cd507..b20d21a11 100644--- a/packages/app/src/locales/en/messages.po+++ b/packages/app/src/locales/en/messages.po@@ -6372,6 +6372,12 @@ msgstr "Move between table cells"msgid "Move block"msgstr "Move block"+msgid "Move chat history to the left"+msgstr "Move chat history to the left"++msgid "Move chat history to the right"+msgstr "Move chat history to the right"+msgid "Move down"msgstr "Move down"diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.poindex 369d38e4f..c1f33996f 100644--- a/packages/app/src/locales/es/messages.po+++ b/packages/app/src/locales/es/messages.po@@ -6372,6 +6372,12 @@ msgstr "Moverse entre celdas de la tabla"msgid "Move block"msgstr "Mover el bloque"+msgid "Move chat history to the left"+msgstr "Mover el historial de chats a la izquierda"++msgid "Move chat history to the right"+msgstr "Mover el historial de chats a la derecha"+msgid "Move down"msgstr "Bajar"diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.poindex 03593be81..eaa997b8c 100644--- a/packages/app/src/locales/fr/messages.po+++ b/packages/app/src/locales/fr/messages.po@@ -6372,6 +6372,12 @@ msgstr "Se déplacer entre les cellules du tableau"msgid "Move block"msgstr "Déplacer le bloc"+msgid "Move chat history to the left"+msgstr "Déplacer l'historique des discussions à gauche"++msgid "Move chat history to the right"+msgstr "Déplacer l'historique des discussions à droite"+msgid "Move down"msgstr "Descendre"diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.poindex e269e0c1b..bd5556143 100644--- a/packages/app/src/locales/hi/messages.po+++ b/packages/app/src/locales/hi/messages.po@@ -6368,6 +6368,12 @@ msgstr "तालिका की कोशिकाओं के बीच जmsgid "Move block"msgstr "ब्लॉक हिलाएँ"+msgid "Move chat history to the left"+msgstr "चैट का इतिहास बाईं ओर ले जाएँ"++msgid "Move chat history to the right"+msgstr "चैट का इतिहास दाईं ओर ले जाएँ"+msgid "Move down"msgstr "नीचे ले जाएँ"diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.poindex f34d7e120..3ad0284f1 100644--- a/packages/app/src/locales/id/messages.po+++ b/packages/app/src/locales/id/messages.po@@ -6368,6 +6368,12 @@ msgstr "Berpindah antarsel tabel"msgid "Move block"msgstr "Pindahkan blok"+msgid "Move chat history to the left"+msgstr "Pindahkan riwayat chat ke kiri"++msgid "Move chat history to the right"+msgstr "Pindahkan riwayat chat ke kanan"+msgid "Move down"msgstr "Turunkan"diff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.poindex 3c7a8f7f3..7fb07e736 100644--- a/packages/app/src/locales/ko/messages.po+++ b/packages/app/src/locales/ko/messages.po@@ -6372,6 +6372,12 @@ msgstr "표 셀 사이를 이동합니다."msgid "Move block"msgstr "블록 이동"+msgid "Move chat history to the left"+msgstr "채팅 기록을 왼쪽으로 이동"++msgid "Move chat history to the right"+msgstr "채팅 기록을 오른쪽으로 이동"+msgid "Move down"msgstr "아래로 이동"diff --git a/packages/app/src/locales/pl/messages.po b/packages/app/src/locales/pl/messages.poindex f4d63ef40..f9bf4a906 100644--- a/packages/app/src/locales/pl/messages.po+++ b/packages/app/src/locales/pl/messages.po@@ -6372,6 +6372,12 @@ msgstr "Przenoszenie między komórkami tabeli"msgid "Move block"msgstr "Przenieś blok"+msgid "Move chat history to the left"+msgstr "Przenieś historię czatu na lewo"++msgid "Move chat history to the right"+msgstr "Przenieś historię czatu na prawo"+msgid "Move down"msgstr "Przenieś w dół"diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.poindex 9c9ab52ed..8ec953952 100644--- a/packages/app/src/locales/pt-BR/messages.po+++ b/packages/app/src/locales/pt-BR/messages.po@@ -6368,6 +6368,12 @@ msgstr "Mover entre as células da tabela"msgid "Move block"msgstr "Mover o bloco"+msgid "Move chat history to the left"+msgstr "Mover o histórico de chats para a esquerda"++msgid "Move chat history to the right"+msgstr "Mover o histórico de chats para a direita"+msgid "Move down"msgstr "Mover para baixo"diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.poindex 005c257aa..72459467c 100644--- a/packages/app/src/locales/ur/messages.po+++ b/packages/app/src/locales/ur/messages.po@@ -6372,6 +6372,12 @@ msgstr "ٹیبل کے خانوں کے درمیان جائیں"msgid "Move block"msgstr "بلاک منتقل کریں"+msgid "Move chat history to the left"+msgstr "چیٹ کی سرگزشت بائیں جانب منتقل کریں"++msgid "Move chat history to the right"+msgstr "چیٹ کی سرگزشت دائیں جانب منتقل کریں"+msgid "Move down"msgstr "نیچے لے جائیں"diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.poindex 0f63c203e..d4743ced9 100644--- a/packages/app/src/locales/zh-Hans/messages.po+++ b/packages/app/src/locales/zh-Hans/messages.po@@ -6372,6 +6372,12 @@ msgstr "在表格单元格之间移动"msgid "Move block"msgstr "移动块"+msgid "Move chat history to the left"+msgstr "将聊天记录移到左侧"++msgid "Move chat history to the right"+msgstr "将聊天记录移到右侧"+msgid "Move down"msgstr "下移"diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.poindex fc1acb49f..f5db3f0de 100644--- a/packages/app/src/locales/zh-Hant/messages.po+++ b/packages/app/src/locales/zh-Hant/messages.po@@ -6372,6 +6372,12 @@ msgstr "在表格儲存格之間移動"msgid "Move block"msgstr "移動區塊"+msgid "Move chat history to the left"+msgstr "將聊天記錄移到左側"++msgid "Move chat history to the right"+msgstr "將聊天記錄移到右側"+msgid "Move down"msgstr "下移"diff --git a/packages/app/tests/a11y/acp-agent-notice.e2e.ts b/packages/app/tests/a11y/acp-agent-notice.e2e.tsindex adb80dca7..6c79f67e8 100644--- a/packages/app/tests/a11y/acp-agent-notice.e2e.ts+++ b/packages/app/tests/a11y/acp-agent-notice.e2e.ts@@ -3,7 +3,7 @@ import { join } from 'node:path';import { fileURLToPath } from 'node:url';import AxeBuilder from '@axe-core/playwright';import type { Locator, Page } from '@playwright/test';-import { expect, test } from '../stress/_helpers';+import { expect, test, threadRosterDelivered } from '../stress/_helpers';interface EnvelopeFixture {agents: Record<string, { source: string; id: string; name: string }>;@@ -79,24 +79,6 @@ function readAnnouncements(page: Page): Promise<string[]> {);}-function threadRosterDelivered(page: Page): Promise<void> {- return new Promise((resolve, reject) => {- const timer = setTimeout(- () => reject(new Error('thread socket never delivered its roster')),- 30_000,- );- page.on('websocket', (socket) => {- if (!socket.url().includes('/collab/thread')) return;- socket.on('framereceived', (frame) => {- if (typeof frame.payload !== 'string') return;- if (!frame.payload.includes('"op":"threads"')) return;- clearTimeout(timer);- resolve();- });- });- });-}-async function openAgentsPanel(page: Page): Promise<void> {await page.getByTestId(AGENTS_HEADER_BUTTON).click({ timeout: PANEL_OPEN_TIMEOUT_MS });await expect(diff --git a/packages/app/tests/a11y/corner-stack.e2e.ts b/packages/app/tests/a11y/corner-stack.e2e.tsindex f351a4e96..6aabd00aa 100644--- a/packages/app/tests/a11y/corner-stack.e2e.ts+++ b/packages/app/tests/a11y/corner-stack.e2e.ts@@ -23,6 +23,7 @@ import {setHeaderPane,terminalPaneCard,test,+ threadRosterDelivered,type WorkerServer,} from '../stress/_helpers';import {@@ -201,24 +202,6 @@ async function seriousOrCriticalViolations(page: Page) {);}-function threadRosterDelivered(page: Page): Promise<void> {- return new Promise((resolve, reject) => {- const timer = setTimeout(- () => reject(new Error('thread socket never delivered its roster')),- HARNESS_TIMEOUT_MS,- );- page.on('websocket', (socket) => {- if (!socket.url().includes('/collab/thread')) return;- socket.on('framereceived', (frame) => {- if (typeof frame.payload !== 'string') return;- if (!frame.payload.includes('"op":"threads"')) return;- clearTimeout(timer);- resolve();- });- });- });-}-async function focusTheTerminal(page: Page): Promise<void> {await page.locator(`${BOTTOM_TERMINAL} .xterm`).click();await expect.poll(() => focusIsInside(page, BOTTOM_TERMINAL)).toBe(true);diff --git a/packages/app/tests/stress/_helpers/index.ts b/packages/app/tests/stress/_helpers/index.tsindex e910bb51c..f44eee4f5 100644--- a/packages/app/tests/stress/_helpers/index.ts+++ b/packages/app/tests/stress/_helpers/index.ts@@ -194,6 +194,7 @@ export {type ThemeFadeProbeWindow,type ThemeFadeReport,} from './theme-fade.ts';+export { threadRosterDelivered } from './thread-roster.ts';export {createMp3Buffer,createMp4Buffer,diff --git a/packages/app/tests/stress/_helpers/thread-roster.ts b/packages/app/tests/stress/_helpers/thread-roster.tsnew file mode 100644index 000000000..db82f3581--- /dev/null+++ b/packages/app/tests/stress/_helpers/thread-roster.ts@@ -0,0 +1,22 @@+import type { Page } from '@playwright/test';++const ROSTER_TIMEOUT_MS = 30_000;++export function threadRosterDelivered(page: Page, onRoster?: () => void): Promise<void> {+ return new Promise((resolve, reject) => {+ const timer = setTimeout(+ () => reject(new Error('thread socket never delivered its roster')),+ ROSTER_TIMEOUT_MS,+ );+ page.once('close', () => clearTimeout(timer));+ page.on('websocket', (socket) => {+ if (!socket.url().includes('/collab/thread')) return;+ socket.on('framereceived', (frame) => {+ if (typeof frame.payload !== 'string' || !frame.payload.includes('"op":"threads"')) return;+ onRoster?.();+ clearTimeout(timer);+ resolve();+ });+ });+ });+}diff --git a/packages/app/tests/stress/agents-panel-reload-visibility.e2e.ts b/packages/app/tests/stress/agents-panel-reload-visibility.e2e.tsindex 3f16d4051..0257de7b9 100644--- a/packages/app/tests/stress/agents-panel-reload-visibility.e2e.ts+++ b/packages/app/tests/stress/agents-panel-reload-visibility.e2e.ts@@ -19,6 +19,7 @@ import {stubAgentCatalog,switchColorThemeAndSettleFade,test,+ threadRosterDelivered,} from './_helpers';const AGENTS_PANEL_MOUNT = '[data-agents-panel-mount]';@@ -270,25 +271,6 @@ async function seedLiveThread(port: number, contentDir: string): Promise<void> {});}-function nextRosterDelivery(page: Page, marks?: RouteMark[]): Promise<void> {- return new Promise((resolve, reject) => {- const timer = setTimeout(- () => reject(new Error('thread socket never delivered its roster')),- ROSTER_TIMEOUT_MS,- );- page.on('websocket', (socket) => {- if (!socket.url().includes('/collab/thread')) return;- socket.on('framereceived', (frame) => {- if (typeof frame.payload !== 'string') return;- if (!frame.payload.includes('"op":"threads"')) return;- marks?.push({ route: 'roster-frame', at: Date.now() });- clearTimeout(timer);- resolve();- });- });- });-}-function settleAfterRoster(page: Page): Promise<void> {return page.evaluate(() =>@@ -301,7 +283,7 @@ function settleAfterRoster(page: Page): Promise<void> {}async function openAppWithRoster(page: Page, path = '/'): Promise<void> {- const roster = nextRosterDelivery(page);+ const roster = threadRosterDelivered(page);await page.goto(path);await page.waitForFunction(() => Boolean(window.__acpThreadHarness), null, {timeout: BOOT_TIMEOUT_MS,@@ -480,7 +462,9 @@ async function expectPersistedPanelLevel(page: Page, level: boolean): Promise<vo}async function reloadAndSettle(page: Page, marks?: RouteMark[]): Promise<void> {- const roster = nextRosterDelivery(page, marks);+ const roster = threadRosterDelivered(page, () =>+ marks?.push({ route: 'roster-frame', at: Date.now() }),+ );await page.reload();await roster;await settleAfterRoster(page);@@ -982,7 +966,7 @@ test.describe('chat history navigation', () => {await page.addInitScript(() => window.localStorage.setItem('ok-theme-v1', 'dark'));await stubAgentCatalog(page);- const roster = nextRosterDelivery(page);+ const roster = threadRosterDelivered(page);await page.goto('/?lang=pseudo');await page.waitForFunction(() => Boolean(window.__acpThreadHarness), null, {timeout: BOOT_TIMEOUT_MS,diff --git a/packages/app/tests/stress/chat-history-side.e2e.ts b/packages/app/tests/stress/chat-history-side.e2e.tsnew file mode 100644index 000000000..20d5f907c--- /dev/null+++ b/packages/app/tests/stress/chat-history-side.e2e.ts@@ -0,0 +1,140 @@+import type { Page } from '@playwright/test';+import {+ expect,+ runPaletteCommand,+ stubAgentCatalog,+ test,+ threadRosterDelivered,+} from './_helpers';++const BOOT_TIMEOUT_MS = 30_000;+const AGENTS_PANEL_MOUNT = '[data-agents-panel-mount]';+const HISTORY_SURFACE = '[data-testid="agent-thread-history-surface"]';+const SESSION_SURFACE = '[data-testid="agent-panel-session-surface"]';+const TAB_ROW = `${AGENTS_PANEL_MOUNT} [data-terminal-tab-row]`;++async function openAgentsWithThread(page: Page): Promise<void> {+ await stubAgentCatalog(page);+ await page.setViewportSize({ width: 2200, height: 1000 });+ const roster = threadRosterDelivered(page);+ await page.goto('/');+ await page.waitForFunction(() => Boolean(window.__acpThreadHarness), null, {+ timeout: BOOT_TIMEOUT_MS,+ });+ await roster;+ await page.evaluate(() => {+ const harness = window.__acpThreadHarness;+ if (harness === undefined) throw new Error('ACP thread harness is not installed');+ harness.openThread({+ agent: { id: 'history-side', name: 'Side Agent', source: 'registry' },+ title: 'Side conversation',+ });+ });+ const agents = page.getByTestId('header-pane-button-agents');+ if ((await agents.getAttribute('aria-pressed')) !== 'true') await agents.click();+ await expect(page.locator(AGENTS_PANEL_MOUNT)).toBeVisible({ timeout: BOOT_TIMEOUT_MS });+}++function historyToggle(page: Page) {+ return page.locator(AGENTS_PANEL_MOUNT).getByTestId('agent-thread-history');+}++async function openHistory(page: Page): Promise<void> {+ const toggle = historyToggle(page);+ if ((await toggle.getAttribute('aria-expanded')) !== 'true') await toggle.click();+ await expect(page.locator(HISTORY_SURFACE)).toBeVisible();+}++async function historySide(page: Page): Promise<'left' | 'right' | 'unsettled'> {+ const [history, session, toggle, row] = await Promise.all([+ page.locator(HISTORY_SURFACE).boundingBox(),+ page.locator(SESSION_SURFACE).boundingBox(),+ historyToggle(page).boundingBox(),+ page.locator(TAB_ROW).boundingBox(),+ ]);+ if (history == null || session == null || toggle == null || row == null) return 'unsettled';+ const toggleNearStart = toggle.x - row.x < row.x + row.width - (toggle.x + toggle.width);+ if (history.x + history.width <= session.x + 1 && toggleNearStart) return 'left';+ if (history.x >= session.x + session.width - 1 && !toggleNearStart) return 'right';+ return 'unsettled';+}++async function expectHistory(page: Page, side: 'left' | 'right'): Promise<void> {+ await expect.poll(() => historySide(page), { timeout: BOOT_TIMEOUT_MS }).toBe(side);+}++async function expectPaletteOffersOnly(+ page: Page,+ offered: string,+ withheld: string,+): Promise<void> {+ await page.evaluate(() => {+ if (document.activeElement instanceof HTMLElement) document.activeElement.blur();+ });+ await page.keyboard.press('ControlOrMeta+k');+ const input = page.locator('[data-slot="command-input"]');+ await expect(input).toBeFocused();+ await input.fill('move chat history');+ await expect(page.getByTestId(`command-palette-${offered}`)).toBeVisible();+ await expect(page.getByTestId(`command-palette-${withheld}`)).toHaveCount(0);+ await page.keyboard.press('Escape');+ await expect(page.locator('[data-slot="command-list"]')).toBeHidden();+}++test.describe('the chat history side', () => {+ test('the palette offers only the move to the other side, and moving docked chat history and its button to the left of the conversation survives a reload', async ({+ page,+ }) => {+ await openAgentsWithThread(page);+ await openHistory(page);+ await expectHistory(page, 'right');+ await expectPaletteOffersOnly(page, 'move-chat-history-left', 'move-chat-history-right');++ await runPaletteCommand(page, 'move chat history left', 'move-chat-history-left');+ await openHistory(page);+ await expectHistory(page, 'left');++ await page.reload();+ await page.waitForFunction(() => Boolean(window.__acpThreadHarness), null, {+ timeout: BOOT_TIMEOUT_MS,+ });+ const agents = page.getByTestId('header-pane-button-agents');+ if ((await agents.getAttribute('aria-pressed')) !== 'true') await agents.click();+ await openHistory(page);+ await expectHistory(page, 'left');+ await expectPaletteOffersOnly(page, 'move-chat-history-right', 'move-chat-history-left');+ });++ test('right-clicking an empty part of the Agents tab strip moves chat history to the other side', async ({+ page,+ }) => {+ await openAgentsWithThread(page);+ await openHistory(page);+ await expectHistory(page, 'right');++ const row = await page.locator(TAB_ROW).boundingBox();+ if (row === null) throw new Error('the Agents tab strip has no layout box');+ await page.mouse.click(row.x + row.width * 0.6, row.y + row.height / 2, { button: 'right' });+ await page.getByRole('menuitem', { name: 'Move chat history to the left' }).click();+ await openHistory(page);+ await expectHistory(page, 'left');+ });++ test('choosing the move from the keyboard leaves focus on the Chat history button at its new end', async ({+ page,+ }) => {+ await openAgentsWithThread(page);+ await openHistory(page);+ await expectHistory(page, 'right');++ await historyToggle(page).focus();+ await page.keyboard.press('Shift+F10');+ const move = page.getByRole('menuitem', { name: 'Move chat history to the left' });+ await expect(move).toBeFocused();+ await page.keyboard.press('Enter');++ await expect(historyToggle(page)).toBeFocused();+ await openHistory(page);+ await expectHistory(page, 'left');+ });+});diff --git a/packages/core/src/commands/command-identity.ts b/packages/core/src/commands/command-identity.tsindex fa86990b9..e8fb41b8e 100644--- a/packages/core/src/commands/command-identity.ts+++ b/packages/core/src/commands/command-identity.ts@@ -564,6 +564,40 @@ export const COMMAND_IDENTITIES: readonly CommandIdentity[] = [availability: { singleFileHidden: true },palette: { group: 'view', visibility: 'search-only' },},+ {+ id: 'move-chat-history-left',+ labelKey: 'chatHistoryMoveLeft',+ keywords: [+ 'chat',+ 'history',+ 'conversations',+ 'agents',+ 'sidebar',+ 'move',+ 'side',+ 'left',+ 'position',+ ],+ availability: {},+ palette: { group: 'view', visibility: 'search-only' },+ },+ {+ id: 'move-chat-history-right',+ labelKey: 'chatHistoryMoveRight',+ keywords: [+ 'chat',+ 'history',+ 'conversations',+ 'agents',+ 'sidebar',+ 'move',+ 'side',+ 'right',+ 'position',+ ],+ availability: {},+ palette: { group: 'view', visibility: 'search-only' },+ },{id: 'toggle-editor',menuActionId: 'toggle-editor',diff --git a/packages/core/src/constants/menu-labels.ts b/packages/core/src/constants/menu-labels.tsindex 4c21a3092..e5d08f6a5 100644--- a/packages/core/src/constants/menu-labels.ts+++ b/packages/core/src/constants/menu-labels.ts@@ -50,6 +50,8 @@ export const MENU_LABELS = {docPanelShow: 'Show document panel',docPanelHide: 'Hide document panel',swapEditorSidebars: 'Swap file sidebar and document panel',+ chatHistoryMoveLeft: 'Move chat history to the left',+ chatHistoryMoveRight: 'Move chat history to the right',back: 'Back',forward: 'Forward',terminalShow: 'Show Terminal',