refactor(surface): remove the main-area surface concept entirely

activeSurface was permanently 'chat' after the legacy mobile layout
removal, so the whole concept is gone: the store field, surfaceGuard,
setActiveSurface/setSurfaceGuard, the per-runtime surface memory in
prepare/restoreForRuntimeSwitch, and WorkspaceSurface itself. All ~30
setActiveSurface('chat') call sites were no-ops and are deleted;
always-true 'is the chat active' checks in keyboard shortcuts, Header
and ChatContainer are unconditional now. FilesView's dirty-file guard
kept its file-switch and close protection but drops the surface-switch
branch nothing could trigger. TerminalView visibility comes only from
its callers. The router keeps parsing legacy ?tab= links (they open the
matching context-panel surface) via its own RouteTab type and no longer
serializes a tab or diff file into URLs — desktop URLs never carried
them anyway.
This commit is contained in:
Bohdan Triapitsyn
2026-08-24 16:36:41 +03:00
parent c6e39f15fe
commit c82f188fc8
31 changed files with 49 additions and 276 deletions
+1 -53
View File
@@ -7,17 +7,11 @@ import type { ShortcutCombo } from '@/lib/shortcuts';
import type { DraftStarterRef } from '@/lib/draftStarters';
import { DEFAULT_MONO_FONT, DEFAULT_UI_FONT, type MonoFontOption, type UiFontOption } from '@/lib/fontOptions';
import { getStoredMobileKeyboardMode, type MobileKeyboardMode } from '@/lib/mobileKeyboardMode';
import { getRuntimeKey } from '@/lib/runtime-switch';
import type { TerminalShell } from '@/lib/api/types';
import { useFilesViewTabsStore } from './useFilesViewTabsStore';
import { isWindowsArm64 } from '@/lib/platform';
import { isVSCodeRuntime } from '@/lib/desktop';
/**
* The primary view on mobile and the desktop's promoted full-screen view.
* Desktop context-panel content is not represented here.
*/
export type WorkspaceSurface = 'chat' | 'plan' | 'git' | 'diff' | 'terminal' | 'files' | 'context';
export type PendingDiffScope = 'working' | 'staged' | 'turn' | 'branch';
export type ContextPanelMode = 'diff' | 'walkthrough' | 'file' | 'context' | 'plan' | 'chat' | 'browser' | 'git' | 'pr' | 'notes' | 'terminal';
export type MermaidRenderingMode = 'svg' | 'ascii';
@@ -81,7 +75,6 @@ type PendingFileNavigation = {
column: number;
};
export type WorkspaceSurfaceGuard = (nextSurface: WorkspaceSurface) => boolean;
export type EventStreamStatus =
| 'idle'
| 'connecting'
@@ -133,15 +126,9 @@ const CONTEXT_PANEL_MAX_WIDTH = 1400;
const CONTEXT_PANEL_MAX_TABS = 12;
const CONTEXT_PANEL_MAX_LABEL_LENGTH = 120;
const LEFT_SIDEBAR_MIN_WIDTH = 280;
const activeSurfaceByRuntime = new Map<string, WorkspaceSurface>();
/** Separates browser tabs opened in the same millisecond. */
let browserTabSequence = 0;
const runtimeMemoryKey = (value?: string | null): string => {
const key = (value ?? getRuntimeKey()).trim();
return key || 'default';
};
// Shared with rail/panel consumers so contextPanelByDirectory lookups agree on keys.
export const normalizeContextPanelDirectoryKey = (value: string): string => normalizeDirectoryPath(value);
@@ -652,9 +639,6 @@ interface UIStore {
workStatusHiddenSections: string[];
isSessionSwitcherOpen: boolean;
isSessionDropdownOpen: boolean;
activeSurface: WorkspaceSurface;
surfaceGuard: WorkspaceSurfaceGuard | null;
sidebarOpenBeforeFullscreenTab: boolean | null;
pendingDiffFile: string | null;
pendingDiffStaged: boolean;
pendingDiffScope: PendingDiffScope | null;
@@ -844,10 +828,6 @@ interface UIStore {
setWorkStatusHiddenSections: (sectionIds: string[]) => void;
setSessionSwitcherOpen: (open: boolean) => void;
setSessionDropdownOpen: (open: boolean) => void;
setActiveSurface: (surface: WorkspaceSurface) => void;
prepareForRuntimeSwitch: (runtimeKey?: string | null) => void;
restoreForRuntimeSwitch: (runtimeKey?: string | null) => void;
setSurfaceGuard: (guard: WorkspaceSurfaceGuard | null) => void;
setPendingDiffFile: (filePath: string | null, staged?: boolean, scope?: PendingDiffScope | null) => void;
setPendingFileNavigation: (navigation: PendingFileNavigation | null) => void;
setPendingFileFocusPath: (path: string | null) => void;
@@ -1019,9 +999,6 @@ export const useUIStore = create<UIStore>()(
workStatusHiddenSections: [],
isSessionSwitcherOpen: false,
isSessionDropdownOpen: false,
activeSurface: 'chat',
surfaceGuard: null,
sidebarOpenBeforeFullscreenTab: null,
pendingDiffFile: null,
pendingDiffStaged: false,
pendingDiffScope: null,
@@ -1633,31 +1610,6 @@ export const useUIStore = create<UIStore>()(
set({ isSessionDropdownOpen: open });
},
setSurfaceGuard: (guard) => {
if (get().surfaceGuard === guard) {
return;
}
set({ surfaceGuard: guard });
},
setActiveSurface: (surface) => {
const guard = get().surfaceGuard;
if (guard && !guard(surface)) {
return;
}
activeSurfaceByRuntime.set(runtimeMemoryKey(), surface);
set({ activeSurface: surface });
},
prepareForRuntimeSwitch: (runtimeKey?: string | null) => {
activeSurfaceByRuntime.set(runtimeMemoryKey(runtimeKey), get().activeSurface);
},
restoreForRuntimeSwitch: (runtimeKey?: string | null) => {
const restored = activeSurfaceByRuntime.get(runtimeMemoryKey(runtimeKey)) ?? 'chat';
set({ activeSurface: restored });
},
setPendingDiffFile: (filePath, staged = false, scope = null) => {
set({
pendingDiffFile: filePath,
@@ -1675,11 +1627,7 @@ export const useUIStore = create<UIStore>()(
},
navigateToDiff: (filePath, staged = false, scope = null) => {
const guard = get().surfaceGuard;
if (guard && !guard('diff')) {
return;
}
set({ pendingDiffFile: filePath, pendingDiffStaged: staged, pendingDiffScope: scope, activeSurface: 'diff' });
set({ pendingDiffFile: filePath, pendingDiffStaged: staged, pendingDiffScope: scope });
},
consumePendingDiffFile: () => {