fix: bootstrap empty Pascal scenes for agents
This commit is contained in:
parent
16bfd0bd38
commit
cc6c4b547c
@ -60,6 +60,24 @@ describe('load_scene', () => {
|
||||
expect(result.isError).toBe(true)
|
||||
})
|
||||
|
||||
test('bootstraps an editable default hierarchy for an empty stored scene', async () => {
|
||||
await store.save({
|
||||
id: 'empty-scene',
|
||||
name: 'Empty',
|
||||
graph: { nodes: {}, rootNodeIds: [] },
|
||||
})
|
||||
|
||||
const result = await client.callTool({
|
||||
name: 'load_scene',
|
||||
arguments: { id: 'empty-scene' },
|
||||
})
|
||||
|
||||
expect(result.isError).toBeFalsy()
|
||||
expect(bridge.getRootNodeIds().length).toBeGreaterThan(0)
|
||||
expect(Object.keys(bridge.getNodes()).length).toBeGreaterThan(0)
|
||||
expect(bridge.findNodes({ type: 'level' }).length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test('rejects empty id per schema', async () => {
|
||||
const result = await client.callTool({
|
||||
name: 'load_scene',
|
||||
|
||||
@ -45,7 +45,12 @@ export function registerLoadScene(server: McpServer, bridge: SceneOperations): v
|
||||
throwMcpError(ErrorCode.InvalidParams, 'scene_not_found', { id })
|
||||
}
|
||||
try {
|
||||
bridge.loadJSON(result.graph)
|
||||
if (Object.keys(result.graph.nodes ?? {}).length === 0) {
|
||||
bridge.setScene({}, [])
|
||||
bridge.loadDefault()
|
||||
} else {
|
||||
bridge.loadJSON(result.graph)
|
||||
}
|
||||
bridge.setActiveScene(result)
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user