fix(desktop): hide fixed titlebar clusters on contributed full pages

Plugin ROUTES_AREA pages own their titlebar chrome; the app clusters were sitting on top of it because only overlays hid them.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
KoNit-K
2026-09-10 17:24:01 +08:00
parent 8068c09432
commit 3f044f9887
4 changed files with 106 additions and 5 deletions
@@ -0,0 +1,21 @@
import { describe, expect, it } from 'vitest'
import { hidesFixedTitlebarClusters, isOverlayView } from './routes'
describe('hidesFixedTitlebarClusters', () => {
it('hides clusters on contributed full pages and overlays', () => {
expect(hidesFixedTitlebarClusters('extension')).toBe(true)
expect(hidesFixedTitlebarClusters('settings')).toBe(true)
})
it('keeps clusters on chat and first-party workspace pages', () => {
expect(hidesFixedTitlebarClusters('chat')).toBe(false)
expect(hidesFixedTitlebarClusters('skills')).toBe(false)
expect(hidesFixedTitlebarClusters('messaging')).toBe(false)
expect(hidesFixedTitlebarClusters('artifacts')).toBe(false)
})
it('does not treat extension as an overlay', () => {
expect(isOverlayView('extension')).toBe(false)
})
})
+9
View File
@@ -141,6 +141,15 @@ export function isOverlayView(view: AppView): boolean {
return OVERLAY_VIEWS.has(view)
}
/** True when TitlebarControls must unmount the app's fixed tool clusters.
* Overlays already own the window; contributed full pages (`extension`)
* bring their own titlebar chrome (`titleBar.center` etc.) and the clusters
* would otherwise sit on top of it. First-party workspace pages
* (skills/messaging/artifacts) keep the clusters. */
export function hidesFixedTitlebarClusters(view: AppView): boolean {
return isOverlayView(view) || view === 'extension'
}
/** The pathname of a router target. Every classifier below reasons about a
* PATH, but callers navigate to full targets (`/skills?tab=mcp`), and an
* unstripped query reaches the session-id parser — `/skills?tab=mcp` reads as
@@ -0,0 +1,70 @@
// @vitest-environment jsdom
import { cleanup, render, screen } from '@testing-library/react'
import { MemoryRouter } from 'react-router'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { registry } from '@/contrib/registry'
import { I18nProvider } from '@/i18n'
import { ROUTES_AREA } from '../routes'
import { TitlebarControls } from './titlebar-controls'
function renderControls(pathname: string) {
return render(
<MemoryRouter initialEntries={[pathname]}>
<I18nProvider configClient={null} initialLocale="en">
<TitlebarControls onOpenSettings={() => {}} />
</I18nProvider>
</MemoryRouter>
)
}
const windowControls = () => screen.queryByLabelText('Window controls')
const appControls = () => screen.queryByLabelText('App controls')
describe('TitlebarControls fixed clusters', () => {
let disposeRoute: () => void
beforeEach(() => {
disposeRoute = registry.register({
area: ROUTES_AREA,
data: { path: '/kanban' },
id: 'test-kanban-route',
render: () => null
})
})
afterEach(() => {
disposeRoute()
cleanup()
})
it('hides the app clusters on a contributed full-page route', () => {
renderControls('/kanban')
expect(windowControls()).toBeNull()
expect(appControls()).toBeNull()
})
it('keeps the app clusters on chat', () => {
renderControls('/')
expect(windowControls()).not.toBeNull()
expect(appControls()).not.toBeNull()
})
it('hides the app clusters on an overlay', () => {
renderControls('/settings')
expect(windowControls()).toBeNull()
expect(appControls()).toBeNull()
})
it('keeps the app clusters on a first-party workspace page', () => {
renderControls('/skills')
expect(windowControls()).not.toBeNull()
expect(appControls()).not.toBeNull()
})
})
@@ -25,7 +25,7 @@ import {
} from '@/store/layout'
import { $unreadSessionCount } from '@/store/session-dot-state'
import { appViewForPath, isOverlayView } from '../routes'
import { appViewForPath, hidesFixedTitlebarClusters } from '../routes'
import {
TITLEBAR_ICON_BADGE_SCALE,
@@ -235,11 +235,12 @@ export function TitlebarControls({ leftTools = [], tools = [], onOpenSettings }:
}
]
// While a full-screen overlay (settings, command center, …) is open it should
// While a full-screen overlay (settings, command center, …) or a contributed
// full-context plugin page (`extension`, e.g. /kanban) is open it should
// visually own the window. These control clusters are `fixed` at a higher
// z-index than the overlay card, so they'd otherwise bleed over it — hide them
// and let the overlay's own chrome (close button, drag region) take over.
if (isOverlayView(appViewForPath(location.pathname))) {
// z-index than the overlay card / plugin titlebar chrome, so they'd otherwise
// bleed over it — hide them and let that surface's own chrome take over.
if (hidesFixedTitlebarClusters(appViewForPath(location.pathname))) {
return null
}