Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(open-knowledge): right-dock terminal empty-state parity + near-full-width resize (PRD-7291) (#2435)
serafin-garcia2ec547216be5
diff --git a/.changeset/right-terminal-empty-state-and-width.md b/.changeset/right-terminal-empty-state-and-width.mdnew file mode 100644index 000000000..0007008ab--- /dev/null+++ b/.changeset/right-terminal-empty-state-and-width.md@@ -0,0 +1,15 @@+---+"@inkeep/open-knowledge": patch+---++Make the right-docked terminal consistent with the bottom dock on the "new tab"+(empty editor) screen: opening a terminal in either position now collapses the+empty state to its header, dropping the chat composer bubble and starter-pack+list — the open terminal is its own AI entry point, so the bubble no longer+competes with it. The header bottom-anchors above a bottom dock and centers+beside a right-docked terminal.++The right-docked terminal can also be resized much wider now: the fixed 900px+cap is gone, and the column can grow to near-full width while the editor always+keeps a minimum visible sliver — mirroring how tall the bottom dock can already+be dragged. A wide width persists across reloads instead of snapping back.diff --git a/packages/app/src/components/EditorArea.dom.test.tsx b/packages/app/src/components/EditorArea.dom.test.tsxindex c291e1073..b42484791 100644--- a/packages/app/src/components/EditorArea.dom.test.tsx+++ b/packages/app/src/components/EditorArea.dom.test.tsx@@ -88,10 +88,11 @@ mock.module('@/editor/DocumentContext', () => ({}));mock.module('@/components/EmptyEditorState', () => ({- // Forward terminalVisible so the EditorArea -> EmptyEditorState prop wiring is- // observable (the empty state collapses to the mascot when the terminal is up).- EmptyEditorState: ({ terminalVisible }: { terminalVisible?: boolean }) => (- <div data-testid="empty-editor-state" data-terminal-visible={String(terminalVisible)} />+ // Forward terminalDock so the EditorArea -> EmptyEditorState prop wiring is+ // observable (the empty state collapses to the header-only view whenever a+ // terminal is up, in either dock).+ EmptyEditorState: ({ terminalDock }: { terminalDock?: string | null }) => (+ <div data-testid="empty-editor-state" data-terminal-dock={String(terminalDock)} />),}));@@ -278,10 +279,6 @@ describe('EditorArea empty-state terminal host', () => {terminalBridge={{} as never}terminalVisibleonTerminalVisibleChange={() => {}}- // Pin the bottom dock so the mascot-collapse forwarding is exercised:- // only a BOTTOM terminal collapses the mascot (it eats vertical space). A- // right-docked terminal eats horizontal space, so the mascot stays full —- // covered by the next test.terminalDock="bottom"/>,);@@ -290,11 +287,12 @@ describe('EditorArea empty-state terminal host', () => {expect(dock.getAttribute('data-visible')).toBe('true');const emptyState = dock.querySelector('[data-testid="empty-editor-state"]');expect(emptyState).not.toBeNull();- // EditorArea forwards terminalVisible so the empty state can collapse to the mascot.- expect(emptyState?.getAttribute('data-terminal-visible')).toBe('true');+ // EditorArea forwards the dock position so the empty state collapses to the+ // header-only view (composer bubble dropped) while the terminal is up.+ expect(emptyState?.getAttribute('data-terminal-dock')).toBe('bottom');});- test('keeps the empty-state mascot full-size when the terminal is right-docked', () => {+ test('collapses the empty state to the header-only view when the terminal is right-docked', () => {render(<EditorAreaeditorMode="wysiwyg"@@ -304,8 +302,9 @@ describe('EditorArea empty-state terminal host', () => {terminalBridge={{} as never}terminalVisibleonTerminalVisibleChange={() => {}}- // Right is the default dock; the terminal eats horizontal (not vertical)- // space, so the empty-state mascot must NOT collapse.+ // Right is the default dock. Either dock position collapses the empty+ // state — the open terminal is its own AI entry point, so the composer+ // bubble must not compete with it.terminalDock="right"/>,);@@ -314,7 +313,7 @@ describe('EditorArea empty-state terminal host', () => {expect(dock.getAttribute('data-visible')).toBe('true');const emptyState = dock.querySelector('[data-testid="empty-editor-state"]');expect(emptyState).not.toBeNull();- expect(emptyState?.getAttribute('data-terminal-visible')).toBe('false');+ expect(emptyState?.getAttribute('data-terminal-dock')).toBe('right');});test('renders the empty state with no terminal dock on the web host (no bridge)', () => {@@ -328,7 +327,12 @@ describe('EditorArea empty-state terminal host', () => {);expect(screen.queryByTestId('terminal-dock')).toBeNull();- expect(screen.getByTestId('empty-editor-state')).toBeTruthy();+ // Pins the `terminalVisible ? position : null` forwarding: without an open+ // terminal the empty state must receive null, or it would collapse to+ // header-only on every new tab.+ expect(screen.getByTestId('empty-editor-state').getAttribute('data-terminal-dock')).toBe(+ 'null',+ );});});diff --git a/packages/app/src/components/EditorArea.tsx b/packages/app/src/components/EditorArea.tsxindex 18e405069..96cf01386 100644--- a/packages/app/src/components/EditorArea.tsx+++ b/packages/app/src/components/EditorArea.tsx@@ -50,7 +50,6 @@ import { applyToggle, readPins, resolveEffectiveState } from '@/lib/sidebar-pin-import type { TerminalDockPosition } from '@/lib/terminal-dock-store';import {getInitialTerminalWidth,- MAX_TERMINAL_WIDTH,MIN_TERMINAL_WIDTH,writeTerminalWidth,} from '@/lib/terminal-width-store';@@ -884,12 +883,13 @@ function EditorAreaInner({return <EditorSkeleton />;}} else {- // The empty state forwards `terminalVisible` so it can collapse to the- // mascot while the BOTTOM-docked terminal is open. A right-docked terminal- // eats horizontal (not vertical) space, so the mascot must stay full-size —- // gate on the resolved bottom position.+ // The empty state collapses to the header-only view while a terminal is+ // open in EITHER dock — the open terminal is its own AI entry point, so+ // the composer bubble + starter packs would compete with it. The dock+ // position picks the header pose (bottom-anchored above the bottom dock;+ // centered beside the right column).viewContent = (- <EmptyEditorState terminalVisible={terminalVisible && terminalDockPosition === 'bottom'} />+ <EmptyEditorState terminalDock={terminalVisible ? terminalDockPosition : null} />);}} else {@@ -1172,7 +1172,11 @@ function EditorAreaInner({style={{ backgroundColor: xtermBackground }}defaultSize={`${initialTerminalWidthPx}px`}minSize={`${MIN_TERMINAL_WIDTH}px`}- maxSize={`${MAX_TERMINAL_WIDTH}px`}+ // The terminal can be dragged wide — up to 95% of the group — leaving the+ // editor a 5% sliver (its panel `minSize` while this column is mounted).+ // Pair the two: the terminal's max plus the editor's min must sum to 100%+ // or the drag can't reach it. Mirrors the bottom dock's 95%/5% split.+ maxSize="95%"// Collapsible so a drag past half the min width snaps the column shut —// the pointerup handler above turns that into a real hide.collapsible@@ -1230,7 +1234,14 @@ function EditorAreaInner({// pixel-width sticky restore. The// left panel is always the first child, so React keeps it mounted// across right-side toggles without one (the terminal still persists).- minSize="30%"+ //+ // With the terminal column mounted the editor yields to a 5% sliver so+ // the terminal can be dragged near-full width without ever fully+ // eclipsing the editor — the horizontal mirror of the bottom dock's+ // 95%/5% split (see the terminal column's maxSize below; the pair must+ // sum to 100% or the drag can't reach the max). Without the terminal+ // the 30% floor keeps the editor usable against the doc panel.+ minSize={terminalColumnPresent ? '5%' : '30%'}// Editor takes full width only when nothing on the right claims space;// otherwise it absorbs the residual while the pixel-sized doc panel and// terminal column hold their widths.diff --git a/packages/app/src/components/EmptyEditorState.dom.test.tsx b/packages/app/src/components/EmptyEditorState.dom.test.tsxnew file mode 100644index 000000000..acc060735--- /dev/null+++ b/packages/app/src/components/EmptyEditorState.dom.test.tsx@@ -0,0 +1,87 @@+/**+ * RTL behavior tests for EmptyEditorState's terminal-aware collapse.+ *+ * The empty state ("new tab" screen) must drop its composer bubble + starter+ * packs whenever a terminal is open — in EITHER dock position — because the+ * open terminal is its own AI entry point. Only the header pose differs:+ * bottom-anchored above a bottom dock, vertically centered beside a right+ * column. The full-view children (CreateView / OnboardingView subtrees) and+ * the document-list fetch are mocked at the module boundary so the assertions+ * pin exactly the branch this component owns.+ */+import { afterEach, describe, expect, mock, test } from 'bun:test';+import { cleanup, render, screen, waitFor } from '@testing-library/react';+import type { ReactNode } from 'react';++mock.module('@lingui/react/macro', () => ({+ Trans: ({ children }: { children: ReactNode }) => <>{children}</>,+ useLingui: () => ({+ t: (input: TemplateStringsArray | string, ...values: unknown[]) =>+ typeof input === 'string'+ ? input+ : input.reduce((acc, part, index) => `${acc}${part}${values[index] ?? ''}`, ''),+ }),+}));++mock.module('@/components/empty-state/EmptyStateHeader', () => ({+ EmptyStateHeader: () => <div data-testid="empty-state-header" />,+}));+mock.module('@/components/empty-state/empty-state-copy', () => ({+ getEmptyStateCopy: () => ({ title: 'title', subtitle: 'subtitle' }),+}));+mock.module('@/components/empty-state/CreateView', () => ({+ CreateView: () => <div data-testid="create-view" />,+}));+mock.module('@/components/empty-state/CreatePromptComposer', () => ({+ CreatePromptComposer: () => <div data-testid="create-prompt-composer" />,+}));+mock.module('@/components/empty-state/CopyablePromptList', () => ({+ CopyablePromptList: () => <div data-testid="copyable-prompt-list" />,+}));+mock.module('@/components/PackCardGrid', () => ({+ PackCardGrid: () => <div data-testid="pack-card-grid" />,+}));+mock.module('@/components/SeedDialog', () => ({+ SeedDialog: () => null,+}));+mock.module('@/hooks/use-is-embedded', () => ({+ useIsEmbedded: () => false,+}));+mock.module('@/lib/documents-events', () => ({+ subscribeToDocumentsChanged: () => () => {},+}));+// One existing document → the non-onboarding (CreateView) branch of the full view.+mock.module('@/lib/documents-fetch', () => ({+ fetchDocumentListShared: async () => ({+ ok: true,+ body: { documents: [{ kind: 'document', docName: 'welcome' }] },+ }),+}));++import { EmptyEditorState } from './EmptyEditorState';++afterEach(cleanup);++describe('EmptyEditorState terminal-aware collapse', () => {+ test('no terminal: renders the full view (composer surface present)', async () => {+ render(<EmptyEditorState terminalDock={null} />);+ await waitFor(() => expect(screen.getByTestId('create-view')).toBeTruthy());+ expect(screen.queryByTestId('empty-state-header')).toBeNull();+ });++ test('bottom-docked terminal: header-only, bottom-anchored above the dock', async () => {+ render(<EmptyEditorState terminalDock="bottom" />);+ const header = await screen.findByTestId('empty-state-header');+ expect(screen.queryByTestId('create-view')).toBeNull();+ const pose = header.closest('.justify-end');+ expect(pose).not.toBeNull();+ });++ test('right-docked terminal: header-only too (the composer bubble must not compete), centered', async () => {+ render(<EmptyEditorState terminalDock="right" />);+ const header = await screen.findByTestId('empty-state-header');+ expect(screen.queryByTestId('create-view')).toBeNull();+ const pose = header.closest('.justify-center');+ expect(pose).not.toBeNull();+ });+});diff --git a/packages/app/src/components/EmptyEditorState.tsx b/packages/app/src/components/EmptyEditorState.tsxindex a82c52c10..370a42267 100644--- a/packages/app/src/components/EmptyEditorState.tsx+++ b/packages/app/src/components/EmptyEditorState.tsx@@ -14,8 +14,15 @@ import { emitCreateTopLevelFile } from '@/lib/create-file-events';import type { OkPackId } from '@/lib/desktop-bridge-types';import { subscribeToDocumentsChanged } from '@/lib/documents-events';import { fetchDocumentListShared } from '@/lib/documents-fetch';+import type { TerminalDockPosition } from '@/lib/terminal-dock-store';+import { cn } from '@/lib/utils';-export function EmptyEditorState({ terminalVisible = false }: { terminalVisible?: boolean }) {+export function EmptyEditorState({+ terminalDock = null,+}: {+ /** Where the visible terminal is docked, or null when no terminal is open. */+ terminalDock?: TerminalDockPosition | null;+}) {const [seedDialogOpen, setSeedDialogOpen] = useState(false);const [seedDialogInitialPackId, setSeedDialogInitialPackId] = useState<OkPackId | undefined>(undefined,@@ -100,15 +107,22 @@ export function EmptyEditorState({ terminalVisible = false }: { terminalVisible?if (!next) setSeedDialogInitialPackId(undefined);}- // When the docked terminal is open (an empty-state CLI launch), keep the- // header — blob + headline + subtitle, left-aligned in the same column as the- // full view — but drop the composer bubble + starter-pack list, since the- // terminal owns the lower half and the full surface would crowd it.- // `justify-end` bottom-anchors the header just above the dock so it rides- // up/down as the terminal is resized (matching the prior blob-only pose).- if (terminalVisible) {+ // When the terminal is open (an empty-state CLI launch), keep the header —+ // blob + headline + subtitle, left-aligned in the same column as the full+ // view — but drop the composer bubble + starter-pack list: the terminal is+ // its own AI entry point, so the composer would be a competing dispatch+ // affordance in either dock position. Bottom dock: `justify-end`+ // bottom-anchors the header just above the dock so it rides up/down as the+ // terminal is resized (matching the prior blob-only pose). Right dock keeps+ // its vertical space, so the header centers instead.+ if (terminalDock !== null) {return (- <div className="flex min-h-0 flex-1 flex-col items-center justify-end px-6 sm:px-12 md:px-16 pb-8 pt-10">+ <div+ className={cn(+ 'flex min-h-0 flex-1 flex-col items-center px-6 sm:px-12 md:px-16 pb-8 pt-10',+ terminalDock === 'bottom' ? 'justify-end' : 'justify-center',+ )}+ >{messageReady ? (<TerminalEmptyHeader isOnboarding={isOnboarding} celebrateSignal={celebrateSignal} />) : null}@@ -173,7 +187,7 @@ export function countEntries(}/**- * Header-only empty state shown while the docked terminal is open. Shares the+ * Header-only empty state shown while a terminal is open (either dock). Shares the* onboarding/create copy with the full-height views via `getEmptyStateCopy`,* but omits the composer + starter packs that would crowd the terminal below.* Left-aligned within the shared `max-w-5xl` column; the parent bottom-anchors it.diff --git a/packages/app/src/lib/terminal-width-store.test.ts b/packages/app/src/lib/terminal-width-store.test.tsindex 5c31abc31..debdaedfb 100644--- a/packages/app/src/lib/terminal-width-store.test.ts+++ b/packages/app/src/lib/terminal-width-store.test.ts@@ -1,7 +1,6 @@import { describe, expect, test } from 'bun:test';import {DEFAULT_TERMINAL_WIDTH,- MAX_TERMINAL_WIDTH,MIN_TERMINAL_WIDTH,readTerminalWidth,TERMINAL_WIDTH_KEY,@@ -36,9 +35,9 @@ describe('readTerminalWidth', () => {expect(readTerminalWidth(s)).toBe(MIN_TERMINAL_WIDTH);});- test('width above ceiling is clamped to MAX', () => {+ test('wide stored width is preserved (no pixel ceiling — layout constraints bound it)', () => {const s = memoryStorage({ [TERMINAL_WIDTH_KEY]: '9999' });- expect(readTerminalWidth(s)).toBe(MAX_TERMINAL_WIDTH);+ expect(readTerminalWidth(s)).toBe(9999);});test('non-numeric value falls back to default', () => {@@ -70,10 +69,10 @@ describe('writeTerminalWidth', () => {expect(s.getItem(TERMINAL_WIDTH_KEY)).toBe(String(MIN_TERMINAL_WIDTH));});- test('clamps to MAX on write above ceiling', () => {+ test('wide width is written unclamped (no pixel ceiling — layout constraints bound it)', () => {const s = memoryStorage();writeTerminalWidth(9999, s);- expect(s.getItem(TERMINAL_WIDTH_KEY)).toBe(String(MAX_TERMINAL_WIDTH));+ expect(s.getItem(TERMINAL_WIDTH_KEY)).toBe('9999');});test('rounds floating-point input before write', () => {diff --git a/packages/app/src/lib/terminal-width-store.ts b/packages/app/src/lib/terminal-width-store.tsindex 5e1aaab28..595cc275e 100644--- a/packages/app/src/lib/terminal-width-store.ts+++ b/packages/app/src/lib/terminal-width-store.ts@@ -3,11 +3,12 @@ export const TERMINAL_WIDTH_KEY = 'ok-terminal-width-v1';// The terminal column wants more horizontal room than the doc panel: a usable// shell needs roughly 80 columns, and tools like `claude` reflow poorly below// ~92 columns / ~650px. The default leans wide for that reason; the min keeps it-// above the point where most CLIs become unusable, the max keeps it from eating-// the whole window on a wide display.+// above the point where most CLIs become unusable. There is deliberately no+// pixel ceiling: the column may grow to near-full width, bounded at apply time+// by the layout's own constraints (the editor keeps a minimum sliver), so a+// wide persisted value must survive a reload rather than snap back.export const DEFAULT_TERMINAL_WIDTH = 480;export const MIN_TERMINAL_WIDTH = 320;-export const MAX_TERMINAL_WIDTH = 900;export interface TerminalWidthStorage {getItem(key: string): string | null;@@ -17,7 +18,6 @@ export interface TerminalWidthStorage {function clamp(px: number): number {if (!Number.isFinite(px)) return DEFAULT_TERMINAL_WIDTH;if (px < MIN_TERMINAL_WIDTH) return MIN_TERMINAL_WIDTH;- if (px > MAX_TERMINAL_WIDTH) return MAX_TERMINAL_WIDTH;return Math.round(px);}