Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

feat(open-knowledge): terminal chat controls — CLI split button, show/hide tab, and fixes (#2350)

serafin-garcia5deae03b7b4e
diff --git a/.changeset/terminal-chat-controls-followups.md b/.changeset/terminal-chat-controls-followups.md
new file mode 100644
index 000000000..97f47e90a
--- /dev/null
+++ b/.changeset/terminal-chat-controls-followups.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Refined the docked terminal's chat controls. Show or hide the terminal with an edge "Show terminal" tab that appears right where you closed it — on the right column or under the editor, depending on where it's docked — and the header's separate chat toggle is gone. The terminal's "new tab" control is now a split button: click it to open a new tab in your current CLI, or use the dropdown to switch CLI (your pick sticks, shared with the Ask AI composer) or open a plain "Terminal" tab (which sticks too, just for the terminal). New-chat now respects a CLI you picked but haven't installed instead of silently falling back, terminal tabs show their full title on hover, and opening the chat no longer collapses the document panel.
diff --git a/packages/app/src/components/EditorArea.tsx b/packages/app/src/components/EditorArea.tsx
index ec0087c4b..b7ed82462 100644
--- a/packages/app/src/components/EditorArea.tsx
+++ b/packages/app/src/components/EditorArea.tsx
@@ -16,7 +16,6 @@ import { AssetPreview } from '@/components/AssetPreview';
import { DocPanel, type PanelTab } from '@/components/DocPanel';
import {
consumePendingDocPanelTabRequest,
- subscribeToDocPanelCollapseRequests,
subscribeToDocPanelTabRequests,
} from '@/components/doc-panel-events';
import { EditorSkeleton } from '@/components/EditorSkeleton';
@@ -60,6 +59,7 @@ import type { EditorMode } from './EditorPane';
import { EditorToolbar } from './EditorToolbar';
import { shouldPaintOverlay } from './editor-area-overlay';
import { TerminalDock } from './TerminalDock';
+import { TerminalRevealTab } from './TerminalRevealTab';
import { xtermThemeForMode } from './terminal-theme';
const LazyActivityModeContent = lazy(async () => {
@@ -92,6 +92,10 @@ interface EditorAreaProps {
/** Report the terminal's attach point up to EditorPane (which owns the session
* host). See {@link TerminalPlacement}. */
onTerminalPlacement?: (placement: TerminalPlacement) => void;
+ /** Reveal the terminal (and spawn a default-CLI session if none is open) —
+ * drives the edge "Show terminal" tab shown while the terminal is hidden.
+ * Absent on the web host (no terminal). */
+ onRevealTerminal?: () => void;
}
export function EditorArea(props: EditorAreaProps) {
@@ -133,6 +137,7 @@ function EditorAreaInner({
onTerminalVisibleChange,
terminalDock = 'right',
onTerminalPlacement,
+ onRevealTerminal,
}: EditorAreaProps) {
const { t } = useLingui();
const { resolvedTheme } = useTheme();
@@ -193,6 +198,9 @@ function EditorAreaInner({
const rightDocked = terminalDock === 'right';
const terminalDockPosition: TerminalDockPosition = rightDocked ? 'right' : 'bottom';
+ const revealTabHidden = terminalBridge != null && !terminalVisible && onRevealTerminal != null;
+ const bottomRevealTabPresent = revealTabHidden && !rightDocked;
+ const rightRevealTabPresent = revealTabHidden && rightDocked;
const rightTerminalShowing = rightDocked && terminalVisible && rightTerminalContainer != null;
const activeTerminalContainer = rightTerminalShowing
? rightTerminalContainer
@@ -322,21 +330,6 @@ function EditorAreaInner({
panelRef.current?.expand();
}, [docPanelExpandSignal, panelRef]);
- useEffect(() => {
- let rafId = 0;
- const unsubscribe = subscribeToDocPanelCollapseRequests(() => {
- if (terminalDock !== 'right') return;
- cancelAnimationFrame(rafId);
- rafId = requestAnimationFrame(() => {
- panelRef.current?.collapse();
- });
- });
- return () => {
- cancelAnimationFrame(rafId);
- unsubscribe();
- };
- }, [panelRef, terminalDock]);
-
useLayoutEffect(() => {
if (!isCollapsed) return;
const panelEl = document.getElementById('doc-panel');
@@ -612,6 +605,7 @@ function EditorAreaInner({
onAddProperty={openAddPropertyForm}
isPanelCollapsed={isPanelCollapsed}
onTogglePanel={togglePanel}
+ reserveRightGutter={rightRevealTabPresent && isPanelCollapsed}
/>
)}
{/* Floats over the bottom of the scroll area (an absolute overlay, like
@@ -638,6 +632,7 @@ function EditorAreaInner({
? { onReopen: () => setComposerDismissed(false) }
: null
}
+ reserveRightGutter={bottomRevealTabPresent}
/>
</div>
);
@@ -701,6 +696,7 @@ function EditorAreaInner({
dockPosition={terminalDockPosition}
onBottomContainer={setBottomTerminalContainer}
onEditorRegion={setTerminalEditorRegion}
+ onReveal={onRevealTerminal}
>
{viewContent}
</TerminalDock>
@@ -756,7 +752,7 @@ function EditorAreaInner({
(rightPanel != null && !initialRightCollapsed) || terminalColumnPresent;
return (
- <div className="flex min-h-0 flex-1" ref={setGroupContainerEl}>
+ <div className="relative flex min-h-0 flex-1" ref={setGroupContainerEl}>
<ResizablePanelGroup
orientation="horizontal"
data-dragging={isDraggingDocHandle || isDraggingTerminalHandle || undefined}
@@ -774,6 +770,13 @@ function EditorAreaInner({
{rightPanel}
{terminalColumn}
</ResizablePanelGroup>
+ {rightRevealTabPresent ? (
+ <TerminalRevealTab
+ dockPosition="right"
+ onReveal={onRevealTerminal}
+ className="top-2.5 right-0"
+ />
+ ) : null}
</div>
);
}
diff --git a/packages/app/src/components/EditorFooter.tsx b/packages/app/src/components/EditorFooter.tsx
index f8dfa906a..78e7ce44d 100644
--- a/packages/app/src/components/EditorFooter.tsx
+++ b/packages/app/src/components/EditorFooter.tsx
@@ -7,6 +7,7 @@ import {
useEditorFooterIdentity,
} from '@/hooks/use-editor-footer-identity';
import type { DocumentStats } from '@/lib/document-stats';
+import { cn } from '@/lib/utils';
interface EditorFooterProps {
stats: DocumentStats;
@@ -20,6 +21,10 @@ interface EditorFooterProps {
/** When set, a "Ask AI" reopen badge renders next to the stats — shown only
* while the bottom composer is dismissed. Clicking it reopens the composer. */
composerBadge?: { onReopen: () => void } | null;
+ /** Reserve extra right padding so the right-aligned stats clear the
+ * bottom-dock "Show terminal" reveal tab, which floats over the footer's
+ * bottom-right corner when the terminal is hidden. */
+ reserveRightGutter?: boolean;
}
export function EditorFooter({
@@ -27,6 +32,7 @@ export function EditorFooter({
selectionStats,
showStats = true,
composerBadge,
+ reserveRightGutter = false,
}: EditorFooterProps) {
const { t } = useLingui();
const identity = useEditorFooterIdentity();
@@ -43,7 +49,10 @@ export function EditorFooter({
? t`Selection statistics`
: t`Document statistics`
}
- className="relative flex h-6 shrink-0 items-center justify-between gap-3 bg-background px-3 text-2xs text-muted-foreground"
+ className={cn(
+ 'relative flex h-6 shrink-0 items-center justify-between gap-3 bg-background px-3 text-2xs text-muted-foreground',
+ reserveRightGutter && 'pr-12',
+ )}
>
<div
aria-hidden
diff --git a/packages/app/src/components/EditorHeader.dom.test.tsx b/packages/app/src/components/EditorHeader.dom.test.tsx
index 2cbd497d5..f8670e519 100644
--- a/packages/app/src/components/EditorHeader.dom.test.tsx
+++ b/packages/app/src/components/EditorHeader.dom.test.tsx
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, mock, test } from 'bun:test';
-import { cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { cleanup, render, screen } from '@testing-library/react';
import type { ReactNode } from 'react';
import { TooltipProvider } from '@/components/ui/tooltip';
import {
@@ -82,17 +82,11 @@ function setElectronHost(enabled: boolean) {
});
}
-interface TerminalHeaderProps {
- terminalAvailable?: boolean;
- terminalVisible?: boolean;
- onToggleChat?: () => void;
-}
-
-async function renderHeader(props: TerminalHeaderProps = {}) {
+async function renderHeader() {
const { EditorHeader } = await import('./EditorHeader');
render(
<TooltipProvider>
- <EditorHeader {...props} />
+ <EditorHeader />
</TooltipProvider>,
);
return document.querySelector('header') as HTMLElement;
@@ -221,33 +215,4 @@ describe('EditorHeader runtime behavior', () => {
expect(lastShareInput).toBeNull();
});
-
- test('terminalAvailable renders a single Open chat button when the dock is hidden', async () => {
- await renderHeader({ terminalAvailable: true, terminalVisible: false });
-
- expect(screen.getByRole('button', { name: 'Open chat' })).toBeTruthy();
- expect(screen.queryByRole('button', { name: 'Close chat' })).toBeNull();
- });
-
- test('the button label flips to Close chat when the dock is visible', async () => {
- await renderHeader({ terminalAvailable: true, terminalVisible: true });
-
- expect(screen.getByRole('button', { name: 'Close chat' })).toBeTruthy();
- expect(screen.queryByRole('button', { name: 'Open chat' })).toBeNull();
- });
-
- test('clicking the chat toggle fires its handler', async () => {
- const onToggleChat = mock(() => {});
- await renderHeader({ terminalAvailable: true, terminalVisible: false, onToggleChat });
-
- fireEvent.click(screen.getByRole('button', { name: 'Open chat' }));
- expect(onToggleChat).toHaveBeenCalledTimes(1);
- });
-
- test('the chat toggle does not render when terminalAvailable is false (web / no terminal surface)', async () => {
- await renderHeader({ terminalAvailable: false });
-
- expect(screen.queryByRole('button', { name: 'Open chat' })).toBeNull();
- expect(screen.queryByRole('button', { name: 'Close chat' })).toBeNull();
- });
});
diff --git a/packages/app/src/components/EditorHeader.tsx b/packages/app/src/components/EditorHeader.tsx
index 476dc78fd..d15937c35 100644
--- a/packages/app/src/components/EditorHeader.tsx
+++ b/packages/app/src/components/EditorHeader.tsx
@@ -1,6 +1,6 @@
import { parseManagedArtifactName } from '@inkeep/open-knowledge-core';
import { Trans, useLingui } from '@lingui/react/macro';
-import { MessageSquare, Search } from 'lucide-react';
+import { Search } from 'lucide-react';
import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { Separator } from '@/components/ui/separator';
@@ -28,27 +28,10 @@ interface EditorHeaderProps {
onSignIn?: () => void;
onSetIdentity?: () => void;
onOpenSearch?: () => void;
- /** Desktop terminal is available (bridge + `terminal` surface). Gates the
- * chat toggle header button; absent/false on web. */
- terminalAvailable?: boolean;
- /** Current dock visibility — flips the button between "Open chat" and "Close
- * chat" so the label always names the action it performs. */
- terminalVisible?: boolean;
- /** Toggle the docked chat: when hidden, reveal it (collapsing the doc-panel)
- * and spawn a default-CLI chat if none exists; when shown, hide it. */
- onToggleChat?: () => void;
}
-export function EditorHeader({
- onSignIn,
- onSetIdentity,
- onOpenSearch,
- terminalAvailable,
- terminalVisible,
- onToggleChat,
-}: EditorHeaderProps) {
+export function EditorHeader({ onSignIn, onSetIdentity, onOpenSearch }: EditorHeaderProps) {
const { t } = useLingui();
- const chatToggleLabel = terminalVisible ? t`Close chat` : t`Open chat`;
const { activeDocName, activeTarget } = useDocumentContext();
const managedArtifact = activeDocName ? parseManagedArtifactName(activeDocName) : null;
const { state: sidebarState, isDraggingRail } = useSidebar();
@@ -166,29 +149,6 @@ export function EditorHeader({
)}
<SyncStatusBadge onSignIn={onSignIn} onSetIdentity={onSetIdentity} />
<PresenceBar />
- {/* Desktop-only chat toggle (gated on the derived terminalAvailable),
- placed after the badges, before the vertical separator. One control:
- Open chat (reveal-and-start) ⇄ Close chat (hide). */}
- {terminalAvailable && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="icon-sm"
- onClick={() => onToggleChat?.()}
- aria-label={chatToggleLabel}
- data-telemetry-event="ok.editor_header.toggle_chat.click"
- className={cn(
- 'shrink-0 text-muted-foreground',
- isElectronHost && '[-webkit-app-region:no-drag]',
- )}
- >
- <MessageSquare aria-hidden="true" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>{chatToggleLabel}</TooltipContent>
- </Tooltip>
- )}
<Separator orientation="vertical" className="h-4 shrink-0 data-vertical:self-center" />
<BetaBadge />
{/* Settings is unavailable in single-file mode (config editing is inert). */}
diff --git a/packages/app/src/components/EditorPane.tsx b/packages/app/src/components/EditorPane.tsx
index aa356c1ad..2402d66e7 100644
--- a/packages/app/src/components/EditorPane.tsx
+++ b/packages/app/src/components/EditorPane.tsx
@@ -16,13 +16,13 @@ import {
type TerminalDockPosition,
writeTerminalDock,
} from '@/lib/terminal-dock-store';
+import { readPreferBareTerminal } from '@/lib/terminal-new-tab-store';
import { recordTerminalOpened } from '@/lib/terminal-telemetry';
import { loadStickyAgent } from '@/lib/unified-agent-store';
import { AuthModal } from './AuthModal';
import { AutoSyncOnboardingDialog } from './AutoSyncOnboardingDialog';
import { shouldShowAutoSyncOnboarding } from './auto-sync-onboarding-gate';
import { type PanelTab, TABS } from './DocPanel';
-import { requestDocPanelCollapse } from './doc-panel-events';
import { EditorArea, type TerminalPlacement } from './EditorArea';
import { EditorHeader } from './EditorHeader';
import { subscribeToTerminalLaunchRequests } from './handoff/terminal-launch-events';
@@ -80,14 +80,9 @@ export function EditorPane({ onOpenSearch }: EditorPaneProps = {}) {
setTerminalLaunch({ prompt: null, cli: resolvedCli, nonce: launchNonceRef.current });
}
- function handleToggleChat() {
- if (terminalVisible) {
- setTerminalVisible(false);
- return;
- }
+ function revealTerminal() {
setTerminalVisible(true);
- requestDocPanelCollapse();
- if (!hasSessions) launchNewChat();
+ if (!hasSessions && !readPreferBareTerminal()) launchNewChat();
}
const syncStatus = useGitSyncStatus();
@@ -145,7 +140,6 @@ export function EditorPane({ onOpenSearch }: EditorPaneProps = {}) {
useEffect(() => {
return subscribeToTerminalLaunchRequests((prompt, cli) => {
setTerminalVisible(true);
- requestDocPanelCollapse();
launchNonceRef.current += 1;
setTerminalLaunch({ prompt, cli, nonce: launchNonceRef.current });
});
@@ -215,9 +209,6 @@ export function EditorPane({ onOpenSearch }: EditorPaneProps = {}) {
setAuthModalOpen(true);
}}
onOpenSearch={onOpenSearch}
- terminalAvailable={terminalAvailable}
- terminalVisible={terminalVisible}
- onToggleChat={handleToggleChat}
/>
{/* The terminal docks to the right of the doc panel (its own column) or
under the editor/file column. EditorArea owns the layout; the dock
@@ -234,6 +225,7 @@ export function EditorPane({ onOpenSearch }: EditorPaneProps = {}) {
onTerminalVisibleChange={setTerminalVisible}
terminalDock={terminalDock}
onTerminalPlacement={setTerminalPlacement}
+ onRevealTerminal={terminalAvailable ? revealTerminal : undefined}
/>
{/* The `desktopBridge != null` clause re-narrows the bridge to non-null for
the prop — the derived `terminalAvailable` boolean can't narrow it. */}
diff --git a/packages/app/src/components/EditorToolbar.tsx b/packages/app/src/components/EditorToolbar.tsx
index f4c72251e..8d436fc08 100644
--- a/packages/app/src/components/EditorToolbar.tsx
+++ b/packages/app/src/components/EditorToolbar.tsx
@@ -7,6 +7,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip
import type { EditorModeValue } from '@/editor/use-editor-mode.ts';
import { formatShortcut, formatShortcutLabel } from '@/lib/keyboard-shortcuts';
import { parseProjectSkillContentDocName } from '@/lib/managed-artifact-doc-name';
+import { cn } from '@/lib/utils';
import { EditorBreadcrumb } from './EditorBreadcrumb';
import { EditorModeToggle } from './EditorModeToggle';
@@ -23,6 +24,11 @@ interface EditorToolbarProps {
onAddProperty: () => void;
isPanelCollapsed: boolean;
onTogglePanel: () => void;
+ /** Reserve right-side room in the action cluster so it sits left of the
+ * right-dock "Show terminal" reveal tab (which pins to the far-right corner
+ * the cluster reaches once the doc panel is collapsed) — keeping the two in
+ * one row instead of overlapping. */
+ reserveRightGutter?: boolean;
}
export function EditorToolbar({
@@ -34,6 +40,7 @@ export function EditorToolbar({
onAddProperty,
isPanelCollapsed,
onTogglePanel,
+ reserveRightGutter = false,
}: EditorToolbarProps) {
const { t } = useLingui();
const panelShortcut = formatShortcut('toggle-document-panel');
@@ -90,7 +97,12 @@ export function EditorToolbar({
them clear of the `.editor-content-aligned` grid; `pointer-events-auto`
re-enables clicks under the toolbar's `pointer-events-none` root.
*/}
- <div className="pointer-events-auto absolute top-0 right-0 flex items-center justify-end gap-1 py-2 pr-2">
+ <div
+ className={cn(
+ 'pointer-events-auto absolute top-0 right-0 flex items-center justify-end gap-1 py-2 pr-2',
+ reserveRightGutter && 'pr-9',
+ )}
+ >
{activeSkill ? (
<Suspense fallback={null}>
<SkillEditorActions scope={activeSkill.scope} name={activeSkill.name} />
diff --git a/packages/app/src/components/TerminalDock.dom.test.tsx b/packages/app/src/components/TerminalDock.dom.test.tsx
index 993502779..76a33cb72 100644
--- a/packages/app/src/components/TerminalDock.dom.test.tsx
+++ b/packages/app/src/components/TerminalDock.dom.test.tsx
@@ -46,8 +46,12 @@ mock.module('@/components/ui/resizable', () => ({
);
},
// biome-ignore lint/suspicious/noExplicitAny: test stub
- ResizableHandle: ({ onPointerDown }: any) => (
- <div data-testid="terminal-resize-handle" onPointerDown={onPointerDown} />
+ ResizableHandle: ({ onPointerDown, disabled }: any) => (
+ <div
+ data-testid="terminal-resize-handle"
+ data-disabled={disabled ? 'true' : 'false'}
+ onPointerDown={onPointerDown}
+ />
),
}));
@@ -149,7 +153,7 @@ function makeBridge() {
}
// biome-ignore lint/suspicious/noExplicitAny: test harness props
-function DockHarness({ v, l, onVisibleChange, bridge }: any) {
+function DockHarness({ v, l, onVisibleChange, bridge, onReveal }: any) {
const [bottomContainer, setBottomContainer] = useState<HTMLDivElement | null>(null);
const [editorRegionEl, setEditorRegionEl] = useState<HTMLDivElement | null>(null);
return (
@@ -160,6 +164,7 @@ function DockHarness({ v, l, onVisibleChange, bridge }: any) {
dockPosition="bottom"
onBottomContainer={setBottomContainer}
onEditorRegion={setEditorRegionEl}
+ onReveal={onReveal}
>
<div data-testid="editor-child" />
</TerminalDock>
@@ -181,11 +186,18 @@ function DockHarness({ v, l, onVisibleChange, bridge }: any) {
function renderDock(
visible: boolean,
launch?: { prompt: string; nonce: number; cli?: string } | null,
+ onReveal?: () => void,
) {
const onVisibleChange = mock((_v: boolean) => {});
const { bridge, create, kill, input, viewMenuPushes, dispatchMenuAction } = makeBridge();
const ui = (v: boolean, l?: { prompt: string; nonce: number; cli?: string } | null) => (
- <DockHarness v={v} l={l ?? null} onVisibleChange={onVisibleChange} bridge={bridge} />
+ <DockHarness
+ v={v}
+ l={l ?? null}
+ onVisibleChange={onVisibleChange}
+ bridge={bridge}
+ onReveal={onReveal}
+ />
);
const utils = render(ui(visible, launch));
return {
@@ -227,6 +239,11 @@ function editorRegion(): HTMLElement {
return region;
}
+async function addTerminalTab(user: ReturnType<typeof userEvent.setup>) {
+ await user.click(screen.getByRole('button', { name: 'Choose CLI for new chat' }));
+ await user.click(await screen.findByRole('menuitem', { name: 'Terminal' }));
+}
+
describe('TerminalDock multi-session', () => {
beforeEach(() => {
terminalPanelProps = null;
@@ -274,7 +291,7 @@ describe('TerminalDock multi-session', () => {
expect(screen.getAllByTestId('terminal-session')).toHaveLength(1);
const firstActive = activePanelId();
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
expect(screen.getAllByTestId('terminal-session')).toHaveLength(2);
expect(activePanelId()).not.toBe(firstActive);
@@ -284,8 +301,8 @@ describe('TerminalDock multi-session', () => {
test('all sessions stay mounted with exactly one active', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
+ await addTerminalTab(user);
expect(screen.getAllByTestId('terminal-session')).toHaveLength(3);
const tabpanels = screen.getAllByRole('tabpanel', { hidden: true });
@@ -298,7 +315,7 @@ describe('TerminalDock multi-session', () => {
test('switching tabs changes the active session without unmounting the others', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
const secondActive = activePanelId();
await user.click(screen.getByRole('tab', { name: 'Terminal 1' }));
@@ -310,7 +327,7 @@ describe('TerminalDock multi-session', () => {
test('typing target stays scoped: the active panel is the only one shown', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
expect(sessionPanels()).toHaveLength(2);
const activeCount = document.querySelectorAll(
@@ -322,7 +339,7 @@ describe('TerminalDock multi-session', () => {
test('selecting a tab moves focus to that session', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
const second = activePanelId();
await user.click(screen.getByRole('tab', { name: 'Terminal 1' }));
@@ -338,7 +355,7 @@ describe('TerminalDock multi-session', () => {
test('closing a non-active tab removes only it and leaves the active one running', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
const activeBefore = activePanelId();
await user.click(screen.getByRole('button', { name: 'Close Terminal 1' }));
@@ -350,7 +367,7 @@ describe('TerminalDock multi-session', () => {
test("a session's OSC title becomes its tab label; siblings keep the default", async () => {
const user = userEvent.setup();
const view = renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
await waitFor(() => expect(view.create).toHaveBeenCalledTimes(2));
act(() => emitTitle('pty-1', 'claude — repo'));
@@ -396,7 +413,7 @@ describe('TerminalDock multi-session', () => {
test("closing a tab reaps only that session's PTY and leaves the others alive", async () => {
const user = userEvent.setup();
const view = renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
await waitFor(() => expect(view.create).toHaveBeenCalledTimes(2));
expect(view.kill).not.toHaveBeenCalled();
@@ -410,8 +427,8 @@ describe('TerminalDock multi-session', () => {
test('closing the active tab activates its left neighbor', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
+ await addTerminalTab(user);
await user.click(screen.getByRole('tab', { name: 'Terminal 2' }));
const middle = activePanelId();
@@ -428,7 +445,7 @@ describe('TerminalDock multi-session', () => {
test('closing the active leftmost tab activates its right neighbor', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
await user.click(screen.getByRole('tab', { name: 'Terminal 1' }));
const closedId = activePanelId();
const rightNeighborId =
@@ -445,8 +462,8 @@ describe('TerminalDock multi-session', () => {
test('closing the active tab moves focus into the surviving neighbor', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
+ await addTerminalTab(user);
await user.click(screen.getByRole('tab', { name: 'Terminal 2' }));
await user.click(screen.getByRole('button', { name: 'Close Terminal 2' }));
@@ -473,8 +490,8 @@ describe('TerminalDock multi-session', () => {
test('hiding the dock preserves every session and keeps the last-active tab on reopen', async () => {
const user = userEvent.setup();
const view = renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
+ await addTerminalTab(user);
await user.click(screen.getByRole('tab', { name: 'Terminal 2' }));
const activeBeforeHide = activePanelId();
expect(screen.getAllByTestId('terminal-session')).toHaveLength(3);
@@ -590,7 +607,7 @@ describe('TerminalDock multi-session', () => {
test('the Terminal menu "Kill Terminal" action closes the active tab', async () => {
const user = userEvent.setup();
const view = renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
expect(screen.getAllByTestId('terminal-session')).toHaveLength(2);
act(() => view.dispatchMenuAction('kill-terminal'));
@@ -601,8 +618,8 @@ describe('TerminalDock multi-session', () => {
test('Cmd+number jumps to the matching tab while the terminal is focused', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
+ await addTerminalTab(user);
const panels = sessionPanels();
const thirdSink = panels[2]?.querySelector<HTMLElement>('.xterm-helper-textarea');
act(() => thirdSink?.focus());
@@ -628,7 +645,7 @@ describe('TerminalDock multi-session', () => {
test('Cmd+number for a tab that does not exist is left for the shell', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
const panels = sessionPanels();
act(() => panels[1]?.querySelector<HTMLElement>('.xterm-helper-textarea')?.focus());
const before = activePanelId();
@@ -650,7 +667,7 @@ describe('TerminalDock multi-session', () => {
test('Cmd+number is ignored when focus is outside the terminal dock', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
await user.click(screen.getByRole('tab', { name: 'Terminal 1' }));
const before = activePanelId();
@@ -672,7 +689,7 @@ describe('TerminalDock multi-session', () => {
test('a non-chord keystroke is not intercepted so it reaches the active shell', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
const before = activePanelId();
act(() => sessionPanels()[0]?.querySelector<HTMLElement>('.xterm-helper-textarea')?.focus());
@@ -711,7 +728,7 @@ describe('TerminalDock multi-session', () => {
test('wires each tab to its panel via accessible tablist/tabpanel relationships', async () => {
const user = userEvent.setup();
renderDock(true);
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await addTerminalTab(user);
const tablist = screen.getByRole('tablist', { name: 'Terminal sessions' });
const tabs = within(tablist).getAllByRole('tab');
@@ -743,6 +760,42 @@ describe('TerminalDock multi-session', () => {
act(() => view.rerender(true));
expect(document.activeElement).toBe(session);
});
+
+ test('shows the bottom-edge "Show terminal" tab only while hidden, inside the editor column', () => {
+ const onReveal = mock(() => {});
+ const view = renderDock(false, null, onReveal);
+
+ const reveal = screen.getByRole('button', { name: 'Show terminal' });
+ expect(editorRegion().contains(reveal)).toBe(true);
+
+ act(() => view.rerender(true));
+ expect(screen.queryByRole('button', { name: 'Show terminal' })).toBeNull();
+ });
+
+ test('clicking the reveal tab requests a reveal', async () => {
+ const user = userEvent.setup();
+ const onReveal = mock(() => {});
+ renderDock(false, null, onReveal);
+
+ await user.click(screen.getByRole('button', { name: 'Show terminal' }));
+
+ expect(onReveal).toHaveBeenCalledTimes(1);
+ });
+
+ test('renders no reveal tab when no reveal handler is wired (web host)', () => {
+ renderDock(false);
+ expect(screen.queryByRole('button', { name: 'Show terminal' })).toBeNull();
+ });
+
+ test('disables the resize handle while hidden so there is no drag-to-open', () => {
+ const view = renderDock(false);
+ expect(screen.getByTestId('terminal-resize-handle').getAttribute('data-disabled')).toBe('true');
+
+ act(() => view.rerender(true));
+ expect(screen.getByTestId('terminal-resize-handle').getAttribute('data-disabled')).toBe(
+ 'false',
+ );
+ });
});
describe('TerminalSessionsHost focus-return gating across a dock move', () => {
diff --git a/packages/app/src/components/TerminalDock.tsx b/packages/app/src/components/TerminalDock.tsx
index 20ebf2025..4447b30a2 100644
--- a/packages/app/src/components/TerminalDock.tsx
+++ b/packages/app/src/components/TerminalDock.tsx
@@ -5,6 +5,7 @@ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/componen
import type { TerminalDockPosition } from '@/lib/terminal-dock-store';
import { getInitialTerminalHeight, writeTerminalHeight } from '@/lib/terminal-height-store';
import { cn } from '@/lib/utils';
+import { TerminalRevealTab } from './TerminalRevealTab';
import { xtermThemeForMode } from './terminal-theme';
const TERMINAL_PANEL_ID = 'terminal-dock-panel';
@@ -16,6 +17,7 @@ interface TerminalDockProps {
readonly dockPosition?: TerminalDockPosition;
readonly onBottomContainer: (el: HTMLDivElement | null) => void;
readonly onEditorRegion: (el: HTMLDivElement | null) => void;
+ readonly onReveal?: () => void;
}
export function TerminalDock({
@@ -25,11 +27,13 @@ export function TerminalDock({
dockPosition = 'bottom',
onBottomContainer,
onEditorRegion,
+ onReveal,
}: TerminalDockProps) {
const { resolvedTheme } = useTheme();
const panelRef = usePanelRef();
const [isCollapsed, setIsCollapsed] = useState(!visible);
const xtermBackground = xtermThemeForMode(resolvedTheme).background;
+ const showBottomRevealTab = !visible && dockPosition === 'bottom' && onReveal != null;
const [initialHeightPx] = useState(() => getInitialTerminalHeight());
const heightPxRef = useRef(initialHeightPx);
@@ -75,18 +79,34 @@ export function TerminalDock({
>
<ResizablePanel minSize="5%" className="flex min-h-0 flex-col">
{/* tabIndex -1 makes this a programmatic focus target for focus-return on
- collapse without adding it to the tab order. */}
+ collapse without adding it to the tab order. `relative` anchors the
+ bottom-dock reveal tab to the bottom of the editor column. */}
<div
ref={onEditorRegion}
tabIndex={-1}
- className="flex h-full min-h-0 flex-col outline-none"
+ className="relative flex h-full min-h-0 flex-col outline-none"
>
{children}
+ {showBottomRevealTab && onReveal ? (
+ <TerminalRevealTab
+ dockPosition="bottom"
+ onReveal={onReveal}
+ className="right-3 bottom-0"
+ />
+ ) : null}
</div>
</ResizablePanel>
+ {/* The handle drags only while the terminal is open: you can resize it, and
+ drag all the way down to collapse (hide). Once hidden it is disabled — the
+ reveal tab is the single open mechanism, so there is no drag-up-to-open
+ (which would be a second, redundant way in). Gating on the controlled
+ `visible` prop (not `isCollapsed`) means an in-progress drag-to-collapse
+ completes before the handle disables on the next commit. */}
<ResizableHandle
- withHandle
+ withHandle={visible}
+ disabled={!visible}
onPointerDown={() => {
+ if (!visible) return;
setIsDragging(true);
isDraggingRef.current = true;
const handleUp = () => {
diff --git a/packages/app/src/components/TerminalNewChatButton.dom.test.tsx b/packages/app/src/components/TerminalNewChatButton.dom.test.tsx
new file mode 100644
index 000000000..dd139e964
--- /dev/null
+++ b/packages/app/src/components/TerminalNewChatButton.dom.test.tsx
@@ -0,0 +1,115 @@
+import { afterEach, describe, expect, mock, test } from 'bun:test';
+import type { TerminalCli } from '@inkeep/open-knowledge-core';
+import { cleanup, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { TooltipProvider } from '@/components/ui/tooltip';
+import { TerminalNewChatButton, type TerminalNewTabChoice } from './TerminalNewChatButton';
+
+function renderButton(selected: TerminalNewTabChoice = 'claude') {
+ const onLaunchSelected = mock(() => {});
+ const onPickCli = mock((_cli: TerminalCli) => {});
+ const onPickTerminal = mock(() => {});
+ render(
+ <TooltipProvider>
+ <TerminalNewChatButton
+ selected={selected}
+ onLaunchSelected={onLaunchSelected}
+ onPickCli={onPickCli}
+ onPickTerminal={onPickTerminal}
+ />
+ </TooltipProvider>,
+ );
+ return { onLaunchSelected, onPickCli, onPickTerminal };
+}
+
+describe('TerminalNewChatButton', () => {
+ afterEach(() => cleanup());
+
+ test('the primary launches the current selection (a CLI) without changing it', async () => {
+ const user = userEvent.setup();
+ const { onLaunchSelected, onPickCli } = renderButton('codex');
+
+ await user.click(screen.getByRole('button', { name: 'New Codex chat' }));
+
+ expect(onLaunchSelected).toHaveBeenCalledTimes(1);
+ expect(onPickCli).not.toHaveBeenCalled();
+ });
+
+ test('when Terminal is the selection the primary opens a bare terminal', async () => {
+ const user = userEvent.setup();
+ const { onLaunchSelected, onPickTerminal } = renderButton('terminal');
+
+ await user.click(screen.getByRole('button', { name: 'New terminal' }));
+
+ expect(onLaunchSelected).toHaveBeenCalledTimes(1);
+ expect(onPickTerminal).not.toHaveBeenCalled();
+ });
+
+ test('the dropdown lists every CLI plus a Terminal option', async () => {
+ const user = userEvent.setup();
+ renderButton('claude');
+
+ await user.click(screen.getByRole('button', { name: 'Choose CLI for new chat' }));
+
+ for (const name of ['Claude CLI', 'Codex CLI', 'OpenCode CLI', 'Cursor CLI']) {
+ expect(await screen.findByRole('menuitem', { name })).toBeDefined();
+ }
+ expect(screen.getByRole('menuitem', { name: 'Terminal' })).toBeDefined();
+ });
+
+ test('picking a CLI from the dropdown switches the default (persist + launch)', async () => {
+ const user = userEvent.setup();
+ const { onPickCli, onLaunchSelected, onPickTerminal } = renderButton('claude');
+
+ await user.click(screen.getByRole('button', { name: 'Choose CLI for new chat' }));
+ await user.click(await screen.findByRole('menuitem', { name: 'OpenCode CLI' }));
+
+ expect(onPickCli).toHaveBeenCalledTimes(1);
+ expect(onPickCli).toHaveBeenCalledWith('opencode');
+ expect(onLaunchSelected).not.toHaveBeenCalled();
+ expect(onPickTerminal).not.toHaveBeenCalled();
+ });
+
+ test('marks the current pick with aria-current so it is in the a11y tree', async () => {
+ const user = userEvent.setup();
+ renderButton('codex');
+
+ await user.click(screen.getByRole('button', { name: 'Choose CLI for new chat' }));
+
+ expect(
+ (await screen.findByRole('menuitem', { name: 'Codex CLI' })).getAttribute('aria-current'),
+ ).toBe('true');
+ expect(
+ screen.getByRole('menuitem', { name: 'Claude CLI' }).getAttribute('aria-current'),
+ ).toBeNull();
+ expect(
+ screen.getByRole('menuitem', { name: 'Terminal' }).getAttribute('aria-current'),
+ ).toBeNull();
+ });
+
+ test('marks the Terminal row current when a bare shell is the selection', async () => {
+ const user = userEvent.setup();
+ renderButton('terminal');
+
+ await user.click(screen.getByRole('button', { name: 'Choose CLI for new chat' }));
+
+ expect(
+ (await screen.findByRole('menuitem', { name: 'Terminal' })).getAttribute('aria-current'),
+ ).toBe('true');
+ expect(
+ screen.getByRole('menuitem', { name: 'Claude CLI' }).getAttribute('aria-current'),
+ ).toBeNull();
+ });
+
+ test('picking Terminal from the dropdown switches the default to a bare shell', async () => {
+ const user = userEvent.setup();
+ const { onPickTerminal, onPickCli, onLaunchSelected } = renderButton('claude');
+
+ await user.click(screen.getByRole('button', { name: 'Choose CLI for new chat' }));
+ await user.click(await screen.findByRole('menuitem', { name: 'Terminal' }));
+
+ expect(onPickTerminal).toHaveBeenCalledTimes(1);
+ expect(onPickCli).not.toHaveBeenCalled();
+ expect(onLaunchSelected).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/app/src/components/TerminalNewChatButton.tsx b/packages/app/src/components/TerminalNewChatButton.tsx
new file mode 100644
index 000000000..e85ca7738
--- /dev/null
+++ b/packages/app/src/components/TerminalNewChatButton.tsx
@@ -0,0 +1,127 @@
+import { TERMINAL_CLIS, type TerminalCli } from '@inkeep/open-knowledge-core';
+import { Trans, useLingui } from '@lingui/react/macro';
+import { CheckIcon, ChevronDownIcon, PlusIcon, SquareTerminalIcon } from 'lucide-react';
+import { TargetIcon } from '@/components/handoff/OpenInAgentMenuItem';
+import { cliIconTargetId, VISIBLE_CLIS } from '@/components/handoff/terminal-cli-display';
+import { Button } from '@/components/ui/button';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import { cn } from '@/lib/utils';
+
+export type TerminalNewTabChoice = TerminalCli | 'terminal';
+
+interface TerminalNewChatButtonProps {
+ /** The current pick — a CLI (resolved from the sticky pick + installed set, the
+ * same default logic the Ask-AI surfaces use) or `'terminal'` (a bare shell).
+ * Drives the primary icon/label + the dropdown checkmark. */
+ readonly selected: TerminalNewTabChoice;
+ /** Primary click — open a new tab running the current {@link selected} pick
+ * (a CLI chat, or a bare shell). A plain launch: it does not change the pick. */
+ readonly onLaunchSelected: () => void;
+ /** Dropdown CLI row — make `cli` the new default (persist, like the Ask-AI
+ * picker) AND open a new tab running it. */
+ readonly onPickCli: (cli: TerminalCli) => void;
+ /** Dropdown "Terminal" row — make a bare shell the new default (persist,
+ * terminal-only) AND open a new bare-shell tab. */
+ readonly onPickTerminal: () => void;
+ readonly className?: string;
+}
+
+export function TerminalNewChatButton({
+ selected,
+ onLaunchSelected,
+ onPickCli,
+ onPickTerminal,
+ className,
+}: TerminalNewChatButtonProps) {
+ const { t } = useLingui();
+ const isTerminal = selected === 'terminal';
+ const primaryLabel = isTerminal
+ ? t`New terminal`
+ : t`New ${TERMINAL_CLIS[selected].displayName} chat`;
+ return (
+ <div className={cn('flex shrink-0 items-center', className)}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ aria-label={primaryLabel}
+ data-testid="terminal-new-chat"
+ className="cursor-pointer gap-0.5 rounded-r-none px-1.5 text-muted-foreground hover:text-foreground"
+ onClick={onLaunchSelected}
+ >
+ {isTerminal ? (
+ <SquareTerminalIcon aria-hidden="true" className="size-3.5" />
+ ) : (
+ <TargetIcon id={cliIconTargetId(selected)} className="size-3.5" aria-hidden="true" />
+ )}
+ <PlusIcon aria-hidden="true" className="size-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" sideOffset={8}>
+ {primaryLabel}
+ </TooltipContent>
+ </Tooltip>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-xs"
+ aria-label={t`Choose CLI for new chat`}
+ data-testid="terminal-new-chat-menu"
+ className="cursor-pointer rounded-l-none text-muted-foreground hover:text-foreground"
+ >
+ <ChevronDownIcon aria-hidden="true" className="size-3" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="min-w-[180px]">
+ <DropdownMenuLabel>
+ <Trans>New chat</Trans>
+ </DropdownMenuLabel>
+ {VISIBLE_CLIS.map((cli) => {
+ const { displayName: name } = TERMINAL_CLIS[cli];
+ return (
+ <DropdownMenuItem
+ key={cli}
+ onSelect={() => onPickCli(cli)}
+ data-testid={`terminal-new-chat-cli-${cli}`}
+ aria-label={t`${name} CLI`}
+ aria-current={selected === cli ? 'true' : undefined}
+ >
+ <TargetIcon id={cliIconTargetId(cli)} className="size-4" aria-hidden="true" />
+ <span className="flex-1">{name}</span>
+ {selected === cli ? (
+ <CheckIcon aria-hidden="true" className="size-4 text-muted-foreground" />
+ ) : null}
+ </DropdownMenuItem>
+ );
+ })}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ onSelect={onPickTerminal}
+ data-testid="terminal-new-chat-terminal"
+ aria-current={isTerminal ? 'true' : undefined}
+ >
+ <SquareTerminalIcon aria-hidden="true" className="size-4" />
+ <span className="flex-1">
+ <Trans>Terminal</Trans>
+ </span>
+ {isTerminal ? (
+ <CheckIcon aria-hidden="true" className="size-4 text-muted-foreground" />
+ ) : null}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ );
+}
diff --git a/packages/app/src/components/TerminalRevealTab.dom.test.tsx b/packages/app/src/components/TerminalRevealTab.dom.test.tsx
new file mode 100644
index 000000000..ec2c0fa2d
--- /dev/null
+++ b/packages/app/src/components/TerminalRevealTab.dom.test.tsx
@@ -0,0 +1,51 @@
+import { afterEach, describe, expect, mock, test } from 'bun:test';
+import { cleanup, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { TooltipProvider } from '@/components/ui/tooltip';
+import { TerminalRevealTab } from './TerminalRevealTab';
+
+function renderTab(dockPosition: 'bottom' | 'right') {
+ const onReveal = mock(() => {});
+ render(
+ <TooltipProvider>
+ <TerminalRevealTab dockPosition={dockPosition} onReveal={onReveal} />
+ </TooltipProvider>,
+ );
+ return { onReveal };
+}
+
+describe('TerminalRevealTab', () => {
+ afterEach(() => cleanup());
+
+ test('exposes a "Show terminal" control and fires onReveal on click', async () => {
+ const user = userEvent.setup();
+ const { onReveal } = renderTab('right');
+
+ await user.click(screen.getByRole('button', { name: 'Show terminal' }));
+
+ expect(onReveal).toHaveBeenCalledTimes(1);
+ });
+
+ test('marks which edge it hugs so it sits where the collapse control was', () => {
+ renderTab('right');
+ expect(
+ screen.getByRole('button', { name: 'Show terminal' }).getAttribute('data-terminal-reveal'),
+ ).toBe('right');
+ cleanup();
+
+ renderTab('bottom');
+ expect(
+ screen.getByRole('button', { name: 'Show terminal' }).getAttribute('data-terminal-reveal'),
+ ).toBe('bottom');
+ });
+
+ test('surfaces its label in a tooltip on hover', async () => {
+ const user = userEvent.setup();
+ renderTab('bottom');
+
+ await user.hover(screen.getByRole('button', { name: 'Show terminal' }));
+
+ const tooltip = await screen.findByRole('tooltip');
+ expect(tooltip.textContent).toContain('Show terminal');
+ });
+});
diff --git a/packages/app/src/components/TerminalRevealTab.tsx b/packages/app/src/components/TerminalRevealTab.tsx
new file mode 100644
index 000000000..0909b41f6
--- /dev/null
+++ b/packages/app/src/components/TerminalRevealTab.tsx
@@ -0,0 +1,52 @@
+import { useLingui } from '@lingui/react/macro';
+import { ChevronLeftIcon, ChevronUpIcon } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import type { TerminalDockPosition } from '@/lib/terminal-dock-store';
+import { cn } from '@/lib/utils';
+
+interface TerminalRevealTabProps {
+ /** Where the terminal was docked — decides the chevron direction, the edge the
+ * tab is flush against, and the tooltip side so it sits right where the
+ * collapse control was. */
+ readonly dockPosition: TerminalDockPosition;
+ readonly onReveal: () => void;
+ /** Absolute-placement offsets from the call site (which edge/corner it pins to).
+ * The caller owns placement because the two dock positions attach to different
+ * containers — the right column edge vs. the bottom of the editor column. */
+ readonly className?: string;
+}
+
+export function TerminalRevealTab({ dockPosition, onReveal, className }: TerminalRevealTabProps) {
+ const { t } = useLingui();
+ const rightDocked = dockPosition === 'right';
+ const label = t`Show terminal`;
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ type="button"
+ variant="outline"
+ size="icon-sm"
+ aria-label={label}
+ data-terminal-reveal={dockPosition}
+ onClick={onReveal}
+ className={cn(
+ 'absolute z-20 shrink-0 bg-background text-muted-foreground shadow-sm hover:text-foreground',
+ rightDocked ? 'rounded-r-none border-r-0' : 'rounded-b-none border-b-0',
+ className,
+ )}
+ >
+ {rightDocked ? (
+ <ChevronLeftIcon aria-hidden="true" />
+ ) : (
+ <ChevronUpIcon aria-hidden="true" />
+ )}
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent side={rightDocked ? 'left' : 'top'} sideOffset={8}>
+ {label}
+ </TooltipContent>
+ </Tooltip>
+ );
+}
diff --git a/packages/app/src/components/TerminalSessionsHost.tsx b/packages/app/src/components/TerminalSessionsHost.tsx
index 1f374c31e..6a8aeafe1 100644
--- a/packages/app/src/components/TerminalSessionsHost.tsx
+++ b/packages/app/src/components/TerminalSessionsHost.tsx
@@ -6,11 +6,16 @@ import { TabsContent } from '@/components/ui/tabs';
import { resolveDefaultCli } from '@/lib/default-cli-resolver';
import type { OkDesktopBridge } from '@/lib/desktop-bridge-types';
import type { TerminalDockPosition } from '@/lib/terminal-dock-store';
-import { loadStickyAgent } from '@/lib/unified-agent-store';
+import {
+ getInitialPreferBareTerminal,
+ writePreferBareTerminal,
+} from '@/lib/terminal-new-tab-store';
+import { loadStickyAgent, saveStickyAgent, terminalCliId } from '@/lib/unified-agent-store';
import { emitOpenAskAiComposer } from './ask-ai-composer-events';
import type { TerminalLaunchIntent } from './EditorPane';
import { subscribeToActiveTerminalInput } from './handoff/terminal-input-events';
import { TerminalGate } from './TerminalGate';
+import type { TerminalNewTabChoice } from './TerminalNewChatButton';
import { TerminalTabStrip } from './TerminalTabStrip';
/** A concurrent terminal session the host keeps as a tab. `id` is a stable
@@ -125,13 +130,36 @@ export function TerminalSessionsHost({
setActiveSessionId(id);
}
- function openNewChatSession() {
+ const [stickyCliId, setStickyCliId] = useState<string | null>(() => loadStickyAgent());
+ const [preferBareTerminal, setPreferBareTerminal] = useState(() =>
+ getInitialPreferBareTerminal(),
+ );
+ const newChatDefaultCli = resolveDefaultCli(stickyCliId, installedClis ?? {});
+ const newChatSelected: TerminalNewTabChoice = preferBareTerminal ? 'terminal' : newChatDefaultCli;
+
+ function openNewChatSession(cli: TerminalCli) {
stripLaunchNonceRef.current += 1;
- openSession({
- prompt: null,
- cli: resolveDefaultCli(loadStickyAgent(), installedClis ?? {}),
- nonce: stripLaunchNonceRef.current,
- });
+ openSession({ prompt: null, cli, nonce: stripLaunchNonceRef.current });
+ }
+
+ function launchSelectedNewTab() {
+ if (preferBareTerminal) openSession(null);
+ else openNewChatSession(newChatDefaultCli);
+ }
+
+ function pickNewChatCli(cli: TerminalCli) {
+ setPreferBareTerminal(false);
+ writePreferBareTerminal(false);
+ const id = terminalCliId(cli);
+ setStickyCliId(id);
+ saveStickyAgent(id);
+ openNewChatSession(cli);
+ }
+
+ function pickNewChatTerminal() {
+ setPreferBareTerminal(true);
+ writePreferBareTerminal(true);
+ openSession(null);
}
function setSessionTitle(id: string, title: string) {
@@ -287,8 +315,10 @@ export function TerminalSessionsHost({
activeSessionId={activeSessionId}
onSelect={setActiveSessionId}
onTabActivate={(id) => queueMicrotask(() => focusTerminalSession(id))}
- onNewChat={openNewChatSession}
- onNewTerminalTab={() => openSession(null)}
+ newChatSelected={newChatSelected}
+ onNewChatLaunch={launchSelectedNewTab}
+ onNewChatPickCli={pickNewChatCli}
+ onNewChatPickTerminal={pickNewChatTerminal}
onClose={closeSession}
dockPosition={dockPosition}
onToggleDock={onToggleDock}
diff --git a/packages/app/src/components/TerminalTabStrip.dom.test.tsx b/packages/app/src/components/TerminalTabStrip.dom.test.tsx
index d0f0bece2..67af6921c 100644
--- a/packages/app/src/components/TerminalTabStrip.dom.test.tsx
+++ b/packages/app/src/components/TerminalTabStrip.dom.test.tsx
@@ -14,11 +14,13 @@ function renderStrip(props?: {
sessions?: readonly TerminalTabDescriptor[];
activeSessionId?: string;
dockPosition?: 'bottom' | 'right';
+ newChatSelected?: 'claude' | 'codex' | 'opencode' | 'cursor' | 'terminal';
}) {
const onSelect = mock((_id: string) => {});
const onTabActivate = mock((_id: string) => {});
- const onNewChat = mock(() => {});
- const onNewTerminalTab = mock(() => {});
+ const onNewChatLaunch = mock(() => {});
+ const onNewChatPickCli = mock((_cli: string) => {});
+ const onNewChatPickTerminal = mock(() => {});
const onClose = mock((_id: string) => {});
const onToggleDock = mock(() => {});
const onCollapse = mock(() => {});
@@ -29,8 +31,10 @@ function renderStrip(props?: {
activeSessionId={props?.activeSessionId ?? 's1'}
onSelect={onSelect}
onTabActivate={onTabActivate}
- onNewChat={onNewChat}
- onNewTerminalTab={onNewTerminalTab}
+ newChatSelected={props?.newChatSelected ?? 'claude'}
+ onNewChatLaunch={onNewChatLaunch}
+ onNewChatPickCli={onNewChatPickCli}
+ onNewChatPickTerminal={onNewChatPickTerminal}
onClose={onClose}
dockPosition={props?.dockPosition ?? 'bottom'}
onToggleDock={onToggleDock}
@@ -41,8 +45,9 @@ function renderStrip(props?: {
return {
onSelect,
onTabActivate,
- onNewChat,
- onNewTerminalTab,
+ onNewChatLaunch,
+ onNewChatPickCli,
+ onNewChatPickTerminal,
onClose,
onToggleDock,
onCollapse,
@@ -59,6 +64,18 @@ describe('TerminalTabStrip', () => {
expect(tabs.map((tab) => tab.textContent)).toEqual(['Terminal 1', 'Terminal 2', 'Terminal 3']);
});
+ test('hovering a tab surfaces the full (untruncated) title in a tooltip', async () => {
+ const user = userEvent.setup();
+ const longTitle =
+ 'claude — refactor the terminal dock reveal affordance across every view kind';
+ renderStrip({ sessions: [{ id: 's1', label: longTitle }], activeSessionId: 's1' });
+
+ await user.hover(screen.getByRole('tab', { name: longTitle }));
+
+ const tooltip = await screen.findByRole('tooltip');
+ expect(tooltip.textContent).toContain(longTitle);
+ });
+
test('marks the active session as selected and leaves others unselected', () => {
renderStrip({ activeSessionId: 's2' });
expect(screen.getByRole('tab', { name: 'Terminal 2' }).getAttribute('aria-selected')).toBe(
@@ -114,50 +131,60 @@ describe('TerminalTabStrip', () => {
expect(onSelect).toHaveBeenCalledWith('s2');
});
- test('the New chat control reports onNewChat and never onSelect / onNewTerminalTab', async () => {
+ test('the New-chat primary launches the current selection and never onSelect', async () => {
const user = userEvent.setup();
- const { onNewChat, onNewTerminalTab, onSelect } = renderStrip();
+ const { onNewChatLaunch, onNewChatPickTerminal, onSelect } = renderStrip();
- await user.click(screen.getByRole('button', { name: 'New chat' }));
+ await user.click(screen.getByRole('button', { name: 'New Claude chat' }));
- expect(onNewChat).toHaveBeenCalledTimes(1);
- expect(onNewTerminalTab).not.toHaveBeenCalled();
+ expect(onNewChatLaunch).toHaveBeenCalledTimes(1);
+ expect(onNewChatPickTerminal).not.toHaveBeenCalled();
expect(onSelect).not.toHaveBeenCalled();
});
- test('the New terminal tab control reports onNewTerminalTab (bare shell) and never onNewChat', async () => {
+ test('the primary reflects a Terminal selection (opens a bare terminal)', async () => {
+ const user = userEvent.setup();
+ const { onNewChatLaunch } = renderStrip({ newChatSelected: 'terminal' });
+
+ await user.click(screen.getByRole('button', { name: 'New terminal' }));
+
+ expect(onNewChatLaunch).toHaveBeenCalledTimes(1);
+ });
+
+ test('the New-chat dropdown picks a bare terminal via its "Terminal" option', async () => {
const user = userEvent.setup();
- const { onNewChat, onNewTerminalTab } = renderStrip();
+ const { onNewChatPickTerminal, onNewChatLaunch } = renderStrip();
- await user.click(screen.getByRole('button', { name: 'New terminal tab' }));
+ await user.click(screen.getByRole('button', { name: 'Choose CLI for new chat' }));
+ await user.click(await screen.findByRole('menuitem', { name: 'Terminal' }));
- expect(onNewTerminalTab).toHaveBeenCalledTimes(1);
- expect(onNewChat).not.toHaveBeenCalled();
+ expect(onNewChatPickTerminal).toHaveBeenCalledTimes(1);
+ expect(onNewChatLaunch).not.toHaveBeenCalled();
});
- test('New chat hugs the last tab, preceding the trailing New terminal tab / collapse controls', () => {
+ test('New chat hugs the last tab, preceding the trailing dock-toggle / collapse controls', () => {
renderStrip();
- const newChat = screen.getByRole('button', { name: 'New chat' });
- const newTerminalTab = screen.getByRole('button', { name: 'New terminal tab' });
+ const newChat = screen.getByRole('button', { name: 'New Claude chat' });
+ const dockToggle = screen.getByRole('button', { name: 'Dock terminal to the right' });
const collapse = screen.getByRole('button', { name: 'Collapse terminal' });
expect(
- newChat.compareDocumentPosition(newTerminalTab) & Node.DOCUMENT_POSITION_FOLLOWING,
+ newChat.compareDocumentPosition(dockToggle) & Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
expect(
- newTerminalTab.compareDocumentPosition(collapse) & Node.DOCUMENT_POSITION_FOLLOWING,
+ dockToggle.compareDocumentPosition(collapse) & Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
});
test('a tab close control reports onClose with that session id only', async () => {
const user = userEvent.setup();
- const { onClose, onSelect, onNewChat } = renderStrip({ activeSessionId: 's1' });
+ const { onClose, onSelect, onNewChatLaunch } = renderStrip({ activeSessionId: 's1' });
await user.click(screen.getByRole('button', { name: 'Close Terminal 2' }));
expect(onClose).toHaveBeenCalledTimes(1);
expect(onClose).toHaveBeenCalledWith('s2');
expect(onSelect).not.toHaveBeenCalled();
- expect(onNewChat).not.toHaveBeenCalled();
+ expect(onNewChatLaunch).not.toHaveBeenCalled();
});
test('the dock-toggle reports onToggleDock and labels the resulting position', async () => {
@@ -176,16 +203,16 @@ describe('TerminalTabStrip', () => {
expect(screen.queryByRole('button', { name: 'Dock terminal to the right' })).toBeNull();
});
- test('the collapse control reports onCollapse and never onClose / onNewChat / onNewTerminalTab', async () => {
+ test('the collapse control reports onCollapse and never onClose / new-chat', async () => {
const user = userEvent.setup();
- const { onCollapse, onClose, onNewChat, onNewTerminalTab } = renderStrip();
+ const { onCollapse, onClose, onNewChatLaunch, onNewChatPickTerminal } = renderStrip();
await user.click(screen.getByRole('button', { name: 'Collapse terminal' }));
expect(onCollapse).toHaveBeenCalledTimes(1);
expect(onClose).not.toHaveBeenCalled();
- expect(onNewChat).not.toHaveBeenCalled();
- expect(onNewTerminalTab).not.toHaveBeenCalled();
+ expect(onNewChatLaunch).not.toHaveBeenCalled();
+ expect(onNewChatPickTerminal).not.toHaveBeenCalled();
});
test('no drag-to-dock grip is rendered (dragging was removed)', () => {
@@ -195,8 +222,8 @@ describe('TerminalTabStrip', () => {
test('every icon-only control exposes an accessible name', () => {
renderStrip();
- expect(screen.getByRole('button', { name: 'New chat' })).toBeDefined();
- expect(screen.getByRole('button', { name: 'New terminal tab' })).toBeDefined();
+ expect(screen.getByRole('button', { name: 'New Claude chat' })).toBeDefined();
+ expect(screen.getByRole('button', { name: 'Choose CLI for new chat' })).toBeDefined();
expect(screen.getByRole('button', { name: 'Dock terminal to the right' })).toBeDefined();
expect(screen.getByRole('button', { name: 'Collapse terminal' })).toBeDefined();
for (const label of ['Terminal 1', 'Terminal 2', 'Terminal 3']) {
diff --git a/packages/app/src/components/TerminalTabStrip.tsx b/packages/app/src/components/TerminalTabStrip.tsx
index 997224bc9..4a63369d5 100644
--- a/packages/app/src/components/TerminalTabStrip.tsx
+++ b/packages/app/src/components/TerminalTabStrip.tsx
@@ -1,11 +1,10 @@
+import type { TerminalCli } from '@inkeep/open-knowledge-core';
import { Trans, useLingui } from '@lingui/react/macro';
import {
ChevronDownIcon,
ChevronRightIcon,
PanelBottomIcon,
PanelRightIcon,
- PlusIcon,
- SquareTerminalIcon,
XIcon,
} from 'lucide-react';
import type { ReactNode } from 'react';
@@ -14,6 +13,7 @@ import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import type { TerminalDockPosition } from '@/lib/terminal-dock-store';
import { cn } from '@/lib/utils';
+import { TerminalNewChatButton, type TerminalNewTabChoice } from './TerminalNewChatButton';
export interface TerminalTabDescriptor {
readonly id: string;
@@ -25,12 +25,13 @@ interface TerminalTabStripProps {
readonly activeSessionId: string;
readonly onSelect: (id: string) => void;
readonly onTabActivate?: (id: string) => void;
- /** Fires when the user clicks "New chat" (hugs the last tab) — launch the
- * default CLI promptless in a fresh session. */
- readonly onNewChat: () => void;
- /** Fires when the user clicks "New terminal tab" (trailing group) — open a
- * bare shell (the previous `+` behavior). */
- readonly onNewTerminalTab: () => void;
+ /** The New-chat split button's current pick — a CLI (resolved by the host from
+ * the sticky pick + installed set) or `'terminal'` (a bare shell). Drives the
+ * primary icon/label + the dropdown checkmark. */
+ readonly newChatSelected: TerminalNewTabChoice;
+ readonly onNewChatLaunch: () => void;
+ readonly onNewChatPickCli: (cli: TerminalCli) => void;
+ readonly onNewChatPickTerminal: () => void;
readonly onClose: (id: string) => void;
/** Where the terminal is currently docked — drives the dock-toggle + collapse
* button icons/labels. */
@@ -46,8 +47,10 @@ export function TerminalTabStrip({
activeSessionId,
onSelect,
onTabActivate,
- onNewChat,
- onNewTerminalTab,
+ newChatSelected,
+ onNewChatLaunch,
+ onNewChatPickCli,
+ onNewChatPickTerminal,
onClose,
dockPosition,
onToggleDock,
@@ -79,13 +82,23 @@ export function TerminalTabStrip({
isActive ? 'bg-muted' : 'hover:bg-muted/50',
)}
>
- <TabsTrigger
- value={session.id}
- onClick={() => onTabActivate?.(session.id)}
- className="h-7 flex-none rounded-md px-2 text-xs"
- >
- <span className="max-w-40 truncate">{session.label}</span>
- </TabsTrigger>
+ {/* The label truncates at max-w-40, so a process-set title
+ (OSC 0/2) that overflows is hard-clipped in the tab — the
+ tooltip surfaces the full title on hover. */}
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <TabsTrigger
+ value={session.id}
+ onClick={() => onTabActivate?.(session.id)}
+ className="h-7 flex-none rounded-md px-2 text-xs"
+ >
+ <span className="max-w-40 truncate">{session.label}</span>
+ </TabsTrigger>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" sideOffset={8}>
+ {session.label}
+ </TooltipContent>
+ </Tooltip>
<Button
type="button"
variant="ghost"
@@ -107,45 +120,18 @@ export function TerminalTabStrip({
);
})}
</TabsList>
- {/* New chat hugs the last tab (outside the tablist's scroll+fade so it is
- never clipped): launch the default CLI promptless. */}
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- type="button"
- variant="ghost"
- size="icon-xs"
- aria-label={t`New chat`}
- className="shrink-0 cursor-pointer text-muted-foreground hover:text-foreground"
- onClick={onNewChat}
- >
- <PlusIcon aria-hidden="true" />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="bottom" sideOffset={8}>
- <Trans>New chat</Trans>
- </TooltipContent>
- </Tooltip>
+ {/* New-chat split button hugs the last tab (outside the tablist's
+ scroll+fade so it is never clipped): the primary launches the default
+ CLI, the carat switches CLI or opens a bare terminal. */}
+ <TerminalNewChatButton
+ selected={newChatSelected}
+ onLaunchSelected={onNewChatLaunch}
+ onPickCli={onNewChatPickCli}
+ onPickTerminal={onNewChatPickTerminal}
+ className="shrink-0"
+ />
{/* Spacer pushes the trailing controls to the far right. */}
<div className="flex-1" />
- {/* New terminal tab opens a bare shell (the previous `+` behavior). */}
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- type="button"
- variant="ghost"
- size="icon-xs"
- aria-label={t`New terminal tab`}
- className="shrink-0 cursor-pointer text-muted-foreground hover:text-foreground"
- onClick={onNewTerminalTab}
- >
- <SquareTerminalIcon aria-hidden="true" />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="bottom" sideOffset={8}>
- <Trans>New terminal tab</Trans>
- </TooltipContent>
- </Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button
diff --git a/packages/app/src/components/doc-panel-events.test.ts b/packages/app/src/components/doc-panel-events.test.ts
index eca6022a3..c104c9858 100644
--- a/packages/app/src/components/doc-panel-events.test.ts
+++ b/packages/app/src/components/doc-panel-events.test.ts
@@ -1,9 +1,7 @@
import { describe, expect, mock, test } from 'bun:test';
import {
consumePendingDocPanelTabRequest,
- requestDocPanelCollapse,
requestDocPanelTab,
- subscribeToDocPanelCollapseRequests,
subscribeToDocPanelTabRequests,
} from './doc-panel-events';
@@ -25,17 +23,4 @@ describe('doc-panel-events', () => {
expect(onRequest).toHaveBeenCalledTimes(1);
expect(consumePendingDocPanelTabRequest()).toBe('outline');
});
-
- test('dispatches and subscribes collapse requests, and unsubscribes cleanly', () => {
- const target = new EventTarget();
- const onCollapse = mock(() => {});
-
- const unsubscribe = subscribeToDocPanelCollapseRequests(onCollapse, target);
- requestDocPanelCollapse(target);
- expect(onCollapse).toHaveBeenCalledTimes(1);
-
- unsubscribe();
- requestDocPanelCollapse(target);
- expect(onCollapse).toHaveBeenCalledTimes(1);
- });
});
diff --git a/packages/app/src/components/doc-panel-events.ts b/packages/app/src/components/doc-panel-events.ts
index 056204f17..aada2470d 100644
--- a/packages/app/src/components/doc-panel-events.ts
+++ b/packages/app/src/components/doc-panel-events.ts
@@ -46,25 +46,3 @@ export function subscribeToDocPanelTabRequests(
target.addEventListener(DOC_PANEL_TAB_EVENT, listener as EventListener);
return () => target.removeEventListener(DOC_PANEL_TAB_EVENT, listener as EventListener);
}
-
-const DOC_PANEL_COLLAPSE_EVENT = 'open-knowledge:doc-panel-collapse';
-
-export function requestDocPanelCollapse(
- target: Pick<Window, 'dispatchEvent'> | EventTarget = typeof window === 'undefined'
- ? new EventTarget()
- : window,
-): void {
- target.dispatchEvent(new CustomEvent(DOC_PANEL_COLLAPSE_EVENT));
-}
-
-export function subscribeToDocPanelCollapseRequests(
- onRequest: () => void,
- target: Pick<Window, 'addEventListener' | 'removeEventListener'> | EventTarget = typeof window ===
- 'undefined'
- ? new EventTarget()
- : window,
-): () => void {
- const listener = () => onRequest();
- target.addEventListener(DOC_PANEL_COLLAPSE_EVENT, listener as EventListener);
- return () => target.removeEventListener(DOC_PANEL_COLLAPSE_EVENT, listener as EventListener);
-}
diff --git a/packages/app/src/lib/default-cli-resolver.test.ts b/packages/app/src/lib/default-cli-resolver.test.ts
index eee924521..0be2b17fb 100644
--- a/packages/app/src/lib/default-cli-resolver.test.ts
+++ b/packages/app/src/lib/default-cli-resolver.test.ts
@@ -18,9 +18,9 @@ describe('resolveDefaultCli', () => {
);
});
- test('a sticky CLI that is NOT installed falls through to first-installed by priority', () => {
+ test('a sticky CLI that is NOT installed is still honored (respect the explicit pick)', () => {
expect(resolveDefaultCli(terminalCliId('cursor'), installedMap(['opencode', 'codex']))).toBe(
- 'codex',
+ 'cursor',
);
});
@@ -28,8 +28,8 @@ describe('resolveDefaultCli', () => {
expect(resolveDefaultCli(TERMINAL_CLI_ID, installedMap(['claude', 'codex']))).toBe('claude');
});
- test('the legacy bare sentinel falls through when claude is not installed', () => {
- expect(resolveDefaultCli(TERMINAL_CLI_ID, installedMap(['opencode']))).toBe('opencode');
+ test('the legacy bare sentinel is honored (claude) even when claude is not installed', () => {
+ expect(resolveDefaultCli(TERMINAL_CLI_ID, installedMap(['opencode']))).toBe('claude');
});
test('an app-target sticky (not a CLI sentinel) is ignored — New chat only launches CLIs', () => {
@@ -62,8 +62,8 @@ describe('resolveDefaultCli', () => {
).toBe('claude');
});
- test('a KNOWN-absent sticky CLI with nothing installed → claude', () => {
- expect(resolveDefaultCli(terminalCliId('codex'), installedMap([]))).toBe('claude');
+ test('a KNOWN-absent sticky CLI with nothing installed is still honored', () => {
+ expect(resolveDefaultCli(terminalCliId('codex'), installedMap([]))).toBe('codex');
});
});
diff --git a/packages/app/src/lib/default-cli-resolver.ts b/packages/app/src/lib/default-cli-resolver.ts
index 9bda48d2a..4ef4d9109 100644
--- a/packages/app/src/lib/default-cli-resolver.ts
+++ b/packages/app/src/lib/default-cli-resolver.ts
@@ -6,6 +6,6 @@ export function resolveDefaultCli(
installed: Partial<Record<TerminalCli, boolean>>,
): TerminalCli {
const stickyCli = parseStickyCliId(sticky);
- if (stickyCli && installed[stickyCli] !== false) return stickyCli;
+ if (stickyCli) return stickyCli;
return TERMINAL_CLI_IDS.find((cli) => installed[cli] === true) ?? 'claude';
}
diff --git a/packages/app/src/lib/terminal-new-tab-store.test.ts b/packages/app/src/lib/terminal-new-tab-store.test.ts
new file mode 100644
index 000000000..f6d5c531e
--- /dev/null
+++ b/packages/app/src/lib/terminal-new-tab-store.test.ts
@@ -0,0 +1,43 @@
+import { describe, expect, test } from 'bun:test';
+import {
+ readPreferBareTerminal,
+ TERMINAL_NEW_TAB_BARE_KEY,
+ writePreferBareTerminal,
+} from './terminal-new-tab-store';
+
+function fakeStorage() {
+ const map = new Map<string, string>();
+ return {
+ getItem: (k: string) => map.get(k) ?? null,
+ setItem: (k: string, v: string) => {
+ map.set(k, v);
+ },
+ removeItem: (k: string) => {
+ map.delete(k);
+ },
+ has: (k: string) => map.has(k),
+ };
+}
+
+describe('terminal-new-tab-store', () => {
+ test('defaults to false when nothing is stored', () => {
+ expect(readPreferBareTerminal(fakeStorage())).toBe(false);
+ });
+
+ test('writing true then reading returns true; writing false removes the key', () => {
+ const s = fakeStorage();
+ writePreferBareTerminal(true, s);
+ expect(s.has(TERMINAL_NEW_TAB_BARE_KEY)).toBe(true);
+ expect(readPreferBareTerminal(s)).toBe(true);
+
+ writePreferBareTerminal(false, s);
+ expect(s.has(TERMINAL_NEW_TAB_BARE_KEY)).toBe(false);
+ expect(readPreferBareTerminal(s)).toBe(false);
+ });
+
+ test('a junk stored value is not treated as true', () => {
+ const s = fakeStorage();
+ s.setItem(TERMINAL_NEW_TAB_BARE_KEY, 'yes');
+ expect(readPreferBareTerminal(s)).toBe(false);
+ });
+});
diff --git a/packages/app/src/lib/terminal-new-tab-store.ts b/packages/app/src/lib/terminal-new-tab-store.ts
new file mode 100644
index 000000000..920147c02
--- /dev/null
+++ b/packages/app/src/lib/terminal-new-tab-store.ts
@@ -0,0 +1,33 @@
+export const TERMINAL_NEW_TAB_BARE_KEY = 'ok-terminal-new-tab-bare-v1';
+
+export interface NewTabStorage {
+ getItem(key: string): string | null;
+ setItem(key: string, value: string): void;
+ removeItem(key: string): void;
+}
+
+export function readPreferBareTerminal(storage?: NewTabStorage): boolean {
+ try {
+ const s = storage ?? localStorage;
+ return s.getItem(TERMINAL_NEW_TAB_BARE_KEY) === '1';
+ } catch {
+ return false;
+ }
+}
+
+export function writePreferBareTerminal(bare: boolean, storage?: NewTabStorage): void {
+ try {
+ const s = storage ?? localStorage;
+ if (bare) s.setItem(TERMINAL_NEW_TAB_BARE_KEY, '1');
+ else s.removeItem(TERMINAL_NEW_TAB_BARE_KEY);
+ } catch {}
+}
+
+export function getInitialPreferBareTerminal(): boolean {
+ try {
+ if (typeof localStorage === 'undefined') return false;
+ return readPreferBareTerminal();
+ } catch {
+ return false;
+ }
+}
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index 2741445c0..649741115 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -42,6 +42,7 @@
"0Gd0NU": ["Shared"],
"0LBDjY": ["\"", ["0"], "\" uninstalled — back to a draft"],
"0NA4b3": ["Keep my version"],
+ "0SBTff": ["Show terminal"],
"0YEbfk": ["Connect to AI tools"],
"0YUS3Q": ["Subfolder under current folder"],
"0_J12R": [
@@ -264,7 +265,6 @@
"67f-3g": ["Duplicate succeeded but the sidebar may be out of date — refresh to resync"],
"6Aih4U": ["Offline"],
"6EKG_c": ["What agents match on to decide when to use the skill."],
- "6I7cJR": ["Open chat"],
"6LbUG7": ["The repository is private and your GitHub account doesn't have access to it."],
"6MnZEC": ["Terminal failed to load"],
"6O626z": ["No headings match \"", ["trimmedAnchorQuery"], "\""],
@@ -395,6 +395,7 @@
"9fvog2": ["Preview unavailable: ", ["errorDetail"]],
"9i21pa": ["Commits happen automatically"],
"9jnjV0": ["Embed an audio file with native player controls."],
+ "9mEZeD": [["name"], " CLI"],
"9npOH9": ["Open file"],
"9o1bIV": [["behind"], " behind"],
"9oE4C3": ["Browse your repos:"],
@@ -410,6 +411,7 @@
"AAlr5Y": [
"No collab server for this worktree — run <0>ok start</0> here, or reopen the project."
],
+ "AB4qw9": ["New terminal"],
"AE7BY3": ["The terminal session ended."],
"AIn2Yv": [["displayName"], " CLI, ", ["hint"]],
"ALhMYW": ["Terminal"],
@@ -970,6 +972,7 @@
"Q7W-mC": ["Same folder as current file"],
"Q8A-U_": ["Connected to"],
"QDZbvN": [["diffDays"], "d ago"],
+ "QJaG-9": ["Choose CLI for new chat"],
"QNxpRm": ["Dock terminal to the right"],
"QOINDn": ["empty"],
"QQghPu": ["Install in Claude Desktop"],
@@ -1616,7 +1619,6 @@
["trimmedSlug"],
"</0> already exists here. Saving creates a local copy that overrides it for this folder."
],
- "k0vc0N": ["New terminal tab"],
"kCNU4q": [
"Indexing your pages — ",
["semanticIndexedCount"],
@@ -1737,6 +1739,7 @@
"This path is on an external volume (/Volumes/...). OpenKnowledge will lose track of files when the drive ejects."
],
"nNYV3Y": ["and ", ["remaining"], " more"],
+ "nP-KFo": ["New ", ["0"], " chat"],
"nTwL53": ["Open a doc to share its URL."],
"nUNZL4": ["Ask ", ["0"]],
"nWv1ja": ["Manage hidden files in Settings → Ignore patterns."],
@@ -1824,7 +1827,6 @@
"pmKdif": ["Failed: ", ["loadError"]],
"pmUArF": ["Workspace"],
"ppDgFi": ["Restart with this app's version"],
- "pqZJT2": ["Close chat"],
"pzutoc": ["Italic"],
"q2kXMG": ["Inline Math"],
"q4YJl_": ["The terminal session ended (exit code ", ["0"], ")."],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 6df8e56d0..2dd0f8439 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -323,6 +323,10 @@ msgstr "{minutes} min ago"
msgid "{minutes}m ago"
msgstr "{minutes}m ago"
+#: src/components/TerminalNewChatButton.tsx
+msgid "{name} CLI"
+msgstr "{name} CLI"
+
#: src/components/GraphPanel.tsx
msgid "{nodeCount, plural, one {# node} other {# nodes}}"
msgstr "{nodeCount, plural, one {# node} other {# nodes}}"
@@ -1040,6 +1044,10 @@ msgstr "Checklist with checkboxes."
msgid "Choose agent"
msgstr "Choose agent"
+#: src/components/TerminalNewChatButton.tsx
+msgid "Choose CLI for new chat"
+msgstr "Choose CLI for new chat"
+
#: src/components/settings/SharingSection.tsx
msgid "Choose whether this project's OpenKnowledge setup, including its AI-tool connections, is saved with the project so teammates get it too, or kept only on your computer."
msgstr "Choose whether this project's OpenKnowledge setup, including its AI-tool connections, is saved with the project so teammates get it too, or kept only on your computer."
@@ -1172,10 +1180,6 @@ msgstr "Close all"
msgid "Close all unpinned"
msgstr "Close all unpinned"
-#: src/components/EditorHeader.tsx
-msgid "Close chat"
-msgstr "Close chat"
-
#: src/editor/find-replace/FindReplaceBar.tsx
msgid "Close find"
msgstr "Close find"
@@ -3898,7 +3902,12 @@ msgstr "never"
msgid "New"
msgstr "New"
-#: src/components/TerminalTabStrip.tsx
+#. placeholder {0}: TERMINAL_CLIS[selected].displayName
+#: src/components/TerminalNewChatButton.tsx
+msgid "New {0} chat"
+msgstr "New {0} chat"
+
+#: src/components/TerminalNewChatButton.tsx
msgid "New chat"
msgstr "New chat"
@@ -3960,9 +3969,9 @@ msgstr "New tab"
msgid "New template"
msgstr "New template"
-#: src/components/TerminalTabStrip.tsx
-msgid "New terminal tab"
-msgstr "New terminal tab"
+#: src/components/TerminalNewChatButton.tsx
+msgid "New terminal"
+msgstr "New terminal"
#: src/editor/find-replace/FindReplaceBar.tsx
msgid "Next match"
@@ -4351,10 +4360,6 @@ msgstr "Open and focus the Ask AI composer for the current editor selection."
msgid "Open and focus the bottom Ask AI prompt composer."
msgstr "Open and focus the bottom Ask AI prompt composer."
-#: src/components/EditorHeader.tsx
-msgid "Open chat"
-msgstr "Open chat"
-
#: src/lib/keyboard-shortcuts.ts
msgid "Open CodeMirror search in source editor mode."
msgstr "Open CodeMirror search in source editor mode."
@@ -5765,6 +5770,10 @@ msgstr "Show replace"
msgid "Show selection preview"
msgstr "Show selection preview"
+#: src/components/TerminalRevealTab.tsx
+msgid "Show terminal"
+msgstr "Show terminal"
+
#: src/editor/components/Pdf.tsx
msgid "Show thumbnails"
msgstr "Show thumbnails"
@@ -6199,6 +6208,7 @@ msgstr "Templates available"
#: src/components/handoff/OpenInAgentMenu.tsx
#: src/components/settings/SettingsDialogShell.tsx
#: src/components/settings/TerminalSection.tsx
+#: src/components/TerminalNewChatButton.tsx
#: src/components/TerminalPanel.tsx
msgid "Terminal"
msgstr "Terminal"
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index 8b46c2359..7edc8952b 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -42,6 +42,7 @@
"0Gd0NU": ["Śĥàŕēď"],
"0LBDjY": ["\"", ["0"], "\" ũńĩńśţàĺĺēď — ƀàćķ ţō à ďŕàƒţ"],
"0NA4b3": ["Ķēēƥ ḿŷ vēŕśĩōń"],
+ "0SBTff": ["Śĥōŵ ţēŕḿĩńàĺ"],
"0YEbfk": ["Ćōńńēćţ ţō ÀĨ ţōōĺś"],
"0YUS3Q": ["Śũƀƒōĺďēŕ ũńďēŕ ćũŕŕēńţ ƒōĺďēŕ"],
"0_J12R": [
@@ -264,7 +265,6 @@
"67f-3g": ["Ďũƥĺĩćàţē śũććēēďēď ƀũţ ţĥē śĩďēƀàŕ ḿàŷ ƀē ōũţ ōƒ ďàţē — ŕēƒŕēśĥ ţō ŕēśŷńć"],
"6Aih4U": ["Ōƒƒĺĩńē"],
"6EKG_c": ["Ŵĥàţ àĝēńţś ḿàţćĥ ōń ţō ďēćĩďē ŵĥēń ţō ũśē ţĥē śķĩĺĺ."],
- "6I7cJR": ["Ōƥēń ćĥàţ"],
"6LbUG7": ["Ţĥē ŕēƥōśĩţōŕŷ ĩś ƥŕĩvàţē àńď ŷōũŕ ĜĩţĤũƀ àććōũńţ ďōēśń'ţ ĥàvē àććēśś ţō ĩţ."],
"6MnZEC": ["Ţēŕḿĩńàĺ ƒàĩĺēď ţō ĺōàď"],
"6O626z": ["Ńō ĥēàďĩńĝś ḿàţćĥ \"", ["trimmedAnchorQuery"], "\""],
@@ -395,6 +395,7 @@
"9fvog2": ["Ƥŕēvĩēŵ ũńàvàĩĺàƀĺē: ", ["errorDetail"]],
"9i21pa": ["Ćōḿḿĩţś ĥàƥƥēń àũţōḿàţĩćàĺĺŷ"],
"9jnjV0": ["Ēḿƀēď àń àũďĩō ƒĩĺē ŵĩţĥ ńàţĩvē ƥĺàŷēŕ ćōńţŕōĺś."],
+ "9mEZeD": [["name"], " ĆĹĨ"],
"9npOH9": ["Ōƥēń ƒĩĺē"],
"9o1bIV": [["behind"], " ƀēĥĩńď"],
"9oE4C3": ["ßŕōŵśē ŷōũŕ ŕēƥōś:"],
@@ -410,6 +411,7 @@
"AAlr5Y": [
"Ńō ćōĺĺàƀ śēŕvēŕ ƒōŕ ţĥĩś ŵōŕķţŕēē — ŕũń <0>ōķ śţàŕţ</0> ĥēŕē, ōŕ ŕēōƥēń ţĥē ƥŕōĴēćţ."
],
+ "AB4qw9": ["Ńēŵ ţēŕḿĩńàĺ"],
"AE7BY3": ["Ţĥē ţēŕḿĩńàĺ śēśśĩōń ēńďēď."],
"AIn2Yv": [["displayName"], " ĆĹĨ, ", ["hint"]],
"ALhMYW": ["Ţēŕḿĩńàĺ"],
@@ -970,6 +972,7 @@
"Q7W-mC": ["Śàḿē ƒōĺďēŕ àś ćũŕŕēńţ ƒĩĺē"],
"Q8A-U_": ["Ćōńńēćţēď ţō"],
"QDZbvN": [["diffDays"], "ď àĝō"],
+ "QJaG-9": ["Ćĥōōśē ĆĹĨ ƒōŕ ńēŵ ćĥàţ"],
"QNxpRm": ["Ďōćķ ţēŕḿĩńàĺ ţō ţĥē ŕĩĝĥţ"],
"QOINDn": ["ēḿƥţŷ"],
"QQghPu": ["Ĩńśţàĺĺ ĩń Ćĺàũďē Ďēśķţōƥ"],
@@ -1616,7 +1619,6 @@
["trimmedSlug"],
"</0> àĺŕēàďŷ ēxĩśţś ĥēŕē. Śàvĩńĝ ćŕēàţēś à ĺōćàĺ ćōƥŷ ţĥàţ ōvēŕŕĩďēś ĩţ ƒōŕ ţĥĩś ƒōĺďēŕ."
],
- "k0vc0N": ["Ńēŵ ţēŕḿĩńàĺ ţàƀ"],
"kCNU4q": [
"Ĩńďēxĩńĝ ŷōũŕ ƥàĝēś — ",
["semanticIndexedCount"],
@@ -1737,6 +1739,7 @@
"Ţĥĩś ƥàţĥ ĩś ōń àń ēxţēŕńàĺ vōĺũḿē (/Vōĺũḿēś/...). ŌƥēńĶńōŵĺēďĝē ŵĩĺĺ ĺōśē ţŕàćķ ōƒ ƒĩĺēś ŵĥēń ţĥē ďŕĩvē ēĴēćţś."
],
"nNYV3Y": ["àńď ", ["remaining"], " ḿōŕē"],
+ "nP-KFo": ["Ńēŵ ", ["0"], " ćĥàţ"],
"nTwL53": ["Ōƥēń à ďōć ţō śĥàŕē ĩţś ŨŔĹ."],
"nUNZL4": ["Àśķ ", ["0"]],
"nWv1ja": ["Ḿàńàĝē ĥĩďďēń ƒĩĺēś ĩń Śēţţĩńĝś → Ĩĝńōŕē ƥàţţēŕńś."],
@@ -1824,7 +1827,6 @@
"pmKdif": ["Ƒàĩĺēď: ", ["loadError"]],
"pmUArF": ["Ŵōŕķśƥàćē"],
"ppDgFi": ["Ŕēśţàŕţ ŵĩţĥ ţĥĩś àƥƥ'ś vēŕśĩōń"],
- "pqZJT2": ["Ćĺōśē ćĥàţ"],
"pzutoc": ["Ĩţàĺĩć"],
"q2kXMG": ["Ĩńĺĩńē Ḿàţĥ"],
"q4YJl_": ["Ţĥē ţēŕḿĩńàĺ śēśśĩōń ēńďēď (ēxĩţ ćōďē ", ["0"], ")."],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index c2b217ab6..bf3cfbbf6 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -323,6 +323,10 @@ msgstr ""
msgid "{minutes}m ago"
msgstr ""
+#: src/components/TerminalNewChatButton.tsx
+msgid "{name} CLI"
+msgstr ""
+
#: src/components/GraphPanel.tsx
msgid "{nodeCount, plural, one {# node} other {# nodes}}"
msgstr ""
@@ -1035,6 +1039,10 @@ msgstr ""
msgid "Choose agent"
msgstr ""
+#: src/components/TerminalNewChatButton.tsx
+msgid "Choose CLI for new chat"
+msgstr ""
+
#: src/components/settings/SharingSection.tsx
msgid "Choose whether this project's OpenKnowledge setup, including its AI-tool connections, is saved with the project so teammates get it too, or kept only on your computer."
msgstr ""
@@ -1167,10 +1175,6 @@ msgstr ""
msgid "Close all unpinned"
msgstr ""
-#: src/components/EditorHeader.tsx
-msgid "Close chat"
-msgstr ""
-
#: src/editor/find-replace/FindReplaceBar.tsx
msgid "Close find"
msgstr ""
@@ -3893,7 +3897,12 @@ msgstr ""
msgid "New"
msgstr ""
-#: src/components/TerminalTabStrip.tsx
+#. placeholder {0}: TERMINAL_CLIS[selected].displayName
+#: src/components/TerminalNewChatButton.tsx
+msgid "New {0} chat"
+msgstr ""
+
+#: src/components/TerminalNewChatButton.tsx
msgid "New chat"
msgstr ""
@@ -3955,8 +3964,8 @@ msgstr ""
msgid "New template"
msgstr ""
-#: src/components/TerminalTabStrip.tsx
-msgid "New terminal tab"
+#: src/components/TerminalNewChatButton.tsx
+msgid "New terminal"
msgstr ""
#: src/editor/find-replace/FindReplaceBar.tsx
@@ -4346,10 +4355,6 @@ msgstr ""
msgid "Open and focus the bottom Ask AI prompt composer."
msgstr ""
-#: src/components/EditorHeader.tsx
-msgid "Open chat"
-msgstr ""
-
#: src/lib/keyboard-shortcuts.ts
msgid "Open CodeMirror search in source editor mode."
msgstr ""
@@ -5760,6 +5765,10 @@ msgstr ""
msgid "Show selection preview"
msgstr ""
+#: src/components/TerminalRevealTab.tsx
+msgid "Show terminal"
+msgstr ""
+
#: src/editor/components/Pdf.tsx
msgid "Show thumbnails"
msgstr ""
@@ -6194,6 +6203,7 @@ msgstr ""
#: src/components/handoff/OpenInAgentMenu.tsx
#: src/components/settings/SettingsDialogShell.tsx
#: src/components/settings/TerminalSection.tsx
+#: src/components/TerminalNewChatButton.tsx
#: src/components/TerminalPanel.tsx
msgid "Terminal"
msgstr ""