feat(windows): clue windows open docked in the right sidebar when a session is available
This commit is contained in:
1 parent
efbc21d65c
commit
bcc0efa917
10 files changed
+36
-1
No files matched your search
@@ -156,6 +156,7 @@ export function openClueCollectionWindow(
|
||||
const guard: ClueCollectGuard = { busy: false }
|
||||
const handle = options.windows.open({
|
||||
id: collectWindowId(options.workspaceId, options.targets),
|
||||
surface: 'sidebar',
|
||||
title: t('clueBrowserAddToPack'),
|
||||
size: 'compact',
|
||||
bodyLayout: 'fill',
|
||||
|
||||
@@ -69,6 +69,7 @@ export function openCreatePackWindow(options: OpenCreatePackWindowOptions): Wind
|
||||
const guard: CreatePackGuard = { busy: false }
|
||||
const handle = options.windows.open({
|
||||
id: createPackWindowId(options.workspaceId),
|
||||
surface: 'sidebar',
|
||||
title: title(),
|
||||
size: 'compact',
|
||||
bodyLayout: 'fill',
|
||||
|
||||
@@ -1625,6 +1625,7 @@ export function openClueDetailWindow(options: ClueDetailWindowOptions): WindowHa
|
||||
const handle = windows.open({
|
||||
id,
|
||||
...(options.sessionId === undefined ? {} : { sessionId: options.sessionId }),
|
||||
surface: 'sidebar',
|
||||
title: controller.initialTitle,
|
||||
size: 'document',
|
||||
bodyLayout: 'fill',
|
||||
|
||||
@@ -201,6 +201,7 @@ export function openPackManagementWindow(options: PackManagementOptions): Window
|
||||
dirty ? `${options.pack.name} · ${t('cluePackUnsaved')}` : options.pack.name
|
||||
const handle: WindowHandle = options.windows.open({
|
||||
id: packWindowId(options.pack.id),
|
||||
surface: 'sidebar',
|
||||
title: titleFor(false),
|
||||
size: 'collection',
|
||||
content: <PackManagementPage {...options} guard={guard} />,
|
||||
|
||||
@@ -38,6 +38,7 @@ export function openClueSettingsWindow(options: OpenClueSettingsWindowOptions):
|
||||
openClueSettings({ group })
|
||||
return options.windows.open({
|
||||
id: CLUE_SETTINGS_WINDOW_ID,
|
||||
surface: 'sidebar',
|
||||
title: t('clueSettingsWindowTitle'),
|
||||
size: 'collection',
|
||||
content: createElement(SideCardSection, {
|
||||
|
||||
@@ -84,6 +84,7 @@ function requestShareWindow(request: ShareWindowRequest): void {
|
||||
export function openShareWindow(options: OpenShareWindowOptions): WindowHandle {
|
||||
const handle = options.windows.open({
|
||||
id: CLUE_SHARE_WINDOW_ID,
|
||||
surface: 'sidebar',
|
||||
title: t('clueShareTitle'),
|
||||
size: 'collection',
|
||||
bodyLayout: 'fill',
|
||||
|
||||
@@ -20,6 +20,7 @@ export function openClueSourceConfigWindow(options: {
|
||||
const name = sourceDisplayName(source, options.display)
|
||||
return options.windows.open({
|
||||
id: `clue-source:${source.sourceId}`,
|
||||
surface: 'sidebar',
|
||||
title: t('clueConfigTitle', { source: name }),
|
||||
size: 'collection',
|
||||
bodyLayout: 'fill',
|
||||
|
||||
@@ -428,7 +428,7 @@ export function createWindowHost(options: WindowHostOptions = {}): WindowHostCon
|
||||
}
|
||||
record.handle = createHandle(record)
|
||||
records = [...records, record]
|
||||
notify()
|
||||
if (options.surface !== 'sidebar' || !setSurface(record, 'sidebar')) notify()
|
||||
return record.handle
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,12 @@ export interface WindowOpenOptions {
|
||||
bodyLayout?: WindowBodyLayout
|
||||
/** Where the window first appears; omitted = centred. */
|
||||
anchor?: HTMLElement | null
|
||||
/**
|
||||
* Where a NEW window first appears; defaults to 'floating'. 'sidebar' docks it
|
||||
* as a right-sidebar tab when the native sidebar and a session are available,
|
||||
* and floats it otherwise. Re-opening a live id never changes its surface.
|
||||
*/
|
||||
surface?: 'floating' | 'sidebar'
|
||||
/** Explicit initial pixel size, overriding the preset target (still clamped). */
|
||||
initialSize?: WindowSize
|
||||
/** Resize floor; defaults to 320×240. */
|
||||
|
||||
@@ -173,3 +173,25 @@ it('restores the native destination while an async close decision still needs th
|
||||
expect(open).toHaveBeenCalledTimes(2)
|
||||
expect(host.getSnapshot().windows).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('opens a surface:sidebar window docked, floats it without a sidebar or session, and never re-docks a live id', () => {
|
||||
const open = vi.fn()
|
||||
host = createWindowHost({ sessionId: () => 'original' })
|
||||
const unfloated = host.open({ id: 'early', title: 'Early', content: 'x', surface: 'sidebar' })
|
||||
expect(host.getSnapshot().windows[0]?.surface).toBe('floating')
|
||||
unfloated.close()
|
||||
|
||||
host.attachSidebar({ open, focus: () => {}, close: () => {} })
|
||||
const handle = host.open({ id: 'docked', title: 'Docked', content: 'x', surface: 'sidebar' })
|
||||
expect(open).toHaveBeenCalledWith('docked', 'original', 'Docked')
|
||||
expect(host.getSnapshot().windows.find(window => window.id === 'docked')?.surface).toBe('sidebar')
|
||||
|
||||
handle.float()
|
||||
host.open({ id: 'docked', title: 'Docked', content: 'x', surface: 'sidebar' })
|
||||
expect(host.getSnapshot().windows.find(window => window.id === 'docked')?.surface).toBe('floating')
|
||||
expect(open).toHaveBeenCalledTimes(1)
|
||||
|
||||
const defaulted = host.open({ id: 'plain', title: 'Plain', content: 'x' })
|
||||
expect(host.getSnapshot().windows.find(window => window.id === 'plain')?.surface).toBe('floating')
|
||||
defaulted.close()
|
||||
})
|
||||
Reference in new issue
Block a user