Skip to content
Merged
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
25 changes: 20 additions & 5 deletions src/web-ui/src/app/layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ import { AcpSessionNotifications } from './AcpSessionNotifications';
import { api } from '@/infrastructure/api/service-api/ApiClient';
import { AppearanceBackgroundMediaLayer, appearanceRuntime, useAppearance } from '@/infrastructure/appearance';
import { PeerConnectionStatus } from '@/infrastructure/peer-device/PeerConnectionStatus';
import { useSceneStore } from '../stores/sceneStore';
import { standaloneSettingsPane } from '../workbench/scenePaneModel';
import { selectWorkbenchPaneHasSession, workbenchPaneLayoutStore } from '../workbench/workbenchPaneLayoutStore';

type TransitionDirection = 'entering' | 'returning' | null;

function isStandaloneSettingsActive(): boolean {
const { paneSelections } = useSceneStore.getState();
return standaloneSettingsPane(paneSelections, selectWorkbenchPaneHasSession(workbenchPaneLayoutStore.getState())) !== null;
}

const log = createLogger('AppLayout');
const ToolbarMode = lazyWithRecovery(() =>
import('../../flow_chat/components/toolbar-mode/ToolbarMode').then(module => ({
Expand Down Expand Up @@ -116,6 +124,9 @@ const AppLayout: React.FC<AppLayoutProps> = ({ className = '' }) => {
const { isFullscreenChrome } = useFullscreenChrome(isFullscreen);

const { state, switchLeftPanelTab, toggleLeftPanel, toggleRightPanel } = useApp();
const toggleAvailableRightPanel = useCallback(() => {
if (!isStandaloneSettingsActive()) toggleRightPanel();
}, [toggleRightPanel]);
const [windowModeHint, setWindowModeHint] = useState<WindowModeHint | null>(null);
const windowModeHintTimerRef = useRef<number | null>(null);

Expand Down Expand Up @@ -494,14 +505,14 @@ const AppLayout: React.FC<AppLayoutProps> = ({ className = '' }) => {
const handleSwitchToFilesPanel = () => {
switchLeftPanelTab('files');
if (state.layout.leftPanelCollapsed) toggleLeftPanel();
if (state.layout.rightPanelCollapsed) {
setTimeout(() => toggleRightPanel(), 100);
if (state.layout.rightPanelCollapsed && !isStandaloneSettingsActive()) {
setTimeout(toggleAvailableRightPanel, 100);
}
};

window.addEventListener('switch-to-files-panel', handleSwitchToFilesPanel);
return () => window.removeEventListener('switch-to-files-panel', handleSwitchToFilesPanel);
}, [state.layout.leftPanelCollapsed, state.layout.rightPanelCollapsed, switchLeftPanelTab, toggleLeftPanel, toggleRightPanel]);
}, [state.layout.leftPanelCollapsed, state.layout.rightPanelCollapsed, switchLeftPanelTab, toggleLeftPanel, toggleAvailableRightPanel]);

// Toolbar send message
React.useEffect(() => {
Expand Down Expand Up @@ -534,13 +545,17 @@ const AppLayout: React.FC<AppLayoutProps> = ({ className = '' }) => {
'panel.toggleBoth',
{ key: 'B', ctrl: true, shift: true, scope: 'app' },
() => {
if (isStandaloneSettingsActive()) {
toggleLeftPanel();
return;
}
const bothCollapsed = state.layout.leftPanelCollapsed && state.layout.rightPanelCollapsed;
if (bothCollapsed) {
toggleLeftPanel();
setTimeout(() => toggleRightPanel(), 50);
setTimeout(toggleAvailableRightPanel, 50);
} else {
if (!state.layout.leftPanelCollapsed) toggleLeftPanel();
if (!state.layout.rightPanelCollapsed) toggleRightPanel();
if (!state.layout.rightPanelCollapsed) toggleAvailableRightPanel();
}
},
{ priority: 5, description: 'keyboard.shortcuts.panel.toggleBoth' }
Expand Down
12 changes: 12 additions & 0 deletions src/web-ui/src/app/scenes/SceneViewport.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ describe('SceneViewport transitions', () => {
expect(visibleScenes().map(scene => scene.getAttribute('data-scene-id'))).toEqual(['settings']);
});

it('activates standalone Settings in the secondary pane even when the session pane was collapsed', () => {
sessionPaneLayoutStore.getState().activate('local', 'session');
sceneHarness.state = {
openTabs: [{ id: 'settings', lastUsed: 1, pane: 'secondary' }],
activeTabId: 'settings', navigationMotion: 'instant', navigationSequence: 1,
paneSelections: { primary: { kind: 'canvas' }, secondary: sceneSelection('settings') },
};
act(() => root.render(<SceneViewport paned />));
expect(container.querySelector('[data-testid="settings-scene-content"]')?.getAttribute('data-scene-prop-active')).toBe('true');
expect(visibleScenes().map(scene => scene.getAttribute('data-scene-id'))).toEqual(['settings']);
});

it('keeps a visible secondary Todos clock active even while another pane is focused', async () => {
sessionPaneLayoutStore.getState().showContent();
sceneHarness.state = {
Expand Down
9 changes: 5 additions & 4 deletions src/web-ui/src/app/scenes/SceneViewport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { useSceneManager } from '../hooks/useSceneManager';
import { useI18n } from '@/infrastructure/i18n/hooks/useI18n';
import { useDialogCompletionNotify } from '../hooks/useDialogCompletionNotify';
import { Spinner, SplitViewSurface } from '@openbitfun/ui';
import { selectedScene, tabPane } from '../workbench/scenePaneModel';
import { selectedScene, standaloneSettingsPane, tabPane } from '../workbench/scenePaneModel';
import { useWorkbenchPaneLayout, workbenchSplitMode } from '../workbench/workbenchPaneLayoutStore';
import { useSceneStore } from '../stores/sceneStore';
import { useSessionPaneLayout } from './session/sessionPaneLayoutStore';
import SettingsScene from './settings/SettingsScene';
import { DEFAULT_SETTINGS_PAGE_ID, preloadSettingsPage } from './settings/settingsRegistry';
import { backgroundTaskScheduler } from '@/shared/utils/backgroundTaskScheduler';
Expand Down Expand Up @@ -161,7 +161,8 @@ const SceneViewport: React.FC<SceneViewportProps> = ({ workspacePath, isEntering
} = useSceneManager();
const { t } = useI18n('common');
const resources = useContentResourceStore(state => state.resources);
const pane = useSessionPaneLayout();
const { mode, hasSession } = useWorkbenchPaneLayout();
const splitMode = paned ? workbenchSplitMode(mode, standaloneSettingsPane(paneSelections, hasSession)) : 'split';
const primaryTabId = paned ? selectedScene(paneSelections.primary) : activeTabId;
const secondaryTabId = paned ? selectedScene(paneSelections.secondary) : null;
const activeRenderedSceneId: RenderedSceneId | null = primaryTabId ? getSceneViewId(primaryTabId)
Expand Down Expand Up @@ -204,7 +205,7 @@ const SceneViewport: React.FC<SceneViewportProps> = ({ workspacePath, isEntering
const location = paned && isSecondary ? 'secondary' : 'primary';
const selectedId = location === 'secondary' ? secondarySceneId : activeRenderedSceneId;
const transition = location === 'secondary' ? secondaryTransition : primaryTransition;
const paneVisible = !paned || (location === 'secondary' ? pane.mode !== 'chat-only' : pane.mode !== 'content-only');
const paneVisible = splitMode === 'split' || splitMode === location;
const isActive = tabId === selectedId && paneVisible;
const isOutgoing = !isActive && tabId === transition.outgoingTabId;
const isIncoming = isActive && transition.pendingTransition?.incomingTabId === tabId;
Expand Down
8 changes: 6 additions & 2 deletions src/web-ui/src/app/stores/sceneStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ import {
selectedSessionTab,
selectCanvasInPane,
selectSceneInPane,
standaloneSettingsPane,
tabPane,
vacantSelection,
workbenchPanes,
type ScenePaneState,
type WorkbenchPane,
} from '../workbench/scenePaneModel';
import { sessionPaneLayoutStore } from '../scenes/session/sessionPaneLayoutStore';
import { selectWorkbenchPaneHasSession, workbenchPaneLayoutStore } from '../workbench/workbenchPaneLayoutStore';
import { useContentResourceStore } from '../workbench/contentResourceStore';
import { requestContentClose } from '../workbench/contentResourceLifecycle';
import { requestMiniAppClose } from '../scenes/miniapps/miniAppLifecycle';
Expand Down Expand Up @@ -624,7 +625,10 @@ function navigateWorkbench(build: (state: SceneState) => WorkbenchNavigationPlan
&& useSceneStore.getState().paneSelections === previous.paneSelections;
const commit = () => {
if (!unchanged()) return false;
sessionPaneLayoutStore.getState().revealPanes(plan.reveal ?? [plan.panes.focusedPane]);
const paneLayout = workbenchPaneLayoutStore.getState();
if (standaloneSettingsPane(plan.panes.paneSelections, selectWorkbenchPaneHasSession(paneLayout)) === null) {
paneLayout.revealPanes(plan.reveal ?? [plan.panes.focusedPane]);
}
useSceneStore.setState({ ...projectPaneState(plan.panes), ...plan.history, pendingTabId: null,
navigationMotion: plan.motion ?? getInteractionMotion(), navigationSequence: previous.navigationSequence + 1 });
options.onCommitted?.();
Expand Down
4 changes: 4 additions & 0 deletions src/web-ui/src/app/workbench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ changing sessions cannot inherit a neighbour's pane or hide a moved page. The le
retains old preference keys/legacy layout projection.
The `session.auxiliary` Appearance address stays on the shell wrapper for legacy appearance customization.

When Settings replaces a conversation beside its canvas, it fills the workbench
and temporarily hides that canvas. The session keeps its tabs and remembered
pane mode. Settings can share the workbench with a scene selected in the other pane.

SceneTopBar owns both tab regions and the short separator. SplitView supplies the
header's live column geometry, including clamping, resizing and overlay placement;
header actions and native controls do not shift that boundary. The outer shell is
Expand Down
48 changes: 48 additions & 0 deletions src/web-ui/src/app/workbench/WorkbenchLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SessionPanelSettingsSection from '../scenes/settings/pages/application/Se
import { useSceneStore, resetSceneStoreForTest } from '../stores/sceneStore';
import { getSessionSceneTabId } from '../components/SceneBar/types';
import { useWindowResizeLayout } from '../layout/windowResizeScheduler';
import { activateSurface } from '@/infrastructure/peer-device/deviceSurface';

const mocks = vi.hoisted(() => ({ selectLayout: null as null | ((value: string) => void), terminalPosition: 'right' }));

Expand Down Expand Up @@ -72,6 +73,7 @@ describe('workbench pane layout integration', () => {

afterEach(() => {
act(() => root.unmount());
activateSurface('local');
useWindowResizeLayout.setState(useWindowResizeLayout.getInitialState());
container.remove();
sessionPaneLayoutStore.setState(sessionPaneLayoutStore.getInitialState());
Expand Down Expand Up @@ -254,4 +256,50 @@ describe('workbench pane layout integration', () => {
expect(container.querySelector('iframe')).toBe(canvas);
expect(host().getAttribute('data-split-surface')).toBe('secondary');
});

it.each([
['split', 'primary', 'local'],
['overlay', 'secondary', 'peer:review'],
] as const)('hides the session canvas beside Settings in %s layout with Settings in %s on %s', async (layout, settingsPane, surfaceId) => {
activateSurface(surfaceId);
const panes = sessionPaneLayoutStore.getState();
const scenes = useSceneStore.getState();
const target = { surfaceId, workspaceKey: 'project', sessionId: 'session' };
panes.activate(target.surfaceId, target.sessionId);
panes.setDisplayMode(layout);
scenes.openScene('settings');
await scenes.moveScene('settings', settingsPane);
scenes.openSessionScene(target);
await scenes.moveScene(getSessionSceneTabId(target), settingsPane);
scenes.revealCanvas();

act(() => root.render(<WorkbenchLayout><main /></WorkbenchLayout>));
const canvas = container.querySelector('iframe')!;
const host = canvas.closest('[data-split-surface]')!;
const savedModes = sessionPaneLayoutStore.getState().modes;
expect(split().getAttribute('data-mode')).toBe('split');
expect(host.getAttribute('data-split-active')).toBe('true');

act(() => scenes.openScene('settings'));
expect(split().getAttribute('data-mode')).toBe(settingsPane);
expect(host.getAttribute('data-split-active')).toBe('false');
expect(host.hasAttribute('hidden')).toBe(true);
expect(sessionPaneLayoutStore.getState().modes).toBe(savedModes);

act(() => scenes.goBack());
expect(split().getAttribute('data-mode')).toBe('split');
expect(container.querySelector('iframe')).toBe(canvas);
expect(host.getAttribute('data-split-active')).toBe('true');
});

it('keeps Settings and a deliberately split session visible together', async () => {
const scenes = useSceneStore.getState();
sessionPaneLayoutStore.getState().activate('local', 'session');
scenes.openSessionScene({ surfaceId: 'local', workspaceKey: 'project', sessionId: 'session' });
scenes.openScene('settings');
await scenes.moveScene('settings', 'secondary');

act(() => root.render(<WorkbenchLayout><main /></WorkbenchLayout>));
expect(split().getAttribute('data-mode')).toBe('split');
});
});
22 changes: 12 additions & 10 deletions src/web-ui/src/app/workbench/WorkbenchLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { useSceneStore } from '../stores/sceneStore';
import { dropSceneTab, isSceneTabDrag } from './sceneTabTransfer';
import { dropSessionTabOnWorkbench, isSessionTabDrag } from './canvasTabTransfer';
import { observeTabDragLifecycle } from './tabDragLifecycle';
import { selectedScene, type WorkbenchPane } from './scenePaneModel';
import { selectedScene, standaloneSettingsPane, type WorkbenchPane } from './scenePaneModel';
import { SceneTopBar } from '../components/SceneTopBar';
import { CanvasToolbarHost, CanvasToolbarProvider } from '../components/panels/content-canvas/CanvasToolbar';
import AuxPane from '../scenes/session/AuxPane';
import { useWorkbenchPaneLayout } from './workbenchPaneLayoutStore';
import { useWorkbenchPaneLayout, workbenchSplitMode } from './workbenchPaneLayoutStore';
import { WorkbenchResizeContext } from './workbenchResize';
import { useWindowResizeLayout } from '../layout/windowResizeScheduler';
import { PANEL_COMMON_CONFIG, RIGHT_PANEL_CONFIG } from '../layout/panelConfig';
Expand All @@ -40,9 +40,11 @@ export default function WorkbenchLayout({ workspacePath, navigationResizing = fa
}), [resizing, navigationResizing, settling, windowMeasurementSuspended]);
const [offeredTab, setOfferedTab] = useState(false);
const [dropTarget, setDropTarget] = useState<'leading' | 'trailing' | null>(null);
const panelOpen = pane.mode !== 'chat-only';
const panelMaximized = pane.mode === 'content-only';
const selections = useSceneStore(state => state.paneSelections);
const settingsPane = standaloneSettingsPane(selections, pane.hasSession);
const mode = workbenchSplitMode(pane.mode, settingsPane);
const panelOpen = mode !== 'primary';
const panelMaximized = mode === 'secondary';
const hasSecondaryScenes = useSceneStore(state => state.openTabs.some(tab => tab.pane === 'secondary'));
const canvasPane = useSceneStore(state => state.canvasPane);
const canvasActive = selections[canvasPane].kind === 'canvas';
Expand All @@ -66,9 +68,9 @@ export default function WorkbenchLayout({ workspacePath, navigationResizing = fa
frame = requestAnimationFrame(() => setSettling(false));
});
return () => cancelAnimationFrame(frame);
}, [pane.mode, pane.contentSide, pane.displayMode, pane.preferredRightPaneWidth, pane.preferredOverlayWidth, navigationResizing]);
}, [mode, pane.contentSide, pane.displayMode, pane.preferredRightPaneWidth, pane.preferredOverlayWidth, navigationResizing]);
const panelLabel = tCommon(panelOpen ? 'header.collapseRightPanel' : 'header.expandRightPanel');
const maximizeLabel = t(pane.mode === 'content-only' ? 'canvas.restorePanel' : 'canvas.maximizePanel');
const maximizeLabel = t(panelMaximized ? 'canvas.restorePanel' : 'canvas.maximizePanel');
const dropOnPane = (event: React.DragEvent, location: WorkbenchPane) => {
if (!accepts(event.dataTransfer)) return;
event.preventDefault();
Expand Down Expand Up @@ -119,10 +121,10 @@ export default function WorkbenchLayout({ workspacePath, navigationResizing = fa
event.dataTransfer.dropEffect = 'move';
}}
onPanelDrop={event => dropOnPane(event, trailingPane)}
panelToggle={<ToolbarGroup gap="sm">
panelToggle={settingsPane === null && <ToolbarGroup gap="sm">
{panelOpen && <Tooltip content={maximizeLabel}>
<IconButton size="xs" aria-label={maximizeLabel} aria-pressed={pane.mode === 'content-only'}
data-testid="workbench-maximize-panel" icon={<Icon glyph={pane.mode === 'content-only' ? Minimize2 : Maximize2} size="sm" />}
<IconButton size="xs" aria-label={maximizeLabel} aria-pressed={panelMaximized}
data-testid="workbench-maximize-panel" icon={<Icon glyph={panelMaximized ? Minimize2 : Maximize2} size="sm" />}
onClick={pane.toggleMaximized} />
</Tooltip>}
<Tooltip content={panelLabel}>
Expand All @@ -135,7 +137,7 @@ export default function WorkbenchLayout({ workspacePath, navigationResizing = fa
return <WorkbenchResizeContext.Provider value={resizeState}><CanvasToolbarProvider>
<div className="openbitfun-workbench-layout__body" data-openbitfun-scene="workbench" data-openbitfun-part="contentLayout">
<SplitView header={header}
mode={pane.mode === 'chat-only' ? 'primary' : pane.mode === 'content-only' ? 'secondary' : 'split'}
mode={mode}
layout={pane.displayMode} secondarySide={pane.contentSide}
rightSize={pane.displayMode === 'overlay' ? pane.preferredOverlayWidth : pane.preferredRightPaneWidth}
minLeftSize={PANEL_COMMON_CONFIG.MIN_CENTER_WIDTH}
Expand Down
7 changes: 7 additions & 0 deletions src/web-ui/src/app/workbench/scenePaneModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ export const otherPane = (pane: WorkbenchPane): WorkbenchPane => pane === 'prima
export const sceneSelection = (tabId: SceneTabId): PaneSelection => ({ kind: 'scene', tabId });
export const selectedScene = (selection: PaneSelection): SceneTabId | null => selection.kind === 'scene' ? selection.tabId : null;

/** Settings fills its pane when the only other selection is the session canvas. */
export function standaloneSettingsPane(selections: PaneSelections, hasSession: boolean): WorkbenchPane | null {
if (!hasSession) return null;
return workbenchPanes.find(pane => selectedScene(selections[pane]) === 'settings'
&& selections[otherPane(pane)].kind === 'canvas') ?? null;
}

export interface ScenePaneState {
openTabs: SceneTab[];
paneSelections: PaneSelections;
Expand Down
Loading
Loading