refactor(web): consume owner remote events directly

This commit is contained in:
imccyu
2026-08-11 16:50:03 +08:00
parent 80f1a064f5
commit e0bbe42242
75 changed files with 353 additions and 350 deletions
+3 -1
View File
@@ -12,6 +12,8 @@
* history outside the direct-parent continuation path.
*/
import type { ModelSelection, SessionModels } from '@deepseek-ai/dsh-client-connection/client'
// Type-only: pulls the forwarded Host-event face and ctx.remote merge.
import type {} from '@deepseek-ai/dsh-api-remotes/client'
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'
import type { CommandServiceContract, SelectOption } from '@deepseek-ai/dsh-client-ui-command/client'
// Type-only: pulls the ui-conversation SlotMap merge (the input.model seat).
@@ -96,7 +98,7 @@ function selectionOf(state: ModelDirectoryState, id: string): ModelSelection | u
const NS = 'model'
/** Required services: the contribution registry, the seat's slot registry, locale, and the service's own faces. */
export const inject = ['command', 'connection', 'locale', 'sessions', 'slots']
export const inject = ['command', 'connection', 'locale', 'sessions', 'slots', 'remote']
/**
* Client plugin body: mount ModelService, register the `model` dictionaries,
@@ -32,7 +32,7 @@ interface LiveState {
/** The `ctx.models` session model-selection service. */
export class ModelService extends Service {
static inject = ['connection', 'sessions']
static inject = ['connection', 'sessions', 'remote']
private readonly live: LiveState = { directories: new Map() }
@@ -49,14 +49,15 @@ export class ModelService extends Service {
ctx.on('connection/reset', () => {
for (const directory of this.live.directories.values()) directory.resetConnected()
})
// Provider topology changed on the host (a settings-born route appeared
// or dropped): refresh every open directory in the background so pickers
// show the new catalog without a reopen. Failures stay on each store.
ctx.on('models/changed', () => {
// Either source can change the directory: registry topology commits and
// settings documents that carry provider catalogs or default selection.
const refresh = (): void => {
for (const directory of this.live.directories.values()) {
directory.load().catch(() => undefined)
}
})
}
ctx.remote.$on('llm/adapters-updated', refresh)
ctx.remote.$on('settings/document-updated', refresh)
}
/**