Rewrite listing-use to create blank instances via atomic operations, unskip its suite - #680
Rewrite listing-use to create blank instances via atomic operations, unskip its suite#680richardhjtan wants to merge 1 commit into
Conversation
…unskip its suite A blank instance is just a document adopting from the spec's ref, so the command writes that doc through ExecuteAtomicOperationsCommand instead of loading the card class and instantiating it client-side. This matches how listing-install writes instances, drops the module fetch entirely, and lets field defaults materialize at load time. The suite's trailing-slash test also had a latent path bug: openDir treats a path without a trailing slash as a file path and strips the last segment, so the instance folder was never expanded. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Staging Submissions PreviewThis PR's content is pushed to the staging submissions realm: https://realms-staging.stack.cards/submissions/ Changed folders:
Updated at 2026-07-31 05:32:07 UTC for commit |
There was a problem hiding this comment.
Pull request overview
Updates the listing-use command to create blank card instances by writing minimal JSON:API documents via atomic operations (instead of dynamically loading card classes), and re-enables the previously skipped live acceptance tests for the command.
Changes:
- Rewrites
commands/listing-use.tsto batch-create blank instances usingExecuteAtomicOperationsCommand(noimport.meta.loader/ module fetch). - Unskips and refactors
tests/live/catalog-app/listing-use.test.gts, including fixing the instance-folder path to include a trailing slash foropenDir.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/live/catalog-app/listing-use.test.gts | Unskips and updates acceptance tests for listing use, including a trailing-slash path fix when expanding the instance folder in the file tree. |
| commands/listing-use.ts | Replaces runtime card-class loading + SaveCardCommand with atomic “add” operations that write blank instance documents adopting from the resolved spec ref. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| operations.push({ | ||
| op: 'add' as const, | ||
| href: join(realmUrl, localDir, ref.name, crypto.randomUUID()) + '.json', | ||
| data: { type: 'card', meta: { adoptsFrom: ref } }, | ||
| }); |
There was a problem hiding this comment.
[Claude Code 🤖] join is variadic — export function join(...pathParts: string[]) in runtime-common/paths.ts maps over every part (strips edge slashes, filters empties, joins with '/'), so all four segments are kept. Verified at runtime while debugging this suite: the atomic operation logged the full href http://test-realm/test2/author-<uuid>/Author/<uuid>.json and the realm's result echoed the file created at exactly that path. The 2-arg call sites elsewhere are just the shape those callers needed. Leaving as-is.
Un-skips the last listing-command suite. The
usecommand was the one remaining listing command that loaded a card class at runtime (loadCardDefthroughimport.meta.loader) just to instantiate a blank card and save it. A blank instance is fully described by a document adopting from the spec's ref, so the command now writes that doc throughExecuteAtomicOperationsCommand— the same waylisting-installwrites instances.Why this shape:
The suite's trailing-slash test also had a latent path bug that only surfaced once the command got this far:
openDirtreats a path without a trailing slash as a file path and strips the last segment, so theAuthor/instance folder was never expanded in the file tree.Test plan
Acceptance | Catalog | catalog app - listing use: 2/2 green against a locally running catalog realmPart of the Eliminate Skipped Tests in Catalog CI project (CS-11462).
🤖 Generated with Claude Code