Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Move workspace panes by dragging their tab strips (#7165)

Abrahama21868907d16
diff --git a/.changeset/dock-redock-panes.md b/.changeset/dock-redock-panes.md
new file mode 100644
index 000000000..23f9bb790
--- /dev/null
+++ b/.changeset/dock-redock-panes.md
@@ -0,0 +1,5 @@
+---
+'@inkeep/open-knowledge': patch
+---
+
+Drag a panel by an empty part of its tab strip onto another panel's edge to dock it there, or onto its middle to swap the two. In the desktop app those tab strips no longer move the window; drag the header at the top of the window instead.
diff --git a/.changeset/dock-tree-workspace-panes.md b/.changeset/dock-tree-workspace-panes.md
index e6aaf8c19..b5b5b6da1 100644
--- a/.changeset/dock-tree-workspace-panes.md
+++ b/.changeset/dock-tree-workspace-panes.md
@@ -1,5 +1,5 @@
---
-"@inkeep/open-knowledge-app": minor
+'@inkeep/open-knowledge': patch
---
The editor, Agents panel and terminal now split the window by proportion, and each project remembers its own arrangement. Panes no longer close when dragged small or when another one opens; hide them with the header buttons.
diff --git a/docs/content/features/editor.mdx b/docs/content/features/editor.mdx
index 310964f12..17ed90c32 100644
--- a/docs/content/features/editor.mdx
+++ b/docs/content/features/editor.mdx
@@ -183,7 +183,7 @@ Select text in the WYSIWYG editor and the selection bubble menu shows a **Commen
## Terminal
-The desktop app on macOS, Windows, and Linux has a built-in terminal with real interactive shells inside the editor window. On Windows, the terminal requires Windows 10 version 1809 (build 17763) or later, Windows 11, or Windows Server 2019 or later. On Linux, OpenKnowledge inherits Electron's supported distribution range: releases of the major distributions that both Chromium and the distribution vendor still support. Toggle it with `Cmd+J` on macOS or `Ctrl+J` on Windows and Linux, with `` Ctrl+` `` on any desktop platform (which also works from inside a focused terminal), with **View ▸ Show / Hide Terminal**, or with the **Terminal** button at the right end of the header at the top of the window, which is highlighted while the Terminal is open. That button appears in project windows and in windows showing a single file, wherever a terminal can run and is turned on for the project; single-file windows offer it in the shared header when available. It opens where it was last placed in this project. A project with no saved arrangement uses the placement from before arrangements were saved per project, or opens it below the editor. Right-click a bottom-dock tab and choose **Move to right panel**, use the matching command in the command palette or **Terminal** menu, or use the right-panel header button to move it back to the bottom. Moving or hiding the Terminal keeps its live shells, tabs, and scrollback intact.
+The desktop app on macOS, Windows, and Linux has a built-in terminal with real interactive shells inside the editor window. On Windows, the terminal requires Windows 10 version 1809 (build 17763) or later, Windows 11, or Windows Server 2019 or later. On Linux, OpenKnowledge inherits Electron's supported distribution range: releases of the major distributions that both Chromium and the distribution vendor still support. Toggle it with `Cmd+J` on macOS or `Ctrl+J` on Windows and Linux, with `` Ctrl+` `` on any desktop platform (which also works from inside a focused terminal), with **View ▸ Show / Hide Terminal**, or with the **Terminal** button at the right end of the header at the top of the window, which is highlighted while the Terminal is open. That button appears in project windows and in windows showing a single file, wherever a terminal can run and is turned on for the project; single-file windows offer it in the shared header when available. It opens where it was last placed in this project. A project with no saved arrangement uses the placement from before arrangements were saved per project, or opens it below the editor. **Move Terminal to right** puts it to the right of the editor and **Move Terminal to bottom** puts it back below the editor; whichever applies is in the command palette, the **Terminal** menu and the button on the Terminal's tab strip, and while the Terminal is stacked above or below another panel, **Move to right panel** on a tab's right-click menu does the same as **Move Terminal to right**. Moving or hiding the Terminal keeps its live shells, tabs, and scrollback intact.
The terminal is also the editor's AI-chat surface: opening it starts your remembered CLI pick, or a plain shell when you have none, and the tab strip's **+** button opens another tab with whatever you picked last — a CLI chat or a plain shell. Its dropdown switches that pick and opens a tab in the thing you picked, in one action. A CLI pick sticks and is shared with the Ask AI composer; the plain-shell pick is remembered for the terminal only. In-app agents run in the Agents panel, which has its own tab strip and **+** button; picking an agent there sticks the same way and also becomes your Ask AI default. Each agent tab carries a dot for its chat's state: pulsing blue while the agent starts, signs in or works, amber while it waits for your approval or for you to sign in, green when it is ready (pulsing while it has activity you have not seen), red once the agent has stopped or hit an error, and grey for a past chat reopened from history. Hovering a tab shows its full title, that state in words, whether it has new activity, and when it was last active, and screen readers hear the state and any new activity as part of the tab's name. Picking a different agent while the open chat has not been sent yet switches that chat to the chosen agent and keeps what you have typed and attached; until that new chat has started, the agents in the **+** menu are greyed out, and the original chat stays if the new one cannot start (while a dropped file is still being read, the pick opens a new chat beside the original instead); a chat that already has a message keeps its agent, and the pick opens a new chat beside it. In an in-app chat, the **Add to prompt (+)** menu offers files and page mentions, plus selected comments when available. **Commands** appears when the selected agent provides commands and the prompt draft is empty. `Cmd+J` on macOS, `Ctrl+J` on Windows or Linux, and `` Ctrl+` `` on any desktop platform only show and hide the Terminal, even with text selected. With text selected in the editor, `Cmd+Shift+J` on macOS or `Ctrl+Shift+J` on Windows or Linux stages it into a new session with your preferred AI (a new CLI tab when that is a CLI); the passage sits in the input for you to add to, and nothing is submitted until you press Enter. **Terminal ▸ New Terminal Window** (see [Terminal menu](#terminal-menu)) opens a dedicated window with the same multi-session tabs, switched with `Cmd+<number>` on macOS or `Ctrl+<number>` on Windows and Linux, and shells starting at the project root.
@@ -209,6 +209,8 @@ Messages in an agent chat link the references they mention. A qualified GitHub r
The editor, the Agents panel and the terminal split the window by proportion. Drag the gap between two of them, or focus it and use the arrow keys, to change their shares; each project remembers its own arrangement. Opening a panel never closes another one to make room. Dragging a gap stops at each panel's minimum size; when there is not room for the open panels' minimum sizes, they shrink below them in proportion, so a right-side Terminal between the editor and the Agents panel can drop under 40 columns. Below 48rem only one of Editor, Agents and Terminal is shown at a time; see [Narrow windows](#narrow-windows).
+To move a panel, drag an empty part of its tab strip (the editor's row of tabs, or the Agents or Terminal tab strip) onto another panel; with only one panel open there is nowhere to move it, and the drag does nothing. Drop it within about a quarter of the way in from one of that panel's edges and it docks on that side, in the area the outline shows; drop it nearer the middle and the two panels swap places. Pressing a tab or a button in the strip starts no move, and `Esc` cancels one. In the desktop app's project and single-file windows these strips never move the window, even with one panel open, so drag the header at the top of the window to move it; note windows have no panels to move, and their header still moves the window. The command palette can also move a panel along a whole edge of the window and show it: search for **Move Editor to the left edge of the window**, **Move Agents to the left edge of the window** or **Move Terminal to the left edge of the window**, or the same for the right, top or bottom edge. These commands are not in the menus and appear only when you search, and the Terminal ones only in the desktop app, where a terminal can run. They also reach a panel whose tab strip has no empty space left to grab. **Move Terminal to right** and **Move Terminal to bottom** are different: they put the Terminal beside or below the editor.
+
The shells run at full user privilege. To turn the terminal off for a project on this machine, use **Settings ▸ Terminal** or set `terminal.enabled: false` in `.ok/local/config.yml` (see the [configuration reference](../reference/configuration.mdx)); the setting is project-local, never shared via git or sync, and not agent-settable — only a human can flip it. On Windows, set `terminal.shell` in the same file to an absolute shell executable if you want to override automatic PowerShell and `cmd.exe` discovery. PowerShell, `cmd.exe`, and Git Bash (`bash.exe`) support OpenKnowledge-managed launches (agent chat tabs and fixed commands such as **Resolve in terminal** or **Install Slidev**) and dropped-file path insertion. A different existing executable remains active for plain terminal tabs and shows a capability notice; requested agent and command launches open only the plain shell without running the agent or command, and dropped-file paths are refused. Enter WSL by running `wsl` inside a supported shell rather than setting `wsl.exe` as the override.
## Hide the editor
@@ -217,14 +219,14 @@ In a project window you can hide the editor and give the window to the Agents pa
Hiding the editor hides all of it: the file sidebar, the tabs, the document, the document panel, the status bar with the checkout line (the project folder and the branch or worktree), and the bottom [Ask AI](#ask-ai) composer. Nothing reloads. Open documents, tabs, the file sidebar and the document panel stay loaded, and showing the editor brings them back as they were.
-The panels that are still open fill the space:
+The panels that are still open take over the editor's space, shared in proportion to their sizes among the panels in the same row or column as the editor. With the Agents panel at the right and the Terminal below or to the right of the editor, where **Move Terminal to bottom** and **Move Terminal to right** put it:
-- A bottom terminal fills the column it shares with the editor, top to bottom, and beside the Agents panel that column takes the same share of the row whether the editor is shown or hidden.
-- A right-side terminal and the Agents panel divide the row in the ratio of their shares, as far as each one's minimum width allows.
+- A terminal below the editor fills the column they share, top to bottom, and beside the Agents panel that column takes the same share of the row whether the editor is shown or hidden.
+- A terminal to the right of the editor and the Agents panel divide the row in the ratio of their shares, as far as each one's minimum width allows.
- A single remaining panel fills the window.
- The Agents panel on its own keeps the conversation and the message box at a comfortable reading width, centered.
-Sizes you drag while the editor is hidden are kept. A bottom terminal shares its column with the editor, so dragging the gap beside the Agents panel also sets the editor's width; with a right-side terminal, the editor keeps its own size.
+Sizes you drag while the editor is hidden are kept. In the arrangements above, a terminal below the editor shares its column with it, so dragging the gap beside the Agents panel also sets the editor's width; with the terminal to the right of the editor, the editor keeps its own size.
Any deliberate way of opening a document shows the editor again with that document: search and quick open, links in the Agents panel and the terminal, an agent navigating, deep and share links, back and forward, creating a page, the sync badge, dialogs that open a file, and opening the document that is already active. Agent navigation includes following an agent with a chat's **Follow the agent's edits** toggle, so with it on, the next agent turn that moves to a document shows the editor again. Editor shortcuts and menu actions show the editor first and then act: the tab shortcuts, reopening or closing a tab, **New File**, **New Folder**, **New from Template…**, **Rename**, **Duplicate**, **Move to Trash**, showing or hiding the document panel or the file sidebar, the file sidebar's view options (hidden files, `.ok` folders, Markdown only, the skills section) and **Expand all** / **Collapse all**, **Skills**, **Blob Run**, **Initialize starter pack** once it applies, and **View in source**. Reloading the window or restarting the app never shows a hidden editor.
@@ -465,7 +467,7 @@ Toggling the menu checkboxes flips the underlying config field, which propagates
| --- | --- | --- |
| **New Terminal** | (none) | Opens a new terminal tab, revealing the Terminal in its current placement if it's hidden. |
| **New Terminal Window** | (none) | Opens a terminal in its own window — the same multi-session tabs, switched with `Cmd+<number>` on macOS or `Ctrl+<number>` on Windows and Linux, shells starting at the project root. |
-| **Move Terminal to right / bottom** | (none) | Moves the live Terminal workspace to the opposite placement. The label names the destination. |
+| **Move Terminal to right / bottom** | (none) | Puts the live Terminal to the right of the editor or below it. The label names the destination: **to right** while the Terminal is stacked above or below another panel, **to bottom** while it sits beside one. |
| **Kill Terminal** | (none) | Closes the active terminal tab and kills its shell. |
## Real-time collaboration
diff --git a/packages/app/src/components/DockWorkspace.dom.test.tsx b/packages/app/src/components/DockWorkspace.dom.test.tsx
index 1525746d6..8ad9303c3 100644
--- a/packages/app/src/components/DockWorkspace.dom.test.tsx
+++ b/packages/app/src/components/DockWorkspace.dom.test.tsx
@@ -101,12 +101,14 @@ function Workspace({
onTreeChange = () => {},
onLayoutChange,
units,
+ redockable,
}: {
tree: DockNode;
visible?: Record<PaneId, boolean>;
onTreeChange?: (update: (tree: DockNode) => DockNode) => void;
onLayoutChange?: (layout: DockLayout) => void;
units?: Record<PaneId, ReactNode>;
+ redockable?: boolean;
}) {
return (
<DockWorkspace
@@ -118,10 +120,84 @@ function Workspace({
paneLabel={(pane) => LABELS[pane]}
onTreeChange={onTreeChange}
onLayoutChange={onLayoutChange}
+ redockable={redockable}
/>
);
}
+const HEADED_UNITS: Record<PaneId, ReactNode> = {
+ editor: (
+ <header data-dock-handle="" data-testid="editor-handle">
+ Editor tabs
+ </header>
+ ),
+ agents: (
+ <header data-dock-handle="" data-testid="agents-handle">
+ Agent chats
+ <button type="button">New chat</button>
+ </header>
+ ),
+ terminal: (
+ <header data-dock-handle="" data-testid="terminal-handle">
+ Terminal sessions
+ </header>
+ ),
+};
+
+function RedockHarness({ visible }: { visible?: Record<PaneId, boolean> }) {
+ const [tree, setTree] = useState<DockNode>(DEFAULT_DOCK_TREE);
+ return (
+ <Workspace
+ tree={tree}
+ visible={visible}
+ onTreeChange={setTree}
+ units={HEADED_UNITS}
+ redockable
+ />
+ );
+}
+
+interface Box {
+ readonly start: number;
+ readonly top: number;
+ readonly width: number;
+ readonly height: number;
+}
+
+function box(pane: PaneId): Box {
+ return boxOf(unit(pane));
+}
+
+function boxOf(element: HTMLElement): Box {
+ return {
+ start: px(element, 'insetInlineStart'),
+ top: px(element, 'insetBlockStart'),
+ width: px(element, 'width'),
+ height: px(element, 'height'),
+ };
+}
+
+function dragHeader(
+ pane: PaneId,
+ to: { clientX: number; clientY: number },
+ { release = true }: { release?: boolean } = {},
+) {
+ const from = box(pane);
+ const handle = screen.getByTestId(`${pane}-handle`);
+ const start = { clientX: from.start + 20, clientY: from.top + 10 };
+ fireEvent.pointerDown(handle, { button: 0, buttons: 1, pointerId: 7, ...start });
+ fireEvent.pointerMove(handle, { buttons: 1, pointerId: 7, ...to });
+ if (release) fireEvent.pointerUp(handle, { pointerId: 7, ...to });
+}
+
+function chip(): HTMLElement | null {
+ return document.body.querySelector<HTMLElement>('[data-dock-drag-chip]');
+}
+
+function dropZone(): HTMLElement | null {
+ return document.querySelector<HTMLElement>('[data-dock-drop-zone]');
+}
+
describe('DockWorkspace', () => {
test('places each unit from the tree, with the gap between them', () => {
render(<Workspace tree={DEFAULT_DOCK_TREE} />);
@@ -573,3 +649,170 @@ describe('DockWorkspace', () => {
expect(px(unit('terminal'), 'insetInlineStart')).toBe(px(unit('agents'), 'insetInlineStart'));
});
});
+
+describe('DockWorkspace re-docking', () => {
+ test('dragging a tab strip onto the start edge of another unit docks it where the outline shows', () => {
+ render(<RedockHarness />);
+ const editor = box('editor');
+ const target = { clientX: editor.start + 10, clientY: editor.top + editor.height / 2 };
+
+ dragHeader('agents', target, { release: false });
+ const zone = dropZone();
+ expect(zone?.dataset).toMatchObject({ dockDropZone: 'start', dockDropPane: 'editor' });
+ if (zone === null) throw new Error('no drop zone outlined');
+ const outline = boxOf(zone);
+ expect(chip()?.textContent).toBe('Agents');
+ expect(document.querySelector('[data-redocking="agents"]')).not.toBeNull();
+ fireEvent.pointerUp(screen.getByTestId('agents-handle'), { pointerId: 7, ...target });
+
+ const agents = box('agents');
+ const moved = box('editor');
+ expect(agents).toEqual(outline);
+ expect(agents.start).toBe(editor.start);
+ expect(agents.top).toBe(moved.top);
+ expect(moved.start).toBeGreaterThan(agents.start);
+ expect(box('terminal').width).toBe(WIDTH);
+ expect(chip()).toBeNull();
+ expect(dropZone()).toBeNull();
+ });
+
+ test('dropping a tab strip on the middle of another unit trades the two places', () => {
+ render(<RedockHarness />);
+ const editor = box('editor');
+ const agents = box('agents');
+
+ dragHeader('agents', {
+ clientX: editor.start + editor.width / 2,
+ clientY: editor.top + editor.height / 2,
+ });
+
+ expect(box('agents')).toEqual(editor);
+ expect(box('editor')).toEqual(agents);
+ });
+
+ test('a press on a control inside the tab strip starts no drag', () => {
+ render(<RedockHarness />);
+ const before = layoutBoxes();
+ const editor = box('editor');
+ const button = screen.getByRole('button', { name: 'New chat' });
+ fireEvent.pointerDown(button, {
+ button: 0,
+ buttons: 1,
+ pointerId: 7,
+ clientX: 1100,
+ clientY: 10,
+ });
+ fireEvent.pointerMove(button, {
+ buttons: 1,
+ pointerId: 7,
+ clientX: editor.start + 10,
+ clientY: 300,
+ });
+ expect(chip()).toBeNull();
+ fireEvent.pointerUp(button, { pointerId: 7, clientX: editor.start + 10, clientY: 300 });
+
+ expect(layoutBoxes()).toEqual(before);
+ });
+
+ test('a press that moves less than the start distance shows no drag and leaves the layout alone', () => {
+ render(<RedockHarness />);
+ const before = layoutBoxes();
+ const agents = box('agents');
+ const nudged = { clientX: agents.start + 22, clientY: agents.top + 11 };
+
+ dragHeader('agents', nudged, { release: false });
+ expect(chip()).toBeNull();
+ expect(document.querySelector('[data-redocking]')).toBeNull();
+ fireEvent.pointerUp(screen.getByTestId('agents-handle'), { pointerId: 7, ...nudged });
+
+ expect(layoutBoxes()).toEqual(before);
+ });
+
+ test('Escape during a drag puts everything back and the release changes nothing', () => {
+ render(<RedockHarness />);
+ const before = layoutBoxes();
+ const editor = box('editor');
+ const target = { clientX: editor.start + 10, clientY: editor.top + 100 };
+
+ dragHeader('agents', target, { release: false });
+ expect(chip()).not.toBeNull();
+ expect(fireEvent.keyDown(window, { key: 'Escape' })).toBe(false);
+ expect(chip()).toBeNull();
+ expect(dropZone()).toBeNull();
+ expect(document.querySelector('[data-redocking]')).toBeNull();
+ fireEvent.pointerUp(screen.getByTestId('agents-handle'), { pointerId: 7, ...target });
+
+ expect(layoutBoxes()).toEqual(before);
+ });
+
+ test('a press whose release is lost to a context menu ends there, and a later release changes nothing', () => {
+ render(<RedockHarness />);
+ const before = layoutBoxes();
+ const agents = box('agents');
+ const editor = box('editor');
+ const handle = screen.getByTestId('agents-handle');
+ const target = { clientX: editor.start + 10, clientY: editor.top + editor.height / 2 };
+ fireEvent.pointerDown(handle, {
+ button: 0,
+ buttons: 1,
+ pointerId: 7,
+ clientX: agents.start + 20,
+ clientY: agents.top + 10,
+ });
+ fireEvent.contextMenu(handle);
+ fireEvent.pointerMove(handle, { buttons: 1, pointerId: 7, ...target });
+ expect(chip()).toBeNull();
+ fireEvent.pointerUp(handle, { pointerId: 7, ...target });
+
+ expect(layoutBoxes()).toEqual(before);
+ });
+
+ test('a move that arrives with the button already up ends the drag without a drop', () => {
+ render(<RedockHarness />);
+ const before = layoutBoxes();
+ const editor = box('editor');
+ const target = { clientX: editor.start + 10, clientY: editor.top + editor.height / 2 };
+
+ dragHeader('agents', target, { release: false });
+ expect(chip()).not.toBeNull();
+ fireEvent.pointerMove(window, { buttons: 0, pointerId: 7, ...target });
+ expect(chip()).toBeNull();
+ expect(dropZone()).toBeNull();
+ fireEvent.pointerUp(window, { pointerId: 7, ...target });
+
+ expect(layoutBoxes()).toEqual(before);
+ });
+
+ test('with one unit showing, a header drag finds nowhere to go and starts nothing', () => {
+ render(<RedockHarness visible={{ editor: true, agents: false, terminal: false }} />);
+ const editor = box('editor');
+
+ dragHeader(
+ 'editor',
+ { clientX: editor.start + 300, clientY: editor.top + 300 },
+ { release: false },
+ );
+
+ expect(chip()).toBeNull();
+ expect(dropZone()).toBeNull();
+ });
+
+ test('right to left, a drop near the physical left of the editor docks at its end', () => {
+ direction = 'rtl';
+ render(<RedockHarness />);
+ const editor = box('editor');
+ const physicalLeft = WIDTH - (editor.start + editor.width);
+ const target = { clientX: physicalLeft + 10, clientY: editor.top + editor.height / 2 };
+
+ dragHeader('terminal', target, { release: false });
+ expect(dropZone()?.dataset).toMatchObject({ dockDropZone: 'end', dockDropPane: 'editor' });
+ fireEvent.pointerUp(screen.getByTestId('terminal-handle'), { pointerId: 7, ...target });
+
+ expect(box('terminal').start).toBeGreaterThan(box('editor').start);
+ expect(box('terminal').top).toBe(box('editor').top);
+ });
+});
+
+function layoutBoxes() {
+ return { editor: box('editor'), agents: box('agents'), terminal: box('terminal') };
+}
diff --git a/packages/app/src/components/DockWorkspace.tsx b/packages/app/src/components/DockWorkspace.tsx
index 563c41fa8..6989dd159 100644
--- a/packages/app/src/components/DockWorkspace.tsx
+++ b/packages/app/src/components/DockWorkspace.tsx
@@ -10,7 +10,7 @@ import {
useRef,
useState,
} from 'react';
-import { flushSync } from 'react-dom';
+import { createPortal, flushSync } from 'react-dom';
import {
clampDockSeam,
type DockExtent,
@@ -22,12 +22,27 @@ import {
EMPTY_DOCK_LAYOUT,
layoutDock,
} from '@/lib/dock-layout';
-import { DOCK_PANES, type DockNode, resizeDockGroup, visibleDockTree } from '@/lib/dock-tree';
-import type { PaneId } from '@/lib/pane-visibility-store';
+import {
+ DOCK_PANES,
+ type DockEdge,
+ type DockNode,
+ moveDockPane,
+ resizeDockGroup,
+ swapDockPanes,
+ visibleDockTree,
+} from '@/lib/dock-tree';
+import { isPaneId, type PaneId } from '@/lib/pane-visibility-store';
import { cn } from '@/lib/utils';
const KEYBOARD_STEP_PX = 16;
const KEYBOARD_LARGE_STEP_PX = 64;
+const REDOCK_START_DISTANCE_PX = 6;
+const REDOCK_EDGE_FRACTION = 0.26;
+const REDOCK_SHARE = 0.5;
+const REDOCK_CHIP_OFFSET_PX = { x: 14, y: 12 };
+const REDOCK_HANDLE = '[data-dock-handle]';
+const REDOCK_IGNORED =
+ 'button, a[href], input, textarea, select, [role="tab"], [role="button"], [role="menuitem"], [role="combobox"], [contenteditable=""], [contenteditable="true"]';
function dockUnitId(pane: PaneId): string {
return `dock-unit-${pane}`;
@@ -42,6 +57,50 @@ interface DockWorkspaceProps {
readonly paneLabel: (pane: PaneId) => string;
readonly onTreeChange: (update: (tree: DockNode) => DockNode) => void;
readonly onLayoutChange?: (layout: DockLayout) => void;
+ readonly redockable?: boolean;
+}
+
+type DockDropZone = DockEdge | 'center';
+
+interface DockDropSpot {
+ readonly pane: PaneId;
+ readonly zone: DockDropZone;
+}
+
+interface DockDropTarget extends DockDropSpot {
+ readonly hint: DockRect;
+}
+
+interface DockRedock {
+ readonly pane: PaneId;
+ readonly client: { readonly x: number; readonly y: number };
+ readonly target: DockDropTarget | null;
+}
+
+function dropSpotAt(
+ layout: DockLayout,
+ dragged: PaneId,
+ point: { readonly x: number; readonly y: number },
+): DockDropSpot | null {
+ for (const [pane, rect] of layout.panes) {
+ if (pane === dragged) continue;
+ const fromStart = (point.x - rect.x) / rect.width;
+ const fromTop = (point.y - rect.y) / rect.height;
+ if (fromStart < 0 || fromStart > 1 || fromTop < 0 || fromTop > 1) continue;
+ const nearest = Math.min(fromStart, 1 - fromStart, fromTop, 1 - fromTop);
+ if (nearest > REDOCK_EDGE_FRACTION) return { pane, zone: 'center' };
+ if (nearest === fromStart) return { pane, zone: 'start' };
+ if (nearest === 1 - fromStart) return { pane, zone: 'end' };
+ if (nearest === fromTop) return { pane, zone: 'top' };
+ return { pane, zone: 'bottom' };
+ }
+ return null;
+}
+
+function droppedTree(tree: DockNode, dragged: PaneId, spot: DockDropSpot): DockNode {
+ return spot.zone === 'center'
+ ? swapDockPanes(tree, dragged, spot.pane)
+ : moveDockPane(tree, dragged, spot.pane, spot.zone, REDOCK_SHARE);
}
interface DockDrag {
@@ -103,6 +162,7 @@ export function DockWorkspace({
paneLabel,
onTreeChange,
onLayoutChange,
+ redockable = false,
}: DockWorkspaceProps) {
const { t } = useLingui();
const containerRef = useRef<HTMLDivElement | null>(null);
@@ -112,6 +172,8 @@ export function DockWorkspace({
() => new Map(),
);
const releaseDragRef = useRef<(() => void) | null>(null);
+ const [redock, setRedock] = useState<DockRedock | null>(null);
+ const releaseRedockRef = useRef<(() => void) | null>(null);
const onTreeChangeRef = useRef(onTreeChange);
useLayoutEffect(() => {
onTreeChangeRef.current = onTreeChange;
@@ -184,6 +246,7 @@ export function DockWorkspace({
if (dragOutlived) endOutlivedDrag();
}, [dragOutlived]);
useEffect(() => () => releaseDragRef.current?.(), []);
+ useEffect(() => () => releaseRedockRef.current?.(), []);
function isRtl(): boolean {
const element = containerRef.current;
@@ -235,6 +298,101 @@ export function DockWorkspace({
setDrag(started);
}
+ function stopRedock() {
+ releaseRedockRef.current?.();
+ releaseRedockRef.current = null;
+ setRedock(null);
+ }
+
+ const redockAt = useEffectEvent((pane: PaneId, event: globalThis.PointerEvent): DockRedock => {
+ const box = containerRef.current?.getBoundingClientRect();
+ const point =
+ box === undefined
+ ? null
+ : {
+ x: isRtl() ? box.right - event.clientX : event.clientX - box.left,
+ y: event.clientY - box.top,
+ };
+ const spot = point === null ? null : dropSpotAt(layout, pane, point);
+ const hint =
+ spot === null ? undefined : layoutOf(droppedTree(tree, pane, spot)).panes.get(pane);
+ return {
+ pane,
+ client: { x: event.clientX, y: event.clientY },
+ target: spot === null || hint === undefined ? null : { ...spot, hint },
+ };
+ });
+
+ const commitRedock = useEffectEvent((pane: PaneId, target: DockDropSpot) => {
+ onTreeChangeRef.current((current) => droppedTree(current, pane, target));
+ });
+
+ const startRedock = useEffectEvent((event: globalThis.PointerEvent) => {
+ const container = containerRef.current;
+ const pressed = event.target;
+ if (!redockable || event.button !== 0 || releaseRedockRef.current !== null) return;
+ if (container === null || !(pressed instanceof Element)) return;
+ const handle = pressed.closest(REDOCK_HANDLE);
+ const unit = handle?.closest('[data-dock-unit]');
+ if (handle == null || unit == null || !container.contains(unit)) return;
+ const ignored = pressed.closest(REDOCK_IGNORED);
+ if (ignored !== null && handle.contains(ignored)) return;
+ const pane = unit.getAttribute('data-dock-unit');
+ if (!isPaneId(pane) || !layout.panes.has(pane) || layout.panes.size < 2) return;
+ const pointerId = event.pointerId;
+ const start = { x: event.clientX, y: event.clientY };
+ let live = false;
+ const follow = (move: globalThis.PointerEvent) => {
+ if (move.pointerId !== pointerId) return;
+ if ((move.buttons & 1) === 0) {
+ stopRedock();
+ return;
+ }
+ if (!live) {
+ const travel = Math.abs(move.clientX - start.x) + Math.abs(move.clientY - start.y);
+ if (travel < REDOCK_START_DISTANCE_PX) return;
+ live = true;
+ }
+ setRedock(redockAt(pane, move));
+ };
+ const finish = (up: globalThis.PointerEvent) => {
+ if (up.pointerId !== pointerId) return;
+ const target = live ? redockAt(pane, up).target : null;
+ stopRedock();
+ if (target !== null) commitRedock(pane, target);
+ };
+ const abandon = (cancel: globalThis.PointerEvent) => {
+ if (cancel.pointerId === pointerId) stopRedock();
+ };
+ const abandonForMenu = () => stopRedock();
+ const cancelOnEscape = (key: globalThis.KeyboardEvent) => {
+ if (!live || key.key !== 'Escape') return;
+ key.preventDefault();
+ key.stopPropagation();
+ stopRedock();
+ };
+ window.addEventListener('pointermove', follow);
+ window.addEventListener('pointerup', finish);
+ window.addEventListener('pointercancel', abandon);
+ window.addEventListener('contextmenu', abandonForMenu);
+ window.addEventListener('keydown', cancelOnEscape, true);
+ releaseRedockRef.current = () => {
+ window.removeEventListener('pointermove', follow);
+ window.removeEventListener('pointerup', finish);
+ window.removeEventListener('pointercancel', abandon);
+ window.removeEventListener('contextmenu', abandonForMenu);
+ window.removeEventListener('keydown', cancelOnEscape, true);
+ };
+ });
+
+ useEffect(() => {
+ const element = containerRef.current;
+ if (element === null) return;
+ const press = (event: globalThis.PointerEvent) => startRedock(event);
+ element.addEventListener('pointerdown', press);
+ return () => element.removeEventListener('pointerdown', press);
+ }, []);
+
function resizeFromKeyboard(seam: DockSeam, event: KeyboardEvent<HTMLDivElement>) {
if (event.altKey || event.ctrlKey || event.metaKey) return;
const row = seam.direction === 'row';
@@ -256,7 +414,7 @@ export function DockWorkspace({
commitSeam(tree, seam, next);
}
- const dragging = liveDrag !== null;
+ const dragging = liveDrag !== null || redock !== null;
const seamBefore = new Map<PaneId, DockSeam>();
for (const seam of layout.seams) {
const resized = seam.after[0];
@@ -276,9 +434,10 @@ export function DockWorkspace({
hidden={shownRect === undefined}
inert={rect === undefined}
className={cn(
- 'absolute flex min-h-0 min-w-0',
+ 'absolute flex min-h-0 min-w-0 transition-opacity duration-150 ease-out motion-reduce:transition-none',
rect === undefined && 'invisible',
dragging && 'pointer-events-none',
+ redock?.pane === pane && 'opacity-50',
)}
style={shownRect === undefined ? undefined : placement(shownRect)}
>
@@ -333,7 +492,17 @@ export function DockWorkspace({
ref={containerRef}
data-dock-workspace=""
data-dragging={dragging ? '' : undefined}
- className={cn('relative min-h-0 min-w-0 flex-1', dragging && 'select-none')}
+ data-redocking={redock === null ? undefined : redock.pane}
+ className={cn(
+ 'relative min-h-0 min-w-0 flex-1',
+ dragging && 'select-none',
+ redock !== null && 'cursor-grabbing',
+ redockable && [
+ '[&_[data-dock-handle]]:select-none',
+ '[&_[data-dock-handle][data-electron-drag]]:[-webkit-app-region:no-drag]',
+ '[&_[data-dock-handle]_[data-electron-drag]]:[-webkit-app-region:no-drag]',
+ ],
+ )}
>
{DOCK_PANES.map((pane) => {
const seam = seamBefore.get(pane);
@@ -344,6 +513,31 @@ export function DockWorkspace({
</Fragment>
);
})}
+ {redock?.target == null ? null : (
+ <div
+ aria-hidden="true"
+ data-dock-drop-pane={redock.target.pane}
+ data-dock-drop-zone={redock.target.zone}
+ className="pointer-events-none absolute z-30 rounded-xl bg-primary/10 ring-2 ring-primary ring-inset outline-current -outline-offset-2 forced-colors:outline-solid forced-colors:outline-2 contrast-more:outline-solid contrast-more:outline-2"
+ style={placement(redock.target.hint)}
+ />
+ )}
+ {redock === null
+ ? null
+ : createPortal(
+ <div
+ aria-hidden="true"
+ data-dock-drag-chip=""
+ className="pointer-events-none fixed z-50 rounded-lg bg-foreground px-2.5 py-1.5 font-semibold text-background text-xs shadow-lg outline-current forced-colors:outline-solid forced-colors:outline-1"
+ style={{
+ left: redock.client.x + REDOCK_CHIP_OFFSET_PX.x,
+ top: redock.client.y + REDOCK_CHIP_OFFSET_PX.y,
+ }}
+ >
+ {paneLabel(redock.pane)}
+ </div>,
+ document.body,
+ )}
</div>
);
}
diff --git a/packages/app/src/components/EditorArea.tsx b/packages/app/src/components/EditorArea.tsx
index 336b18537..8fc00bb38 100644
--- a/packages/app/src/components/EditorArea.tsx
+++ b/packages/app/src/components/EditorArea.tsx
@@ -2213,6 +2213,7 @@ function EditorAreaInner({
paneLabel={(pane) => t(PANE_LABEL[pane])}
onTreeChange={onDockTreeChange}
onLayoutChange={setDockLayout}
+ redockable={!noteWindow}
/>
{nothingOpen ? <NothingOpen /> : null}
</div>
diff --git a/packages/app/src/components/EditorHeader.dom.test.tsx b/packages/app/src/components/EditorHeader.dom.test.tsx
index c2a4d8ed1..445feaea6 100644
--- a/packages/app/src/components/EditorHeader.dom.test.tsx
+++ b/packages/app/src/components/EditorHeader.dom.test.tsx
@@ -1,12 +1,13 @@
import { REDUCED_CHROME_HEADER_HEIGHT } from '@inkeep/open-knowledge-core';
import * as actualLinguiMacro from '@lingui/react/macro';
-import { act, cleanup, render, screen } from '@testing-library/react';
-import { type ComponentProps, type ReactNode, useEffect } from 'react';
+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { type ComponentProps, type ReactNode, useEffect, useState } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
-import { afterEach, describe, expect, test, vi } from 'vitest';
+import { afterEach, describe, expect, onTestFinished, test, vi } from 'vitest';
import { TooltipProvider } from '@/components/ui/tooltip';
import type { GitSyncStatus } from '@/hooks/use-git-sync-status';
import { ConfigContext } from '@/lib/config-context';
+import { DEFAULT_DOCK_TREE, type DockNode } from '@/lib/dock-tree';
import {
__resetPaneVisibilityStoreForTests,
type PaneVisibility,
@@ -245,7 +246,7 @@ describe('EditorHeader runtime behavior', () => {
});
for (const state of ['expanded', 'collapsed'] as const) {
- test(`an Electron project window tab row with the file list ${state} is a drag region holding only the tab strip`, async () => {
+ test(`an Electron project window tab row with the file list ${state} opts into the window drag region and holds only the tab strip`, async () => {
setElectronHost(true);
sidebarState = state;
const header = await renderHeader(<div data-testid="editor-tabs">tabs</div>);
@@ -450,6 +451,81 @@ describe('EditorHeader runtime behavior', () => {
expect(screen.queryByRole('button', { name: 'Terminal' })).toBeNull();
});
+ test('dragging the tab row onto the middle of the Agents panel trades the editor and the Agents panel', async () => {
+ const { DockWorkspace } = await import('./DockWorkspace');
+ const { EditorHeader } = await import('./EditorHeader');
+ const rects = vi
+ .spyOn(HTMLElement.prototype, 'getBoundingClientRect')
+ .mockImplementation(function (this: HTMLElement) {
+ const [width, height] = this.hasAttribute('data-dock-workspace') ? [1200, 800] : [0, 0];
+ return {
+ x: 0,
+ y: 0,
+ top: 0,
+ left: 0,
+ right: width,
+ bottom: height,
+ width,
+ height,
+ toJSON() {},
+ } as DOMRect;
+ });
+ onTestFinished(() => rects.mockRestore());
+ function Workspace() {
+ const [tree, setTree] = useState<DockNode>(DEFAULT_DOCK_TREE);
+ return (
+ <ConfigContext value={configContextWithTerminal(projectTerminal)}>
+ <TooltipProvider delayDuration={0}>
+ <DockWorkspace
+ tree={tree}
+ visible={{ editor: true, agents: true, terminal: true }}
+ units={{
+ editor: (
+ <EditorHeader>
+ <div data-testid="editor-tabs">tabs</div>
+ </EditorHeader>
+ ),
+ agents: <div>Agents</div>,
+ terminal: <div>Terminal</div>,
+ }}
+ gap={8}
+ minExtent={() => ({ width: 100, height: 100 })}
+ paneLabel={(pane) => pane}
+ onTreeChange={setTree}
+ redockable
+ />
+ </TooltipProvider>
+ </ConfigContext>
+ );
+ }
+ render(<Workspace />);
+ const placed = (pane: string) => {
+ const style = document.querySelector<HTMLElement>(`[data-dock-unit="${pane}"]`)?.style;
+ return {
+ start: Number.parseFloat(style?.insetInlineStart ?? ''),
+ top: Number.parseFloat(style?.insetBlockStart ?? ''),
+ width: Number.parseFloat(style?.width ?? ''),
+ height: Number.parseFloat(style?.height ?? ''),
+ };
+ };
+ const editor = placed('editor');
+ const agents = placed('agents');
+ expect(editor.width).toBeGreaterThan(0);
+ expect(agents.start).toBeGreaterThan(editor.start);
+ const middle = {
+ clientX: agents.start + agents.width / 2,
+ clientY: agents.top + agents.height / 2,
+ };
+ const tabs = screen.getByTestId('editor-tabs');
+
+ fireEvent.pointerDown(tabs, { button: 0, buttons: 1, pointerId: 3, clientX: 20, clientY: 10 });
+ fireEvent.pointerMove(tabs, { buttons: 1, pointerId: 3, ...middle });
+ fireEvent.pointerUp(tabs, { pointerId: 3, ...middle });
+
+ expect(placed('editor')).toEqual(agents);
+ expect(placed('agents')).toEqual(editor);
+ });
+
test('renders workspace tabs between the global action zones', async () => {
await renderHeader(<div data-testid="editor-tabs">tabs</div>);
diff --git a/packages/app/src/components/EditorHeader.tsx b/packages/app/src/components/EditorHeader.tsx
index d6a9af0d4..1767fa9ec 100644
--- a/packages/app/src/components/EditorHeader.tsx
+++ b/packages/app/src/components/EditorHeader.tsx
@@ -90,6 +90,7 @@ export function EditorHeader({ children, trailing, noteModeToggle }: EditorHeade
return (
<header
data-editor-header=""
+ data-dock-handle=""
data-electron-drag={isElectronHost ? '' : undefined}
style={
reducedChrome
diff --git a/packages/app/src/components/EditorPane.dom.test.tsx b/packages/app/src/components/EditorPane.dom.test.tsx
index 6f7c6a749..251b41d8e 100644
--- a/packages/app/src/components/EditorPane.dom.test.tsx
+++ b/packages/app/src/components/EditorPane.dom.test.tsx
@@ -32,7 +32,14 @@ import {
withDockTerminalPlacement,
writeDockArrangement,
} from '@/lib/dock-arrangement-store';
-import { type DockNode, moveDockPane } from '@/lib/dock-tree';
+import { requestDockPaneMove } from '@/lib/dock-move-requests';
+import {
+ bottomTerminalDockTree,
+ DEFAULT_CHAT_SHARE,
+ type DockNode,
+ isDockLeaf,
+ moveDockPane,
+} from '@/lib/dock-tree';
import { narrowWorkspaceSessionKey } from '@/lib/narrow-workspace-session';
import {
__resetPaneVisibilityStoreForTests,
@@ -283,10 +290,12 @@ vi.doMock('./EditorArea', () => ({
dockTree,
onDockTreeChange,
editorVisible,
+ agentsVisible,
onSessionPlacements,
}: {
ref?: Ref<MockEditorAreaHandle>;
editorVisible?: boolean;
+ agentsVisible?: boolean;
onPaneExtentChange?: () => void;
renderWorkspaceHeader?: (tabs: ReactNode, chrome: { trailing: ReactNode }) => ReactNode;
dockTree: DockNode;
@@ -300,6 +309,7 @@ vi.doMock('./EditorArea', () => ({
data-testid="editor-area"
data-terminal-placement={dockTerminalPlacement(dockTree)}
data-editor-visible={String(editorVisible)}
+ data-agents-visible={String(agentsVisible)}
>
{renderWorkspaceHeader?.(<div data-testid="workspace-tabs" />, { trailing: null })}
<ReportPlacements onSessionPlacements={onSessionPlacements} />
@@ -2773,6 +2783,103 @@ describe('EditorPane keeps each project its own dock arrangement', () => {
return keys;
}
const moveTerminalRight = (tree: DockNode) => moveDockPane(tree, 'terminal', 'editor', 'end');
+ const shape = (node: DockNode): unknown =>
+ isDockLeaf(node) ? node.pane : { [node.direction]: node.items.map((item) => shape(item.node)) };
+
+ test('a request to move Agents to the left edge docks it along the start, saves that, and shows it', async () => {
+ await renderEditorPane();
+ expect(screen.getByTestId('editor-area').getAttribute('data-agents-visible')).toBe('false');
+
+ act(() => requestDockPaneMove({ pane: 'agents', side: 'left' }));
+ await act(async () => {});
+
+ const drawn = drawnDockTrees.at(-1);
+ if (drawn === undefined) throw new Error('the editor area never drew');
+ expect(shape(drawn)).toEqual({ row: ['agents', { column: ['editor', 'terminal'] }] });
+ const saved = readDockArrangement(dockArrangementStorageKey('/tmp/project'));
+ expect(saved === null ? null : shape(saved.tree)).toEqual(shape(drawn));
+ expect(screen.getByTestId('editor-area').getAttribute('data-agents-visible')).toBe('true');
+ });
+
+ test('right to left, a request for the right edge docks the pane at the start', async () => {
+ document.documentElement.style.direction = 'rtl';
+ try {
+ await renderEditorPane();
+ act(() => requestDockPaneMove({ pane: 'agents', side: 'right' }));
+
+ const drawn = drawnDockTrees.at(-1);
+ if (drawn === undefined) throw new Error('the editor area never drew');
+ expect(shape(drawn)).toEqual({ row: ['agents', { column: ['editor', 'terminal'] }] });
+ } finally {
+ document.documentElement.style.direction = '';
+ }
+ });
+
+ test('a request to move the Terminal to the bottom edge puts it under the editor and Agents', async () => {
+ await renderEditorPane();
+ act(() => requestDockPaneMove({ pane: 'terminal', side: 'bottom' }));
+
+ const drawn = drawnDockTrees.at(-1);
+ if (drawn === undefined) throw new Error('the editor area never drew');
+ expect(shape(drawn)).toEqual({ column: [{ row: ['editor', 'agents'] }, 'terminal'] });
+ });
+
+ test('a request to move the Terminal to the right edge opens it at the share of the space it last split with the editor', async () => {
+ writeDockArrangement(dockArrangementStorageKey('/tmp/project'), {
+ tree: bottomTerminalDockTree(DEFAULT_CHAT_SHARE, 0.3),
+ terminalShares: { bottom: 0.3, right: 0.45 },
+ });
+ await renderEditorPane();
+ act(() => requestDockPaneMove({ pane: 'terminal', side: 'right' }));
+
+ const drawn = drawnDockTrees.at(-1);
+ if (drawn === undefined || isDockLeaf(drawn)) throw new Error('the editor area never drew');
+ expect(shape(drawn)).toEqual({ row: ['editor', 'agents', 'terminal'] });
+ const [editor, , terminal] = drawn.items.map((item) => item.size);
+ if (editor === undefined || terminal === undefined) throw new Error('the row lost a pane');
+ expect(terminal / (terminal + editor)).toBeCloseTo(0.45, 10);
+ });
+
+ test('a Terminal moved to an edge and back below the editor returns at the height it left with', async () => {
+ const desk = makeOkDesktopStub();
+ (window as { okDesktop?: unknown }).okDesktop = desk.stub;
+ writeDockArrangement(dockArrangementStorageKey('/tmp/project'), {
+ tree: bottomTerminalDockTree(DEFAULT_CHAT_SHARE, 0.5),
+ terminalShares: { bottom: 0.3, right: 0.45 },
+ });
+ await renderEditorPane();
+
+ act(() => requestDockPaneMove({ pane: 'terminal', side: 'left' }));
+ expect(drawnPlacement()).toBe('right');
+ act(() => desk.dispatchMenuAction('move-terminal'));
+
+ const drawn = drawnDockTrees.at(-1);
+ if (drawn === undefined || isDockLeaf(drawn)) throw new Error('the editor area never drew');
+ expect(shape(drawn)).toEqual({ row: [{ column: ['editor', 'terminal'] }, 'agents'] });
+ const column = drawn.items[0]?.node;
+ if (column === undefined || isDockLeaf(column)) throw new Error('the editor column is gone');
+ expect(column.items[1]?.size).toBeCloseTo(0.5, 10);
+ });
+
+ test('repeated trips to the right edge and back under the editor by header drag open the same sizes every time', async () => {
+ await renderEditorPane();
+ const atEdge: number[][] = [];
+
+ for (let round = 0; round < 3; round += 1) {
+ act(() => requestDockPaneMove({ pane: 'terminal', side: 'right' }));
+ const drawn = drawnDockTrees.at(-1);
+ if (drawn === undefined || isDockLeaf(drawn)) throw new Error('the editor area never drew');
+ expect(shape(drawn)).toEqual({ row: ['editor', 'agents', 'terminal'] });
+ atEdge.push(drawn.items.map((item) => Number(item.size.toFixed(9))));
+ act(() =>
+ changeDrawnDockTree?.((tree) => moveDockPane(tree, 'terminal', 'editor', 'bottom', 0.5)),
+ );
+ expect(drawnPlacement()).toBe('bottom');
+ }
+
+ expect(atEdge[1]).toEqual(atEdge[0]);
+ expect(atEdge[2]).toEqual(atEdge[0]);
+ });
test('the first layout drawn is the arrangement the project stored', async () => {
writeDockArrangement(dockArrangementStorageKey('/tmp/project'), rightTerminal());
diff --git a/packages/app/src/components/EditorPane.tsx b/packages/app/src/components/EditorPane.tsx
index a7b1bf01c..af7800854 100644
--- a/packages/app/src/components/EditorPane.tsx
+++ b/packages/app/src/components/EditorPane.tsx
@@ -42,11 +42,14 @@ import {
dockTerminalPlacement,
legacyDockArrangement,
readDockArrangement,
+ withDockPaneAtEdge,
withDockTerminalPlacement,
+ withDockTree,
writeDockArrangement,
} from '@/lib/dock-arrangement-store';
+import { type DockPaneMove, subscribeDockPaneMoves } from '@/lib/dock-move-requests';
import { readWebDockSessionOrder } from '@/lib/dock-session-persistence';
-import type { DockNode } from '@/lib/dock-tree';
+import type { DockEdge, DockNode } from '@/lib/dock-tree';
import { focusAwayFromHiddenEditor } from '@/lib/editor-hidden-focus';
import { matchesKeyboardShortcut, matchesRendererShortcut } from '@/lib/keyboard-shortcuts';
import { subscribeLocalMenuAction } from '@/lib/local-menu-action-bus';
@@ -635,10 +638,7 @@ export function EditorPane() {
});
}
function changeDockTree(update: (tree: DockNode) => DockNode) {
- updateDockArrangement((current) => {
- const tree = update(current.tree);
- return tree === current.tree ? current : { tree, terminalShares: current.terminalShares };
- });
+ updateDockArrangement((current) => withDockTree(current, update(current.tree)));
}
const dockTree = dock.arrangement.tree;
const terminalPlacement = dockTerminalPlacement(dockTree);
@@ -653,6 +653,17 @@ export function EditorPane() {
),
);
});
+ const moveDockPaneEvent = useEffectEvent(({ pane, side }: DockPaneMove) => {
+ const rtl = getComputedStyle(document.documentElement).direction === 'rtl';
+ const edge: DockEdge =
+ side === 'top' || side === 'bottom' ? side : (side === 'left') !== rtl ? 'start' : 'end';
+ updateDockArrangement((current) => withDockPaneAtEdge(current, pane, edge));
+ paneVisibilityStore.request(pane, true);
+ });
+ useEffect(() => {
+ if (noteWindow) return;
+ return subscribeDockPaneMoves(moveDockPaneEvent);
+ }, [noteWindow]);
const [agentsVisible, setAgentsVisible] = useState<boolean>(() =>
desktopBridge == null
? (readWebDockSessionOrder('agents')?.agentPanelVisible ?? false)
diff --git a/packages/app/src/components/TerminalTabStrip.dom.test.tsx b/packages/app/src/components/TerminalTabStrip.dom.test.tsx
index c8b9006ef..52d7e4113 100644
--- a/packages/app/src/components/TerminalTabStrip.dom.test.tsx
+++ b/packages/app/src/components/TerminalTabStrip.dom.test.tsx
@@ -667,7 +667,7 @@ describe('TerminalTabStrip as a card top bar', () => {
expect(row?.className).toContain('[-webkit-app-region:drag]');
});
- test('on desktop the docked strip drags the window from its empty space while every control opts out', () => {
+ test('on desktop the docked strip opts its empty space into the window drag region while every control opts out', () => {
Object.defineProperty(window, 'okDesktop', {
configurable: true,
value: { config: { mode: 'editor' } },
diff --git a/packages/app/src/components/TerminalTabStrip.tsx b/packages/app/src/components/TerminalTabStrip.tsx
index 2efeb7880..4cf00c3d0 100644
--- a/packages/app/src/components/TerminalTabStrip.tsx
+++ b/packages/app/src/components/TerminalTabStrip.tsx
@@ -272,6 +272,7 @@ export function TerminalTabStrip({
<div
ref={rowRef}
data-terminal-tab-row=""
+ data-dock-handle={draggable ? undefined : ''}
data-electron-drag={windowDragRegion ? '' : undefined}
className={cn(
'flex shrink-0 flex-row items-center gap-1 px-1.5 py-1',
diff --git a/packages/app/src/components/command-palette-commands.ts b/packages/app/src/components/command-palette-commands.ts
index 7f146eb5c..8860d3c35 100644
--- a/packages/app/src/components/command-palette-commands.ts
+++ b/packages/app/src/components/command-palette-commands.ts
@@ -2,6 +2,8 @@ import {
COMMAND_IDENTITIES,
type CommandContext,
type CommandIdentity,
+ DOCK_MOVE_COMMANDS,
+ type DockMoveSide,
evaluateCommandAvailability,
} from '@inkeep/open-knowledge-core/commands/command-identity';
import { SHOW_INSTALL_SKILL } from '@inkeep/open-knowledge-core/constants/feature-flags';
@@ -34,8 +36,10 @@ import {
MessageSquare,
Network,
Package,
+ PanelBottom,
PanelLeft,
PanelRight,
+ PanelTop,
Pencil,
Plus,
RefreshCw,
@@ -56,6 +60,7 @@ import type { ResolvedNavigationTarget } from '@/components/navigation-targets';
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 { i18n } from '@/lib/i18n';
import type { KeyboardShortcutId } from '@/lib/keyboard-shortcuts';
import { openDocInNoteWindow } from '@/lib/open-note-window';
@@ -165,6 +170,18 @@ const PALETTE_COMMAND_LABELS = {
agentPanelShow: msg`Show Agents`,
agentPanelHide: msg`Hide Agents`,
agentPanelAskSelection: msg`Ask AI About Selection`,
+ editorMoveToLeftEdge: msg`Move Editor to the left edge of the window`,
+ editorMoveToRightEdge: msg`Move Editor to the right edge of the window`,
+ editorMoveToTopEdge: msg`Move Editor to the top edge of the window`,
+ editorMoveToBottomEdge: msg`Move Editor to the bottom edge of the window`,
+ agentsMoveToLeftEdge: msg`Move Agents to the left edge of the window`,
+ agentsMoveToRightEdge: msg`Move Agents to the right edge of the window`,
+ agentsMoveToTopEdge: msg`Move Agents to the top edge of the window`,
+ agentsMoveToBottomEdge: msg`Move Agents to the bottom edge of the window`,
+ terminalMoveToLeftEdge: msg`Move Terminal to the left edge of the window`,
+ terminalMoveToRightEdge: msg`Move Terminal to the right edge of the window`,
+ terminalMoveToTopEdge: msg`Move Terminal to the top edge of the window`,
+ terminalMoveToBottomEdge: msg`Move Terminal to the bottom edge of the window`,
showHiddenFiles: msg`Show hidden files`,
showOkFolders: msg`Show .ok folders`,
showOnlyMarkdownFiles: msg`Show only markdown files`,
@@ -211,7 +228,17 @@ function paletteLabelDescriptor(
return PALETTE_COMMAND_LABELS[key];
}
+const DOCK_SIDE_ICON = {
+ left: PanelLeft,
+ right: PanelRight,
+ top: PanelTop,
+ bottom: PanelBottom,
+} as const satisfies Record<DockMoveSide, ComponentType<{ className?: string }>>;
+
const COMMAND_ICONS: Record<string, ComponentType<{ className?: string }>> = {
+ ...Object.fromEntries(
+ DOCK_MOVE_COMMANDS.map((command) => [command.id, DOCK_SIDE_ICON[command.side]]),
+ ),
'open-blob-run': Gamepad2,
'navigate-back': ChevronLeft,
'navigate-forward': ChevronRight,
@@ -264,6 +291,15 @@ const COMMAND_ICONS: Record<string, ComponentType<{ className?: string }>> = {
};
const COMMAND_DISPATCH: Record<string, (ctx: PaletteCommandContext) => void> = {
+ ...Object.fromEntries(
+ DOCK_MOVE_COMMANDS.map((command) => [
+ command.id,
+ (ctx: PaletteCommandContext) => {
+ ctx.closePalette();
+ requestDockPaneMove({ pane: command.pane, side: command.side });
+ },
+ ]),
+ ),
'open-blob-run': (ctx) => ctx.openBlobRun(),
'new-file': (ctx) => {
ctx.closePalette();
diff --git a/packages/app/src/components/command-palette-dock-moves.test.ts b/packages/app/src/components/command-palette-dock-moves.test.ts
new file mode 100644
index 000000000..ed9d4da43
--- /dev/null
+++ b/packages/app/src/components/command-palette-dock-moves.test.ts
@@ -0,0 +1,37 @@
+import { afterEach, describe, expect, test, vi } from 'vitest';
+import { type DockPaneMove, subscribeDockPaneMoves } from '@/lib/dock-move-requests';
+import { PALETTE_COMMANDS, type PaletteCommandContext } from './command-palette-commands';
+
+let stopListening: (() => void) | undefined;
+
+afterEach(() => {
+ stopListening?.();
+ stopListening = undefined;
+});
+
+describe('dock move palette commands', () => {
+ test.each([
+ ['move-agents-left', { pane: 'agents', side: 'left' }],
+ ['move-editor-bottom', { pane: 'editor', side: 'bottom' }],
+ ['move-terminal-top', { pane: 'terminal', side: 'top' }],
+ ] as const)('%s closes the palette and asks for that pane at that edge', (id, move) => {
+ const requested: DockPaneMove[] = [];
+ stopListening = subscribeDockPaneMoves((request) => requested.push(request));
+ const command = PALETTE_COMMANDS.find((entry) => entry.id === id);
+ if (command === undefined) throw new Error(`no ${id} command`);
+ const closePalette = vi.fn();
+
+ command.dispatch({ closePalette } as unknown as PaletteCommandContext);
+
+ expect(closePalette).toHaveBeenCalledOnce();
+ expect(requested).toEqual([move]);
+ });
+
+ test('the moves only show up when searched for', () => {
+ const moves = PALETTE_COMMANDS.filter((entry) =>
+ /^move-(editor|agents|terminal)-/.test(entry.id),
+ );
+ expect(moves).toHaveLength(12);
+ expect(new Set(moves.map((entry) => entry.visibility))).toEqual(new Set(['search-only']));
+ });
+});
diff --git a/packages/app/src/components/command-palette-vocabulary.test.ts b/packages/app/src/components/command-palette-vocabulary.test.ts
index ef4759cc1..3fa60bb9f 100644
--- a/packages/app/src/components/command-palette-vocabulary.test.ts
+++ b/packages/app/src/components/command-palette-vocabulary.test.ts
@@ -64,6 +64,12 @@ const INTENTS: ReadonlyArray<readonly [string, string]> = [
['close terminal', 'kill-terminal'],
['stop terminal', 'kill-terminal'],
['move terminal right', 'move-terminal'],
+ ['move chat left', 'move-agents-left'],
+ ['move ai to bottom', 'move-agents-bottom'],
+ ['move console top', 'move-terminal-top'],
+ ['move shell right', 'move-terminal-right'],
+ ['move shell right', 'move-terminal'],
+ ['move document right', 'move-editor-right'],
['open chat', 'toggle-agent-panel'],
['open agents', 'toggle-agent-panel'],
['show ai', 'toggle-agent-panel'],
diff --git a/packages/app/src/lib/command-menu-parity.uncached.test.ts b/packages/app/src/lib/command-menu-parity.uncached.test.ts
index 1f91468ad..0c59870b2 100644
--- a/packages/app/src/lib/command-menu-parity.uncached.test.ts
+++ b/packages/app/src/lib/command-menu-parity.uncached.test.ts
@@ -1,6 +1,10 @@
import { readdirSync, readFileSync } from 'node:fs';
import { join, relative } from 'node:path';
-import { COMMAND_IDENTITIES, type MenuPlatform } from '@inkeep/open-knowledge-core';
+import {
+ COMMAND_IDENTITIES,
+ DOCK_MOVE_COMMANDS,
+ type MenuPlatform,
+} from '@inkeep/open-knowledge-core';
import { describe, expect, test } from 'vitest';
import { PALETTE_COMMANDS } from '@/components/command-palette-commands';
import { APP_RESERVED_IDS, PALETTE_COMMAND_IDS } from '@/lib/command-menu-parity.test-helper';
@@ -531,6 +535,7 @@ describe('command identity registry (Phase 2b)', () => {
'open-github',
'open-docs',
'open-discord',
+ ...DOCK_MOVE_COMMANDS.map((command) => command.id),
]);
const missing = COMMAND_IDENTITIES.flatMap((cmd) =>
cmd.palette && !OVERRIDES.has(cmd.id) && cmd.menuActionId === undefined ? [cmd.id] : [],
diff --git a/packages/app/src/lib/dock-arrangement-store.test.ts b/packages/app/src/lib/dock-arrangement-store.test.ts
index f86a36822..d0d508c07 100644
--- a/packages/app/src/lib/dock-arrangement-store.test.ts
+++ b/packages/app/src/lib/dock-arrangement-store.test.ts
@@ -8,11 +8,13 @@ import {
dockTerminalPlacement,
legacyDockArrangement,
readDockArrangement,
+ withDockPaneAtEdge,
withDockTerminalPlacement,
writeDockArrangement,
} from './dock-arrangement-store.ts';
import { dockPaneMinExtent, layoutDock } from './dock-layout.ts';
import {
+ bottomTerminalDockTree,
DEFAULT_CHAT_SHARE,
DEFAULT_DOCK_TREE,
type DockNode,
@@ -434,3 +436,104 @@ describe('the first move right at a 1440px window', () => {
});
});
});
+
+describe('moving the Terminal back and forth', () => {
+ const sized = (node: DockNode): unknown =>
+ isDockLeaf(node)
+ ? node.pane
+ : {
+ [node.direction]: node.items.map((item) => [
+ Number(item.size.toFixed(9)),
+ sized(item.node),
+ ]),
+ };
+ const EDGES = ['start', 'end', 'top', 'bottom'] as const;
+ const STARTS: ReadonlyArray<
+ readonly [string, (arrangement: DockArrangement) => DockArrangement]
+ > = [
+ ...(['agents', 'editor'] as const).flatMap((pane) =>
+ EDGES.map(
+ (edge) =>
+ [
+ `${pane} along the ${edge} edge`,
+ (arrangement: DockArrangement) => withDockPaneAtEdge(arrangement, pane, edge),
+ ] as const,
+ ),
+ ),
+ [
+ 'the Terminal along the right edge',
+ (arrangement) => withDockPaneAtEdge(arrangement, 'terminal', 'end'),
+ ],
+ [
+ 'the Terminal toggled right',
+ (arrangement) => withDockTerminalPlacement(arrangement, 'right'),
+ ],
+ ];
+
+ test.each(STARTS)(
+ 'from %s, toggling the Terminal over and back keeps every size from the first round on',
+ (_name, arrange) => {
+ const start = arrange(
+ legacyDockArrangement({ widthPx: 1440, heightPx: 900 }, memoryStorage()),
+ );
+ const placement = dockTerminalPlacement(start.tree);
+ const away = placement === 'bottom' ? 'right' : 'bottom';
+ const roundTrip = (arrangement: DockArrangement) =>
+ withDockTerminalPlacement(withDockTerminalPlacement(arrangement, away), placement);
+ const first = roundTrip(start);
+ let current = first;
+ for (let round = 0; round < 5; round += 1) current = roundTrip(current);
+ expect(sized(current.tree)).toEqual(sized(first.tree));
+ expect(current.terminalShares.bottom).toBeCloseTo(first.terminalShares.bottom, 9);
+ expect(current.terminalShares.right).toBeCloseTo(first.terminalShares.right, 9);
+ },
+ );
+
+ test('a move to the right edge and back under the editor returns the arrangement it started from', () => {
+ const start = legacyDockArrangement({ widthPx: 1440, heightPx: 900 }, memoryStorage());
+ const back = withDockTerminalPlacement(withDockPaneAtEdge(start, 'terminal', 'end'), 'bottom');
+ expect(sized(back.tree)).toEqual(sized(start.tree));
+ });
+});
+
+describe('moving the Terminal to a workspace edge', () => {
+ test('a move to an edge in the Terminal’s current placement keeps the size it has', () => {
+ const arrangement: DockArrangement = {
+ tree: bottomTerminalDockTree(DEFAULT_CHAT_SHARE, 0.5),
+ terminalShares: { bottom: 0.3, right: 0.45 },
+ };
+ const moved = withDockPaneAtEdge(arrangement, 'terminal', 'bottom');
+ expect(shape(moved.tree)).toEqual({ column: [{ row: ['editor', 'agents'] }, 'terminal'] });
+ expect(rowShare(moved.tree, 'terminal')).toBeCloseTo(0.5, 10);
+ expect(moved.terminalShares).toEqual(arrangement.terminalShares);
+ });
+
+ function widthsAfterMovingToTheRightEdge(isVisible: (pane: PaneId) => boolean) {
+ const seeded = legacyDockArrangement({ widthPx: 1440, heightPx: 900 }, memoryStorage());
+ const { tree } = withDockPaneAtEdge(seeded, 'terminal', 'end');
+ const layout = layoutDock(
+ visibleDockTree(tree, isVisible),
+ { x: 0, y: 0, width: 1440, height: 900 },
+ PANE_CARD_GAP_PX,
+ dockPaneMinExtent,
+ );
+ return Object.fromEntries(
+ [...layout.panes].map(([pane, rect]) => [pane, Math.round(rect.width)]),
+ );
+ }
+
+ test('the first move to the right edge at a 1440px window opens the Terminal as wide as the first move right while Agents is closed', () => {
+ expect(widthsAfterMovingToTheRightEdge((pane) => pane !== 'agents')).toEqual({
+ editor: 696,
+ terminal: 736,
+ });
+ });
+
+ test('the first move to the right edge at a 1440px window keeps the editor’s share of the split with Agents open, down to the Agents minimum', () => {
+ expect(widthsAfterMovingToTheRightEdge(() => true)).toEqual({
+ editor: 551,
+ agents: 290,
+ terminal: 583,
+ });
+ });
+});
diff --git a/packages/app/src/lib/dock-arrangement-store.ts b/packages/app/src/lib/dock-arrangement-store.ts
index f57a2436f..358fb75a5 100644
--- a/packages/app/src/lib/dock-arrangement-store.ts
+++ b/packages/app/src/lib/dock-arrangement-store.ts
@@ -4,12 +4,19 @@ import {
bottomTerminalDockTree,
DEFAULT_BOTTOM_TERMINAL_SHARE,
DEFAULT_CHAT_SHARE,
+ DOCK_EDGE_SHARE,
+ type DockDirection,
+ type DockEdge,
type DockNode,
+ dockEdgeDirection,
dockPaneDirection,
- dockPaneHeirShare,
+ dockPaneExtent,
moveDockPane,
+ moveDockPaneToEdge,
parseDockTree,
+ withoutDockPane,
} from './dock-tree';
+import type { PaneId } from './pane-visibility-store';
import { scopedStorageKey } from './storage-scope';
import { readTerminalHeight } from './terminal-height-store';
import { readTerminalPlacement } from './terminal-placement-store';
@@ -159,28 +166,71 @@ export function legacyDockArrangement(
return seededDockArrangement(workspace, legacyStorage(storage));
}
+const PLACEMENT_DIRECTION = {
+ bottom: 'column',
+ right: 'row',
+} as const satisfies Record<TerminalPlacement, DockDirection>;
+
export function dockTerminalPlacement(tree: DockNode): TerminalPlacement {
return dockPaneDirection(tree, 'terminal') === 'column' ? 'bottom' : 'right';
}
+function terminalShareWithEditor(tree: DockNode, placement: TerminalPlacement): number | null {
+ const direction = PLACEMENT_DIRECTION[placement];
+ const terminal = dockPaneExtent(tree, 'terminal', direction);
+ const editor = dockPaneExtent(tree, 'editor', direction);
+ return terminal === null || editor === null ? null : terminal / (terminal + editor);
+}
+
+export function withDockTree(arrangement: DockArrangement, tree: DockNode): DockArrangement {
+ if (tree === arrangement.tree) return arrangement;
+ const leaving = dockTerminalPlacement(arrangement.tree);
+ const leavingShare =
+ dockTerminalPlacement(tree) === leaving
+ ? null
+ : terminalShareWithEditor(arrangement.tree, leaving);
+ return {
+ tree,
+ terminalShares:
+ leavingShare === null
+ ? arrangement.terminalShares
+ : { ...arrangement.terminalShares, [leaving]: leavingShare },
+ };
+}
+
export function withDockTerminalPlacement(
arrangement: DockArrangement,
placement: TerminalPlacement,
): DockArrangement {
- const leaving = dockTerminalPlacement(arrangement.tree);
- if (leaving === placement) return arrangement;
- const leavingShare = dockPaneHeirShare(arrangement.tree, 'terminal');
- return {
- tree: moveDockPane(
+ if (dockTerminalPlacement(arrangement.tree) === placement) return arrangement;
+ return withDockTree(
+ arrangement,
+ moveDockPane(
arrangement.tree,
'terminal',
'editor',
placement === 'bottom' ? 'bottom' : 'end',
arrangement.terminalShares[placement],
),
- terminalShares:
- leavingShare === null
- ? arrangement.terminalShares
- : { ...arrangement.terminalShares, [leaving]: leavingShare },
- };
+ );
+}
+
+function terminalEdgeShare(arrangement: DockArrangement, edge: DockEdge): number {
+ const direction = dockEdgeDirection(edge);
+ const placement: TerminalPlacement = direction === 'row' ? 'right' : 'bottom';
+ const current = dockPaneExtent(arrangement.tree, 'terminal', direction);
+ if (dockTerminalPlacement(arrangement.tree) === placement && current !== null) return current;
+ const share = arrangement.terminalShares[placement];
+ const rest = withoutDockPane(arrangement.tree, 'terminal');
+ const editor = rest === null ? null : dockPaneExtent(rest, 'editor', direction);
+ return editor === null ? share : (share * editor) / (1 - share + share * editor);
+}
+
+export function withDockPaneAtEdge(
+ arrangement: DockArrangement,
+ pane: PaneId,
+ edge: DockEdge,
+): DockArrangement {
+ const share = pane === 'terminal' ? terminalEdgeShare(arrangement, edge) : DOCK_EDGE_SHARE[pane];
+ return withDockTree(arrangement, moveDockPaneToEdge(arrangement.tree, pane, edge, share));
}
diff --git a/packages/app/src/lib/dock-move-requests.ts b/packages/app/src/lib/dock-move-requests.ts
new file mode 100644
index 000000000..7a2a4181f
--- /dev/null
+++ b/packages/app/src/lib/dock-move-requests.ts
@@ -0,0 +1,20 @@
+import type { DockMoveSide } from '@inkeep/open-knowledge-core/commands/command-identity';
+import type { PaneId } from '@/lib/pane-visibility-store';
+
+export interface DockPaneMove {
+ readonly pane: PaneId;
+ readonly side: DockMoveSide;
+}
+
+const handlers = new Set<(move: DockPaneMove) => void>();
+
+export function requestDockPaneMove(move: DockPaneMove): void {
+ for (const handler of handlers) handler(move);
+}
+
+export function subscribeDockPaneMoves(handler: (move: DockPaneMove) => void): () => void {
+ handlers.add(handler);
+ return () => {
+ handlers.delete(handler);
+ };
+}
diff --git a/packages/app/src/lib/dock-tree.test.ts b/packages/app/src/lib/dock-tree.test.ts
index d95b58ae2..660a35523 100644
--- a/packages/app/src/lib/dock-tree.test.ts
+++ b/packages/app/src/lib/dock-tree.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, test } from 'vitest';
import {
+ DEFAULT_BOTTOM_TERMINAL_SHARE,
DEFAULT_DOCK_TREE,
type DockGroup,
type DockNode,
@@ -8,9 +9,11 @@ import {
isDockLeaf,
isVisibleDockLeaf,
moveDockPane,
+ moveDockPaneToEdge,
normalizeDockTree,
parseDockTree,
resizeDockGroup,
+ swapDockPanes,
type VisibleDockGroup,
visibleDockTree,
} from './dock-tree.ts';
@@ -317,3 +320,111 @@ describe('moveDockPane', () => {
expect(moveDockPane(DEFAULT_DOCK_TREE, 'editor', 'editor', 'end')).toBe(DEFAULT_DOCK_TREE);
});
});
+
+describe('moveDockPaneToEdge', () => {
+ test('puts chat along the start edge, beside the editor and terminal column', () => {
+ const moved = moveDockPaneToEdge(DEFAULT_DOCK_TREE, 'agents', 'start', 0.3);
+ expect(shape(moved)).toEqual({ row: ['agents', { column: ['editor', 'terminal'] }] });
+ expect(sizes(moved)).toEqual([0.3, 0.7]);
+ });
+
+ test('puts the terminal along the bottom edge, under the editor and chat', () => {
+ const moved = moveDockPaneToEdge(DEFAULT_DOCK_TREE, 'terminal', 'bottom', 0.25);
+ expect(shape(moved)).toEqual({ column: [{ row: ['editor', 'agents'] }, 'terminal'] });
+ expect(sizes(moved)).toEqual([0.75, 0.25]);
+ });
+
+ test('puts the editor along the top edge, over a row the other two now share', () => {
+ const moved = moveDockPaneToEdge(DEFAULT_DOCK_TREE, 'editor', 'top', 0.6);
+ expect(shape(moved)).toEqual({ column: ['editor', { row: ['terminal', 'agents'] }] });
+ });
+
+ test('a pane already along that whole edge stays put at its size, and one only at the end of a nested row still moves', () => {
+ expect(moveDockPaneToEdge(DEFAULT_DOCK_TREE, 'agents', 'end', 0.5)).toBe(DEFAULT_DOCK_TREE);
+ const bottomEdgeTerminal = moveDockPaneToEdge(DEFAULT_DOCK_TREE, 'terminal', 'bottom', 0.25);
+ expect(moveDockPaneToEdge(bottomEdgeTerminal, 'terminal', 'bottom', 0.4)).toBe(
+ bottomEdgeTerminal,
+ );
+ expect(shape(moveDockPaneToEdge(bottomEdgeTerminal, 'agents', 'end', 0.3))).toEqual({
+ row: [{ column: ['editor', 'terminal'] }, 'agents'],
+ });
+ expect(shape(moveDockPaneToEdge(bottomEdgeTerminal, 'terminal', 'end', 0.3))).toEqual({
+ row: ['editor', 'agents', 'terminal'],
+ });
+ expect(shape(moveDockPaneToEdge(DEFAULT_DOCK_TREE, 'terminal', 'end', 0.3))).toEqual({
+ row: ['editor', 'agents', 'terminal'],
+ });
+ });
+
+ test('every edge keeps all three panes, each once, in a tree that reads back', () => {
+ const edges = ['start', 'end', 'top', 'bottom'] as const;
+ const panes: PaneId[] = ['editor', 'agents', 'terminal'];
+ for (const pane of panes) {
+ for (const edge of edges) {
+ const moved = moveDockPaneToEdge(DEFAULT_DOCK_TREE, pane, edge, 1 / 3);
+ expect(dockTreePanes(moved).toSorted()).toEqual(['agents', 'editor', 'terminal']);
+ expect(parseDockTree(JSON.parse(JSON.stringify(moved)))).not.toBeNull();
+ }
+ }
+ });
+});
+
+describe('giving space back when a pane leaves', () => {
+ const sized = (node: DockNode): unknown =>
+ isDockLeaf(node)
+ ? node.pane
+ : {
+ [node.direction]: node.items.map((item) => [
+ Number(item.size.toFixed(9)),
+ sized(item.node),
+ ]),
+ };
+
+ test('a pane docked along a whole edge gives its space back to every other pane, also after the tree is read back', () => {
+ const atEdge = moveDockPaneToEdge(DEFAULT_DOCK_TREE, 'terminal', 'end', 0.3);
+ const readBack = parseDockTree(JSON.parse(JSON.stringify(atEdge)));
+ if (readBack === null) throw new Error('expected the tree to read back');
+ for (const tree of [atEdge, readBack]) {
+ const back = moveDockPane(
+ tree,
+ 'terminal',
+ 'editor',
+ 'bottom',
+ DEFAULT_BOTTOM_TERMINAL_SHARE,
+ );
+ expect(sized(back)).toEqual(sized(DEFAULT_DOCK_TREE));
+ }
+ });
+
+ test('a pane docked beside another gives its space back to it, even when it ends up at the end of the window', () => {
+ const besideEditor = moveDockPane(
+ moveDockPaneToEdge(DEFAULT_DOCK_TREE, 'agents', 'start', 0.3),
+ 'terminal',
+ 'editor',
+ 'end',
+ 0.4,
+ );
+ expect(shape(besideEditor)).toEqual({ row: ['agents', 'editor', 'terminal'] });
+ const back = moveDockPane(besideEditor, 'terminal', 'editor', 'bottom', 0.5);
+ expect(sizes(back)).toEqual([0.3, 0.7]);
+ });
+
+ test('dropping a pane on the far half of its neighbour changes only those two panes', () => {
+ const rightTerminal = moveDockPane(DEFAULT_DOCK_TREE, 'terminal', 'editor', 'end', 0.4);
+ const moved = moveDockPane(rightTerminal, 'editor', 'terminal', 'end');
+ expect(shape(moved)).toEqual({ row: ['terminal', 'editor', 'agents'] });
+ expect(sizes(moved)[2]).toBe(sizes(rightTerminal)[2]);
+ });
+});
+
+describe('swapDockPanes', () => {
+ test('trades the places of two panes and keeps every size', () => {
+ const sizeShape = (node: DockNode): unknown =>
+ isDockLeaf(node)
+ ? null
+ : node.items.map((item) => [Number(item.size.toFixed(4)), sizeShape(item.node)]);
+ const swapped = swapDockPanes(DEFAULT_DOCK_TREE, 'editor', 'agents');
+ expect(shape(swapped)).toEqual({ row: [{ column: ['agents', 'terminal'] }, 'editor'] });
+ expect(sizeShape(swapped)).toEqual(sizeShape(DEFAULT_DOCK_TREE));
+ });
+});
diff --git a/packages/app/src/lib/dock-tree.ts b/packages/app/src/lib/dock-tree.ts
index b0154f6c3..3ed2784bd 100644
--- a/packages/app/src/lib/dock-tree.ts
+++ b/packages/app/src/lib/dock-tree.ts
@@ -11,6 +11,7 @@ export interface DockLeaf {
interface DockItem {
readonly size: number;
readonly node: DockNode;
+ readonly alongEdge?: true;
}
export interface DockGroup {
@@ -52,6 +53,11 @@ const MAX_DOCK_DEPTH = DOCK_PANES.length;
export const DEFAULT_CHAT_SHARE = 1 / 3.5;
export const DEFAULT_BOTTOM_TERMINAL_SHARE = 1 / 3.3;
+export const DOCK_EDGE_SHARE = {
+ editor: 1 - DEFAULT_CHAT_SHARE,
+ agents: DEFAULT_CHAT_SHARE,
+} as const satisfies Record<Exclude<PaneId, 'terminal'>, number>;
+
export function bottomTerminalDockTree(chatShare: number, terminalShare: number): DockGroup {
return {
direction: 'row',
@@ -84,7 +90,7 @@ export function isVisibleDockLeaf(node: VisibleDockNode): node is VisibleDockLea
return 'pane' in node;
}
-function dockEdgeDirection(edge: DockEdge): DockDirection {
+export function dockEdgeDirection(edge: DockEdge): DockDirection {
return edge === 'start' || edge === 'end' ? 'row' : 'column';
}
@@ -106,11 +112,11 @@ function parseDockNode(value: unknown, depth: number): DockNode | null {
const items: DockItem[] = [];
for (const raw of record.items) {
if (typeof raw !== 'object' || raw === null) return null;
- const { size, node } = raw as Record<string, unknown>;
+ const { size, node, alongEdge } = raw as Record<string, unknown>;
if (typeof size !== 'number' || !Number.isFinite(size) || size <= 0) return null;
const child = parseDockNode(node, depth + 1);
if (child === null) return null;
- items.push({ size, node: child });
+ items.push(alongEdge === true ? { size, node: child, alongEdge } : { size, node: child });
}
return { direction: record.direction, items };
}
@@ -135,7 +141,7 @@ export function parseDockTree(value: unknown): DockNode | null {
function normalizedItems(items: readonly DockItem[]): DockItem[] {
const total = items.reduce((sum, item) => sum + item.size, 0);
- return items.map((item) => ({ size: item.size / total, node: item.node }));
+ return items.map((item) => ({ ...item, size: item.size / total }));
}
export function normalizeDockTree(node: DockNode): DockNode {
@@ -145,10 +151,10 @@ export function normalizeDockTree(node: DockNode): DockNode {
const child = normalizeDockTree(item.node);
if (!isDockLeaf(child) && child.direction === node.direction) {
for (const nested of child.items) {
- items.push({ size: item.size * nested.size, node: nested.node });
+ items.push({ ...nested, size: item.size * nested.size });
}
} else {
- items.push({ size: item.size, node: child });
+ items.push({ ...item, node: child });
}
}
const only = items[0];
@@ -203,7 +209,7 @@ function replaceAt(tree: DockNode, path: DockPath, next: DockNode): DockNode {
return {
direction: tree.direction,
items: tree.items.map((item, index) =>
- index === slot ? { size: item.size, node: replaceAt(item.node, rest, next) } : item,
+ index === slot ? { ...item, node: replaceAt(item.node, rest, next) } : item,
),
};
}
@@ -226,9 +232,7 @@ export function resizeDockGroup(
if (visibleTotal <= 0 || shareTotal <= 0) return tree;
const items = group.items.map((item, slot) => {
const share = shares.get(slot);
- return share === undefined
- ? item
- : { size: (share / shareTotal) * visibleTotal, node: item.node };
+ return share === undefined ? item : { ...item, size: (share / shareTotal) * visibleTotal };
});
return replaceAt(tree, path, { direction: group.direction, items: normalizedItems(items) });
}
@@ -237,31 +241,32 @@ function heirIndex(index: number): number {
return index > 0 ? index - 1 : index + 1;
}
-function withoutPane(node: DockNode, pane: PaneId): DockNode | null {
+export function withoutDockPane(node: DockNode, pane: PaneId): DockNode | null {
if (isDockLeaf(node)) return node.pane === pane ? null : node;
- const kept = node.items.map((item) => ({ size: item.size, node: withoutPane(item.node, pane) }));
- const removed = kept.findIndex((item) => item.node === null);
- const heir = kept[heirIndex(removed)];
- const gone = kept[removed];
- if (heir !== undefined && gone !== undefined) heir.size += gone.size;
- const items = kept.flatMap((item) =>
- item.node === null ? [] : [{ size: item.size, node: item.node }],
- );
+ const kept = node.items.map((item) => ({ item, node: withoutDockPane(item.node, pane) }));
+ const removed = kept.findIndex((entry) => entry.node === null);
+ const gone = kept[removed]?.item;
+ const heir = gone?.alongEdge ? undefined : kept[heirIndex(removed)];
+ const items = kept.flatMap(({ item, node: child }) => {
+ if (child === null) return [];
+ const size = item.size + (gone !== undefined && heir?.item === item ? gone.size : 0);
+ return [{ ...item, size, node: child }];
+ });
const only = items[0];
if (items.length === 1 && only !== undefined) return only.node;
if (items.length === 0) return null;
- return { direction: node.direction, items };
+ return { direction: node.direction, items: gone?.alongEdge ? normalizedItems(items) : items };
}
-export function dockPaneHeirShare(tree: DockNode, pane: PaneId): number | null {
- if (isDockLeaf(tree)) return null;
- const index = tree.items.findIndex((item) => isDockLeaf(item.node) && item.node.pane === pane);
- const item = tree.items[index];
- const heir = tree.items[heirIndex(index)];
- if (item !== undefined && heir !== undefined) return item.size / (item.size + heir.size);
- for (const child of tree.items) {
- const share = dockPaneHeirShare(child.node, pane);
- if (share !== null) return share;
+export function dockPaneExtent(
+ node: DockNode,
+ pane: PaneId,
+ direction: DockDirection,
+): number | null {
+ if (isDockLeaf(node)) return node.pane === pane ? 1 : null;
+ for (const item of node.items) {
+ const inner = dockPaneExtent(item.node, pane, direction);
+ if (inner !== null) return node.direction === direction ? item.size * inner : inner;
}
return null;
}
@@ -283,7 +288,7 @@ function withPaneBeside(
const index = node.items.findIndex((item) => isDockLeaf(item.node) && item.node.pane === target);
const item = node.items[index];
if (item !== undefined && node.direction === direction) {
- const kept: DockItem = { size: item.size * (1 - share), node: item.node };
+ const kept: DockItem = { ...item, size: item.size * (1 - share) };
const placed: DockItem = { size: item.size * share, node: { pane } };
const items = [...node.items];
items.splice(index, 1, ...(edgeLeads(edge) ? [placed, kept] : [kept, placed]));
@@ -292,7 +297,7 @@ function withPaneBeside(
return {
direction: node.direction,
items: node.items.map((child) => ({
- size: child.size,
+ ...child,
node: withPaneBeside(child.node, target, pane, edge, share),
})),
};
@@ -310,11 +315,45 @@ export function moveDockPane(
share = 0.5,
): DockNode {
if (pane === target) return tree;
- const rest = withoutPane(tree, pane);
+ const rest = withoutDockPane(tree, pane);
if (rest === null || !dockTreePanes(rest).includes(target)) return tree;
return normalizeDockTree(withPaneBeside(rest, target, pane, edge, clampDockShare(share)));
}
+function isAlongEdge(tree: DockNode, pane: PaneId, edge: DockEdge): boolean {
+ if (isDockLeaf(tree) || tree.direction !== dockEdgeDirection(edge)) return false;
+ const outer = edgeLeads(edge) ? tree.items[0] : tree.items.at(-1);
+ return outer !== undefined && isDockLeaf(outer.node) && outer.node.pane === pane;
+}
+
+export function moveDockPaneToEdge(
+ tree: DockNode,
+ pane: PaneId,
+ edge: DockEdge,
+ share: number,
+): DockNode {
+ if (isAlongEdge(tree, pane, edge)) return tree;
+ const rest = withoutDockPane(tree, pane);
+ if (rest === null) return tree;
+ const placed: DockItem = { size: clampDockShare(share), node: { pane }, alongEdge: true };
+ const kept: DockItem = { size: 1 - placed.size, node: rest };
+ return normalizeDockTree({
+ direction: dockEdgeDirection(edge),
+ items: edgeLeads(edge) ? [placed, kept] : [kept, placed],
+ });
+}
+
+export function swapDockPanes(node: DockNode, a: PaneId, b: PaneId): DockNode {
+ if (isDockLeaf(node)) {
+ if (node.pane === a) return { pane: b };
+ return node.pane === b ? { pane: a } : node;
+ }
+ return {
+ direction: node.direction,
+ items: node.items.map((item) => ({ ...item, node: swapDockPanes(item.node, a, b) })),
+ };
+}
+
export function dockPaneDirection(tree: DockNode, pane: PaneId): DockDirection | null {
if (isDockLeaf(tree)) return null;
for (const item of tree.items) {
diff --git a/packages/app/src/lib/pane-visibility-store.ts b/packages/app/src/lib/pane-visibility-store.ts
index 7e028ea94..aaf5a5ea0 100644
--- a/packages/app/src/lib/pane-visibility-store.ts
+++ b/packages/app/src/lib/pane-visibility-store.ts
@@ -1,4 +1,6 @@
-export type PaneId = 'editor' | 'agents' | 'terminal';
+import type { PaneId } from '@inkeep/open-knowledge-core/terminal-layout';
+
+export type { PaneId } from '@inkeep/open-knowledge-core/terminal-layout';
export function assertNeverPaneId(pane: never): never {
throw new Error(`unhandled pane: ${String(pane)}`);
diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.po
index a9d8208c6..fad45ea78 100644
--- a/packages/app/src/locales/ar/messages.po
+++ b/packages/app/src/locales/ar/messages.po
@@ -6333,6 +6333,18 @@ msgstr "نقل {0} مهارات إلى المشروع"
msgid "Move across"
msgstr "تنتقل"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "نقل الوكلاء إلى الحافة السفلية للنافذة"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "نقل الوكلاء إلى الحافة اليسرى للنافذة"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "نقل الوكلاء إلى الحافة اليمنى للنافذة"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "نقل الوكلاء إلى الحافة العلوية للنافذة"
+
msgid "Move between table cells"
msgstr "التنقل بين خلايا الجدول"
@@ -6342,6 +6354,18 @@ msgstr "نقل الكتلة"
msgid "Move down"
msgstr "تحريك لأسفل"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "نقل المحرر إلى الحافة السفلية للنافذة"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "نقل المحرر إلى الحافة اليسرى للنافذة"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "نقل المحرر إلى الحافة اليمنى للنافذة"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "نقل المحرر إلى الحافة العلوية للنافذة"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "انقل OpenKnowledge.app إلى سلة المهملات"
@@ -6357,6 +6381,18 @@ msgstr "نقل Terminal إلى الأسفل"
msgid "Move Terminal to right"
msgstr "نقل Terminal إلى اليمين"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "نقل Terminal إلى الحافة السفلية للنافذة"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "نقل Terminal إلى الحافة اليسرى للنافذة"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "نقل Terminal إلى الحافة اليمنى للنافذة"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "نقل Terminal إلى الحافة العلوية للنافذة"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "انقل الكتلة الحالية إلى أعلى أو أسفل. في القوائم، انقل العنصر الحالي أو العناصر المحددة."
diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.po
index af00237d1..d769b3b6b 100644
--- a/packages/app/src/locales/bn/messages.po
+++ b/packages/app/src/locales/bn/messages.po
@@ -6329,6 +6329,18 @@ msgstr "{0}টি স্কিল প্রকল্পে সরান"
msgid "Move across"
msgstr "সরে যাবে"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "এজেন্ট উইন্ডোর নিচের প্রান্তে সরান"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "এজেন্ট উইন্ডোর বাম প্রান্তে সরান"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "এজেন্ট উইন্ডোর ডান প্রান্তে সরান"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "এজেন্ট উইন্ডোর উপরের প্রান্তে সরান"
+
msgid "Move between table cells"
msgstr "টেবিলের ঘরগুলোর মধ্যে সরুন"
@@ -6338,6 +6350,18 @@ msgstr "ব্লক সরান"
msgid "Move down"
msgstr "নিচে সরান"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "সম্পাদক উইন্ডোর নিচের প্রান্তে সরান"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "সম্পাদক উইন্ডোর বাম প্রান্তে সরান"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "সম্পাদক উইন্ডোর ডান প্রান্তে সরান"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "সম্পাদক উইন্ডোর উপরের প্রান্তে সরান"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "OpenKnowledge.app ট্র্যাশে সরান"
@@ -6353,6 +6377,18 @@ msgstr "Terminal নিচে সরান"
msgid "Move Terminal to right"
msgstr "Terminal ডান দিকে সরান"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Terminal উইন্ডোর নিচের প্রান্তে সরান"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Terminal উইন্ডোর বাম প্রান্তে সরান"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Terminal উইন্ডোর ডান প্রান্তে সরান"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Terminal উইন্ডোর উপরের প্রান্তে সরান"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "বর্তমান ব্লকটি উপরে বা নিচে সরান। তালিকায়, বর্তমান আইটেম বা নির্বাচিত আইটেমগুলি সরান।"
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 6f2a29dc8..27240b16a 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -6333,6 +6333,18 @@ msgstr "Move {0} to Project"
msgid "Move across"
msgstr "Move across"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "Move Agents to the bottom edge of the window"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "Move Agents to the left edge of the window"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "Move Agents to the right edge of the window"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "Move Agents to the top edge of the window"
+
msgid "Move between table cells"
msgstr "Move between table cells"
@@ -6342,6 +6354,18 @@ msgstr "Move block"
msgid "Move down"
msgstr "Move down"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "Move Editor to the bottom edge of the window"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "Move Editor to the left edge of the window"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "Move Editor to the right edge of the window"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "Move Editor to the top edge of the window"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "Move OpenKnowledge.app to the Trash"
@@ -6357,6 +6381,18 @@ msgstr "Move Terminal to bottom"
msgid "Move Terminal to right"
msgstr "Move Terminal to right"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Move Terminal to the bottom edge of the window"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Move Terminal to the left edge of the window"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Move Terminal to the right edge of the window"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Move Terminal to the top edge of the window"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "Move the current block up or down. In lists, move the current item or selected items."
diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.po
index 04145a678..0263cb769 100644
--- a/packages/app/src/locales/es/messages.po
+++ b/packages/app/src/locales/es/messages.po
@@ -6333,6 +6333,18 @@ msgstr "Mover {0} a Proyecto"
msgid "Move across"
msgstr "Se trasladan"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "Mover Agentes al borde inferior de la ventana"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "Mover Agentes al borde izquierdo de la ventana"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "Mover Agentes al borde derecho de la ventana"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "Mover Agentes al borde superior de la ventana"
+
msgid "Move between table cells"
msgstr "Moverse entre celdas de la tabla"
@@ -6342,6 +6354,18 @@ msgstr "Mover el bloque"
msgid "Move down"
msgstr "Bajar"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "Mover Editor al borde inferior de la ventana"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "Mover Editor al borde izquierdo de la ventana"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "Mover Editor al borde derecho de la ventana"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "Mover Editor al borde superior de la ventana"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "Mueve OpenKnowledge.app a la Papelera"
@@ -6357,6 +6381,18 @@ msgstr "Mover Terminal a la parte inferior"
msgid "Move Terminal to right"
msgstr "Mover Terminal a la derecha"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Mover Terminal al borde inferior de la ventana"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Mover Terminal al borde izquierdo de la ventana"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Mover Terminal al borde derecho de la ventana"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Mover Terminal al borde superior de la ventana"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "Mueve el bloque actual hacia arriba o hacia abajo. En las listas, mueve el elemento actual o los elementos seleccionados."
diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.po
index f7295b89a..e39825289 100644
--- a/packages/app/src/locales/fr/messages.po
+++ b/packages/app/src/locales/fr/messages.po
@@ -6333,6 +6333,18 @@ msgstr "Déplacer {0} vers Projet"
msgid "Move across"
msgstr "Déplacées"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "Déplacer les agents vers le bord inférieur de la fenêtre"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "Déplacer les agents vers le bord gauche de la fenêtre"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "Déplacer les agents vers le bord droit de la fenêtre"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "Déplacer les agents vers le bord supérieur de la fenêtre"
+
msgid "Move between table cells"
msgstr "Se déplacer entre les cellules du tableau"
@@ -6342,6 +6354,18 @@ msgstr "Déplacer le bloc"
msgid "Move down"
msgstr "Descendre"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "Déplacer l’éditeur vers le bord inférieur de la fenêtre"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "Déplacer l’éditeur vers le bord gauche de la fenêtre"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "Déplacer l’éditeur vers le bord droit de la fenêtre"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "Déplacer l’éditeur vers le bord supérieur de la fenêtre"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "Placez OpenKnowledge.app dans la Corbeille"
@@ -6357,6 +6381,18 @@ msgstr "Déplacer Terminal en bas"
msgid "Move Terminal to right"
msgstr "Déplacer Terminal à droite"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Déplacer Terminal vers le bord inférieur de la fenêtre"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Déplacer Terminal vers le bord gauche de la fenêtre"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Déplacer Terminal vers le bord droit de la fenêtre"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Déplacer Terminal vers le bord supérieur de la fenêtre"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "Déplace le bloc courant vers le haut ou vers le bas. Dans les listes, déplace l’élément courant ou les éléments sélectionnés."
diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.po
index 32d31ebea..586bd2248 100644
--- a/packages/app/src/locales/hi/messages.po
+++ b/packages/app/src/locales/hi/messages.po
@@ -6329,6 +6329,18 @@ msgstr "{0} स्किलें प्रोजेक्ट में ले
msgid "Move across"
msgstr "स्थानांतरित होंगी"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "एजेंट को विंडो के निचले किनारे पर ले जाएँ"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "एजेंट को विंडो के बाएँ किनारे पर ले जाएँ"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "एजेंट को विंडो के दाएँ किनारे पर ले जाएँ"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "एजेंट को विंडो के ऊपरी किनारे पर ले जाएँ"
+
msgid "Move between table cells"
msgstr "तालिका की कोशिकाओं के बीच जाएँ"
@@ -6338,6 +6350,18 @@ msgstr "ब्लॉक हिलाएँ"
msgid "Move down"
msgstr "नीचे ले जाएँ"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "संपादक को विंडो के निचले किनारे पर ले जाएँ"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "संपादक को विंडो के बाएँ किनारे पर ले जाएँ"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "संपादक को विंडो के दाएँ किनारे पर ले जाएँ"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "संपादक को विंडो के ऊपरी किनारे पर ले जाएँ"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "OpenKnowledge.app को ट्रैश में ले जाएँ"
@@ -6353,6 +6377,18 @@ msgstr "Terminal को नीचे ले जाएँ"
msgid "Move Terminal to right"
msgstr "Terminal को दाईं ओर ले जाएँ"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Terminal को विंडो के निचले किनारे पर ले जाएँ"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Terminal को विंडो के बाएँ किनारे पर ले जाएँ"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Terminal को विंडो के दाएँ किनारे पर ले जाएँ"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Terminal को विंडो के ऊपरी किनारे पर ले जाएँ"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "मौजूदा ब्लॉक को ऊपर या नीचे ले जाएँ। सूचियों में, मौजूदा आइटम या चुने हुए आइटम ले जाएँ।"
diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.po
index 18b77e7f5..e76797266 100644
--- a/packages/app/src/locales/id/messages.po
+++ b/packages/app/src/locales/id/messages.po
@@ -6329,6 +6329,18 @@ msgstr "Pindahkan {0} ke Proyek"
msgid "Move across"
msgstr "Dipindahkan"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "Pindahkan Agen ke tepi bawah jendela"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "Pindahkan Agen ke tepi kiri jendela"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "Pindahkan Agen ke tepi kanan jendela"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "Pindahkan Agen ke tepi atas jendela"
+
msgid "Move between table cells"
msgstr "Berpindah antarsel tabel"
@@ -6338,6 +6350,18 @@ msgstr "Pindahkan blok"
msgid "Move down"
msgstr "Turunkan"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "Pindahkan Penyunting ke tepi bawah jendela"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "Pindahkan Penyunting ke tepi kiri jendela"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "Pindahkan Penyunting ke tepi kanan jendela"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "Pindahkan Penyunting ke tepi atas jendela"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "Pindahkan OpenKnowledge.app ke Tong Sampah"
@@ -6353,6 +6377,18 @@ msgstr "Pindahkan Terminal ke bawah"
msgid "Move Terminal to right"
msgstr "Pindahkan Terminal ke kanan"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Pindahkan Terminal ke tepi bawah jendela"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Pindahkan Terminal ke tepi kiri jendela"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Pindahkan Terminal ke tepi kanan jendela"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Pindahkan Terminal ke tepi atas jendela"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "Pindahkan blok saat ini ke atas atau ke bawah. Dalam daftar, pindahkan item saat ini atau item yang dipilih."
diff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.po
index 4fc8ecd0d..922079f86 100644
--- a/packages/app/src/locales/ko/messages.po
+++ b/packages/app/src/locales/ko/messages.po
@@ -6333,6 +6333,18 @@ msgstr "스킬 {0}개를 프로젝트로 이동"
msgid "Move across"
msgstr "이동됨"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "에이전트를 창 아래쪽 가장자리로 이동"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "에이전트를 창 왼쪽 가장자리로 이동"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "에이전트를 창 오른쪽 가장자리로 이동"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "에이전트를 창 위쪽 가장자리로 이동"
+
msgid "Move between table cells"
msgstr "표 셀 사이를 이동합니다."
@@ -6342,6 +6354,18 @@ msgstr "블록 이동"
msgid "Move down"
msgstr "아래로 이동"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "편집기를 창 아래쪽 가장자리로 이동"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "편집기를 창 왼쪽 가장자리로 이동"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "편집기를 창 오른쪽 가장자리로 이동"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "편집기를 창 위쪽 가장자리로 이동"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "OpenKnowledge.app을 휴지통으로 이동하세요"
@@ -6357,6 +6381,18 @@ msgstr "터미널을 아래로 이동"
msgid "Move Terminal to right"
msgstr "터미널을 오른쪽으로 이동"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "터미널을 창 아래쪽 가장자리로 이동"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "터미널을 창 왼쪽 가장자리로 이동"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "터미널을 창 오른쪽 가장자리로 이동"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "터미널을 창 위쪽 가장자리로 이동"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "현재 블록을 위나 아래로 이동합니다. 목록에서는 현재 항목이나 선택한 항목을 이동합니다."
diff --git a/packages/app/src/locales/pl/messages.po b/packages/app/src/locales/pl/messages.po
index 82aeedf88..e4d6fb22c 100644
--- a/packages/app/src/locales/pl/messages.po
+++ b/packages/app/src/locales/pl/messages.po
@@ -6333,6 +6333,18 @@ msgstr "Przenieś {0} do projektu"
msgid "Move across"
msgstr "Przenieś w inne miejsce"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "Przenieś agentów do dolnej krawędzi okna"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "Przenieś agentów do lewej krawędzi okna"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "Przenieś agentów do prawej krawędzi okna"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "Przenieś agentów do górnej krawędzi okna"
+
msgid "Move between table cells"
msgstr "Przenoszenie między komórkami tabeli"
@@ -6342,6 +6354,18 @@ msgstr "Przenieś blok"
msgid "Move down"
msgstr "Przenieś w dół"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "Przenieś edytor do dolnej krawędzi okna"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "Przenieś edytor do lewej krawędzi okna"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "Przenieś edytor do prawej krawędzi okna"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "Przenieś edytor do górnej krawędzi okna"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "Przenieś OpenKnowledge.app do Kosza"
@@ -6357,6 +6381,18 @@ msgstr "Przenieś terminal na dół"
msgid "Move Terminal to right"
msgstr "Przenieś terminal na prawo"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Przenieś terminal do dolnej krawędzi okna"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Przenieś terminal do lewej krawędzi okna"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Przenieś terminal do prawej krawędzi okna"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Przenieś terminal do górnej krawędzi okna"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "Przenieś bieżący blok w górę lub w dół. Na listach przenieś bieżący element lub zaznaczone elementy."
diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.po
index c36bf8938..168b9059b 100644
--- a/packages/app/src/locales/pt-BR/messages.po
+++ b/packages/app/src/locales/pt-BR/messages.po
@@ -6329,6 +6329,18 @@ msgstr "Mover {0} para Projeto"
msgid "Move across"
msgstr "São movidas"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "Mover Agentes para a borda inferior da janela"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "Mover Agentes para a borda esquerda da janela"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "Mover Agentes para a borda direita da janela"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "Mover Agentes para a borda superior da janela"
+
msgid "Move between table cells"
msgstr "Mover entre as células da tabela"
@@ -6338,6 +6350,18 @@ msgstr "Mover o bloco"
msgid "Move down"
msgstr "Mover para baixo"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "Mover o Editor para a borda inferior da janela"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "Mover o Editor para a borda esquerda da janela"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "Mover o Editor para a borda direita da janela"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "Mover o Editor para a borda superior da janela"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "Mova OpenKnowledge.app para o Lixo"
@@ -6353,6 +6377,18 @@ msgstr "Mover o Terminal para a parte inferior"
msgid "Move Terminal to right"
msgstr "Mover o Terminal para a direita"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Mover o Terminal para a borda inferior da janela"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Mover o Terminal para a borda esquerda da janela"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Mover o Terminal para a borda direita da janela"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Mover o Terminal para a borda superior da janela"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "Move o bloco atual para cima ou para baixo. Nas listas, move o item atual ou os itens selecionados."
diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.po
index 6a0c4b8e8..6ab667672 100644
--- a/packages/app/src/locales/ur/messages.po
+++ b/packages/app/src/locales/ur/messages.po
@@ -6333,6 +6333,18 @@ msgstr "{0} مہارتیں پروجیکٹ میں منتقل کریں"
msgid "Move across"
msgstr "منتقل ہوں گی"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "ایجنٹس کو ونڈو کے نچلے کنارے پر منتقل کریں"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "ایجنٹس کو ونڈو کے بائیں کنارے پر منتقل کریں"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "ایجنٹس کو ونڈو کے دائیں کنارے پر منتقل کریں"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "ایجنٹس کو ونڈو کے اوپری کنارے پر منتقل کریں"
+
msgid "Move between table cells"
msgstr "ٹیبل کے خانوں کے درمیان جائیں"
@@ -6342,6 +6354,18 @@ msgstr "بلاک منتقل کریں"
msgid "Move down"
msgstr "نیچے لے جائیں"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "ایڈیٹر کو ونڈو کے نچلے کنارے پر منتقل کریں"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "ایڈیٹر کو ونڈو کے بائیں کنارے پر منتقل کریں"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "ایڈیٹر کو ونڈو کے دائیں کنارے پر منتقل کریں"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "ایڈیٹر کو ونڈو کے اوپری کنارے پر منتقل کریں"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "OpenKnowledge.app کو کوڑے دان میں منتقل کریں"
@@ -6357,6 +6381,18 @@ msgstr "Terminal کو نیچے منتقل کریں"
msgid "Move Terminal to right"
msgstr "Terminal کو دائیں منتقل کریں"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "Terminal کو ونڈو کے نچلے کنارے پر منتقل کریں"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "Terminal کو ونڈو کے بائیں کنارے پر منتقل کریں"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "Terminal کو ونڈو کے دائیں کنارے پر منتقل کریں"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "Terminal کو ونڈو کے اوپری کنارے پر منتقل کریں"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "موجودہ بلاک کو اوپر یا نیچے منتقل کریں۔ فہرستوں میں، موجودہ آئٹم یا منتخب آئٹمز کو منتقل کریں۔"
diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.po
index f99316a9e..d6fd20d6e 100644
--- a/packages/app/src/locales/zh-Hans/messages.po
+++ b/packages/app/src/locales/zh-Hans/messages.po
@@ -6333,6 +6333,18 @@ msgstr "将 {0} 个技能移至项目"
msgid "Move across"
msgstr "移动过去"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "将「智能体」移到窗口底部边缘"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "将「智能体」移到窗口左边缘"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "将「智能体」移到窗口右边缘"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "将「智能体」移到窗口顶部边缘"
+
msgid "Move between table cells"
msgstr "在表格单元格之间移动"
@@ -6342,6 +6354,18 @@ msgstr "移动块"
msgid "Move down"
msgstr "下移"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "将编辑器移到窗口底部边缘"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "将编辑器移到窗口左边缘"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "将编辑器移到窗口右边缘"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "将编辑器移到窗口顶部边缘"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "将 OpenKnowledge.app 移到废纸篓"
@@ -6357,6 +6381,18 @@ msgstr "将 Terminal 移到底部"
msgid "Move Terminal to right"
msgstr "将 Terminal 移到右侧"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "将 Terminal 移到窗口底部边缘"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "将 Terminal 移到窗口左边缘"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "将 Terminal 移到窗口右边缘"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "将 Terminal 移到窗口顶部边缘"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "向上或向下移动当前块。在列表中,移动当前项或所选项。"
diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.po
index 4f7998b71..a61f43bc8 100644
--- a/packages/app/src/locales/zh-Hant/messages.po
+++ b/packages/app/src/locales/zh-Hant/messages.po
@@ -6333,6 +6333,18 @@ msgstr "將 {0} 個技能移至專案"
msgid "Move across"
msgstr "移動過去"
+msgid "Move Agents to the bottom edge of the window"
+msgstr "將「代理」移到視窗底部邊緣"
+
+msgid "Move Agents to the left edge of the window"
+msgstr "將「代理」移到視窗左邊緣"
+
+msgid "Move Agents to the right edge of the window"
+msgstr "將「代理」移到視窗右邊緣"
+
+msgid "Move Agents to the top edge of the window"
+msgstr "將「代理」移到視窗頂部邊緣"
+
msgid "Move between table cells"
msgstr "在表格儲存格之間移動"
@@ -6342,6 +6354,18 @@ msgstr "移動區塊"
msgid "Move down"
msgstr "下移"
+msgid "Move Editor to the bottom edge of the window"
+msgstr "將編輯器移到視窗底部邊緣"
+
+msgid "Move Editor to the left edge of the window"
+msgstr "將編輯器移到視窗左邊緣"
+
+msgid "Move Editor to the right edge of the window"
+msgstr "將編輯器移到視窗右邊緣"
+
+msgid "Move Editor to the top edge of the window"
+msgstr "將編輯器移到視窗頂部邊緣"
+
msgid "Move OpenKnowledge.app to the Trash"
msgstr "將 OpenKnowledge.app 移到垃圾桶"
@@ -6357,6 +6381,18 @@ msgstr "將 Terminal 移到底部"
msgid "Move Terminal to right"
msgstr "將 Terminal 移到右側"
+msgid "Move Terminal to the bottom edge of the window"
+msgstr "將 Terminal 移到視窗底部邊緣"
+
+msgid "Move Terminal to the left edge of the window"
+msgstr "將 Terminal 移到視窗左邊緣"
+
+msgid "Move Terminal to the right edge of the window"
+msgstr "將 Terminal 移到視窗右邊緣"
+
+msgid "Move Terminal to the top edge of the window"
+msgstr "將 Terminal 移到視窗頂部邊緣"
+
msgid "Move the current block up or down. In lists, move the current item or selected items."
msgstr "將目前的區塊向上或向下移動。在清單中,移動目前的項目或所選項目。"
diff --git a/packages/app/tests/stress/dock-redock.e2e.ts b/packages/app/tests/stress/dock-redock.e2e.ts
new file mode 100644
index 000000000..7304759ae
--- /dev/null
+++ b/packages/app/tests/stress/dock-redock.e2e.ts
@@ -0,0 +1,199 @@
+import type { Page } from '@playwright/test';
+import {
+ type DockUnitRect,
+ dockUnitRect,
+ expect,
+ type HeaderPane,
+ identityOf,
+ openDesktopLayout,
+ openWebLayout,
+ runPaletteCommand,
+ SAME_NODE,
+ setHeaderPane,
+ test,
+ waitForActiveProviderSynced,
+} from './_helpers';
+
+const VIEWPORT = { width: 1600, height: 900 };
+const CHIP = '[data-dock-drag-chip]';
+
+async function seedDoc(
+ api: { seedDocs: (docs: { name: string; markdown: string }[]) => Promise<unknown> },
+ slug: string,
+) {
+ const name = `dock-redock-${slug}-${test.info().workerIndex}`;
+ await api.seedDocs([{ name, markdown: `# ${name}\n\nRe-docking fixture.\n` }]);
+ return name;
+}
+
+async function rectOf(page: Page, pane: HeaderPane): Promise<DockUnitRect> {
+ const rect = await dockUnitRect(page, pane);
+ if (rect === null) throw new Error(`the ${pane} unit is not showing`);
+ return rect;
+}
+
+async function grabPoint(page: Page, pane: HeaderPane): Promise<{ x: number; y: number }> {
+ const point = await page.evaluate((target) => {
+ const handle = document.querySelector(`[data-dock-unit="${target}"] [data-dock-handle]`);
+ if (!(handle instanceof HTMLElement)) return null;
+ const box = handle.getBoundingClientRect();
+ const y = box.top + box.height / 2;
+ const controls =
+ 'button, a[href], input, textarea, select, [role="tab"], [role="button"], [role="menuitem"], [role="combobox"]';
+ for (let x = box.right - 6; x > box.left; x -= 6) {
+ const hit = document.elementFromPoint(x, y);
+ if (hit === null || !handle.contains(hit)) continue;
+ const control = hit.closest(controls);
+ if (control === null || !handle.contains(control)) return { x, y };
+ }
+ return null;
+ }, pane);
+ if (point === null) throw new Error(`the ${pane} tab strip has no free spot to grab`);
+ return point;
+}
+
+async function dragHeaderTo(
+ page: Page,
+ pane: HeaderPane,
+ to: { x: number; y: number },
+ whileDragging?: () => Promise<void>,
+): Promise<void> {
+ const from = await grabPoint(page, pane);
+ await page.mouse.move(from.x, from.y);
+ await page.mouse.down();
+ await page.mouse.move(to.x, to.y, { steps: 10 });
+ await whileDragging?.();
+ await page.mouse.up();
+}
+
+async function agentsSitsLeftOfEditor(page: Page): Promise<boolean> {
+ const agents = await dockUnitRect(page, 'agents');
+ const editor = await dockUnitRect(page, 'editor');
+ return agents !== null && editor !== null && agents.x + agents.width <= editor.x;
+}
+
+test.describe('re-docking a pane by its tab strip', () => {
+ test('dragging the Agents tab strip onto the left half of the editor docks it there, and a reload keeps it', async ({
+ page,
+ api,
+ }) => {
+ const docName = await seedDoc(api, 'left-of-editor');
+ await openWebLayout(page, docName, VIEWPORT);
+ await setHeaderPane(page, 'agents', true);
+ expect(await agentsSitsLeftOfEditor(page)).toBe(false);
+ const editor = await rectOf(page, 'editor');
+
+ await dragHeaderTo(
+ page,
+ 'agents',
+ { x: editor.x + 40, y: editor.y + editor.height / 2 },
+ async () => {
+ await expect(
+ page.locator('[data-dock-drop-zone="start"][data-dock-drop-pane="editor"]'),
+ ).toBeVisible();
+ await expect(page.locator(CHIP)).toHaveText('Agents');
+ },
+ );
+
+ await expect(page.locator(CHIP)).toHaveCount(0);
+ await expect.poll(() => agentsSitsLeftOfEditor(page)).toBe(true);
+
+ await page.reload();
+ await waitForActiveProviderSynced(page);
+ await setHeaderPane(page, 'agents', true);
+ await expect.poll(() => agentsSitsLeftOfEditor(page)).toBe(true);
+ });
+
+ test('dropping the Agents tab strip on the middle of the editor swaps the two', async ({
+ page,
+ api,
+ }) => {
+ const docName = await seedDoc(api, 'swap');
+ await openWebLayout(page, docName, VIEWPORT);
+ await setHeaderPane(page, 'agents', true);
+ const editor = await rectOf(page, 'editor');
+ const agents = await rectOf(page, 'agents');
+
+ await dragHeaderTo(page, 'agents', {
+ x: editor.x + editor.width / 2,
+ y: editor.y + editor.height / 2,
+ });
+
+ await expect.poll(async () => (await rectOf(page, 'agents')).x).toBeCloseTo(editor.x, 0);
+ expect((await rectOf(page, 'agents')).width).toBeCloseTo(editor.width, 0);
+ expect((await rectOf(page, 'editor')).width).toBeCloseTo(agents.width, 0);
+ });
+
+ test('Escape cancels a drag, and the release leaves the layout as it was', async ({
+ page,
+ api,
+ }) => {
+ const docName = await seedDoc(api, 'escape');
+ await openWebLayout(page, docName, VIEWPORT);
+ await setHeaderPane(page, 'agents', true);
+ const before = { agents: await rectOf(page, 'agents'), editor: await rectOf(page, 'editor') };
+
+ await dragHeaderTo(
+ page,
+ 'agents',
+ { x: before.editor.x + 40, y: before.editor.y + 200 },
+ async () => {
+ await expect(page.locator(CHIP)).toBeVisible();
+ await page.keyboard.press('Escape');
+ await expect(page.locator(CHIP)).toHaveCount(0);
+ },
+ );
+
+ expect({ agents: await rectOf(page, 'agents'), editor: await rectOf(page, 'editor') }).toEqual(
+ before,
+ );
+ });
+
+ test('the palette moves Agents to the left edge and shows it', async ({ page, api }) => {
+ const docName = await seedDoc(api, 'palette');
+ await openWebLayout(page, docName, VIEWPORT);
+ await expect(page.locator('[data-dock-unit="agents"]')).toHaveAttribute(
+ 'data-dock-unit-off',
+ '',
+ );
+
+ await runPaletteCommand(page, 'Move Agents to the left', 'move-agents-left');
+
+ await expect.poll(() => agentsSitsLeftOfEditor(page)).toBe(true);
+ });
+
+ test('dragging the Terminal tab strip onto the bottom half of Agents docks it under Agents without restarting it', async ({
+ page,
+ api,
+ workerServer,
+ }) => {
+ const docName = await seedDoc(api, 'terminal-under-agents');
+ await openDesktopLayout(page, workerServer, docName, {
+ viewport: VIEWPORT,
+ terminalPlacement: 'bottom',
+ });
+ await setHeaderPane(page, 'agents', true);
+ await setHeaderPane(page, 'terminal', true);
+ const mount = await page.locator('[data-terminal-panel-mount]').elementHandle();
+ if (mount === null) throw new Error('no terminal mount');
+ const agents = await rectOf(page, 'agents');
+
+ await dragHeaderTo(page, 'terminal', {
+ x: agents.x + agents.width / 2,
+ y: agents.y + agents.height - 40,
+ });
+
+ await expect
+ .poll(async () => {
+ const terminal = await rectOf(page, 'terminal');
+ const above = await rectOf(page, 'agents');
+ return (
+ terminal.y >= above.y + above.height &&
+ Math.abs(terminal.x - above.x) <= 1 &&
+ Math.abs(terminal.width - above.width) <= 1
+ );
+ })
+ .toBe(true);
+ expect(await identityOf(mount, page.locator('[data-terminal-panel-mount]'))).toEqual(SAME_NODE);
+ });
+});
diff --git a/packages/core/src/commands/command-identity.test.ts b/packages/core/src/commands/command-identity.test.ts
index 3011f35f6..57830711f 100644
--- a/packages/core/src/commands/command-identity.test.ts
+++ b/packages/core/src/commands/command-identity.test.ts
@@ -3,6 +3,7 @@ import { MENU_LABELS } from '../constants/menu-labels.ts';
import {
COMMAND_IDENTITIES,
type CommandContext,
+ DOCK_MOVE_COMMANDS,
evaluateCommandAvailability,
} from './command-identity.ts';
@@ -106,7 +107,16 @@ describe('COMMAND_IDENTITIES registry invariants', () => {
(command) => command.palette && command.availability.requiresTerminalCapability,
).map((command) => command.id);
- expect(gatedIds).toEqual(['toggle-terminal', 'new-terminal', 'move-terminal', 'kill-terminal']);
+ expect(gatedIds).toEqual([
+ 'toggle-terminal',
+ 'new-terminal',
+ 'move-terminal',
+ 'kill-terminal',
+ 'move-terminal-left',
+ 'move-terminal-right',
+ 'move-terminal-top',
+ 'move-terminal-bottom',
+ ]);
});
test('the menu-only terminal window command declares the terminal capability gate', () => {
@@ -168,3 +178,38 @@ describe('COMMAND_IDENTITIES registry invariants', () => {
}
});
});
+
+describe('dock move commands', () => {
+ test('every pane can be moved to every edge, each by one search-only command', () => {
+ const moves = DOCK_MOVE_COMMANDS.map((command) => `${command.pane}:${command.side}`);
+ expect(moves.toSorted()).toEqual(
+ ['editor', 'agents', 'terminal']
+ .flatMap((pane) => ['left', 'right', 'top', 'bottom'].map((side) => `${pane}:${side}`))
+ .toSorted(),
+ );
+ for (const command of DOCK_MOVE_COMMANDS) {
+ const identity = COMMAND_IDENTITIES.find((entry) => entry.id === command.id);
+ expect(identity?.palette?.visibility).toBe('search-only');
+ }
+ });
+
+ test.each([
+ ['move-editor-left', 'Move Editor to the left edge of the window'],
+ ['move-editor-right', 'Move Editor to the right edge of the window'],
+ ['move-editor-top', 'Move Editor to the top edge of the window'],
+ ['move-editor-bottom', 'Move Editor to the bottom edge of the window'],
+ ['move-agents-left', 'Move Agents to the left edge of the window'],
+ ['move-agents-right', 'Move Agents to the right edge of the window'],
+ ['move-agents-top', 'Move Agents to the top edge of the window'],
+ ['move-agents-bottom', 'Move Agents to the bottom edge of the window'],
+ ['move-terminal-left', 'Move Terminal to the left edge of the window'],
+ ['move-terminal-right', 'Move Terminal to the right edge of the window'],
+ ['move-terminal-top', 'Move Terminal to the top edge of the window'],
+ ['move-terminal-bottom', 'Move Terminal to the bottom edge of the window'],
+ ])('%s is labelled "%s"', (id, label) => {
+ const identity = COMMAND_IDENTITIES.find((entry) => entry.id === id);
+ expect(identity?.labelKey === undefined ? undefined : MENU_LABELS[identity.labelKey]).toBe(
+ label,
+ );
+ });
+});
diff --git a/packages/core/src/commands/command-identity.ts b/packages/core/src/commands/command-identity.ts
index e92ae6c57..8c6a12b98 100644
--- a/packages/core/src/commands/command-identity.ts
+++ b/packages/core/src/commands/command-identity.ts
@@ -1,4 +1,5 @@
import type { MenuLabelKey } from '../constants/menu-labels.ts';
+import type { PaneId } from '../terminal-layout.ts';
export type CommandGroup = 'commands' | 'project' | 'file' | 'view' | 'terminal' | 'app';
@@ -131,6 +132,75 @@ export interface CommandIdentity {
readonly menu?: readonly CommandMenuPlacement[];
}
+export type DockMoveSide = 'left' | 'right' | 'top' | 'bottom';
+
+export interface DockMoveCommand {
+ readonly id: string;
+ readonly pane: PaneId;
+ readonly side: DockMoveSide;
+ readonly labelKey: MenuLabelKey;
+}
+
+const DOCK_MOVE_LABELS = {
+ editor: {
+ left: 'editorMoveToLeftEdge',
+ right: 'editorMoveToRightEdge',
+ top: 'editorMoveToTopEdge',
+ bottom: 'editorMoveToBottomEdge',
+ },
+ agents: {
+ left: 'agentsMoveToLeftEdge',
+ right: 'agentsMoveToRightEdge',
+ top: 'agentsMoveToTopEdge',
+ bottom: 'agentsMoveToBottomEdge',
+ },
+ terminal: {
+ left: 'terminalMoveToLeftEdge',
+ right: 'terminalMoveToRightEdge',
+ top: 'terminalMoveToTopEdge',
+ bottom: 'terminalMoveToBottomEdge',
+ },
+} as const satisfies Record<PaneId, Record<DockMoveSide, MenuLabelKey>>;
+
+const DOCK_MOVE_PANE_ALIASES = {
+ editor: ['document'],
+ agents: ['chat', 'ai'],
+ terminal: ['shell', 'console'],
+} as const satisfies Record<PaneId, readonly string[]>;
+
+const DOCK_MOVE_SIDES: readonly DockMoveSide[] = ['left', 'right', 'top', 'bottom'];
+
+export const DOCK_MOVE_COMMANDS: readonly DockMoveCommand[] = (
+ Object.keys(DOCK_MOVE_LABELS) as PaneId[]
+).flatMap((pane) =>
+ DOCK_MOVE_SIDES.map((side) => ({
+ id: `move-${pane}-${side}`,
+ pane,
+ side,
+ labelKey: DOCK_MOVE_LABELS[pane][side],
+ })),
+);
+
+function dockMoveIdentity(command: DockMoveCommand): CommandIdentity {
+ const terminal = command.pane === 'terminal';
+ return {
+ id: command.id,
+ labelKey: command.labelKey,
+ keywords: [
+ 'move',
+ 'dock',
+ 'pane',
+ 'layout',
+ 'edge',
+ command.pane,
+ ...DOCK_MOVE_PANE_ALIASES[command.pane],
+ command.side,
+ ],
+ availability: terminal ? { host: 'desktop', requiresTerminalCapability: true } : {},
+ palette: { group: terminal ? 'terminal' : 'view', visibility: 'search-only' },
+ };
+}
+
export const COMMAND_IDENTITIES: readonly CommandIdentity[] = [
{
id: 'open-blob-run',
@@ -614,7 +684,7 @@ export const COMMAND_IDENTITIES: readonly CommandIdentity[] = [
id: 'move-terminal',
menuActionId: 'move-terminal',
labelKey: 'terminalMoveRight',
- keywords: ['terminal', 'move', 'dock', 'right', 'bottom', 'placement'],
+ keywords: ['terminal', 'shell', 'console', 'move', 'dock', 'right', 'bottom', 'placement'],
placementToggle: {
bottomKey: 'terminalMoveRight',
rightKey: 'terminalMoveBottom',
@@ -701,4 +771,5 @@ export const COMMAND_IDENTITIES: readonly CommandIdentity[] = [
},
],
},
+ ...DOCK_MOVE_COMMANDS.map(dockMoveIdentity),
];
diff --git a/packages/core/src/constants/menu-labels.ts b/packages/core/src/constants/menu-labels.ts
index 79a1337c5..20b536c9f 100644
--- a/packages/core/src/constants/menu-labels.ts
+++ b/packages/core/src/constants/menu-labels.ts
@@ -60,6 +60,18 @@ export const MENU_LABELS = {
agentPanelShow: 'Show Agents',
agentPanelHide: 'Hide Agents',
agentPanelAskSelection: 'Ask AI About Selection',
+ editorMoveToLeftEdge: 'Move Editor to the left edge of the window',
+ editorMoveToRightEdge: 'Move Editor to the right edge of the window',
+ editorMoveToTopEdge: 'Move Editor to the top edge of the window',
+ editorMoveToBottomEdge: 'Move Editor to the bottom edge of the window',
+ agentsMoveToLeftEdge: 'Move Agents to the left edge of the window',
+ agentsMoveToRightEdge: 'Move Agents to the right edge of the window',
+ agentsMoveToTopEdge: 'Move Agents to the top edge of the window',
+ agentsMoveToBottomEdge: 'Move Agents to the bottom edge of the window',
+ terminalMoveToLeftEdge: 'Move Terminal to the left edge of the window',
+ terminalMoveToRightEdge: 'Move Terminal to the right edge of the window',
+ terminalMoveToTopEdge: 'Move Terminal to the top edge of the window',
+ terminalMoveToBottomEdge: 'Move Terminal to the bottom edge of the window',
installClaudeDesktop: 'Install for Claude Chat & Cowork (Desktop App)',
} as const satisfies Record<string, string>;
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index dd5cfe5f9..5dcd4797e 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -185,6 +185,9 @@ export {
type CommandPalettePresence,
type CommandStateToggle,
type ContextualTargetKind,
+ DOCK_MOVE_COMMANDS,
+ type DockMoveCommand,
+ type DockMoveSide,
evaluateCommandAvailability,
type MenuPlatform,
type MenuSection,
diff --git a/packages/core/src/terminal-layout.ts b/packages/core/src/terminal-layout.ts
index e8530ce29..a6d7bdef6 100644
--- a/packages/core/src/terminal-layout.ts
+++ b/packages/core/src/terminal-layout.ts
@@ -1,3 +1,5 @@
+export type PaneId = 'editor' | 'agents' | 'terminal';
+
export const TERMINAL_PLACEMENTS = ['bottom', 'right'] as const;
export type TerminalPlacement = (typeof TERMINAL_PLACEMENTS)[number];
diff --git a/packages/desktop/tests/smoke/window-chrome.e2e.ts b/packages/desktop/tests/smoke/window-chrome.e2e.ts
index 30f5193cb..e657bca47 100644
--- a/packages/desktop/tests/smoke/window-chrome.e2e.ts
+++ b/packages/desktop/tests/smoke/window-chrome.e2e.ts
@@ -248,7 +248,7 @@ test.describe('Editor header drag-region smoke', () => {
test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);
test.skip(!TARGET.exists, TARGET.missingReason);
- test('keeps the full header canvas draggable and its controls clickable', async ({
+ test('keeps the app header draggable, takes the workspace tab rows out of the window drag region, and keeps their controls clickable', async ({
captureStderrFor,
}) => {
const { tmpHome, projectDir } = seedHomeWithLastOpenedProject();
@@ -423,22 +423,22 @@ test.describe('Editor header drag-region smoke', () => {
agentsButton: 'no-drag',
editorButton: 'no-drag',
filesButton: 'no-drag',
- headerCanvas: 'drag',
- leadingGapRegion: 'drag',
- filesToggleZone: 'drag',
+ headerCanvas: 'no-drag',
+ leadingGapRegion: 'no-drag',
+ filesToggleZone: 'no-drag',
newTabButton: 'no-drag',
- overflowRoot: 'drag',
+ overflowRoot: 'no-drag',
paneDivider: 'drag',
paneDividerGapAfter: 'drag',
paneDividerGapBefore: 'drag',
- paneTabs: 'drag',
+ paneTabs: 'no-drag',
resourcesButton: 'no-drag',
terminalButton: ptyAvailable ? 'no-drag' : 'no terminal on this host',
scrollViewport: 'no-drag',
shareButton: 'no-drag',
shareHasDraggableVerticalGutter: true,
tabRowHoldsNoShare: true,
- tabsHost: 'drag',
+ tabsHost: 'no-drag',
toggleLeadsFirstPaneRow: true,
appHeaderCanvas: 'drag',
});