Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/BoardSidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function BoardSidePanelClose() {
<Show when={!store.showNewTaskPanel}>
<button
type="button"
class="board-side-panel-close"
class="edge-tab board-side-panel-close"
title="Close side panel (Escape)"
aria-label="Close side panel"
onClick={() => closeSidePanel()}
Expand Down
37 changes: 37 additions & 0 deletions src/components/TaskPanel.reasoning.client.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
setTaskContext,
setShowPromptInput,
setActiveTask,
setTaskSideCollapsed,
} from '../store/store';
import { GIST_LABEL } from '../lib/understanding-tour';
import type { Task } from '../store/types';
Expand Down Expand Up @@ -57,6 +58,7 @@ vi.mock('../store/store', () => {
tasks: { parent: { id: 'parent', name: 'Parent task', collapsed: false } },
focusMode: false,
taskSplitMode: {} as Record<string, unknown>,
taskSideCollapsed: false,
themePreset: 'obsidian',
showPlans: true,
focusedPanel: { task: 'prompt' },
Expand Down Expand Up @@ -91,6 +93,8 @@ vi.mock('../store/store', () => {
deletePanelUserSize: vi.fn(),
setPanelUserSize: vi.fn(),
setTaskSplitMode: vi.fn(),
setTaskSideCollapsed: (on: boolean) => setStore('taskSideCollapsed', on),
isSideColumnPanel: (panel: string) => ['notes', 'changed-files'].includes(panel),
registerFocusFn: vi.fn(),
unregisterFocusFn: vi.fn(),
setActiveAgent: vi.fn(),
Expand Down Expand Up @@ -306,6 +310,7 @@ afterEach(() => {
dispose?.();
toggleFocusMode(false);
setTaskFocusedPanel('task', 'prompt');
setTaskSideCollapsed(false);
document.body.replaceChildren();
channels.length = 0;
vi.mocked(showNotification).mockClear();
Expand Down Expand Up @@ -830,6 +835,38 @@ it('gives the focus support column height to changed files until a shell opens,
}
});

it('hides the side column with its toggle and brings it back for focus, keeping the terminal', () => {
const width = vi.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockReturnValue(1200);
try {
toggleFocusMode(true);
const { container } = mountEmptyTask();
const terminal = expectDefined(container.querySelector('.test-terminal'));
const toggle = expectDefined(container.querySelector<HTMLButtonElement>('.task-side-toggle'));
expect(toggle.getAttribute('aria-label')).toBe('Hide side panel');
expect(container.querySelector('.test-notes')).not.toBeNull();

setTaskFocusedPanel('task', 'notes');
toggle.click();
expect(container.querySelector('.test-notes')).toBeNull();
expect(container.querySelector('.test-files')).toBeNull();
expect(container.querySelector('.test-terminal')).toBe(terminal);
// Focus leaves the hidden notes instead of bringing them straight back.
expect(store.focusedPanel.task).toBe('ai-terminal');
expect(toggle.getAttribute('aria-label')).toBe('Show side panel');
expect(toggle.classList.contains('collapsed')).toBe(true);

toggle.click();
expect(container.querySelector('.test-notes')).not.toBeNull();
toggle.click();
// A keyboard jump into the hidden column shows it again.
setTaskFocusedPanel('task', 'changed-files');
expect(container.querySelector('.test-files')).not.toBeNull();
expect(container.querySelector('.test-terminal')).toBe(terminal);
} finally {
width.mockRestore();
}
});

it('preserves commit rows on unchanged polls and updates changed messages, order and length', async () => {
vi.useFakeTimers();
let commits: CommitInfo[] = [
Expand Down
152 changes: 100 additions & 52 deletions src/components/TaskPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
clearPendingAction,
showNotification,
setTaskSplitMode,
setTaskSideCollapsed,
isSideColumnPanel,
isTaskCanvasVisible,
referenceTourCard,
openCanvasDocument,
Expand Down Expand Up @@ -72,6 +74,7 @@ import type { DocumentSnapshot } from '../documents/types';
import { SubTaskStrip } from './SubTaskStrip';
import { theme } from '../lib/theme';
import { isMac } from '../lib/platform';
import { ChevronRightSmallIcon } from './icons';
import type { Task } from '../store/types';
import type { ChangedFile, CommitInfo } from '../ipc/types';
import type { TranscriptMarks } from '../investigation/transcript';
Expand Down Expand Up @@ -447,8 +450,10 @@ export function TaskPanel(props: TaskPanelProps) {
const SPLIT_EXIT_WIDTH = 1030;
const [panelWidth, setPanelWidth] = createSignal(0);
const [useSplit, setUseSplit] = createSignal(false);
// The user can hide the split layout's side column; the setting is global.
const sideShown = () => useSplit() && !store.taskSideCollapsed;
// Split mode shows task context as a pane in the side column instead.
const showContextStrip = () => contextOn() && !useSplit();
const showContextStrip = () => contextOn() && !sideShown();
createEffect(() => {
const w = panelWidth();
const focused = document.activeElement;
Expand Down Expand Up @@ -479,6 +484,29 @@ export function TaskPanel(props: TaskPanelProps) {
});
onCleanup(() => setTaskSplitMode(props.task.id, false));

// Focus moving to a pane of the hidden side column, such as a new shell or
// a keyboard jump to the notes, brings the column back.
createEffect(
on(
() => store.focusedPanel[props.task.id],
(panel) => {
if (panel && useSplit() && store.taskSideCollapsed && isSideColumnPanel(panel)) {
setTaskSideCollapsed(false);
}
},
{ defer: true },
),
);
const toggleSideColumn = () => {
const collapsing = !store.taskSideCollapsed;
const panel = store.focusedPanel[props.task.id];
// Focus can't stay in a pane that leaves the layout.
if (collapsing && panel && isSideColumnPanel(panel)) {
setTaskFocusedPanel(props.task.id, 'ai-terminal');
}
setTaskSideCollapsed(collapsing);
};

const editingProject = () => {
const id = editingProjectId();
return id ? (getProject(id) ?? null) : null;
Expand Down Expand Up @@ -873,14 +901,66 @@ export function TaskPanel(props: TaskPanelProps) {
),
};

// Split-mode columns, created once so hiding the side column keeps the
// terminal column mounted.
const leftColChild: PanelChild = {
id: 'left-col',
minSize: 420,
content: () => (
<ResizablePanel
direction="vertical"
persistKey={`task:${props.task.id}:split-left`}
absorberIds={['ai-terminal']}
children={[aiTerminalChild, ...(promptBoxShown() ? [promptInputChild] : [])]}
/>
),
};

const rightColChild: PanelChild = {
id: 'right-col',
resizeLabel: 'Resize side panel',
minSize: 360,
defaultSize: 420,
content: () => (
<ResizablePanel
direction="vertical"
class="task-side-stack"
persistKey={`task:${props.task.id}:split-right`}
// An empty shell is just its toolbar, so without shells the
// changed files (or notes, without git) take the free height
// instead of leaving it blank below a capped pane.
absorberIds={[
props.task.shellAgentIds.length > 0
? 'shell-section'
: isGitUnavailable()
? 'notes'
: 'changed-files',
]}
// Vertical pins don't shrink, so pinned or dragged panels can
// outgrow the column; scroll keeps them and their handles reachable.
style={{
height: '100%',
'max-height': '100%',
overflow: 'auto',
}}
children={[
...(contextOn() ? [contextChild] : []),
...(isGitUnavailable() ? [] : [changedFilesChild]),
notesChild,
shellSectionChild,
]}
/>
),
};

// The task body left of the canvas. Created once so toggling the canvas
// column reparents it instead of remounting the terminal.
const mainEl = (
<div
ref={mainRef}
style={{ height: '100%', 'min-height': '0', display: 'flex', 'flex-direction': 'column' }}
>
<div style={{ flex: '1', 'min-height': '0' }}>
<div class="task-main-body" style={{ flex: '1', 'min-height': '0' }}>
{/* Layout flips swap containers; the terminal, composer, notes, and canvas stay mounted. */}
<Show
when={useSplit()}
Expand All @@ -900,59 +980,27 @@ export function TaskPanel(props: TaskPanelProps) {
>
<ResizablePanel
direction="horizontal"
class="task-split-cols"
persistKey={`task:${props.task.id}:split-cols`}
absorberIds={['left-col']}
children={[
{
id: 'left-col',
minSize: 420,
content: () => (
<ResizablePanel
direction="vertical"
persistKey={`task:${props.task.id}:split-left`}
absorberIds={['ai-terminal']}
children={[aiTerminalChild, ...(promptBoxShown() ? [promptInputChild] : [])]}
/>
),
},
{
id: 'right-col',
resizeLabel: 'Resize side panel',
minSize: 360,
defaultSize: 420,
content: () => (
<ResizablePanel
direction="vertical"
class="task-side-stack"
persistKey={`task:${props.task.id}:split-right`}
// An empty shell is just its toolbar, so without shells the
// changed files (or notes, without git) take the free height
// instead of leaving it blank below a capped pane.
absorberIds={[
props.task.shellAgentIds.length > 0
? 'shell-section'
: isGitUnavailable()
? 'notes'
: 'changed-files',
]}
// Vertical pins don't shrink, so pinned or dragged panels can
// outgrow the column; scroll keeps them and their handles reachable.
style={{
height: '100%',
'max-height': '100%',
overflow: 'auto',
}}
children={[
...(contextOn() ? [contextChild] : []),
...(isGitUnavailable() ? [] : [changedFilesChild]),
notesChild,
shellSectionChild,
]}
/>
),
},
]}
children={[leftColChild, ...(store.taskSideCollapsed ? [] : [rightColChild])]}
/>
{/* On the boundary it moves, like the board side panel's tab. */}
<button
type="button"
class="edge-tab task-side-toggle"
classList={{ collapsed: store.taskSideCollapsed }}
title={store.taskSideCollapsed ? 'Show side panel' : 'Hide side panel'}
aria-label={store.taskSideCollapsed ? 'Show side panel' : 'Hide side panel'}
aria-expanded={!store.taskSideCollapsed}
onClick={toggleSideColumn}
>
{/* Points the way the column goes: out to the right, or back in. */}
<ChevronRightSmallIcon
size={10}
style={{ transform: store.taskSideCollapsed ? 'scaleX(-1)' : undefined }}
/>
</button>
</Show>
</div>
</div>
Expand Down
26 changes: 3 additions & 23 deletions src/components/task-board.css
Original file line number Diff line number Diff line change
Expand Up @@ -1134,31 +1134,11 @@ main.board-panel-left > .plan-board-shell {
height: auto;
min-height: 0;
}
/* A pill straddling the edge facing the board, centred on it and above the
resize handle it overlaps, so it reads as a tab of the boundary. */
/* Straddles the edge facing the board, centred on it and above the resize
handle it overlaps, so it reads as a tab of the boundary. The pill itself
is `.edge-tab` in styles.css. */
.board-side-panel-close {
position: absolute;
top: 50%;
left: -8px;
z-index: 3;
display: inline-flex;
align-items: center;
justify-content: center;
width: 16px;
height: 44px;
padding: 0;
translate: 0 -50%;
border: 1px solid var(--border);
border-radius: var(--radius-pill);
background: var(--bg-elevated);
box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
color: var(--fg-muted);
cursor: pointer;
}
.board-side-panel-close:hover {
border-color: var(--fg-muted);
background: var(--bg-hover);
color: var(--fg);
}
/* Ordered after the panel, the board would otherwise paint over the half of
the tab that sticks out, and take its clicks. */
Expand Down
11 changes: 11 additions & 0 deletions src/store/autosave.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ describe('autosave snapshot includes new-task-default fields', () => {
setStore('defaultPropagateSkipPermissions', false);
});

it('a hidden task side column changes the snapshot', () => {
setStore('taskSideCollapsed', false);
const before = persistedSnapshot();
setStore('taskSideCollapsed', true);
try {
expect(persistedSnapshot()).not.toBe(before);
} finally {
setStore('taskSideCollapsed', false);
}
});

it('terminalScreenReaderMode changes the snapshot', () => {
setStore('terminalScreenReaderMode', false);
const before = persistedSnapshot();
Expand Down
1 change: 1 addition & 0 deletions src/store/autosave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function structuralSnapshot(): string {
modelTaskNames: store.modelTaskNames,
taskNameModel: store.taskNameModel,
taskBriefs: store.taskBriefs,
taskSideCollapsed: store.taskSideCollapsed,
briefBarFields: { ...store.briefBarFields },
briefModel: store.briefModel,
reviewGuidance: store.reviewGuidance,
Expand Down
1 change: 1 addition & 0 deletions src/store/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const [store, setStore] = createStore<AppStore>({
modelTaskNames: false,
taskNameModel: DEFAULT_TASK_NAME_MODEL,
taskBriefs: false,
taskSideCollapsed: false,
briefBarFields: { ...DEFAULT_BRIEF_BAR_FIELDS },
briefModel: DEFAULT_BRIEF_MODEL,
reviewGuidance: '',
Expand Down
20 changes: 20 additions & 0 deletions src/store/focus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type MockStore = {
showPromptInput: boolean;
sidebarVisible: boolean;
taskSplitMode: Record<string, boolean>;
taskSideCollapsed: boolean;
shellLayoutOverride: 'row' | 'grid' | 'column' | null;
taskShellAutoLayout: Record<string, 'row' | 'grid' | 'column'>;
pendingAction: { type: 'close' | 'finish'; taskId: string } | null;
Expand Down Expand Up @@ -125,6 +126,7 @@ beforeEach(() => {
showPromptInput: true,
sidebarVisible: true,
taskSplitMode: {},
taskSideCollapsed: false,
shellLayoutOverride: null,
taskShellAutoLayout: {},
pendingAction: null,
Expand Down Expand Up @@ -319,6 +321,24 @@ describe('focus navigation neighbor map', () => {
expect(mockStore.focusedPanel['task-1']).toBe('changed-files');
});

it('keeps a split task without its hidden side column to the terminal column', () => {
setTask('task-1', {
shellAgentIds: ['shell-1'],
});
setTask('task-2');
mockStore.taskOrder = ['task-1', 'task-2'];
mockStore.taskSplitMode['task-1'] = true;
mockStore.taskSideCollapsed = true;
mockStore.showPromptInput = false;
mockStore.focusedPanel['task-1'] = 'ai-terminal';

navigateRow('down');
expect(mockStore.focusedPanel['task-1']).toBe('ai-terminal');

navigateColumn('right');
expect(mockStore.activeTaskId).toBe('task-2');
});

it('falls back from vanished focused panels before navigating', () => {
setTask('task-1');
mockStore.focusedPanel['task-1'] = 'removed-panel';
Expand Down
Loading