feat(client-runtime): add target-owned conversation snapshots

This commit is contained in:
imccyu
2026-08-10 18:37:59 +08:00
parent aa6d0b6efd
commit 3e79f7106e
37 changed files with 183 additions and 117 deletions
@@ -30,10 +30,16 @@ interface TestSnapshot {
}
class TestEventDefinitions {
readonly definitions: readonly ConversationNodeDefinition[]
readonly fallback: ConversationNodeDefinition | undefined
constructor(
readonly definitions: readonly ConversationNodeDefinition[],
readonly fallback?: ConversationNodeDefinition,
) {}
definitions: readonly ConversationNodeDefinition[],
fallback?: ConversationNodeDefinition,
) {
this.definitions = definitions.map(asChatDefinition)
this.fallback = fallback === undefined ? undefined : asChatDefinition(fallback)
}
entries(): readonly ConversationNodeDefinition[] {
return this.definitions
@@ -44,6 +50,12 @@ class TestEventDefinitions {
}
}
function asChatDefinition(definition: ConversationNodeDefinition): ConversationNodeDefinition {
return definition.buildViewNode === undefined || definition.target !== undefined
? definition
: { ...definition, target: 'chat' }
}
class TestViewDefinitions {
constructor(readonly definitions: readonly ConversationViewDefinition[]) {}
@@ -93,7 +105,10 @@ function chatSnapshot(assembler: ConversationNodeAssembler): TestSnapshot | unde
return assembler.snapshot('chat') as TestSnapshot | undefined
}
function node(context: Parameters<ConversationNodeDefinition['buildViewNode']>[0], data: unknown): ConversationViewNode {
function node(
context: Parameters<NonNullable<ConversationNodeDefinition['buildViewNode']>>[0],
data: unknown,
): ConversationViewNode {
return {
key: context.key,
kind: context.kind,