refactor(ui): name workspace surfaces

This commit is contained in:
Bohdan Triapitsyn
2026-08-22 01:10:19 +03:00
parent be234548fa
commit 70a7a77ded
10 changed files with 99 additions and 70 deletions
+3 -3
View File
@@ -6,15 +6,15 @@
*
* URL Schema:
* - `?session=<id>` - Navigate to specific session
* - `?tab=<chat|git|diff|terminal|files>` - Active main tab
* - `?tab=<chat|git|diff|terminal|files>` - Legacy URL name for the active workspace surface
* - `?settings=<section>` - Open settings to specific section
* - `?file=<path>` - Diff view with file selected
*
* Examples:
* - `/?session=abc123` - Open session abc123
* - `/?tab=git` - Open git tab
* - `/?tab=git` - Open the Git surface
* - `/?settings=providers` - Open settings to providers section
* - `/?tab=diff&file=src/main.ts` - Open diff view with file
* - `/?tab=diff&file=src/main.ts` - Open the Diff surface with a file
*/
export type { RouteState } from './types';
+3 -3
View File
@@ -1,4 +1,4 @@
import type { MainTab } from '@/stores/useUIStore';
import type { WorkspaceSurface } from '@/stores/useUIStore';
import {
type RouteState,
VALID_TABS,
@@ -52,13 +52,13 @@ function parseSessionId(params: URLSearchParams): string | null {
* Parse main tab from URL parameters.
* Returns null if missing or invalid.
*/
function parseTab(params: URLSearchParams): MainTab | null {
function parseTab(params: URLSearchParams): WorkspaceSurface | null {
const value = params.get(ROUTE_PARAMS.TAB);
if (!value) {
return null;
}
const normalized = value.toLowerCase().trim() as MainTab;
const normalized = value.toLowerCase().trim() as WorkspaceSurface;
if (VALID_TABS.includes(normalized)) {
return normalized;
}
+3 -3
View File
@@ -1,4 +1,4 @@
import type { MainTab } from '@/stores/useUIStore';
import type { WorkspaceSurface } from '@/stores/useUIStore';
import { isEmbeddedSessionChat } from '@/components/layout/contextPanelEmbeddedChat';
import { ROUTE_PARAMS } from './types';
@@ -7,7 +7,7 @@ import { ROUTE_PARAMS } from './types';
*/
export interface AppRouteState {
sessionId: string | null;
tab: MainTab;
tab: WorkspaceSurface;
isSettingsOpen: boolean;
settingsPath: string;
diffFile: string | null;
@@ -16,7 +16,7 @@ export interface AppRouteState {
/**
* Default tab when none is specified.
*/
const DEFAULT_TAB: MainTab = 'chat';
const DEFAULT_TAB: WorkspaceSurface = 'chat';
/**
* Serialize application state to URL search parameters.
+5 -5
View File
@@ -1,5 +1,5 @@
import type { SidebarSection } from '@/constants/sidebar';
import type { MainTab } from '@/stores/useUIStore';
import type { WorkspaceSurface } from '@/stores/useUIStore';
/**
* Represents the current route state derived from URL parameters.
@@ -8,8 +8,8 @@ import type { MainTab } from '@/stores/useUIStore';
export interface RouteState {
/** Session ID to navigate to */
sessionId: string | null;
/** Main tab to display (chat, git, diff, terminal, files) */
tab: MainTab | null;
/** View selected through the legacy `tab` URL parameter. */
tab: WorkspaceSurface | null;
/** Settings section - when non-null, settings dialog should be open */
settingsPath: string | null;
/** File path for diff view */
@@ -17,9 +17,9 @@ export interface RouteState {
}
/**
* Valid main tab values for URL routing.
* Valid values for the legacy `tab` URL parameter.
*/
export const VALID_TABS: readonly MainTab[] = ['chat', 'git', 'diff', 'terminal', 'files', 'diagram'] as const;
export const VALID_TABS: readonly WorkspaceSurface[] = ['chat', 'git', 'diff', 'terminal', 'files', 'diagram'] as const;
/**
* Valid settings section values for URL routing.