refactor(surface): drop the deprecated main-tab aliases and dead diagram surface
MainTab/activeMainTab/setActiveMainTab/setMainTabGuard were deprecated mirrors of the surface names — every call site now uses activeSurface/setActiveSurface/setSurfaceGuard directly and the aliases are gone, including the persisted mirror field. The 'diagram' surface had no way to open it (navigateToDiagram had no callers except a .drawio attachment click that navigated to a surface nothing rendered); the surface, DiagramView, and its store plumbing are removed, and a .drawio attachment now opens in the file panel. ?tab= deep links map to the matching context-panel surface instead of setting a main-area surface nothing renders, and a persisted non-chat surface can no longer rehydrate into a blank main area.
This commit is contained in:
@@ -59,7 +59,7 @@ export const useKeyboardShortcuts = () => {
|
||||
}, [currentShortcutDirectory]);
|
||||
const isMobile = useUIStore((s) => s.isMobile);
|
||||
const setSessionSwitcherOpen = useUIStore((s) => s.setSessionSwitcherOpen);
|
||||
const setActiveMainTab = useUIStore((s) => s.setActiveMainTab);
|
||||
const setActiveSurface = useUIStore((s) => s.setActiveSurface);
|
||||
const setSettingsDialogOpen = useUIStore((s) => s.setSettingsDialogOpen);
|
||||
const setModelSelectorOpen = useUIStore((s) => s.setModelSelectorOpen);
|
||||
const setTimelineDialogOpen = useUIStore((s) => s.setTimelineDialogOpen);
|
||||
@@ -154,7 +154,7 @@ export const useKeyboardShortcuts = () => {
|
||||
isAboutDialogOpen,
|
||||
isMultiRunLauncherOpen,
|
||||
isImagePreviewOpen,
|
||||
activeMainTab,
|
||||
activeSurface,
|
||||
isPromptNavigatorPanelOpen,
|
||||
} = useUIStore.getState();
|
||||
|
||||
@@ -183,7 +183,7 @@ export const useKeyboardShortcuts = () => {
|
||||
}
|
||||
|
||||
const hasOverlay = isCommandPaletteOpen || isHelpDialogOpen || isSessionSwitcherOpen || isAboutDialogOpen || isMultiRunLauncherOpen || isImagePreviewOpen;
|
||||
const isChatActive = activeMainTab === 'chat';
|
||||
const isChatActive = activeSurface === 'chat';
|
||||
|
||||
if (hasOverlay || !isChatActive) {
|
||||
resetAbortPriming();
|
||||
@@ -245,7 +245,7 @@ export const useKeyboardShortcuts = () => {
|
||||
|
||||
if (eventMatchesShortcut(e, combo('toggle_prompt_navigator'))) {
|
||||
const {
|
||||
activeMainTab,
|
||||
activeSurface,
|
||||
promptNavigatorEnabled,
|
||||
isSettingsDialogOpen,
|
||||
isCommandPaletteOpen,
|
||||
@@ -257,7 +257,7 @@ export const useKeyboardShortcuts = () => {
|
||||
isImagePreviewOpen,
|
||||
} = useUIStore.getState();
|
||||
|
||||
if (!promptNavigatorEnabled || isMobile || isVSCodeRuntime() || activeMainTab !== 'chat') {
|
||||
if (!promptNavigatorEnabled || isMobile || isVSCodeRuntime() || activeSurface !== 'chat') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ export const useKeyboardShortcuts = () => {
|
||||
if (matchedNewSessionShortcut || matchedWorktreeShortcut) {
|
||||
e.preventDefault();
|
||||
|
||||
setActiveMainTab('chat');
|
||||
setActiveSurface('chat');
|
||||
setSessionSwitcherOpen(false);
|
||||
|
||||
if (!isVSCodeRuntime() && matchedWorktreeShortcut) {
|
||||
@@ -394,11 +394,11 @@ export const useKeyboardShortcuts = () => {
|
||||
isHelpDialogOpen,
|
||||
isSessionSwitcherOpen,
|
||||
isAboutDialogOpen,
|
||||
activeMainTab,
|
||||
activeSurface,
|
||||
} = useUIStore.getState();
|
||||
|
||||
const hasOverlay = isSettingsDialogOpen || isCommandPaletteOpen || isHelpDialogOpen || isSessionSwitcherOpen || isAboutDialogOpen;
|
||||
if (hasOverlay || activeMainTab !== 'chat' || !isChatInputTarget(e.target)) {
|
||||
if (hasOverlay || activeSurface !== 'chat' || !isChatInputTarget(e.target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ export const useKeyboardShortcuts = () => {
|
||||
isHelpDialogOpen,
|
||||
isSessionSwitcherOpen,
|
||||
isAboutDialogOpen,
|
||||
activeMainTab,
|
||||
activeSurface,
|
||||
isModelSelectorOpen,
|
||||
} = useUIStore.getState();
|
||||
|
||||
@@ -536,7 +536,7 @@ export const useKeyboardShortcuts = () => {
|
||||
|
||||
// Skip if any overlay open or not on chat tab
|
||||
const hasOverlay = isCommandPaletteOpen || isHelpDialogOpen || isSessionSwitcherOpen || isAboutDialogOpen;
|
||||
const isChatActive = activeMainTab === 'chat';
|
||||
const isChatActive = activeSurface === 'chat';
|
||||
|
||||
if (hasOverlay || !isChatActive) {
|
||||
return;
|
||||
@@ -555,7 +555,7 @@ export const useKeyboardShortcuts = () => {
|
||||
isHelpDialogOpen,
|
||||
isSessionSwitcherOpen,
|
||||
isAboutDialogOpen,
|
||||
activeMainTab,
|
||||
activeSurface,
|
||||
} = useUIStore.getState();
|
||||
|
||||
if (isSettingsDialogOpen) {
|
||||
@@ -563,7 +563,7 @@ export const useKeyboardShortcuts = () => {
|
||||
}
|
||||
|
||||
const hasOverlay = isCommandPaletteOpen || isHelpDialogOpen || isSessionSwitcherOpen || isAboutDialogOpen;
|
||||
const isChatActive = activeMainTab === 'chat';
|
||||
const isChatActive = activeSurface === 'chat';
|
||||
|
||||
if (hasOverlay || !isChatActive) {
|
||||
return;
|
||||
@@ -602,7 +602,7 @@ export const useKeyboardShortcuts = () => {
|
||||
isHelpDialogOpen,
|
||||
isSessionSwitcherOpen,
|
||||
isAboutDialogOpen,
|
||||
activeMainTab,
|
||||
activeSurface,
|
||||
favoriteModels,
|
||||
addRecentModel,
|
||||
} = useUIStore.getState();
|
||||
@@ -612,7 +612,7 @@ export const useKeyboardShortcuts = () => {
|
||||
}
|
||||
|
||||
const hasOverlay = isCommandPaletteOpen || isHelpDialogOpen || isSessionSwitcherOpen || isAboutDialogOpen;
|
||||
const isChatActive = activeMainTab === 'chat';
|
||||
const isChatActive = activeSurface === 'chat';
|
||||
|
||||
if (hasOverlay || !isChatActive || favoriteModels.length === 0) {
|
||||
return;
|
||||
@@ -644,8 +644,8 @@ export const useKeyboardShortcuts = () => {
|
||||
}
|
||||
|
||||
if (eventMatchesShortcut(e, combo('toggle_dictation'))) {
|
||||
const { activeMainTab, isCommandPaletteOpen, isHelpDialogOpen, isSessionSwitcherOpen, isSettingsDialogOpen } = useUIStore.getState();
|
||||
if (activeMainTab !== 'chat' || isCommandPaletteOpen || isHelpDialogOpen || isSessionSwitcherOpen || isSettingsDialogOpen) {
|
||||
const { activeSurface, isCommandPaletteOpen, isHelpDialogOpen, isSessionSwitcherOpen, isSettingsDialogOpen } = useUIStore.getState();
|
||||
if (activeSurface !== 'chat' || isCommandPaletteOpen || isHelpDialogOpen || isSessionSwitcherOpen || isSettingsDialogOpen) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
@@ -695,7 +695,7 @@ export const useKeyboardShortcuts = () => {
|
||||
toggleTerminalSurfaceExpanded,
|
||||
isMobile,
|
||||
setSessionSwitcherOpen,
|
||||
setActiveMainTab,
|
||||
setActiveSurface,
|
||||
setSettingsDialogOpen,
|
||||
setModelSelectorOpen,
|
||||
setTimelineDialogOpen,
|
||||
|
||||
@@ -102,7 +102,7 @@ export const useMenuActions = (
|
||||
const toggleHelpDialog = useUIStore((s) => s.toggleHelpDialog);
|
||||
const toggleSidebar = useUIStore((s) => s.toggleSidebar);
|
||||
const setSessionSwitcherOpen = useUIStore((s) => s.setSessionSwitcherOpen);
|
||||
const setActiveMainTab = useUIStore((s) => s.setActiveMainTab);
|
||||
const setActiveSurface = useUIStore((s) => s.setActiveSurface);
|
||||
const setSettingsDialogOpen = useUIStore((s) => s.setSettingsDialogOpen);
|
||||
const setAboutDialogOpen = useUIStore((s) => s.setAboutDialogOpen);
|
||||
const checkForUpdates = useUpdateStore((state) => state.checkForUpdates);
|
||||
@@ -151,10 +151,10 @@ export const useMenuActions = (
|
||||
const nextSession = sessions[nextIndex];
|
||||
if (!nextSession) return;
|
||||
|
||||
setActiveMainTab('chat');
|
||||
setActiveSurface('chat');
|
||||
setSessionSwitcherOpen(false);
|
||||
useSessionUIStore.getState().setCurrentSession(nextSession.id);
|
||||
}, [setActiveMainTab, setSessionSwitcherOpen]);
|
||||
}, [setActiveSurface, setSessionSwitcherOpen]);
|
||||
|
||||
const navigateProject = React.useCallback((direction: -1 | 1) => {
|
||||
const { activeProjectId, projects, setActiveProject } = useProjectsStore.getState();
|
||||
@@ -191,7 +191,7 @@ export const useMenuActions = (
|
||||
break;
|
||||
|
||||
case 'new-session':
|
||||
setActiveMainTab('chat');
|
||||
setActiveSurface('chat');
|
||||
setSessionSwitcherOpen(false);
|
||||
{
|
||||
const sessionState = useSessionUIStore.getState();
|
||||
@@ -203,7 +203,7 @@ export const useMenuActions = (
|
||||
break;
|
||||
|
||||
case 'new-worktree-session':
|
||||
setActiveMainTab('chat');
|
||||
setActiveSurface('chat');
|
||||
setSessionSwitcherOpen(false);
|
||||
createWorktreeSession();
|
||||
break;
|
||||
@@ -341,7 +341,7 @@ export const useMenuActions = (
|
||||
onToggleMemoryDebug,
|
||||
openNewSessionDraft,
|
||||
setAboutDialogOpen,
|
||||
setActiveMainTab,
|
||||
setActiveSurface,
|
||||
setSessionSwitcherOpen,
|
||||
setCommandPaletteOpen,
|
||||
setSettingsDialogOpen,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import React from 'react';
|
||||
import { useSessionUIStore } from '@/sync/session-ui-store';
|
||||
import { useUIStore } from '@/stores/useUIStore';
|
||||
import { useUIStore, type ContextPanelMode } from '@/stores/useUIStore';
|
||||
import { parseRoute, updateBrowserURL, hasRouteParams } from '@/lib/router';
|
||||
import type { RouteState, AppRouteState } from '@/lib/router';
|
||||
import type { WorkspaceSurface } from '@/stores/useUIStore';
|
||||
import { resolveSettingsSlug } from '@/lib/settings/metadata';
|
||||
import { isEmbeddedSessionChat } from '@/components/layout/contextPanelEmbeddedChat';
|
||||
import { useDirectoryStore } from '@/stores/useDirectoryStore';
|
||||
|
||||
/**
|
||||
* Check if running in VS Code webview context.
|
||||
@@ -88,9 +89,16 @@ export function useRouter(): void {
|
||||
setSettingsDialogOpen(false);
|
||||
}
|
||||
|
||||
// 3. Apply the view selected by the legacy URL parameter.
|
||||
if (route.tab) {
|
||||
setActiveSurface(route.tab);
|
||||
// 3. Apply the view selected by the legacy URL parameter. Desktop
|
||||
// surfaces live in the context panel, so a non-chat tab deep link
|
||||
// opens the matching panel surface; activeSurface itself stays 'chat'
|
||||
// (nothing renders non-chat surfaces in the main area).
|
||||
if (route.tab && route.tab !== 'chat') {
|
||||
const directory = useDirectoryStore.getState().currentDirectory;
|
||||
if (directory) {
|
||||
const mode: ContextPanelMode = route.tab === 'files' ? 'file' : route.tab;
|
||||
useUIStore.getState().openContextSurface(directory, mode);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Apply diff file (only if going to diff tab)
|
||||
|
||||
Reference in New Issue
Block a user