diff options
| author | Adam Malczewski <[email protected]> | 2026-06-11 13:08:38 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-11 13:08:38 +0900 |
| commit | ffbbcf692a97ec8648af39353b49f32896367207 (patch) | |
| tree | 2e2ddfd03d4a868f4a4ba12e20586cc03c37f90a /packages/surface-registry/src | |
| parent | 27fd0be36b2f6395249de5aacc86e41fe4e0207f (diff) | |
| download | dispatch-ffbbcf692a97ec8648af39353b49f32896367207.tar.gz dispatch-ffbbcf692a97ec8648af39353b49f32896367207.zip | |
feat(surfaces): NumberField + per-conversation surface scoping; cache-warming controls
Extend the surface framework so cache-warming exposes per-conversation controls:
- ui-contract: add NumberField (settable free-value numeric) to SurfaceField;
add optional conversationId to subscribe/unsubscribe/invoke + surface/update
- surface-registry: SurfaceContext { conversationId? } on getSpec/invoke (backward-compatible)
- transport-ws: thread conversationId; key subscriptions by (surfaceId, conversationId);
tag surface/update replies with conversationId
- cache-warming: per-conversation surface — Toggle(enabled) + Number(interval seconds,
cache-warming/set-interval) + Stat(last cache %); drop the currentConversationId closure
Global surfaces (surface-loaded-extensions) unchanged. 784 vitest + 109 bun = 893 tests;
tsc -b EXIT 0; biome clean.
Diffstat (limited to 'packages/surface-registry/src')
| -rw-r--r-- | packages/surface-registry/src/index.ts | 2 | ||||
| -rw-r--r-- | packages/surface-registry/src/registry.ts | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/packages/surface-registry/src/index.ts b/packages/surface-registry/src/index.ts index cdfcf7e..da52c92 100644 --- a/packages/surface-registry/src/index.ts +++ b/packages/surface-registry/src/index.ts @@ -1,4 +1,4 @@ export { createSurfaceRegistryExtension, manifest } from "./extension.js"; -export type { SurfaceProvider, SurfaceRegistry } from "./registry.js"; +export type { SurfaceContext, SurfaceProvider, SurfaceRegistry } from "./registry.js"; export { createSurfaceRegistry } from "./registry.js"; export { surfaceRegistryHandle } from "./service.js"; diff --git a/packages/surface-registry/src/registry.ts b/packages/surface-registry/src/registry.ts index b1c8116..5780910 100644 --- a/packages/surface-registry/src/registry.ts +++ b/packages/surface-registry/src/registry.ts @@ -1,6 +1,15 @@ import type { SurfaceCatalog, SurfaceCatalogEntry, SurfaceSpec } from "@dispatch/ui-contract"; /** + * Optional context threaded by the transport when calling a surface provider. + * Providers may use this to scope per-conversation state; omitting it yields + * the default/global behaviour. + */ +export interface SurfaceContext { + readonly conversationId?: string; +} + +/** * What a surface-contributing extension registers with the surface registry. * Each provider owns one surface identified by its catalog entry id. */ @@ -9,10 +18,10 @@ export interface SurfaceProvider { readonly catalogEntry: SurfaceCatalogEntry; /** Build the current surface spec (may be async for dynamic surfaces). */ - getSpec(): SurfaceSpec | Promise<SurfaceSpec>; + getSpec(context?: SurfaceContext): SurfaceSpec | Promise<SurfaceSpec>; /** Run a backend action by id with an optional payload. */ - invoke(actionId: string, payload?: unknown): void | Promise<void>; + invoke(actionId: string, payload?: unknown, context?: SurfaceContext): void | Promise<void>; /** * Optional: subscribe to spec changes. Returns an unsubscribe disposer. |
