feat(guide): let a tab type declare its own line in the new-tab list
The native new-tab list rendered one generic line ("opens in the DSH
sidebar") under every plugin entry, so six plugin rows read identically.
`TabDescriptor.description` now carries the real purpose (string or
locale-following thunk; absent falls back to the generic line), and the
six visible builtins declare theirs across all 20 dictionaries.
- service.ts: `TabDescriptor.description` + docs (guide §4.1, §0 row).
- native/: the guide entry's description follows the descriptor; the
`files` takeover reuses the editor's line.
- builtins: files / changes / tasks / side chat / terminal / browser.
- tests: builtins assert every visible type declares a distinct line;
the lifecycle test asserts descriptor lines (and the takeover reuse).
This commit is contained in:
1 parent
9ebaa09f80
commit
d4765819c0
26 files changed
+186
-5
No files matched your search
@@ -44,6 +44,22 @@ describe('built-in tab registrations', () => {
|
||||
expect(changes?.component).toBeDefined()
|
||||
})
|
||||
|
||||
it('every visible tab declares a real guide line (no generic fallback)', () => {
|
||||
// The native new-tab list renders `description()` under the title; a tab
|
||||
// without one reads the same generic sentence as every other plugin page.
|
||||
const { service } = setup()
|
||||
const visible = service.getTabs().filter(descriptor => descriptor.hidden !== true)
|
||||
expect(visible.length).toBeGreaterThan(0)
|
||||
for (const descriptor of visible) {
|
||||
expect(descriptor.description, `${descriptor.id} must declare a description`).toBeDefined()
|
||||
const line = typeof descriptor.description === 'function' ? descriptor.description() : descriptor.description
|
||||
expect(line, `${descriptor.id} description must be non-empty`).toBeTruthy()
|
||||
}
|
||||
const lines = visible.map(descriptor =>
|
||||
typeof descriptor.description === 'function' ? descriptor.description() : descriptor.description)
|
||||
expect(new Set(lines).size, 'descriptions must differ per tab').toBe(visible.length)
|
||||
})
|
||||
|
||||
it('the changes tab declares no settings of its own (the diff always docks)', () => {
|
||||
const { service } = setup()
|
||||
expect(service.getTab('git')?.settings).toBeUndefined()
|
||||
|
||||
@@ -162,8 +162,8 @@ describe('registerNativeSurface lifecycle (service-driven registration)', () =>
|
||||
const store = createSidebarStore()
|
||||
store.setSession('s1')
|
||||
const service = createBetterSidebarService(store)
|
||||
service.registerTab({ id: 'terminal', title: 'Terminal', component: () => null })
|
||||
service.registerTab({ id: 'editor', title: 'Files', component: () => null, icon: () => null })
|
||||
service.registerTab({ id: 'terminal', title: 'Terminal', component: () => null, description: () => 'Runs a shell' })
|
||||
service.registerTab({ id: 'editor', title: 'Files', component: () => null, icon: () => null, description: () => 'Browse the tree' })
|
||||
const records = createNativeTabRecords()
|
||||
|
||||
const registered: Array<{ id: string; kind: string; title: (address: string) => string; guide: unknown }> = []
|
||||
@@ -225,8 +225,15 @@ describe('registerNativeSurface lifecycle (service-driven registration)', () =>
|
||||
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
|
||||
const filesGuide = filesType?.guide as Array<{ icon?: unknown; description?: () => string }> | undefined
|
||||
expect(filesGuide?.[0]?.icon).toBeDefined()
|
||||
// The guide line is the descriptor's OWN description (the takeover reuses
|
||||
// the editor's), and a descriptor that declares none falls back to the
|
||||
// generic line — otherwise every plugin page would read identically.
|
||||
expect(filesGuide?.[0]?.description?.()).toBe('Browse the tree')
|
||||
const terminalGuide = registered.find(entry => entry.kind === 'terminal')?.guide as
|
||||
Array<{ description?: () => string }> | undefined
|
||||
expect(terminalGuide?.[0]?.description?.()).toBe('Runs a shell')
|
||||
|
||||
dispose()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user