feat(client): inject slot declaration lifetimes

This commit is contained in:
imccyu
2026-08-05 23:38:29 +08:00
parent bb53e25ed0
commit 86965b053c
100 changed files with 1065 additions and 837 deletions

View File

@@ -7,7 +7,6 @@
* both sides of the native interaction with one cordis.yml row; no client
* code branches on a capability kind.
*/
import { deferGroupRegistration } from '@deepseek-ai/dsh-client-ui-slots'
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'
// Type-only: pulls the SlotMap merge declaring the directory-flow holes.
import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
@@ -20,22 +19,22 @@ export const inject = ['slots', 'workspaces']
/**
* Client plugin body: register the renderless native flow into both
* directory-flow holes (declaration-aware deferral — the declaring
* ui-workspace entries may activate later, and an HMR collapse re-declares).
* directory-flow holes through `slots.inject()` because the ui-workspace
* entries may activate later or replace their declarations.
* @param ctx - client root context.
*/
export function apply(ctx: ClientContext): void {
const injected = (): NativeFlowInjected => ({ pick: () => ctx.workspaces.pickDirectory() })
ctx.effect(() => {
// One occupant, both holes, as a unit: construction or late conflicts
// (holes declared after rival providers activated) roll the whole pair
// back and fail loud — semantics owned by deferGroupRegistration.
const group = deferGroupRegistration(
ctx.slots,
['conversation.hero.workspace.directoryFlow', 'sidebar.workspaces.directoryFlow'] as const,
NativeDirectoryFlow,
name => ctx.slots.register({ name, inject: injected }, NativeDirectoryFlow),
)
return () => { group.dispose() }
}, 'directory-picker-native: flow registrations')
// Both declaration lifetimes must be live before the pair installs; the
// generator makes the two registrations one transactional effect. The
// outer/inner nesting order is arbitrary; neither hole has precedence.
ctx.slots.inject('conversation.hero.workspace.directoryFlow', () =>
ctx.slots.inject('sidebar.workspaces.directoryFlow', function* () {
yield ctx.slots.register({
name: 'conversation.hero.workspace.directoryFlow', inject: injected,
}, NativeDirectoryFlow)
yield ctx.slots.register({
name: 'sidebar.workspaces.directoryFlow', inject: injected,
}, NativeDirectoryFlow)
}))
}