Skip to content

fix(artifacts): show a settled preview capture only to the artifact's creator - #33

Merged
fforres merged 1 commit into
feat/share-artifacts-with-orgfrom
fix/artifact-preview-per-creator
Oct 20, 2026
Merged

fforres merged 1 commit into
feat/share-artifacts-with-orgfrom
fix/artifact-preview-per-creator

Conversation

@fforres

@fforres fforres commented Oct 20, 2026

Copy link
Copy Markdown

Stacked on #32 (needs its created_by column).

A settled preview capture is taken after the artifact's queries resolve, so it contains whatever data the capturing viewer could see. Since #31 made artifacts org-tier, any member who opened an artifact could overwrite its single preview column with a snapshot of their data, and that snapshot was then shown to everyone.

Change

  • Separate column. The capture is stored in a new preview_capture column. preview keeps only the data-free layout preview written at save time.
  • Creator only. setPreview stores the capture only for the artifact's creator: a personal row, or an org row whose created_by is the caller. Anyone else, and every caller on a legacy row with no creator, gets { stored: false }.
  • Who sees what. The creator sees their capture, falling back to the layout preview. Everyone else sees the layout preview, or nothing when a legacy row has an image snapshot in preview.
  • Overwrite. Saving over an artifact clears preview_capture along with the other columns derived from the render.
  • Migration. Cloud migration 0024, plus a D1 upgrade test.

All capture paths go through setPreview: the console's shell asks for the save-preview tool, which becomes PUT /artifacts/:id/preview. MCP hosts never ask for captures.

Tests

  • packages/core/sdk/src/artifacts.test.ts, capture privacy: creator vs member previews, a member's capture is not stored, legacy rows with no creator, personal rows, an overwrite clears the capture, a legacy image is hidden from non-creators, list previews, and share keeps the capture.
  • packages/core/api/src/artifacts/artifacts-preview.test.ts: the PUT answers stored: false for a non-creator and stored: true for the creator.
  • Mutation-checked: removing the creator check fails 3 tests, and making readers always return the capture fails 4.

Known limit. A legacy settled markup capture already sitting in preview can't be told apart from layout markup, so it stays visible to every member until that artifact is saved again.

… creator

A settled preview capture is taken after the artifact's queries resolve,
so it holds whatever data the capturing viewer could see. Since org-tier
artifacts are open to every member, any member's capture overwrote the
shared preview column and was shown to everyone.

The capture now goes to its own `preview_capture` column, and setPreview
stores it only for the artifact's creator (a personal row, or an org row
whose `created_by` is the caller). Anyone else gets `{ stored: false }`.
Readers give the creator their capture, falling back to the layout
preview. Every other member gets the data-free layout preview, or nothing
when a legacy row holds an image snapshot there. An overwrite clears the
capture with the rest of the render-derived columns.

Includes the cloud migration and a D1 upgrade test.
@fforres
fforres added this pull request to stack #34 October 20, 2026 21:10
@fforres
fforres merged commit 4fb49d4 into skyward Oct 20, 2026
3 of 39 checks passed
@fforres
fforres deleted the fix/artifact-preview-per-creator branch October 20, 2026 21:11
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.

1 participant