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
19 changes: 19 additions & 0 deletions src/components/TaskPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
clearPendingAction,
showNotification,
collapseTask,
toggleFocusMode,
} from '../store/store';
import { ResizablePanel, type PanelChild } from './ResizablePanel';
import { EditableText, type EditableTextHandle } from './EditableText';
Expand Down Expand Up @@ -344,6 +345,24 @@ export function TaskPanel(props: TaskPanelProps) {
</Show>
</div>
</Show>
<IconButton
icon={
store.focusMode ? (
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
<path d="M5.5 2.75A.75.75 0 0 0 4.75 2H2.5a.5.5 0 0 0-.5.5v2.25a.75.75 0 0 0 1.5 0V3.5h1.25a.75.75 0 0 0 .75-.75ZM11.25 2a.75.75 0 0 0 0 1.5H12.5v1.25a.75.75 0 0 0 1.5 0V2.5a.5.5 0 0 0-.5-.5h-2.25ZM3.5 11.25a.75.75 0 0 0-1.5 0V13.5a.5.5 0 0 0 .5.5h2.25a.75.75 0 0 0 0-1.5H3.5v-1.25ZM14 11.25a.75.75 0 0 0-1.5 0v1.25h-1.25a.75.75 0 0 0 0 1.5H13.5a.5.5 0 0 0 .5-.5v-2.25Z" />
</svg>
) : (
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
<path d="M2.75 5.5A.75.75 0 0 0 3.5 4.75V3.5h1.25a.75.75 0 0 0 0-1.5H2.5a.5.5 0 0 0-.5.5v2.25c0 .414.336.75.75.75ZM12.5 4.75a.75.75 0 0 0 1.5 0V2.5a.5.5 0 0 0-.5-.5h-2.25a.75.75 0 0 0 0 1.5h1.25v1.25ZM3.5 11.25a.75.75 0 0 0-1.5 0V13.5a.5.5 0 0 0 .5.5h2.25a.75.75 0 0 0 0-1.5H3.5v-1.25ZM13.25 10.5a.75.75 0 0 0-.75.75v1.25h-1.25a.75.75 0 0 0 0 1.5H13.5a.5.5 0 0 0 .5-.5v-2.25a.75.75 0 0 0-.75-.75Z" />
</svg>
)
}
onClick={() => {
if (!store.focusMode) setActiveTask(props.task.id);
toggleFocusMode();
}}
title={store.focusMode ? 'Exit focus mode' : 'Focus on this task'}
/>
<IconButton
icon={
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
Expand Down
85 changes: 63 additions & 22 deletions src/components/TilingLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import { Show, createMemo, createEffect, onMount, onCleanup, ErrorBoundary } from 'solid-js';
import { Show, For, createMemo, createEffect, ErrorBoundary } from 'solid-js';
import { store, pickAndAddProject, closeTerminal } from '../store/store';
import { closeTask } from '../store/tasks';
import { ResizablePanel, type PanelChild, type ResizablePanelHandle } from './ResizablePanel';
import type { PanelChild } from './ResizablePanel';
import { TaskPanel } from './TaskPanel';
import { TerminalPanel } from './TerminalPanel';
import { NewTaskPlaceholder } from './NewTaskPlaceholder';
import { markDirty } from '../lib/terminalFitManager';
import { theme } from '../lib/theme';
import { mod } from '../lib/platform';
import { createCtrlShiftWheelResizeHandler } from '../lib/wheelZoom';

export function TilingLayout() {
let containerRef: HTMLDivElement | undefined;
let panelHandle: ResizablePanelHandle | undefined;

onMount(() => {
if (!containerRef) return;
const handleWheel = createCtrlShiftWheelResizeHandler((deltaPx) => {
panelHandle?.resizeAll(deltaPx);
});
containerRef.addEventListener('wheel', handleWheel, { passive: false });
onCleanup(() => containerRef?.removeEventListener('wheel', handleWheel));
});

// Scroll the active task panel into view when selection changes
createEffect(() => {
Expand All @@ -29,6 +19,20 @@ export function TilingLayout() {
const el = containerRef.querySelector<HTMLElement>(`[data-task-id="${CSS.escape(activeId)}"]`);
el?.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior: 'instant' });
});

// When switching tasks in focus mode, mark all terminals of the newly active
// task as dirty so they re-fit to the correct size.
createEffect(() => {
const activeId = store.activeTaskId;
if (!store.focusMode || !activeId) return;
const task = store.tasks[activeId];
if (task) {
for (const agentId of task.agentIds) markDirty(agentId);
for (const shellId of task.shellAgentIds) markDirty(shellId);
}
const terminal = store.terminals[activeId];
if (terminal) markDirty(terminal.agentId);
});
// Cache PanelChild objects by ID so <For> sees stable references
// and doesn't unmount/remount panels when taskOrder changes.
const panelCache = new Map<string, PanelChild>();
Expand All @@ -48,7 +52,7 @@ export function TilingLayout() {
cached = {
id: panelId,
initialSize: 520,
minSize: 300,
minSize: 520,
content: () => {
const task = store.tasks[panelId];
const terminal = store.terminals[panelId];
Expand Down Expand Up @@ -334,15 +338,52 @@ export function TilingLayout() {
</div>
}
>
<ResizablePanel
direction="horizontal"
children={panelChildren()}
fitContent
persistKey="tiling"
onHandle={(h) => {
panelHandle = h;
<div
style={{
display: 'flex',
'flex-direction': 'row',
width: '100%',
'min-width': '100%',
height: '100%',
position: 'relative',
}}
/>
>
<For each={panelChildren()}>
{(child) => {
const isPlaceholder = child.id === '__placeholder';
const hidden = () =>
store.focusMode && !isPlaceholder && child.id !== store.activeTaskId;
const hidePlaceholder = () => store.focusMode && isPlaceholder;
return (
<div
style={{
// Focus mode: stack all panels on top of each other at full size
// so terminals always compute correct dimensions.
// Normal mode: standard flex row layout.
...(store.focusMode && !isPlaceholder
? {
position: hidden() ? 'absolute' : 'relative',
inset: '0',
width: '100%',
height: '100%',
visibility: hidden() ? 'hidden' : undefined,
'pointer-events': hidden() ? 'none' : undefined,
}
: {
flex: isPlaceholder ? '0 0 54px' : '1 1 0px',
'min-width': isPlaceholder ? undefined : '520px',
height: '100%',
display: hidePlaceholder() ? 'none' : undefined,
}),
overflow: 'hidden',
}}
>
{child.content()}
</div>
);
}}
</For>
</div>
</Show>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/store/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const [store, setStore] = createStore<AppStore>({
connectedClients: 0,
},
showArena: false,
focusMode: false,
});

export function updateWindowTitle(_taskName?: string): void {
Expand Down
3 changes: 3 additions & 0 deletions src/store/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function saveState(): Promise<void> {
inactiveColumnOpacity: store.inactiveColumnOpacity,
editorCommand: store.editorCommand || undefined,
customAgents: store.customAgents.length > 0 ? [...store.customAgents] : undefined,
focusMode: store.focusMode || undefined,
};

for (const taskId of store.taskOrder) {
Expand Down Expand Up @@ -175,6 +176,7 @@ interface LegacyPersistedState {
editorCommand?: unknown;
customAgents?: unknown;
terminals?: unknown;
focusMode?: unknown;
}

export async function loadState(): Promise<void> {
Expand Down Expand Up @@ -280,6 +282,7 @@ export async function loadState(): Promise<void> {

const rawEditorCommand = raw.editorCommand;
s.editorCommand = typeof rawEditorCommand === 'string' ? rawEditorCommand.trim() : '';
s.focusMode = raw.focusMode === true;

// Restore custom agents
if (Array.isArray(raw.customAgents)) {
Expand Down
1 change: 1 addition & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export {
setPanelSizes,
toggleSidebar,
toggleArena,
toggleFocusMode,
setTerminalFont,
setThemePreset,
setAutoTrustFolders,
Expand Down
2 changes: 2 additions & 0 deletions src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export interface PersistedState {
inactiveColumnOpacity?: number;
editorCommand?: string;
customAgents?: AgentDef[];
focusMode?: boolean;
}

// Panel cell IDs. Shell terminals use "shell:0", "shell:1", etc.
Expand Down Expand Up @@ -183,4 +184,5 @@ export interface AppStore {
missingProjectIds: Record<string, true>;
remoteAccess: RemoteAccess;
showArena: boolean;
focusMode: boolean;
}
4 changes: 4 additions & 0 deletions src/store/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export function toggleArena(show?: boolean): void {
setStore('showArena', show ?? !store.showArena);
}

export function toggleFocusMode(on?: boolean): void {
setStore('focusMode', on ?? !store.focusMode);
}

export function setWindowState(windowState: PersistedWindowState): void {
const current = store.windowState;
if (
Expand Down