Skip to content

Rewrite listing-use to create blank instances via atomic operations, unskip its suite - #680

Open
richardhjtan wants to merge 1 commit into
mainfrom
fix/listing-use-atomic-create
Open

Rewrite listing-use to create blank instances via atomic operations, unskip its suite#680
richardhjtan wants to merge 1 commit into
mainfrom
fix/listing-use-atomic-create

Conversation

@richardhjtan

Copy link
Copy Markdown
Collaborator

Un-skips the last listing-command suite. The use command was the one remaining listing command that loaded a card class at runtime (loadCardDef through import.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 through ExecuteAtomicOperationsCommand — the same way listing-install writes instances.

Why this shape:

  • No module fetch at all — the command no longer needs the loader to resolve the spec's module, which also unblocks the live-test environment (the shared test-module loader can't see per-test mock realms, which is why this suite was skipped).
  • Consistent with install — instances are written as docs; field defaults materialize when the card loads rather than being serialized at create time.

The suite's trailing-slash test also had a latent path bug that only surfaced once the command got this far: openDir treats a path without a trailing slash as a file path and strips the last segment, so the Author/ 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 realm
  • Full listing-suite regression run (install + remix + use): 12/12 green

Part of the Eliminate Skipped Tests in Catalog CI project (CS-11462).

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings July 31, 2026 05:31
@github-actions

Copy link
Copy Markdown

Staging Submissions Preview

This PR's content is pushed to the staging submissions realm: https://realms-staging.stack.cards/submissions/

Changed folders:

  • commands/
  • tests/

Updated at 2026-07-31 05:32:07 UTC for commit 8742495. Shared realm: only this PR's changed files are pushed; files touched by multiple PRs reflect whichever pushed last, and deleted files are not removed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts to batch-create blank instances using ExecuteAtomicOperationsCommand (no import.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 for openDir.

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.

Comment thread commands/listing-use.ts
Comment on lines +75 to 79
operations.push({
op: 'add' as const,
href: join(realmUrl, localDir, ref.name, crypto.randomUUID()) + '.json',
data: { type: 'card', meta: { adoptsFrom: ref } },
});

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants