Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Swap the file sidebar and the document panel (#7171)

Abrahamcc6d41faa82c
diff --git a/.changeset/editor-sidebars-swap.md b/.changeset/editor-sidebars-swap.md
new file mode 100644
index 000000000..fe5433e16
--- /dev/null
+++ b/.changeset/editor-sidebars-swap.md
@@ -0,0 +1,5 @@
+---
+'@inkeep/open-knowledge': patch
+---
+
+Swap the file sidebar and the document panel to put your files on the right: right-click an empty part of the editor's tab row, or search the command palette. Each sidebar's show and hide button moves with it, and the desktop app keeps the choice for every project.
diff --git a/docs/content/advanced/content-rules/overview.mdx b/docs/content/advanced/content-rules/overview.mdx
index 66c22a21d..ab28baf51 100644
--- a/docs/content/advanced/content-rules/overview.mdx
+++ b/docs/content/advanced/content-rules/overview.mdx
@@ -14,7 +14,7 @@ This page covers what's the same whatever linter runs; each linter's page covers
- **Source mode** — wavy underlines on the offending range, markers in the lint gutter, hover tooltips, and (for auto-fixable rules) an inline **Fix** action.
- **WYSIWYG** — the block a problem falls in is marked, so issues stay visible without raw markdown lines to underline.
-- **The Problems panel** — a tab in the document panel on the right, with a live count badge and two scopes:
+- **The Problems panel** — a tab in the document panel, with a live count badge and two scopes:
- **This doc** — live diagnostics for the open document, in both WYSIWYG and source mode. Click a problem to jump to it: source mode lands on the exact line and column, WYSIWYG scrolls to the block it falls in.
- **Project** — an on-demand audit of every in-scope document. It runs when you first open the scope and on the refresh button — never in the background. Results group per file with error/warning totals; configuration problems (a malformed config file, a broken `extends`) surface at the top. Clicking a problem opens the offending doc at that position.
- **The file sidebar** — a file with problems has its row tinted (red for errors, amber for warnings) and carries a count badge. The badge is a control: click it, or tab to it and press Enter or Space, and the file opens with the Problems panel showing that file's problems in **This doc** scope. Keyboard activation moves focus into the panel; clicking preserves pointer focus. Set `validation.fileTreeIndicators: false` in the project's `config.yml` to turn the tint and the badge off (see the [configuration reference](/docs/reference/configuration)). A missing tint has one other cause: a `log.md` whose broken links the reserved-log policy below leaves out.
diff --git a/docs/content/features/editor.mdx b/docs/content/features/editor.mdx
index 17ed90c32..4af8426d2 100644
--- a/docs/content/features/editor.mdx
+++ b/docs/content/features/editor.mdx
@@ -369,7 +369,7 @@ A `tag:` prefix searches by tag: `tag:` alone lists every tag, `tag:fr` narrows
## Sidebars and window width
-The editor has two sidebars: the file sidebar on the left and the document panel on the right (Outline, Links, Graph, Timeline, Problems and Comments; single-file windows show Outline, Problems and Comments). Both adapt to the window:
+The editor has two sidebars on opposite sides of the document: the file sidebar, on the left by default, and the document panel, on the right by default (Outline, Links, Graph, Timeline, Problems and Comments; single-file windows show Outline, Problems and Comments). To swap them, right-click an empty part of the editor's tab row and choose **Swap file sidebar and document panel**, or search the command palette for it. The choice is remembered, in the desktop app for every project, and each sidebar's show and hide button moves with it, to the side its sidebar opens from. Single-file windows have no file sidebar, so their document panel stays on its default side. Both sidebars adapt to the window:
- At comfortable widths (1280px and up) both sidebars open by default.
- Between 1024px and 1279px the document panel defaults to collapsed so the editor keeps its breathing room; the file sidebar stays open.
@@ -389,8 +389,8 @@ Keyboard shortcuts (on Windows / Linux, use `Ctrl` in place of `Cmd` and `Alt` i
| `Cmd+9` | Jump to the last editor tab. |
| `Cmd+Shift+T` | Reopen the most recently closed editor tab. |
| `Cmd+K` | Command palette — or, with text selected in the visual editor, add a link (cursor inside a link edits it). |
-| `Cmd+Option+S` | Show / Hide the file sidebar (left). Matches Apple's standard sidebar accelerator. |
-| `Cmd+Option+B` | Show / Hide the document panel (right). Matches VS Code's Secondary Side Bar accelerator. |
+| `Cmd+Option+S` | Show / Hide the file sidebar. Matches Apple's standard sidebar accelerator. |
+| `Cmd+Option+B` | Show / Hide the document panel. Matches VS Code's Secondary Side Bar accelerator. |
| `Cmd+Option+M` | Toggle between the visual and source editors, keeping your place. |
| `Cmd+Option+E` | **View in source** — jump from the visual editor to the Markdown for the block at the cursor, centered and highlighted (visual editor only). |
| `Cmd+J` / `Ctrl+J` | Show / Hide the Terminal in its current placement (macOS / Windows and Linux desktop apps). |
@@ -450,8 +450,8 @@ Before the existing Zoom and Toggle Fullscreen items, the View menu gets:
| Item | Accelerator | Bound to |
| --- | --- | --- |
-| **Show / Hide Sidebar** | `Cmd+Option+S` | Toggles the file sidebar (left). Label flips between Show and Hide based on current state, matching Finder. |
-| **Show / Hide Document Panel** | `Cmd+Option+B` | Toggles the document panel (right). |
+| **Show / Hide Sidebar** | `Cmd+Option+S` | Toggles the file sidebar. Label flips between Show and Hide based on current state, matching Finder. |
+| **Show / Hide Document Panel** | `Cmd+Option+B` | Toggles the document panel. |
| **Show / Hide Editor** | (none) | Toggles the editor, in project windows only (see [Hide the editor](#hide-the-editor)). Label flips between Show and Hide like the other toggles. |
| **Show / Hide Terminal** | `Cmd+J` / `Ctrl+J` | Toggles the Terminal in its current placement. (`` Ctrl+` `` toggles it too, though that chord has no menu accelerator.) |
| **Show / Hide Agents** | `Cmd+L` | macOS View menu only: the Windows and Linux title-bar menus have no Agents item, so there use `Ctrl+L`, the header **Agents** button or the command palette. Toggles the Agents panel. With text selected in the editor, and the editor shown, the item reads **Ask AI About Selection** and stages the selection in the Agents panel instead. |
diff --git a/packages/app/src/components/DocPanelToggle.tsx b/packages/app/src/components/DocPanelToggle.tsx
index ced4a4bed..e6220ac1b 100644
--- a/packages/app/src/components/DocPanelToggle.tsx
+++ b/packages/app/src/components/DocPanelToggle.tsx
@@ -1,10 +1,12 @@
import { useLingui } from '@lingui/react/macro';
-import { PanelRightClose, PanelRightOpen } from 'lucide-react';
+import { PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen } from 'lucide-react';
import { Button } from '@/components/ui/button.tsx';
import { Kbd } from '@/components/ui/kbd';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import { physicalSide } from '@/lib/editor-sidebar-side-store';
import { formatShortcut, formatShortcutLabel } from '@/lib/keyboard-shortcuts';
import { isNoteWindow } from '@/lib/note-window-mode';
+import { useDocumentDirection } from '@/lib/use-document-direction';
import { cn } from '@/lib/utils';
interface DocPanelToggleProps {
@@ -12,6 +14,7 @@ interface DocPanelToggleProps {
readonly onTogglePanel: () => void;
readonly className?: string;
readonly panelId?: string;
+ readonly side?: 'start' | 'end';
}
export function DocPanelToggle({
@@ -19,8 +22,10 @@ export function DocPanelToggle({
onTogglePanel,
className,
panelId = 'doc-panel',
+ side = 'end',
}: DocPanelToggleProps) {
const { t } = useLingui();
+ const direction = useDocumentDirection();
const panelShortcut = formatShortcut('toggle-document-panel');
const panelShortcutLabel = formatShortcutLabel('toggle-document-panel');
const isElectronHost = typeof window !== 'undefined' && window.okDesktop != null;
@@ -47,7 +52,17 @@ export function DocPanelToggle({
asChild
>
<TooltipTrigger>
- {isPanelCollapsed ? <PanelRightOpen /> : <PanelRightClose />}
+ {physicalSide(side, direction) === 'left' ? (
+ isPanelCollapsed ? (
+ <PanelLeftOpen />
+ ) : (
+ <PanelLeftClose />
+ )
+ ) : isPanelCollapsed ? (
+ <PanelRightOpen />
+ ) : (
+ <PanelRightClose />
+ )}
</TooltipTrigger>
</Button>
<TooltipContent side="bottom">
diff --git a/packages/app/src/components/EditorArea.dom.test.tsx b/packages/app/src/components/EditorArea.dom.test.tsx
index 655d16c31..2e89f42d5 100644
--- a/packages/app/src/components/EditorArea.dom.test.tsx
+++ b/packages/app/src/components/EditorArea.dom.test.tsx
@@ -10,6 +10,7 @@ import {
} from 'react';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { DEFAULT_DOCK_TREE, type DockNode, moveDockPane } from '@/lib/dock-tree';
+import { swapEditorSidebars } from '@/lib/editor-sidebar-side-store';
import {
__resetPaneVisibilityStoreForTests,
type PaneId,
@@ -2773,3 +2774,45 @@ describe('EditorArea with the editor hidden', () => {
expect(dockUnit('agents').getAttribute('style')).toBe(agentsStyle);
});
});
+
+describe('the document panel side', () => {
+ const settle = () => act(async () => {});
+
+ function docPanelFollowsColumn(): boolean {
+ const column = document.querySelector('[data-editor-workspace-column]');
+ const docPanel = document.querySelector('#doc-panel');
+ if (column === null || docPanel === null)
+ throw new Error('the editor column or doc panel is absent');
+ return (column.compareDocumentPosition(docPanel) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;
+ }
+
+ beforeEach(() => {
+ cleanup();
+ localStorage.clear();
+ });
+
+ test('a swap puts the document panel before the editor column in a window with a file sidebar, and a window without one keeps it after', async () => {
+ swapEditorSidebars();
+ try {
+ const view = render(
+ <FileListHostProvider enabled>
+ <EditorArea
+ editorMode="wysiwyg"
+ onModeChange={() => {}}
+ activeTab="timeline"
+ onActiveTabChange={() => {}}
+ />
+ </FileListHostProvider>,
+ );
+ await settle();
+ expect(docPanelFollowsColumn()).toBe(false);
+ view.unmount();
+
+ renderEditorArea();
+ await settle();
+ expect(docPanelFollowsColumn()).toBe(true);
+ } finally {
+ swapEditorSidebars();
+ }
+ });
+});
diff --git a/packages/app/src/components/EditorArea.tsx b/packages/app/src/components/EditorArea.tsx
index 8fc00bb38..befb02817 100644
--- a/packages/app/src/components/EditorArea.tsx
+++ b/packages/app/src/components/EditorArea.tsx
@@ -85,6 +85,7 @@ import { type DockLayout, dockPaneMinExtent, EMPTY_DOCK_LAYOUT } from '@/lib/doc
import type { DockNode } from '@/lib/dock-tree';
import { focusAwayFromHiddenEditor, focusWaitsForEditor } from '@/lib/editor-hidden-focus';
import { type EditorSidebar, resolveEditorSidebarFit } from '@/lib/editor-sidebar-fit';
+import { documentPanelSide, useFileSidebarSide } from '@/lib/editor-sidebar-side-store';
import { matchesKeyboardShortcut } from '@/lib/keyboard-shortcuts';
import { subscribeLocalMenuAction } from '@/lib/local-menu-action-bus';
import { isNoteWindow } from '@/lib/note-window-mode';
@@ -438,8 +439,10 @@ function hasExtent(element: HTMLElement | null): boolean {
return width > 0 && height > 0;
}
-interface WorkspaceHeaderChrome {
+export interface WorkspaceHeaderChrome {
+ readonly leading: ReactNode;
readonly trailing: ReactNode;
+ readonly sidebarSwap: boolean;
}
interface EditorAreaProps {
@@ -462,6 +465,7 @@ interface EditorAreaProps {
function renderTabsWithoutHeader(tabs: ReactNode, chrome: WorkspaceHeaderChrome): ReactNode {
return (
<>
+ {chrome.leading}
{tabs}
{chrome.trailing}
</>
@@ -743,6 +747,8 @@ function EditorAreaInner({
width: filesDockWidth,
} = useSidebar();
const fileListHost = useFileListHost();
+ const fileSidebarSide = useFileSidebarSide();
+ const docPanelSide = fileListHost != null ? documentPanelSide(fileSidebarSide) : 'end';
const [filesCoverTarget, setFilesCoverTarget] = useState<HTMLDivElement | null>(null);
const [agentsContainer, setAgentsContainer] = useState<HTMLElement | null>(null);
@@ -836,6 +842,19 @@ function EditorAreaInner({
const [initialDocPanelWidthPx] = useState(() => getInitialDocPanelWidth());
const docPanelWidthPxRef = useRef(initialDocPanelWidthPx);
const [preferredDocPanelWidthPx, setPreferredDocPanelWidthPx] = useState(initialDocPanelWidthPx);
+ const [docPanelSeed, setDocPanelSeed] = useState(() => ({
+ side: docPanelSide,
+ collapsed: initialRightCollapsed,
+ widthPx: initialDocPanelWidthPx,
+ }));
+ if (docPanelSeed.side !== docPanelSide) {
+ setDocPanelSeed({
+ side: docPanelSide,
+ collapsed: isCollapsed,
+ widthPx: preferredDocPanelWidthPx,
+ });
+ }
+ const [docPanelEl, setDocPanelEl] = useState<HTMLElement | null>(null);
const writeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
function debouncedWriteDocPanelWidth(px: number) {
if (writeTimerRef.current != null) clearTimeout(writeTimerRef.current);
@@ -1286,7 +1305,6 @@ function EditorAreaInner({
useEffect(() => {
if (innerContainerEl == null) return;
if (isEmbedded) return;
- const docPanel = innerContainerEl.querySelector<HTMLElement>(`#${DOC_PANEL_ID}`);
let docSettlementFrame = 0;
const observer = new ResizeObserver(() => {
if (docSettlementFrame !== 0) return;
@@ -1296,13 +1314,13 @@ function EditorAreaInner({
});
});
observer.observe(innerContainerEl);
- if (docPanel != null) observer.observe(docPanel);
+ if (docPanelEl != null) observer.observe(docPanelEl);
return () => {
observer.disconnect();
if (docSettlementFrame !== 0) cancelAnimationFrame(docSettlementFrame);
cancelRailLayoutRetry(observedDocWidthRetryRef);
};
- }, [innerContainerEl, isEmbedded]);
+ }, [innerContainerEl, isEmbedded, docPanelEl]);
const openRequestedDocPanelTab = useEffectEvent((tab: PanelTab) => {
revealEditor();
@@ -1663,14 +1681,18 @@ function EditorAreaInner({
}, [sidebarFit.mode, preferredSidebar]);
const showDocPanelToggle =
!noteWindow && renderFocusedDocument != null && activeDocConflict === null;
+ const docPanelToggle = showDocPanelToggle ? (
+ <DocPanelToggle
+ isPanelCollapsed={!docPanelOnScreen}
+ onTogglePanel={togglePanel}
+ panelId={docPanelCover ? 'doc-panel-cover' : DOC_PANEL_ID}
+ side={docPanelSide}
+ />
+ ) : null;
const workspaceHeaderChrome: WorkspaceHeaderChrome = {
- trailing: showDocPanelToggle ? (
- <DocPanelToggle
- isPanelCollapsed={!docPanelOnScreen}
- onTogglePanel={togglePanel}
- panelId={docPanelCover ? 'doc-panel-cover' : DOC_PANEL_ID}
- />
- ) : null,
+ leading: docPanelSide === 'start' ? docPanelToggle : null,
+ trailing: docPanelSide === 'end' ? docPanelToggle : null,
+ sidebarSwap: fileListHost != null,
};
const returnFocusFromDocPanelCoverEvent = useEffectEvent(returnFocusFromDocPanelCover);
@@ -2004,48 +2026,61 @@ function EditorAreaInner({
</div>
);
- const docSlot = (
- <>
- <ResizableHandle
- data-doc-panel-handle=""
- aria-controls={DOC_PANEL_ID}
- aria-label={t`Resize document panel`}
- withHandle={docSlotPresent && !isCollapsed && !docPanelCover}
- disabled={!docSlotPresent || isCollapsed || docPanelCover}
- className={docSlotPresent ? undefined : 'pointer-events-none'}
- style={docSlotPresent && !isCollapsed && !docPanelCover ? undefined : { display: 'none' }}
- onPointerDown={(event) => {
- beginDocHandleDrag(event.pointerId);
- }}
- />
- <ResizablePanel
- id={DOC_PANEL_ID}
- role="region"
- aria-label={t`Document panel`}
- panelRef={panelRef}
- defaultSize={!docSlotPresent || initialRightCollapsed ? 0 : `${initialDocPanelWidthPx}px`}
- minSize={DOC_PANEL_MIN_SIZE}
- maxSize={docSlotPresent ? DOC_PANEL_MAX_SIZE : '0px'}
- collapsible
- collapsedSize={0}
- onResize={(size) => {
- if (docSlotPresent) {
- setIsCollapsed(size.asPercentage === 0);
- }
- if (size.inPixels > 0 && isDraggingDocHandleRef.current) {
- docPanelWidthPxRef.current = size.inPixels;
- adoptDraggedDocPanelWidth(size.inPixels);
- debouncedWriteDocPanelWidth(size.inPixels);
- }
- reclaimHiddenDocPanel(docSlotPresent, size.inPixels);
- }}
- inert={!docSlotPresent || isCollapsed}
- className={cn('flex flex-col', SECONDARY_PANEL_SURFACE_CLASS)}
- >
- <div ref={docPanelDockRef} className="flex h-full min-h-0 w-full flex-col" />
- </ResizablePanel>
- </>
+ const docHandle = (
+ <ResizableHandle
+ data-doc-panel-handle=""
+ aria-controls={DOC_PANEL_ID}
+ aria-label={t`Resize document panel`}
+ withHandle={docSlotPresent && !isCollapsed && !docPanelCover}
+ disabled={!docSlotPresent || isCollapsed || docPanelCover}
+ className={docSlotPresent ? undefined : 'pointer-events-none'}
+ style={docSlotPresent && !isCollapsed && !docPanelCover ? undefined : { display: 'none' }}
+ onPointerDown={(event) => {
+ beginDocHandleDrag(event.pointerId);
+ }}
+ />
);
+ const docPanelSlot = (
+ <ResizablePanel
+ id={DOC_PANEL_ID}
+ role="region"
+ aria-label={t`Document panel`}
+ panelRef={panelRef}
+ defaultSize={!docSlotPresent || docPanelSeed.collapsed ? 0 : `${docPanelSeed.widthPx}px`}
+ elementRef={setDocPanelEl}
+ minSize={DOC_PANEL_MIN_SIZE}
+ maxSize={docSlotPresent ? DOC_PANEL_MAX_SIZE : '0px'}
+ collapsible
+ collapsedSize={0}
+ onResize={(size) => {
+ if (docSlotPresent) {
+ setIsCollapsed(size.asPercentage === 0);
+ }
+ if (size.inPixels > 0 && isDraggingDocHandleRef.current) {
+ docPanelWidthPxRef.current = size.inPixels;
+ adoptDraggedDocPanelWidth(size.inPixels);
+ debouncedWriteDocPanelWidth(size.inPixels);
+ }
+ reclaimHiddenDocPanel(docSlotPresent, size.inPixels);
+ }}
+ inert={!docSlotPresent || isCollapsed}
+ className={cn('flex flex-col', SECONDARY_PANEL_SURFACE_CLASS)}
+ >
+ <div ref={docPanelDockRef} className="flex h-full min-h-0 w-full flex-col" />
+ </ResizablePanel>
+ );
+ const docSlot =
+ docPanelSide === 'start' ? (
+ <>
+ {docPanelSlot}
+ {docHandle}
+ </>
+ ) : (
+ <>
+ {docHandle}
+ {docPanelSlot}
+ </>
+ );
const chatAlone = !editorVisible && agentsShowing && !terminalShowing;
const nothingOpen = !editorVisible && !agentsVisible && !terminalVisible;
@@ -2058,6 +2093,17 @@ function EditorAreaInner({
/>
);
+ const fileListSlot =
+ fileListHost != null ? (
+ <div
+ data-editor-file-list-slot=""
+ data-side={fileSidebarSide}
+ inert={docPanelCover}
+ className="relative flex shrink-0"
+ ref={fileListSlotRef}
+ />
+ ) : null;
+
const editorUnit = (
<PaneCard
ref={editorCardRef}
@@ -2067,14 +2113,7 @@ function EditorAreaInner({
inert={!editorVisible}
data-editor-hidden={editorVisible ? undefined : ''}
>
- {fileListHost != null ? (
- <div
- data-editor-file-list-slot=""
- inert={docPanelCover}
- className="relative flex shrink-0"
- ref={fileListSlotRef}
- />
- ) : null}
+ {fileSidebarSide === 'start' ? fileListSlot : null}
<SidebarInset inert={docPanelCover || filesCover} className="min-w-0 overflow-hidden">
<div
data-editor-inner-panels=""
@@ -2091,6 +2130,7 @@ function EditorAreaInner({
onLayoutChange={adoptLibraryDrag}
data-dragging={isDraggingDocHandle || undefined}
>
+ {docPanelSide === 'start' ? docSlot : null}
<ResizablePanel
minSize={docSlotPresent && !isCollapsed ? `${DOC_USABLE_MIN_WIDTH_PX}px` : '0%'}
{...(workspaceAbsorbsResidual ? {} : { defaultSize: '100%' })}
@@ -2104,10 +2144,11 @@ function EditorAreaInner({
{documentArea}
</main>
</ResizablePanel>
- {docSlot}
+ {docPanelSide === 'end' ? docSlot : null}
</ResizablePanelGroup>
</div>
</SidebarInset>
+ {fileSidebarSide === 'end' ? fileListSlot : null}
{filesCover && fileListHost != null ? (
<section
aria-label={t`Files`}
diff --git a/packages/app/src/components/EditorHeader.tsx b/packages/app/src/components/EditorHeader.tsx
index 1767fa9ec..d3afb3a04 100644
--- a/packages/app/src/components/EditorHeader.tsx
+++ b/packages/app/src/components/EditorHeader.tsx
@@ -15,6 +15,7 @@ const AppMenubar = lazy(() =>
interface EditorHeaderProps {
children?: ReactNode;
+ leading?: ReactNode;
trailing?: ReactNode;
noteModeToggle?: ReactNode;
}
@@ -80,7 +81,7 @@ function ReducedChromeZones({
const TRAILING_WIDTH_CLASS = '@[15rem]/editor-header:[--editor-header-trailing-width:2rem]';
-export function EditorHeader({ children, trailing, noteModeToggle }: EditorHeaderProps) {
+export function EditorHeader({ children, leading, trailing, noteModeToggle }: EditorHeaderProps) {
const singleFile = useSingleFileMode();
const noteWindow = isNoteWindow();
const { activeDocName } = useDocumentContext();
@@ -113,6 +114,14 @@ export function EditorHeader({ children, trailing, noteModeToggle }: EditorHeade
!reducedChrome && trailing != null && TRAILING_WIDTH_CLASS,
)}
>
+ {reducedChrome || leading == null ? null : (
+ <div
+ data-editor-header-leading=""
+ className="hidden shrink-0 items-center ps-1 @[15rem]/editor-header:flex"
+ >
+ {leading}
+ </div>
+ )}
{singleFile ? (
<div className="flex min-w-0 items-center px-3">
<EditorBreadcrumb docName={activeDocName} includeCurrentPage />
diff --git a/packages/app/src/components/EditorPane.dom.test.tsx b/packages/app/src/components/EditorPane.dom.test.tsx
index 251b41d8e..16f1c6883 100644
--- a/packages/app/src/components/EditorPane.dom.test.tsx
+++ b/packages/app/src/components/EditorPane.dom.test.tsx
@@ -164,6 +164,7 @@ function shiftJKeydownInit(): KeyboardEventInit {
}
import * as actualLinguiMacro from '@lingui/react/macro';
+import type { WorkspaceHeaderChrome } from './EditorArea';
vi.doMock('@lingui/react/macro', () => ({
...actualLinguiMacro,
@@ -297,7 +298,7 @@ vi.doMock('./EditorArea', () => ({
editorVisible?: boolean;
agentsVisible?: boolean;
onPaneExtentChange?: () => void;
- renderWorkspaceHeader?: (tabs: ReactNode, chrome: { trailing: ReactNode }) => ReactNode;
+ renderWorkspaceHeader?: (tabs: ReactNode, chrome: WorkspaceHeaderChrome) => ReactNode;
dockTree: DockNode;
onDockTreeChange: (update: (tree: DockNode) => DockNode) => void;
onSessionPlacements?: (placements: MockPlacements) => void;
@@ -311,7 +312,11 @@ vi.doMock('./EditorArea', () => ({
data-editor-visible={String(editorVisible)}
data-agents-visible={String(agentsVisible)}
>
- {renderWorkspaceHeader?.(<div data-testid="workspace-tabs" />, { trailing: null })}
+ {renderWorkspaceHeader?.(<div data-testid="workspace-tabs" />, {
+ leading: null,
+ trailing: null,
+ sidebarSwap: false,
+ })}
<ReportPlacements onSessionPlacements={onSessionPlacements} />
<MockPaneExtentHandle handleRef={ref} onPaneExtentChange={onPaneExtentChange} />
</div>
diff --git a/packages/app/src/components/EditorPane.tsx b/packages/app/src/components/EditorPane.tsx
index af7800854..e89d3c268 100644
--- a/packages/app/src/components/EditorPane.tsx
+++ b/packages/app/src/components/EditorPane.tsx
@@ -78,9 +78,15 @@ import { AuthModal } from './AuthModal';
import { AutoSyncOnboardingDialog } from './AutoSyncOnboardingDialog';
import { resolveAutoSyncOnboarding } from './auto-sync-onboarding-gate';
import { type PanelTab, TABS } from './DocPanel';
-import { EditorArea, type EditorAreaHandle, type SessionPlacements } from './EditorArea';
+import {
+ EditorArea,
+ type EditorAreaHandle,
+ type SessionPlacements,
+ type WorkspaceHeaderChrome,
+} from './EditorArea';
import { EditorHeader } from './EditorHeader';
import { EditorModeToggle } from './EditorModeToggle';
+import { EditorSidebarsContextMenu } from './EditorSidebarsContextMenu';
import { composeTerminalSelectionPaste } from './handoff/compose-terminal-selection';
import { requestPreferredSession } from './handoff/preferred-session-events';
import {
@@ -434,15 +440,20 @@ type WorkspaceHeaderState = {
function WorkspaceHeader({
tabs,
+ leading,
trailing,
+ sidebarSwap,
state,
}: {
tabs: ReactNode;
+ leading: ReactNode;
trailing: ReactNode;
+ sidebarSwap: boolean;
state: WorkspaceHeaderState;
}) {
- return (
+ const header = (
<EditorHeader
+ leading={leading}
trailing={trailing}
noteModeToggle={
state.noteWindow &&
@@ -459,11 +470,18 @@ function WorkspaceHeader({
{tabs}
</EditorHeader>
);
+ return sidebarSwap ? <EditorSidebarsContextMenu>{header}</EditorSidebarsContextMenu> : header;
}
function createWorkspaceHeaderRenderer(state: WorkspaceHeaderState) {
- return (tabs: ReactNode, chrome: { readonly trailing: ReactNode }) => (
- <WorkspaceHeader tabs={tabs} trailing={chrome.trailing} state={state} />
+ return (tabs: ReactNode, chrome: WorkspaceHeaderChrome) => (
+ <WorkspaceHeader
+ tabs={tabs}
+ leading={chrome.leading}
+ trailing={chrome.trailing}
+ sidebarSwap={chrome.sidebarSwap}
+ state={state}
+ />
);
}
diff --git a/packages/app/src/components/EditorSidebarsContextMenu.tsx b/packages/app/src/components/EditorSidebarsContextMenu.tsx
new file mode 100644
index 000000000..0d93c948c
--- /dev/null
+++ b/packages/app/src/components/EditorSidebarsContextMenu.tsx
@@ -0,0 +1,29 @@
+import { useLingui } from '@lingui/react/macro';
+import { ArrowLeftRight } from 'lucide-react';
+import type { ReactNode } from 'react';
+import {
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuItem,
+ ContextMenuTrigger,
+} from '@/components/ui/context-menu';
+import { swapEditorSidebars } from '@/lib/editor-sidebar-side-store';
+
+export function EditorSidebarsContextMenu({ children }: { readonly children: ReactNode }) {
+ const { t } = useLingui();
+ return (
+ <ContextMenu>
+ <ContextMenuTrigger asChild>
+ <div data-editor-sidebars-menu-trigger="" className="contents">
+ {children}
+ </div>
+ </ContextMenuTrigger>
+ <ContextMenuContent className="min-w-52">
+ <ContextMenuItem data-swap-editor-sidebars="" onSelect={() => swapEditorSidebars()}>
+ <ArrowLeftRight aria-hidden="true" />
+ {t`Swap file sidebar and document panel`}
+ </ContextMenuItem>
+ </ContextMenuContent>
+ </ContextMenu>
+ );
+}
diff --git a/packages/app/src/components/EditorTabs.tsx b/packages/app/src/components/EditorTabs.tsx
index 14a335555..e482bbaa7 100644
--- a/packages/app/src/components/EditorTabs.tsx
+++ b/packages/app/src/components/EditorTabs.tsx
@@ -689,6 +689,7 @@ interface EditorTabsProps {
paneId: string;
onSplitComplete?: (paneId: string, tabId: string) => void;
leading?: ReactNode;
+ trailing?: ReactNode;
}
export function EditorTabs({
@@ -696,6 +697,7 @@ export function EditorTabs({
paneId,
onSplitComplete,
leading,
+ trailing,
}: EditorTabsProps) {
const { t } = useLingui();
const context = useDocumentContext();
@@ -1371,6 +1373,7 @@ export function EditorTabs({
</TooltipContent>
</Tooltip>
</div>
+ {trailing}
{skillActions.dialogs}
</div>
);
diff --git a/packages/app/src/components/EditorWorkspace.dom.test.tsx b/packages/app/src/components/EditorWorkspace.dom.test.tsx
index db761561e..82557e41e 100644
--- a/packages/app/src/components/EditorWorkspace.dom.test.tsx
+++ b/packages/app/src/components/EditorWorkspace.dom.test.tsx
@@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
import { createPortal } from 'react-dom';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import type { EditorPaneState } from '@/editor/editor-panes';
+import { swapEditorSidebars } from '@/lib/editor-sidebar-side-store';
import { OK_SIDEBAR_DRAG_MIME, serializeSidebarDragPayload } from '@/lib/sidebar-drag';
import { renderLinguiTemplate } from '@/test-utils/lingui-mock';
import {
@@ -176,21 +177,24 @@ vi.doMock('./EditorTabs', () => ({
dropIndicatorIndex,
leading,
paneId,
+ trailing,
}: {
dropIndicatorIndex?: number | null;
leading?: ReactNode;
paneId: string;
+ trailing?: ReactNode;
}) => (
<div data-editor-pane-tabs={paneId} data-drop-indicator-index={dropIndicatorIndex ?? undefined}>
{leading}
Tabs {paneId}
+ {trailing}
</div>
),
}));
vi.doMock('./FileListToggle', () => ({
- FileListToggle: () => (
- <button type="button" data-testid="file-list-toggle">
+ FileListToggle: ({ side }: { side?: 'start' | 'end' }) => (
+ <button type="button" data-testid="file-list-toggle" data-side={side}>
Files
</button>
),
@@ -404,6 +408,25 @@ describe('EditorWorkspace', () => {
expect(headerCanvas.style.transform).toBe('translateX(-96px)');
});
+ test('with the file sidebar at the end, the one Files toggle closes the last pane strip', () => {
+ swapEditorSidebars();
+ try {
+ const { container } = renderWorkspace();
+ const toggles = screen.getAllByTestId('file-list-toggle');
+ expect(toggles).toHaveLength(1);
+ expect(toggles[0]?.dataset.side).toBe('end');
+ const lastStrip = container.querySelector('[data-editor-pane-tabs="pane-b"]');
+ expect(lastStrip?.lastElementChild).toBe(toggles[0]);
+ expect(
+ container.querySelector(
+ '[data-editor-pane-tabs="pane-a"] [data-testid="file-list-toggle"]',
+ ),
+ ).toBeNull();
+ } finally {
+ swapEditorSidebars();
+ }
+ });
+
test('resizes header tab groups continuously before persisting the panel layout', () => {
const { container } = renderWorkspace();
const headerGroups = [
diff --git a/packages/app/src/components/EditorWorkspace.tsx b/packages/app/src/components/EditorWorkspace.tsx
index d297a21c1..aad9d4767 100644
--- a/packages/app/src/components/EditorWorkspace.tsx
+++ b/packages/app/src/components/EditorWorkspace.tsx
@@ -35,6 +35,7 @@ import {
import { useDocumentContext } from '@/editor/DocumentContext';
import type { EditorPaneState, PaneSide } from '@/editor/editor-panes';
import { openSidebarDropPayload } from '@/editor/sidebar-drop';
+import { useFileSidebarSide } from '@/lib/editor-sidebar-side-store';
import {
getNoteWindowDeletedDoc,
subscribeNoteWindowDeleted,
@@ -386,6 +387,7 @@ export function EditorWorkspace({
} = useDocumentContext();
const singleFile = useSingleFileMode();
const singleDocumentSurface = singleFile || isNoteWindow();
+ const fileSidebarSide = useFileSidebarSide();
const deletedDocName = useSyncExternalStore(
subscribeNoteWindowDeleted,
getNoteWindowDeletedDoc,
@@ -692,9 +694,19 @@ export function EditorWorkspace({
return paneLabel(data.paneId);
}
+ function holdsFileListToggle(pane: EditorPaneState, index: number): boolean {
+ if (projected) return pane.id === focusedPaneId;
+ return index === (fileSidebarSide === 'start' ? 0 : panes.length - 1);
+ }
+
function paneLeadingControl(pane: EditorPaneState, index: number): ReactNode {
- if (projected) return pane.id === focusedPaneId ? <FileListToggle /> : undefined;
- return index === 0 ? <FileListToggle /> : undefined;
+ if (fileSidebarSide !== 'start' || !holdsFileListToggle(pane, index)) return undefined;
+ return <FileListToggle side="start" />;
+ }
+
+ function paneTrailingControl(pane: EditorPaneState, index: number): ReactNode {
+ if (fileSidebarSide !== 'end' || !holdsFileListToggle(pane, index)) return undefined;
+ return <FileListToggle side="end" />;
}
const paneGroup = (
@@ -785,6 +797,7 @@ export function EditorWorkspace({
paneId={pane.id}
onSplitComplete={requestTabFocus}
leading={paneLeadingControl(pane, index)}
+ trailing={paneTrailingControl(pane, index)}
/>
</PaneStripDropTarget>
</Fragment>
diff --git a/packages/app/src/components/FileListToggle.tsx b/packages/app/src/components/FileListToggle.tsx
index 7477924a1..7190180df 100644
--- a/packages/app/src/components/FileListToggle.tsx
+++ b/packages/app/src/components/FileListToggle.tsx
@@ -3,11 +3,14 @@ import { Kbd } from '@/components/ui/kbd';
import { Separator } from '@/components/ui/separator';
import { SidebarTrigger, useSidebar } from '@/components/ui/sidebar';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import { physicalSide } from '@/lib/editor-sidebar-side-store';
import { formatShortcut, formatShortcutLabel } from '@/lib/keyboard-shortcuts';
+import { useDocumentDirection } from '@/lib/use-document-direction';
import { cn } from '@/lib/utils';
-export function FileListToggle() {
+export function FileListToggle({ side = 'start' }: { readonly side?: 'start' | 'end' }) {
const { t } = useLingui();
+ const direction = useDocumentDirection();
const { state } = useSidebar();
const isElectronHost = typeof window !== 'undefined' && window.okDesktop != null;
@@ -16,13 +19,15 @@ export function FileListToggle() {
data-file-list-toggle=""
data-electron-drag={isElectronHost ? '' : undefined}
className={cn(
- 'flex h-full shrink-0 items-center gap-1 pe-1',
+ 'flex h-full shrink-0 items-center gap-1',
+ side === 'start' ? 'pe-1' : 'flex-row-reverse ps-1',
isElectronHost && '[-webkit-app-region:drag]',
)}
>
<Tooltip>
<TooltipTrigger asChild>
<SidebarTrigger
+ side={physicalSide(side, direction)}
className={cn(
'shrink-0 text-muted-foreground',
isElectronHost && '[-webkit-app-region:no-drag]',
diff --git a/packages/app/src/components/FileSidebar.tsx b/packages/app/src/components/FileSidebar.tsx
index c3cada166..5338b48a1 100644
--- a/packages/app/src/components/FileSidebar.tsx
+++ b/packages/app/src/components/FileSidebar.tsx
@@ -104,6 +104,7 @@ import {
import { useSettingsLoadingReason } from '@/lib/config-context';
import { useConfigContext } from '@/lib/config-provider';
import { subscribeToCreateTopLevelFile } from '@/lib/create-file-events';
+import { physicalSide, useFileSidebarSide } from '@/lib/editor-sidebar-side-store';
import {
buildSendToAiInputForActiveTarget,
resolveActiveTargetAbsPath,
@@ -123,6 +124,7 @@ import { revealEditorBeforeActing } from '@/lib/reveal-editor';
import { scheduleClipboardWrite } from '@/lib/share/clipboard-adapter';
import { buildFolderShareInput, runShareAction } from '@/lib/share/run-share-action';
import { useStickyAgent } from '@/lib/unified-agent-store';
+import { useDocumentDirection } from '@/lib/use-document-direction';
import { useWorkspace } from '@/lib/use-workspace';
import { cn } from '@/lib/utils';
import { setViewMenuState } from '@/lib/view-menu-state-store';
@@ -180,6 +182,8 @@ function SettingsLoadingMenuGroupTooltip({
function FileSidebarInner() {
const { t } = useLingui();
+ const fileSidebarSide = useFileSidebarSide();
+ const fileSidebarEdge = physicalSide(fileSidebarSide, useDocumentDirection());
const settingsLoadingReasonId = useId();
const [tree, setTree] = useState<FileTreeHandle | null>(null);
const suppressTreeMenuFocusRestoreRef = useRef(false);
@@ -586,7 +590,7 @@ function FileSidebarInner() {
]);
return (
- <Sidebar variant="inset" className="pt-0">
+ <Sidebar variant="inset" side={fileSidebarEdge} className="pt-0">
{pendingSettingsReason ? (
<span id={settingsLoadingReasonId} className="sr-only">
{pendingSettingsReason}
@@ -845,6 +849,7 @@ function FileSidebarInner() {
<SidebarRail
enableToggle={false}
enableDrag={!(isEmbedded && sidebarState === 'collapsed')}
+ direction={fileSidebarEdge === 'left' ? 'right' : 'left'}
/>
</div>
</ContextMenuTrigger>
diff --git a/packages/app/src/components/command-palette-commands.ts b/packages/app/src/components/command-palette-commands.ts
index 8860d3c35..0cc027733 100644
--- a/packages/app/src/components/command-palette-commands.ts
+++ b/packages/app/src/components/command-palette-commands.ts
@@ -15,6 +15,7 @@ import {
import type { MessageDescriptor } from '@lingui/core';
import { msg, t } from '@lingui/core/macro';
import {
+ ArrowLeftRight,
Blocks,
BookOpen,
Bug,
@@ -61,6 +62,7 @@ import { PANE_ICON } from '@/components/pane-icons';
import { requestSkillsDockExpanded } from '@/components/skills-dock-expanded-store';
import type { OkDesktopBridge, OkMenuAction } from '@/lib/desktop-bridge-types';
import { requestDockPaneMove } from '@/lib/dock-move-requests';
+import { swapEditorSidebars } from '@/lib/editor-sidebar-side-store';
import { i18n } from '@/lib/i18n';
import type { KeyboardShortcutId } from '@/lib/keyboard-shortcuts';
import { openDocInNoteWindow } from '@/lib/open-note-window';
@@ -161,6 +163,7 @@ const PALETTE_COMMAND_LABELS = {
sidebarHide: msg`Hide sidebar`,
docPanelShow: msg`Show document panel`,
docPanelHide: msg`Hide document panel`,
+ swapEditorSidebars: msg`Swap file sidebar and document panel`,
editorShow: msg`Show Editor`,
editorHide: msg`Hide Editor`,
terminalShow: msg`Show Terminal`,
@@ -270,6 +273,7 @@ const COMMAND_ICONS: Record<string, ComponentType<{ className?: string }>> = {
'switch-worktree': GitBranch,
'toggle-sidebar': PanelLeft,
'toggle-doc-panel': PanelRight,
+ 'swap-editor-sidebars': ArrowLeftRight,
'toggle-terminal': PANE_ICON.terminal,
'move-terminal': SquareTerminal,
'toggle-agent-panel': PANE_ICON.agents,
@@ -300,6 +304,10 @@ const COMMAND_DISPATCH: Record<string, (ctx: PaletteCommandContext) => void> = {
},
]),
),
+ 'swap-editor-sidebars': (ctx) => {
+ ctx.closePalette();
+ swapEditorSidebars();
+ },
'open-blob-run': (ctx) => ctx.openBlobRun(),
'new-file': (ctx) => {
ctx.closePalette();
diff --git a/packages/app/src/components/ui/sidebar.tsx b/packages/app/src/components/ui/sidebar.tsx
index 3730e0d48..97bec38be 100644
--- a/packages/app/src/components/ui/sidebar.tsx
+++ b/packages/app/src/components/ui/sidebar.tsx
@@ -1,7 +1,7 @@
import { detectEmbeddedHostFromBrowser } from '@inkeep/open-knowledge-core/constants/embedded-host';
import { useLingui } from '@lingui/react/macro';
import { cva, type VariantProps } from 'class-variance-authority';
-import { PanelLeft, PanelLeftOpen } from 'lucide-react';
+import { PanelLeft, PanelLeftOpen, PanelRight, PanelRightOpen } from 'lucide-react';
import { Slot } from 'radix-ui';
import * as React from 'react';
import { Button } from '@/components/ui/button';
@@ -371,7 +371,7 @@ function Sidebar({
variant === 'floating'
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
: variant === 'inset'
- ? 'group-data-[side=left]:border-e group-data-[side=right]:border-s group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
+ ? 'group-data-[side=left]:border-r group-data-[side=right]:border-l group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
'group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0',
cover && 'inset-0 size-full transition-none',
@@ -391,7 +391,12 @@ function Sidebar({
);
}
-function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
+function SidebarTrigger({
+ className,
+ onClick,
+ side = 'left',
+ ...props
+}: React.ComponentProps<typeof Button> & { side?: 'left' | 'right' }) {
const { t } = useLingui();
const { toggleSidebar, state } = useSidebar();
const sidebarShortcutLabel = formatShortcutLabel('toggle-files-sidebar');
@@ -416,7 +421,17 @@ function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<t
}}
{...props}
>
- {state === 'expanded' ? <PanelLeft /> : <PanelLeftOpen />}
+ {side === 'right' ? (
+ state === 'expanded' ? (
+ <PanelRight />
+ ) : (
+ <PanelRightOpen />
+ )
+ ) : state === 'expanded' ? (
+ <PanelLeft />
+ ) : (
+ <PanelLeftOpen />
+ )}
</Button>
);
}
@@ -425,16 +440,18 @@ function SidebarRail({
className,
enableDrag = true,
enableToggle = true,
+ direction = 'right',
onMouseDown,
...props
}: React.ComponentProps<'button'> & {
enableDrag?: boolean;
enableToggle?: boolean;
+ direction?: 'left' | 'right';
}) {
const { t } = useLingui();
const { toggleSidebar, setWidth, state, width, setIsDraggingRail, cover } = useSidebar();
const { dragRef, handleMouseDown } = useSidebarResize({
- direction: 'right',
+ direction,
enableDrag: enableDrag && !cover,
enableToggle: enableToggle && !cover,
onResize: setWidth,
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 0c59870b2..93ae2b255 100644
--- a/packages/app/src/lib/command-menu-parity.uncached.test.ts
+++ b/packages/app/src/lib/command-menu-parity.uncached.test.ts
@@ -535,6 +535,7 @@ describe('command identity registry (Phase 2b)', () => {
'open-github',
'open-docs',
'open-discord',
+ 'swap-editor-sidebars',
...DOCK_MOVE_COMMANDS.map((command) => command.id),
]);
const missing = COMMAND_IDENTITIES.flatMap((cmd) =>
diff --git a/packages/app/src/lib/editor-sidebar-side-store.test.ts b/packages/app/src/lib/editor-sidebar-side-store.test.ts
new file mode 100644
index 000000000..85707b8cf
--- /dev/null
+++ b/packages/app/src/lib/editor-sidebar-side-store.test.ts
@@ -0,0 +1,96 @@
+import { describe, expect, test } from 'vitest';
+import {
+ createEditorSidebarSideStore,
+ documentPanelSide,
+ type EditorSidebarSideStorage,
+ FILE_SIDEBAR_SIDE_KEY,
+ physicalSide,
+ swapEditorSidebars,
+} from './editor-sidebar-side-store.ts';
+
+function memoryStorage(initial: Record<string, string> = {}): EditorSidebarSideStorage & {
+ data: Map<string, string>;
+} {
+ const data = new Map(Object.entries(initial));
+ return {
+ data,
+ getItem: (key) => data.get(key) ?? null,
+ setItem: (key, value) => {
+ data.set(key, value);
+ },
+ };
+}
+
+function storeOver(storage: EditorSidebarSideStorage) {
+ return createEditorSidebarSideStore(FILE_SIDEBAR_SIDE_KEY, 'start', () => storage);
+}
+
+describe('editor sidebar sides', () => {
+ test('the file sidebar starts at the start edge and the document panel at the end', () => {
+ const side = storeOver(memoryStorage()).getSnapshot();
+ expect(side).toBe('start');
+ expect(documentPanelSide(side)).toBe('end');
+ });
+
+ test('swapping puts the file sidebar at the end and saves it, and swapping again puts it back', () => {
+ const storage = memoryStorage();
+ const store = storeOver(storage);
+ swapEditorSidebars(store);
+ expect(store.getSnapshot()).toBe('end');
+ expect(storage.data.get(FILE_SIDEBAR_SIDE_KEY)).toBe('end');
+ expect(storeOver(storage).getSnapshot()).toBe('end');
+ swapEditorSidebars(store);
+ expect(store.getSnapshot()).toBe('start');
+ });
+
+ test.each(['', 'left', 'END'])(
+ 'a stored value %j that is not a side reads as the start',
+ (value) => {
+ expect(storeOver(memoryStorage({ [FILE_SIDEBAR_SIDE_KEY]: value })).getSnapshot()).toBe(
+ 'start',
+ );
+ },
+ );
+
+ test('storage that throws starts at the start edge, and a swap still takes effect for the session', () => {
+ const throwing: EditorSidebarSideStorage = {
+ getItem: () => {
+ throw new Error('blocked');
+ },
+ setItem: () => {
+ throw new Error('blocked');
+ },
+ };
+ const store = storeOver(throwing);
+ expect(store.getSnapshot()).toBe('start');
+ swapEditorSidebars(store);
+ expect(store.getSnapshot()).toBe('end');
+ swapEditorSidebars(store);
+ expect(store.getSnapshot()).toBe('start');
+ });
+
+ test.each([
+ ['start', 'ltr', 'left'],
+ ['end', 'ltr', 'right'],
+ ['start', 'rtl', 'right'],
+ ['end', 'rtl', 'left'],
+ ] as const)('a sidebar at the %s of a %s document sits on the %s', (side, direction, edge) => {
+ expect(physicalSide(side, direction)).toBe(edge);
+ });
+
+ test('a change saved by another window is picked up on reload and announced to subscribers', () => {
+ const storage = memoryStorage();
+ const store = storeOver(storage);
+ expect(store.getSnapshot()).toBe('start');
+ let announced = 0;
+ const stop = store.subscribe(() => {
+ announced += 1;
+ });
+ storage.data.set(FILE_SIDEBAR_SIDE_KEY, 'end');
+ expect(store.getSnapshot()).toBe('start');
+ store.syncFromStorage();
+ expect(store.getSnapshot()).toBe('end');
+ expect(announced).toBe(1);
+ stop();
+ });
+});
diff --git a/packages/app/src/lib/editor-sidebar-side-store.ts b/packages/app/src/lib/editor-sidebar-side-store.ts
new file mode 100644
index 000000000..57172026f
--- /dev/null
+++ b/packages/app/src/lib/editor-sidebar-side-store.ts
@@ -0,0 +1,93 @@
+import type { TextDirection } from '@inkeep/open-knowledge-core/i18n/direction';
+import { useSyncExternalStore } from 'react';
+
+export type EditorSidebarSide = 'start' | 'end';
+
+// precedent #59: app-global by intent, a personal layout preference like the theme that follows the user into every project.
+export const FILE_SIDEBAR_SIDE_KEY = 'ok-file-sidebar-side-v1';
+
+export interface EditorSidebarSideStorage {
+ getItem(key: string): string | null;
+ setItem(key: string, value: string): void;
+}
+
+export interface EditorSidebarSideStore {
+ getSnapshot(): EditorSidebarSide;
+ set(side: EditorSidebarSide): void;
+ syncFromStorage(): void;
+ subscribe(listener: () => void): () => void;
+}
+
+export function createEditorSidebarSideStore(
+ key: string,
+ fallback: EditorSidebarSide,
+ storage: () => EditorSidebarSideStorage,
+): EditorSidebarSideStore {
+ const other: EditorSidebarSide = fallback === 'start' ? 'end' : 'start';
+ const listeners = new Set<() => void>();
+ let side: EditorSidebarSide | null = null;
+ const read = (): EditorSidebarSide => {
+ try {
+ return storage().getItem(key) === other ? other : fallback;
+ } catch {
+ return fallback;
+ }
+ };
+ const notify = () => {
+ for (const listener of listeners) listener();
+ };
+ return {
+ getSnapshot() {
+ side ??= read();
+ return side;
+ },
+ set(next) {
+ side = next;
+ try {
+ storage().setItem(key, next);
+ } catch {}
+ notify();
+ },
+ syncFromStorage() {
+ side = read();
+ notify();
+ },
+ subscribe(listener) {
+ listeners.add(listener);
+ return () => listeners.delete(listener);
+ },
+ };
+}
+
+const fileSidebarSideStore = createEditorSidebarSideStore(
+ FILE_SIDEBAR_SIDE_KEY,
+ 'start',
+ () => localStorage,
+);
+
+if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
+ window.addEventListener('storage', (event) => {
+ if (event.key === FILE_SIDEBAR_SIDE_KEY || event.key === null)
+ fileSidebarSideStore.syncFromStorage();
+ });
+}
+
+export function swapEditorSidebars(store: EditorSidebarSideStore = fileSidebarSideStore): void {
+ store.set(store.getSnapshot() === 'start' ? 'end' : 'start');
+}
+
+export function physicalSide(side: EditorSidebarSide, direction: TextDirection): 'left' | 'right' {
+ return (side === 'start') === (direction === 'ltr') ? 'left' : 'right';
+}
+
+export function documentPanelSide(fileSidebarSide: EditorSidebarSide): EditorSidebarSide {
+ return fileSidebarSide === 'start' ? 'end' : 'start';
+}
+
+export function useFileSidebarSide(): EditorSidebarSide {
+ return useSyncExternalStore(
+ fileSidebarSideStore.subscribe,
+ fileSidebarSideStore.getSnapshot,
+ () => 'start',
+ );
+}
diff --git a/packages/app/src/lib/keyboard-shortcuts.ts b/packages/app/src/lib/keyboard-shortcuts.ts
index eb63095a8..4e9378bd2 100644
--- a/packages/app/src/lib/keyboard-shortcuts.ts
+++ b/packages/app/src/lib/keyboard-shortcuts.ts
@@ -145,7 +145,7 @@ const KEYBOARD_SHORTCUT_DEFINITIONS = [
id: 'toggle-files-sidebar',
category: 'general',
title: msg`Show or hide Files`,
- description: msg`Toggle the left file sidebar.`,
+ description: msg`Toggle the file sidebar.`,
scope: msg`Global`,
bindings: [
{
@@ -159,7 +159,7 @@ const KEYBOARD_SHORTCUT_DEFINITIONS = [
id: 'toggle-document-panel',
category: 'general',
title: msg`Show or hide document panel`,
- description: msg`Toggle the right document panel.`,
+ description: msg`Toggle the document panel.`,
scope: msg`Global`,
bindings: [
{
diff --git a/packages/app/src/lib/use-document-direction.ts b/packages/app/src/lib/use-document-direction.ts
new file mode 100644
index 000000000..b9f99a915
--- /dev/null
+++ b/packages/app/src/lib/use-document-direction.ts
@@ -0,0 +1,16 @@
+import type { TextDirection } from '@inkeep/open-knowledge-core/i18n/direction';
+import { useSyncExternalStore } from 'react';
+
+function subscribeDocumentDirection(listener: () => void): () => void {
+ const observer = new MutationObserver(listener);
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ['dir'] });
+ return () => observer.disconnect();
+}
+
+function currentDocumentDirection(): TextDirection {
+ return document.documentElement.dir === 'rtl' ? 'rtl' : 'ltr';
+}
+
+export function useDocumentDirection(): TextDirection {
+ return useSyncExternalStore(subscribeDocumentDirection, currentDocumentDirection, () => 'ltr');
+}
diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.po
index e758a616d..d8ac2bd82 100644
--- a/packages/app/src/locales/ar/messages.po
+++ b/packages/app/src/locales/ar/messages.po
@@ -10127,6 +10127,9 @@ msgstr "قائمة الاقتراحات مفتوحة"
msgid "Summarize everything I changed this week"
msgstr "لخّص كل ما غيّرته هذا الأسبوع"
+msgid "Swap file sidebar and document panel"
+msgstr "تبديل موضعي الشريط الجانبي للملفات ولوحة المستند"
+
msgid "Switch and update branch"
msgstr "تبديل الفرع وتحديثه"
@@ -11291,15 +11294,15 @@ msgstr "بدّل تنسيق الخط في المنتصف."
msgid "Toggle Terminal in its current dock."
msgstr "أظهر Terminal أو أخفه في موضع الإرساء الحالي."
-msgid "Toggle the left file sidebar."
-msgstr "بدّل شريط الملفات الجانبي الأيسر."
+msgid "Toggle the document panel."
+msgstr "بدّل لوحة المستند."
+
+msgid "Toggle the file sidebar."
+msgstr "بدّل شريط الملفات الجانبي."
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "بدّل لوحة الوكلاء اليمنى، حيث تعيش محادثات الوكلاء."
-msgid "Toggle the right document panel."
-msgstr "بدّل لوحة المستند اليمنى."
-
msgid "Toggle thumbnails"
msgstr "تبديل الصور المصغّرة"
diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.po
index f2358ab38..2148d6227 100644
--- a/packages/app/src/locales/bn/messages.po
+++ b/packages/app/src/locales/bn/messages.po
@@ -10123,6 +10123,9 @@ msgstr "পরামর্শ মেনু খোলা"
msgid "Summarize everything I changed this week"
msgstr "এই সপ্তাহে আমি যা যা বদলেছি তার সারসংক্ষেপ দিন"
+msgid "Swap file sidebar and document panel"
+msgstr "ফাইল সাইডবার ও নথি প্যানেলের জায়গা বদলান"
+
msgid "Switch and update branch"
msgstr "ব্রাঞ্চ বদলে হালনাগাদ করুন"
@@ -11287,15 +11290,15 @@ msgstr "কাটা দাগের বিন্যাস চালু বা
msgid "Toggle Terminal in its current dock."
msgstr "Terminal-কে তার বর্তমান ডকে দেখান বা লুকান।"
-msgid "Toggle the left file sidebar."
-msgstr "বাঁ দিকের ফাইল সাইডবার চালু বা বন্ধ করুন।"
+msgid "Toggle the document panel."
+msgstr "নথি প্যানেল চালু বা বন্ধ করুন।"
+
+msgid "Toggle the file sidebar."
+msgstr "ফাইল সাইডবার চালু বা বন্ধ করুন।"
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "ডান দিকের এজেন্ট প্যানেল চালু বা বন্ধ করুন, যেখানে এজেন্টের কথোপকথন থাকে।"
-msgid "Toggle the right document panel."
-msgstr "ডান দিকের নথি প্যানেল চালু বা বন্ধ করুন।"
-
msgid "Toggle thumbnails"
msgstr "থাম্বনেইল চালু বা বন্ধ করুন"
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 701abbde2..c4c7cd507 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -10127,6 +10127,9 @@ msgstr "Suggestion menu open"
msgid "Summarize everything I changed this week"
msgstr "Summarize everything I changed this week"
+msgid "Swap file sidebar and document panel"
+msgstr "Swap file sidebar and document panel"
+
msgid "Switch and update branch"
msgstr "Switch and update branch"
@@ -11291,15 +11294,15 @@ msgstr "Toggle strikethrough formatting."
msgid "Toggle Terminal in its current dock."
msgstr "Toggle Terminal in its current dock."
-msgid "Toggle the left file sidebar."
-msgstr "Toggle the left file sidebar."
+msgid "Toggle the document panel."
+msgstr "Toggle the document panel."
+
+msgid "Toggle the file sidebar."
+msgstr "Toggle the file sidebar."
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "Toggle the right agents panel, where agent conversations live."
-msgid "Toggle the right document panel."
-msgstr "Toggle the right document panel."
-
msgid "Toggle thumbnails"
msgstr "Toggle thumbnails"
diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.po
index d3df2dd50..369d38e4f 100644
--- a/packages/app/src/locales/es/messages.po
+++ b/packages/app/src/locales/es/messages.po
@@ -10127,6 +10127,9 @@ msgstr "Menú de sugerencias abierto"
msgid "Summarize everything I changed this week"
msgstr "Resume todo lo que cambié esta semana"
+msgid "Swap file sidebar and document panel"
+msgstr "Intercambiar la barra lateral de archivos y el panel del documento"
+
msgid "Switch and update branch"
msgstr "Cambiar de rama y actualizar"
@@ -11291,15 +11294,15 @@ msgstr "Activa o desactiva el tachado."
msgid "Toggle Terminal in its current dock."
msgstr "Muestra u oculta Terminal en su panel actual."
-msgid "Toggle the left file sidebar."
-msgstr "Muestra u oculta la barra lateral izquierda de archivos."
+msgid "Toggle the document panel."
+msgstr "Muestra u oculta el panel del documento."
+
+msgid "Toggle the file sidebar."
+msgstr "Muestra u oculta la barra lateral de archivos."
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "Muestra u oculta el panel derecho de agentes, donde viven las conversaciones con agentes."
-msgid "Toggle the right document panel."
-msgstr "Muestra u oculta el panel derecho del documento."
-
msgid "Toggle thumbnails"
msgstr "Mostrar u ocultar las miniaturas"
diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.po
index 09cdce09c..03593be81 100644
--- a/packages/app/src/locales/fr/messages.po
+++ b/packages/app/src/locales/fr/messages.po
@@ -10127,6 +10127,9 @@ msgstr "Menu de suggestions ouvert"
msgid "Summarize everything I changed this week"
msgstr "Résume tout ce que j'ai changé cette semaine"
+msgid "Swap file sidebar and document panel"
+msgstr "Intervertir la barre latérale des fichiers et le panneau du document"
+
msgid "Switch and update branch"
msgstr "Changer de branche et mettre à jour"
@@ -11291,15 +11294,15 @@ msgstr "Bascule la mise en forme barrée."
msgid "Toggle Terminal in its current dock."
msgstr "Affichez ou masquez Terminal dans son panneau actuel."
-msgid "Toggle the left file sidebar."
-msgstr "Affiche ou masque la barre latérale des fichiers, à gauche."
+msgid "Toggle the document panel."
+msgstr "Affiche ou masque le panneau du document."
+
+msgid "Toggle the file sidebar."
+msgstr "Affiche ou masque la barre latérale des fichiers."
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "Affiche ou masque le panneau des agents, à droite, où résident les conversations d'agents."
-msgid "Toggle the right document panel."
-msgstr "Affiche ou masque le panneau du document, à droite."
-
msgid "Toggle thumbnails"
msgstr "Basculer les miniatures"
diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.po
index e3fb6c6d8..e269e0c1b 100644
--- a/packages/app/src/locales/hi/messages.po
+++ b/packages/app/src/locales/hi/messages.po
@@ -10123,6 +10123,9 @@ msgstr "सुझाव मेन्यू खुला"
msgid "Summarize everything I changed this week"
msgstr "इस सप्ताह मैंने जो कुछ बदला उसका सारांश दें"
+msgid "Swap file sidebar and document panel"
+msgstr "फ़ाइल साइडबार और दस्तावेज़ पैनल की जगह बदलें"
+
msgid "Switch and update branch"
msgstr "ब्रांच बदलें और अपडेट करें"
@@ -11287,15 +11290,15 @@ msgstr "काटी हुई फ़ॉर्मैटिंग चालू
msgid "Toggle Terminal in its current dock."
msgstr "Terminal को उसके मौजूदा डॉक में दिखाएँ या छिपाएँ।"
-msgid "Toggle the left file sidebar."
-msgstr "बाईं फ़ाइल साइडबार चालू या बंद करें।"
+msgid "Toggle the document panel."
+msgstr "दस्तावेज़ पैनल चालू या बंद करें।"
+
+msgid "Toggle the file sidebar."
+msgstr "फ़ाइल साइडबार चालू या बंद करें।"
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "दायाँ एजेंट पैनल चालू या बंद करें, जहाँ एजेंट की बातचीत रहती है।"
-msgid "Toggle the right document panel."
-msgstr "दायाँ दस्तावेज़ पैनल चालू या बंद करें।"
-
msgid "Toggle thumbnails"
msgstr "थंबनेल चालू या बंद करें"
diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.po
index 3ee611c45..f34d7e120 100644
--- a/packages/app/src/locales/id/messages.po
+++ b/packages/app/src/locales/id/messages.po
@@ -10123,6 +10123,9 @@ msgstr "Menu saran terbuka"
msgid "Summarize everything I changed this week"
msgstr "Ringkas semua yang saya ubah minggu ini"
+msgid "Swap file sidebar and document panel"
+msgstr "Tukar posisi bilah sisi berkas dan panel dokumen"
+
msgid "Switch and update branch"
msgstr "Ganti cabang dan perbarui"
@@ -11287,15 +11290,15 @@ msgstr "Menyalakan atau mematikan format coret."
msgid "Toggle Terminal in its current dock."
msgstr "Tampilkan atau sembunyikan Terminal di dok saat ini."
-msgid "Toggle the left file sidebar."
-msgstr "Menampilkan atau menyembunyikan bilah sisi berkas di kiri."
+msgid "Toggle the document panel."
+msgstr "Menampilkan atau menyembunyikan panel dokumen."
+
+msgid "Toggle the file sidebar."
+msgstr "Menampilkan atau menyembunyikan bilah sisi berkas."
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "Menampilkan atau menyembunyikan panel agen di kanan, tempat percakapan dengan agen berada."
-msgid "Toggle the right document panel."
-msgstr "Menampilkan atau menyembunyikan panel dokumen di kanan."
-
msgid "Toggle thumbnails"
msgstr "Tampilkan atau sembunyikan gambar mini"
diff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.po
index 97a43a5ab..3c7a8f7f3 100644
--- a/packages/app/src/locales/ko/messages.po
+++ b/packages/app/src/locales/ko/messages.po
@@ -10127,6 +10127,9 @@ msgstr "제안 메뉴 열기"
msgid "Summarize everything I changed this week"
msgstr "이번 주 변경한 내용 모두 요약"
+msgid "Swap file sidebar and document panel"
+msgstr "파일 사이드바와 문서 패널 위치 바꾸기"
+
msgid "Switch and update branch"
msgstr "브랜치 전환 및 업데이트"
@@ -11291,15 +11294,15 @@ msgstr "취소선 서식을 전환합니다."
msgid "Toggle Terminal in its current dock."
msgstr "현재 도크에서 터미널 전환"
-msgid "Toggle the left file sidebar."
-msgstr "왼쪽 파일 사이드바 전환"
+msgid "Toggle the document panel."
+msgstr "문서 패널 전환"
+
+msgid "Toggle the file sidebar."
+msgstr "파일 사이드바 전환"
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "에이전트 대화가 표시되는 오른쪽 에이전트 패널 전환"
-msgid "Toggle the right document panel."
-msgstr "오른쪽 문서 패널 전환"
-
msgid "Toggle thumbnails"
msgstr "썸네일 전환"
diff --git a/packages/app/src/locales/pl/messages.po b/packages/app/src/locales/pl/messages.po
index 629c8d721..f4d63ef40 100644
--- a/packages/app/src/locales/pl/messages.po
+++ b/packages/app/src/locales/pl/messages.po
@@ -10127,6 +10127,9 @@ msgstr "Otwarcie menu podpowiedzi"
msgid "Summarize everything I changed this week"
msgstr "Podsumuj wszystko, co zmieniłem w tym tygodniu"
+msgid "Swap file sidebar and document panel"
+msgstr "Zamień miejscami panel plików i panel dokumentu"
+
msgid "Switch and update branch"
msgstr "Przełącz i zaktualizuj gałąź"
@@ -11291,15 +11294,15 @@ msgstr "Przełącz formatowanie przekreślenia."
msgid "Toggle Terminal in its current dock."
msgstr "Przełącz Terminal w jego bieżącym doku."
-msgid "Toggle the left file sidebar."
-msgstr "Przełącz lewy panel plików."
+msgid "Toggle the document panel."
+msgstr "Przełącz panel dokumentu."
+
+msgid "Toggle the file sidebar."
+msgstr "Przełącz panel plików."
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "Przełącz prawy panel agentów, w którym znajdują się rozmowy z agentami."
-msgid "Toggle the right document panel."
-msgstr "Przełącz prawy panel dokumentu."
-
msgid "Toggle thumbnails"
msgstr "Przełącz miniatury"
diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.po
index 63c0f56db..9c9ab52ed 100644
--- a/packages/app/src/locales/pt-BR/messages.po
+++ b/packages/app/src/locales/pt-BR/messages.po
@@ -10123,6 +10123,9 @@ msgstr "Menu de sugestões aberto"
msgid "Summarize everything I changed this week"
msgstr "Resuma tudo o que mudei esta semana"
+msgid "Swap file sidebar and document panel"
+msgstr "Trocar de lado a barra lateral de arquivos e o painel do documento"
+
msgid "Switch and update branch"
msgstr "Trocar de ramo e atualizar"
@@ -11287,15 +11290,15 @@ msgstr "Liga ou desliga o tachado."
msgid "Toggle Terminal in its current dock."
msgstr "Mostre ou oculte o Terminal no painel atual."
-msgid "Toggle the left file sidebar."
-msgstr "Mostra ou oculta a barra lateral esquerda de arquivos."
+msgid "Toggle the document panel."
+msgstr "Mostra ou oculta o painel do documento."
+
+msgid "Toggle the file sidebar."
+msgstr "Mostra ou oculta a barra lateral de arquivos."
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "Mostra ou oculta o painel direito de agentes, onde ficam as conversas com agentes."
-msgid "Toggle the right document panel."
-msgstr "Mostra ou oculta o painel direito do documento."
-
msgid "Toggle thumbnails"
msgstr "Mostrar ou ocultar as miniaturas"
diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.po
index 42788b0f7..005c257aa 100644
--- a/packages/app/src/locales/ur/messages.po
+++ b/packages/app/src/locales/ur/messages.po
@@ -10127,6 +10127,9 @@ msgstr "تجاویز کا مینو کھلا ہے"
msgid "Summarize everything I changed this week"
msgstr "اس ہفتے میں نے جو کچھ بدلا اس کا خلاصہ کریں"
+msgid "Swap file sidebar and document panel"
+msgstr "فائل سائیڈ بار اور دستاویز کے پینل کی جگہ بدلیں"
+
msgid "Switch and update branch"
msgstr "برانچ بدلیں اور تازہ کریں"
@@ -11291,15 +11294,15 @@ msgstr "درمیان سے کٹی فارمیٹنگ بدلیں۔"
msgid "Toggle Terminal in its current dock."
msgstr "Terminal کو اس کی موجودہ ڈاک میں دکھائیں یا چھپائیں۔"
-msgid "Toggle the left file sidebar."
-msgstr "بائیں فائل سائیڈ بار بدلیں۔"
+msgid "Toggle the document panel."
+msgstr "دستاویز پینل بدلیں۔"
+
+msgid "Toggle the file sidebar."
+msgstr "فائل سائیڈ بار بدلیں۔"
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "دائیں ایجنٹس پینل بدلیں، جہاں ایجنٹس کی گفتگو رہتی ہے۔"
-msgid "Toggle the right document panel."
-msgstr "دائیں دستاویز پینل بدلیں۔"
-
msgid "Toggle thumbnails"
msgstr "تھمب نیلز بدلیں"
diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.po
index 1c2a55ff5..0f63c203e 100644
--- a/packages/app/src/locales/zh-Hans/messages.po
+++ b/packages/app/src/locales/zh-Hans/messages.po
@@ -10127,6 +10127,9 @@ msgstr "建议菜单已打开"
msgid "Summarize everything I changed this week"
msgstr "总结我这周改了些什么"
+msgid "Swap file sidebar and document panel"
+msgstr "交换文件侧边栏与文档面板的位置"
+
msgid "Switch and update branch"
msgstr "切换并更新分支"
@@ -11291,15 +11294,15 @@ msgstr "切换删除线格式。"
msgid "Toggle Terminal in its current dock."
msgstr "在当前停靠位置显示或隐藏 Terminal。"
-msgid "Toggle the left file sidebar."
-msgstr "显示或隐藏左侧的文件侧边栏。"
+msgid "Toggle the document panel."
+msgstr "显示或隐藏文档面板。"
+
+msgid "Toggle the file sidebar."
+msgstr "显示或隐藏文件侧边栏。"
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "显示或隐藏右侧的智能体面板,智能体对话就在那里。"
-msgid "Toggle the right document panel."
-msgstr "显示或隐藏右侧的文档面板。"
-
msgid "Toggle thumbnails"
msgstr "切换缩略图"
diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.po
index 143c45876..fc1acb49f 100644
--- a/packages/app/src/locales/zh-Hant/messages.po
+++ b/packages/app/src/locales/zh-Hant/messages.po
@@ -10127,6 +10127,9 @@ msgstr "建議選單已開啟"
msgid "Summarize everything I changed this week"
msgstr "總結我這週改了哪些東西"
+msgid "Swap file sidebar and document panel"
+msgstr "交換檔案側邊欄與文件面板的位置"
+
msgid "Switch and update branch"
msgstr "切換並更新分支"
@@ -11291,15 +11294,15 @@ msgstr "切換刪除線格式。"
msgid "Toggle Terminal in its current dock."
msgstr "在目前的停靠位置顯示或隱藏 Terminal。"
-msgid "Toggle the left file sidebar."
-msgstr "顯示或隱藏左側的檔案側邊欄。"
+msgid "Toggle the document panel."
+msgstr "顯示或隱藏文件面板。"
+
+msgid "Toggle the file sidebar."
+msgstr "顯示或隱藏檔案側邊欄。"
msgid "Toggle the right agents panel, where agent conversations live."
msgstr "顯示或隱藏右側的代理面板,代理對話就在那裡。"
-msgid "Toggle the right document panel."
-msgstr "顯示或隱藏右側的文件面板。"
-
msgid "Toggle thumbnails"
msgstr "切換縮圖"
diff --git a/packages/app/tests/stress/editor-sidebar-sides.e2e.ts b/packages/app/tests/stress/editor-sidebar-sides.e2e.ts
new file mode 100644
index 000000000..2ad8e4095
--- /dev/null
+++ b/packages/app/tests/stress/editor-sidebar-sides.e2e.ts
@@ -0,0 +1,249 @@
+import type { Page } from '@playwright/test';
+import type { ApiHelpers } from './_helpers';
+import {
+ expect,
+ headerPaneButton,
+ openDesktopHeader,
+ runPaletteCommand,
+ stubAgentCatalog,
+ test,
+ waitForActiveProviderSynced,
+} from './_helpers';
+
+const BOOT_TIMEOUT_MS = 30_000;
+const DOC_TEXT = 'A document between two sidebars.';
+const FILE_LIST = '[data-editor-file-list-slot]';
+const EDITOR_COLUMN = '[data-editor-workspace-column]';
+const DOC_PANEL = '#doc-panel';
+const FILE_LIST_TOGGLE = '[data-file-list-toggle]';
+const DOC_PANEL_TOGGLE = '[data-doc-panel-toggle]';
+const SWAP_LABEL = 'Swap file sidebar and document panel';
+
+interface Span {
+ readonly start: number;
+ readonly end: number;
+}
+
+async function spanOf(page: Page, selector: string): Promise<Span | null> {
+ const box = await page.locator(selector).first().boundingBox();
+ return box === null ? null : { start: box.x, end: box.x + box.width };
+}
+
+async function openWide(page: Page, api: ApiHelpers, slug: string): Promise<void> {
+ const name = `editor-sidebar-sides-${slug}-${test.info().workerIndex}`;
+ await api.seedDocs([{ name, markdown: `# ${name}\n\n${DOC_TEXT}\n` }]);
+ await stubAgentCatalog(page);
+ await page.setViewportSize({ width: 1600, height: 900 });
+ await page.goto(`/#/${name}`);
+ await waitForActiveProviderSynced(page);
+ await expect(headerPaneButton(page, 'editor')).toBeVisible({ timeout: BOOT_TIMEOUT_MS });
+ await expect(page.locator('.tiptap-editor .ProseMirror').first()).toContainText(DOC_TEXT, {
+ timeout: BOOT_TIMEOUT_MS,
+ });
+}
+
+async function fileSidebarSide(page: Page): Promise<'left' | 'right' | 'unsettled'> {
+ const [list, editor, panel, listToggle, panelToggle] = await Promise.all(
+ [FILE_LIST, EDITOR_COLUMN, DOC_PANEL, FILE_LIST_TOGGLE, DOC_PANEL_TOGGLE].map((selector) =>
+ spanOf(page, selector),
+ ),
+ );
+ if (
+ list == null ||
+ editor == null ||
+ panel == null ||
+ listToggle == null ||
+ panelToggle == null
+ ) {
+ return 'unsettled';
+ }
+ if (
+ list.end <= editor.start + 1 &&
+ panel.start >= editor.end - 1 &&
+ listToggle.start < panelToggle.start
+ ) {
+ return 'left';
+ }
+ if (
+ list.start >= editor.end - 1 &&
+ panel.end <= editor.start + 1 &&
+ listToggle.start > panelToggle.start
+ ) {
+ return 'right';
+ }
+ return 'unsettled';
+}
+
+async function widthOf(page: Page, selector: string): Promise<number> {
+ const span = await spanOf(page, selector);
+ return span === null ? 0 : span.end - span.start;
+}
+
+async function expectFileSidebar(page: Page, side: 'left' | 'right'): Promise<void> {
+ await expect.poll(() => fileSidebarSide(page), { timeout: BOOT_TIMEOUT_MS }).toBe(side);
+}
+
+test.describe('swapping the editor sidebars', () => {
+ test('the palette puts the file sidebar on the right and the document panel on the left, the two toggles trade ends, and a reload keeps it', async ({
+ page,
+ api,
+ }) => {
+ await openWide(page, api, 'palette');
+ await expectFileSidebar(page, 'left');
+
+ await runPaletteCommand(page, 'swap file sidebar', 'swap-editor-sidebars');
+ await expectFileSidebar(page, 'right');
+
+ await page.reload();
+ await waitForActiveProviderSynced(page);
+ await expectFileSidebar(page, 'right');
+ });
+
+ test('right-clicking an empty part of the editor tab row offers the swap, and choosing it puts the sidebars back', async ({
+ page,
+ api,
+ }) => {
+ await openWide(page, api, 'menu');
+ await expectFileSidebar(page, 'left');
+ await runPaletteCommand(page, 'swap file sidebar', 'swap-editor-sidebars');
+ await expectFileSidebar(page, 'right');
+
+ const strip = await page.locator('[data-editor-pane-tabs]').first().boundingBox();
+ if (strip === null) throw new Error('the editor tab row has no layout box');
+ await page.mouse.click(strip.x + strip.width * 0.6, strip.y + strip.height / 2, {
+ button: 'right',
+ });
+ await page.getByRole('menuitem', { name: SWAP_LABEL }).click();
+ await expectFileSidebar(page, 'left');
+ });
+
+ test('a document panel resized before a swap keeps its width, and one closed before a swap stays closed', async ({
+ page,
+ api,
+ }) => {
+ await openWide(page, api, 'panel-width');
+ await expectFileSidebar(page, 'left');
+ const handle = await page.locator('[data-doc-panel-handle]').boundingBox();
+ if (handle === null) throw new Error('the document panel handle has no layout box');
+ const before = await widthOf(page, DOC_PANEL);
+ await page.mouse.move(handle.x + handle.width / 2, handle.y + handle.height / 2);
+ await page.mouse.down();
+ await page.mouse.move(handle.x + handle.width / 2 - 80, handle.y + handle.height / 2, {
+ steps: 8,
+ });
+ await page.mouse.up();
+ await expect.poll(() => widthOf(page, DOC_PANEL)).toBeGreaterThan(before + 60);
+ const resized = await widthOf(page, DOC_PANEL);
+
+ await runPaletteCommand(page, 'swap file sidebar', 'swap-editor-sidebars');
+ await expectFileSidebar(page, 'right');
+ await expect
+ .poll(async () => Math.abs((await widthOf(page, DOC_PANEL)) - resized))
+ .toBeLessThan(3);
+
+ const toggle = page.locator(DOC_PANEL_TOGGLE);
+ await toggle.click();
+ await expect(toggle).toHaveAttribute('aria-expanded', 'false');
+ await runPaletteCommand(page, 'swap file sidebar', 'swap-editor-sidebars');
+ await expectFileSidebar(page, 'left');
+ await expect.poll(() => widthOf(page, FILE_LIST)).toBeGreaterThan(0);
+ await expect(page.locator(DOC_PANEL_TOGGLE)).toHaveAttribute('aria-expanded', 'false');
+ await expect.poll(() => widthOf(page, DOC_PANEL)).toBeLessThan(2);
+ });
+
+ test('with the file sidebar on the right, dragging its edge to the left widens it', async ({
+ page,
+ api,
+ }) => {
+ await openWide(page, api, 'rail');
+ await runPaletteCommand(page, 'swap file sidebar', 'swap-editor-sidebars');
+ await expectFileSidebar(page, 'right');
+ const rail = await page.locator(`${FILE_LIST} [data-sidebar="rail"]`).boundingBox();
+ if (rail === null) throw new Error('the file sidebar rail has no layout box');
+ const before = await widthOf(page, FILE_LIST);
+ await page.mouse.move(rail.x + rail.width / 2, rail.y + rail.height / 2);
+ await page.mouse.down();
+ await page.mouse.move(rail.x + rail.width / 2 - 60, rail.y + rail.height / 2, { steps: 8 });
+ await page.mouse.up();
+ await expect.poll(() => widthOf(page, FILE_LIST)).toBeGreaterThan(before + 40);
+ });
+
+ test('in a right-to-left layout the file sidebar keeps its rail on the edge facing the document in both arrangements, and dragging it toward the document widens it', async ({
+ page,
+ api,
+ }) => {
+ await openWide(page, api, 'rtl');
+ await page.evaluate(() => {
+ document.documentElement.dir = 'rtl';
+ });
+ for (const swapped of [false, true]) {
+ if (swapped) await runPaletteCommand(page, 'swap file sidebar', 'swap-editor-sidebars');
+ const expectedSide = swapped ? 'left' : 'right';
+ await expect
+ .poll(async () => {
+ const [list, editor] = await Promise.all([
+ spanOf(page, FILE_LIST),
+ spanOf(page, EDITOR_COLUMN),
+ ]);
+ if (list === null || editor === null) return 'unsettled';
+ if (list.start >= editor.end - 1) return 'right';
+ if (list.end <= editor.start + 1) return 'left';
+ return 'unsettled';
+ })
+ .toBe(expectedSide);
+ const list = await spanOf(page, FILE_LIST);
+ const rail = await spanOf(page, `${FILE_LIST} [data-sidebar="rail"]`);
+ if (list === null || rail === null)
+ throw new Error('the file sidebar or its rail has no layout box');
+ const innerEdge = expectedSide === 'right' ? list.start : list.end;
+ const railCenter = (rail.start + rail.end) / 2;
+ expect(Math.abs(railCenter - innerEdge)).toBeLessThan(2);
+
+ const box = await page.locator(`${FILE_LIST} [data-sidebar="rail"]`).boundingBox();
+ if (box === null) throw new Error('the file sidebar rail has no layout box');
+ const before = await widthOf(page, FILE_LIST);
+ const towardDocument = expectedSide === 'right' ? -60 : 60;
+ await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
+ await page.mouse.down();
+ await page.mouse.move(box.x + box.width / 2 + towardDocument, box.y + box.height / 2, {
+ steps: 8,
+ });
+ await page.mouse.up();
+ await expect.poll(() => widthOf(page, FILE_LIST)).toBeGreaterThan(before + 40);
+ }
+ });
+
+ test('in a desktop project window the empty tab row is not a window drag region, so a right-click there offers the swap', async ({
+ page,
+ api,
+ workerServer,
+ }) => {
+ const name = `editor-sidebar-sides-desktop-${test.info().workerIndex}`;
+ await api.seedDocs([{ name, markdown: `# ${name}\n\n${DOC_TEXT}\n` }]);
+ await stubAgentCatalog(page);
+ await page.setViewportSize({ width: 1600, height: 900 });
+ await openDesktopHeader(page, workerServer, name, {});
+ await expect(page.locator('.tiptap-editor .ProseMirror').first()).toContainText(DOC_TEXT, {
+ timeout: BOOT_TIMEOUT_MS,
+ });
+ const regions = await page.evaluate(() =>
+ ['[data-editor-pane-tabs]', '[data-editor-tab-overflow-root]'].map((selector) => {
+ const element = document.querySelector(selector);
+ if (!(element instanceof HTMLElement)) return `${selector}: missing`;
+ const declared = element.closest('[data-electron-drag]') !== null;
+ return `${selector}: ${declared ? 'declared' : 'undeclared'} ${getComputedStyle(element).getPropertyValue('-webkit-app-region') || 'unset'}`;
+ }),
+ );
+ expect(regions).toEqual([
+ '[data-editor-pane-tabs]: declared no-drag',
+ '[data-editor-tab-overflow-root]: declared no-drag',
+ ]);
+
+ const strip = await page.locator('[data-editor-pane-tabs]').first().boundingBox();
+ if (strip === null) throw new Error('the editor tab row has no layout box');
+ await page.mouse.click(strip.x + strip.width * 0.6, strip.y + strip.height / 2, {
+ button: 'right',
+ });
+ await expect(page.getByRole('menuitem', { name: SWAP_LABEL })).toBeVisible();
+ });
+});
diff --git a/packages/core/src/commands/command-identity.ts b/packages/core/src/commands/command-identity.ts
index 8c6a12b98..fa86990b9 100644
--- a/packages/core/src/commands/command-identity.ts
+++ b/packages/core/src/commands/command-identity.ts
@@ -545,6 +545,25 @@ export const COMMAND_IDENTITIES: readonly CommandIdentity[] = [
palette: { group: 'view', visibility: 'search-only' },
menu: [{ section: 'view-panels', order: 1, accelerator: 'CmdOrCtrl+Alt+B' }],
},
+ {
+ id: 'swap-editor-sidebars',
+ labelKey: 'swapEditorSidebars',
+ keywords: [
+ 'sidebar',
+ 'file',
+ 'files',
+ 'document',
+ 'panel',
+ 'swap',
+ 'move',
+ 'side',
+ 'left',
+ 'right',
+ 'position',
+ ],
+ availability: { singleFileHidden: true },
+ palette: { group: 'view', visibility: 'search-only' },
+ },
{
id: 'toggle-editor',
menuActionId: 'toggle-editor',
diff --git a/packages/core/src/constants/menu-labels.ts b/packages/core/src/constants/menu-labels.ts
index 20b536c9f..4c21a3092 100644
--- a/packages/core/src/constants/menu-labels.ts
+++ b/packages/core/src/constants/menu-labels.ts
@@ -49,6 +49,7 @@ export const MENU_LABELS = {
sidebarHide: 'Hide sidebar',
docPanelShow: 'Show document panel',
docPanelHide: 'Hide document panel',
+ swapEditorSidebars: 'Swap file sidebar and document panel',
back: 'Back',
forward: 'Forward',
terminalShow: 'Show Terminal',