merge #357: read betterSidebar via ctx.get() in all consumers (LuckVd)

This commit is contained in:
HuanLinOTO
2026-08-24 01:35:00 +08:00
10 changed files with 44 additions and 34 deletions
+1
View File
@@ -65,6 +65,7 @@ function mountSidebar(): MountedSidebar {
locale: { subscribe: () => () => {}, getSnapshot: () => localeSnapshot },
sessions: { list: { subscribe: () => () => {}, getSnapshot: () => sessionsSnapshot } },
betterSidebar: service,
get: (name: string) => name === 'betterSidebar' ? service : undefined,
}
const root: Root = createRoot(container)
act(() => { root.render(createElement(Sidebar, { ctx: ctx as never, store })) })
+1
View File
@@ -40,6 +40,7 @@ function setup(): {
const sessionsSnapshot = { byId: { 'editor-home-session': { cwd: '/tmp' } }, current: 'editor-home-session' }
const ctx = {
betterSidebar: service,
get: (name: string) => name === 'betterSidebar' ? service : undefined,
sessions: { list: { subscribe: () => () => {}, getSnapshot: () => sessionsSnapshot } },
} as unknown as Context
return { store, ctx, homeTab }
+3
View File
@@ -108,6 +108,9 @@ describe('open-path interception wiring', () => {
},
workspaces: funnel,
betterSidebar: { openTab: (seed: unknown) => { opened.push(seed as Record<string, unknown>) } },
get: (name: string) => name === 'betterSidebar'
? { openTab: (seed: unknown) => { opened.push(seed as Record<string, unknown>) } }
: undefined,
} as unknown as Context
const store = createSidebarStore()
const original = ctx.workspaces.openPath
+1
View File
@@ -68,6 +68,7 @@ function mountSidebar(): MountedSidebar {
locale: { subscribe: () => () => {}, getSnapshot: () => localeSnapshot },
sessions: { list: { subscribe: () => () => {}, getSnapshot: () => sessionsSnapshot } },
betterSidebar: service,
get: (name: string) => name === 'betterSidebar' ? service : undefined,
}
const root: Root = createRoot(container)
act(() => { root.render(createElement(Sidebar, { ctx: ctx as never, store })) })
+11 -7
View File
@@ -75,13 +75,17 @@ const producedOwner = (paths: string[]): unknown => ({
const emptyOwner = (): unknown => ({ nodes: [{ kind: 'assistant', seq: 1, turn: 1 }], seq: 1 })
/** The minimal client-context fake the registration (and its seats) touch. */
const clientCtx = (slots: unknown): Context => ({
slots,
sessions: {
list: { getSnapshot: () => ({ current: 's1', byId: { s1: { id: 's1', cwd: '/w', displayTitle: 's1' } } }) },
},
betterSidebar: { openTab: vi.fn() },
} as unknown as Context)
const clientCtx = (slots: unknown): Context => {
const betterSidebar = { openTab: vi.fn() }
return {
slots,
sessions: {
list: { getSnapshot: () => ({ current: 's1', byId: { s1: { id: 's1', cwd: '/w', displayTitle: 's1' } } }) },
},
betterSidebar,
get: (name: string) => name === 'betterSidebar' ? betterSidebar : undefined,
} as unknown as Context
}
describe('turn-tail interception registration (issue #15)', () => {
it('registers through slots.inject and lands once the slot is already declared', () => {