fix(native): give the "Files" guide row its glyph

The guide renders `entry.icon`, and the `files` kind takeover registered
without one — so after the editor type stopped contributing its own
duplicate row (b56ceec), the single "Files" row was the only entry in the
new-tab list with a blank icon slot. The takeover now carries the editor
descriptor's icon (the takeover IS that descriptor's page).

Extracted `guideIconOf` so both registration sites build the icon field
the same way; the lifecycle test asserts the takeover's guide entry has
an icon.
This commit is contained in:
Menghuan1918
2026-09-09 15:18:04 +08:00
parent b56ceec41d
commit 91de0e2932
2 changed files with 26 additions and 7 deletions
+6 -2
View File
@@ -88,7 +88,7 @@ describe('service routing into the native surface', () => {
service.setSurface(surface)
service.registerTab({ id: 'terminal', title: 'Terminal', component: () => null, createTab: state => ({ tab: { id: `terminal:${state.nextTerminal}`, type: 'terminal', title: 'Terminal', meta: { n: state.nextTerminal } } }) })
service.registerTab({ id: 'git', title: 'Changes', component: () => null })
service.registerTab({ id: 'editor', title: 'Files', component: () => null })
service.registerTab({ id: 'editor', title: 'Files', component: () => null, icon: () => null })
return { surface, calls, service }
}
@@ -163,7 +163,7 @@ describe('registerNativeSurface lifecycle (service-driven registration)', () =>
store.setSession('s1')
const service = createBetterSidebarService(store)
service.registerTab({ id: 'terminal', title: 'Terminal', component: () => null })
service.registerTab({ id: 'editor', title: 'Files', component: () => null })
service.registerTab({ id: 'editor', title: 'Files', component: () => null, icon: () => null })
const records = createNativeTabRecords()
const registered: Array<{ id: string; kind: string; title: (address: string) => string; guide: unknown }> = []
@@ -223,6 +223,10 @@ describe('registerNativeSurface lifecycle (service-driven registration)', () =>
expect(editorType?.guide).toBeUndefined()
const filesType = registered.find(entry => entry.kind === 'files')
expect(filesType?.guide).toBeDefined()
// The takeover carries the editor's glyph, so the "Files" guide row is
// not the only one with a blank icon slot.
const filesGuide = filesType?.guide as Array<{ icon?: unknown }> | undefined
expect(filesGuide?.[0]?.icon).toBeDefined()
dispose()
})