Fix instance lookups that trusted stale data

Two regressions from the template-resolution rework, plus the harness gap
that hid them:

- `instanceTargetOf` decided from the shape of the id. Unpacking keeps the
  derived ids, so unpacked content still counted as template content. It now
  asks whether the object is spelled out in the holder.
- The parent picker captured its holder when the row was built. Since
  `viewOf()` returns a derived copy, the menu listed the objects of that
  moment (measured: 40 in the model, 17 in the menu). It resolves on open.
- `evaluate()` swallowed page exceptions, so a mutate that died half-way let
  every later check pass or fail for the wrong reason.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5 committed 2026-09-08 21:59:22 +02:00
1 parent ead649eec3
commit f40b8a0523
5 files changed
+45 -6

No files matched your search

+10 -1
View File
@@ -6,7 +6,7 @@ import {
RevertOverrideToTemplateCommand,
RevertPositionToTemplateCommand,
} from '../../src/core/commands/applyCommands';
import { CreateContainerCommand } from '../../src/core/commands/containerCommands';
import { CreateContainerCommand, UnpackContainerCommand } from '../../src/core/commands/containerCommands';
import { MoveSceneObjectCommand, SetOverrideCommand } from '../../src/core/commands/sceneObjectCommands';
import type { ContainerAsset } from '../../src/core/model/Asset';
import { instanceChildId, instanceTargetOf } from '../../src/core/model/instance';
@@ -50,6 +50,15 @@ describe('template link', () => {
// The container object itself is stored, so it has no template behind it.
expect(instanceTargetOf(project, scene, instanceId)).toBeUndefined();
});
it('drops the link once the instance is unpacked, even though the ids stay', () => {
const { project, stack, sceneId, sceneOf, instanceId, a } = setup();
stack.execute(new UnpackContainerCommand(sceneId, instanceId));
expect(sceneOf().objects.some((o) => o.id === a)).toBe(true);
expect(instanceTargetOf(project, sceneOf(), a)).toBeUndefined();
stack.undo();
expect(instanceTargetOf(project, sceneOf(), a)?.asset.type).toBe('container');
});
});
describe('position apply / revert', () => {