text stringlengths 0 1.47k |
|---|
interface ChatSettingsFace { |
getSnapshot(): { readonly value?: { readonly transcriptView?: unknown } | undefined } |
subscribe(listener: () => void): (() => void) | void |
} |
/** The context surface this module reads; optional lookup only. */ |
export interface FoldingHost { |
get(name: string): unknown |
} |
/** |
* Whether a saved mode folds on a 0.1.7+ host. An unset value is the host's |
* `standard` default. |
* @param view - saved `transcriptView`. |
* @returns true unless the reader chose `verbose`. |
*/ |
export function configFormsFolds(view: unknown): boolean { |
return view !== 'verbose' |
} |
/** |
* Whether a saved mode folds on a 0.1.2–0.1.6 host. An unset value is the |
* host's `compact` default. |
* @param view - saved `transcriptView`. |
* @returns true for `compact` or unset. |
*/ |
export function settingsScopeFolds(view: unknown): boolean { |
return view === undefined || view === 'compact' |
} |
/** |
* Adapt a settings face into a boolean observable. |
* @param face - the host namespace binding. |
* @param folds - the generation's mode rule. |
* @returns an observable whose snapshot is a primitive, so it is stable. |
*/ |
function observe(face: ChatSettingsFace, folds: (view: unknown) => boolean): HostObservable<boolean> { |
return { |
getSnapshot: () => folds(face.getSnapshot().value?.transcriptView), |
subscribe: (listener) => { |
const dispose = face.subscribe(listener) |
return typeof dispose === 'function' ? dispose : () => undefined |
}, |
} |
} |
/** |
* Narrow an unknown value to an object exposing a method. |
* @param value - candidate service. |
* @param method - required method name. |
* @returns the value when it carries the method. |
*/ |
function hasMethod<M extends string>(value: unknown, method: M): value is Record<M, (...args: never[]) => unknown> { |
return typeof value === 'object' && value !== null && typeof (value as Record<string, unknown>)[method] === 'function' |
} |
/** |
* Resolve the folding observable for this host. Call it once the Chat target |
* is up (its turn-tail declaration is the signal), when both settings |
* services, where present, are already provided. |
* @param host - the client context, read through optional `get`. |
* @returns whether finished turns currently fold, observed live. |
*/ |
export function foldingSource(host: FoldingHost): HostObservable<boolean> { |
const forms = host.get('configForms') |
if (hasMethod(forms, 'get')) { |
return observe((forms.get as (namespace: string) => ChatSettingsFace)(CHAT_NAMESPACE), configFormsFolds) |
} |
const scope = host.get('settingsScope') |
if (hasMethod(scope, 'bind')) { |
return observe((scope.bind as (options: { namespace: string }) => ChatSettingsFace)({ namespace: CHAT_NAMESPACE }), settingsScopeFolds) |
} |
return { getSnapshot: () => false, subscribe: () => () => undefined } |
} |
# ===== file: src/client/index.tsx ===== |
/** |
* dsh-visualize, browser half: the settled visualization card under the |
* `visualize` key of the atomic toolview hole, the streaming preview in the |
* composer's input dock, and — on hosts that fold finished turns — the turn's |
* cards again under its final answer. Clients without this half degrade to |
* the tool's generic result text by the documented toolview fallback. |
*/ |
import type { Context as ClientContext } from '@deepseek-ai/cordis' |
// Type-only: pulls the `ctx.slots` Context merge. |
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client' |
// Type-only: pulls the `tool.call.toolview` SlotMap declaration. |
import type {} from '@deepseek-ai/dsh-client-ui-tool/client' |
// Type-only: pulls the `conversation.input.dock` SlotMap declaration. |
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client' |
import type { ConversationNodeDefinition } from '@deepseek-ai/dsh-client-ui-conversation/client' |
import { VisualizeCard } from './VisualizeCard.tsx' |
import { StreamingPreview } from './StreamingPreview.tsx' |
import { foldingSource, type FoldingHost } from './folding.ts' |
import { selectTurnCards, turnCardsDefinition, TurnCards } from './TurnCards.tsx' |
export const name = 'dsh-visualize' |
export const inject = ['slots'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.