Skip to content

Draft and published scenes (#458, #459) - #512

Open
Subomiadekunle wants to merge 5 commits into
oss-slu:mainfrom
Subomiadekunle:scene-draft-publish-458-459
Open

Subomiadekunle wants to merge 5 commits into
oss-slu:mainfrom
Subomiadekunle:scene-draft-publish-458-459

Conversation

@Subomiadekunle

@Subomiadekunle Subomiadekunle commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #458, closes #459 (part of #457)

What's new

  • Drafts ([Small Rock] Define Draft Scenes #458): every scene has a status, draft or published. New scenes and duplicates start as drafts, and scenes saved before this change count as drafts, so nothing unfinished is shown as final content.
  • Publish / Unpublish ([Small Rock] Publish and Unpublish Scenes #459): a new button in the Scene Editor. Publishing requires saving first, so only what the editor sees goes live. Unpublishing is always allowed.
  • Visible status: a Draft (amber) or Published (green) badge on the scene title and in the scene list, plus a note on who can see the scene.
  • Bone viewer: scene links only show published scenes.

API

  • PATCH /api/scenes/:id/status with { "status": "draft" | "published" } changes only the status. Content and the save version (updatedAt) are untouched, per [Small Rock] Publish and Unpublish Scenes #459's note that publishing shouldn't change the scene.
  • GET /api/scenes?status=published (or draft) filters the list. Without it, the editor still sees every scene.

Out of scope

Testing

  • boneset-api/sceneStatus.test.js: 14 API tests (defaults, filtering, publish/unpublish, content unchanged, saving after publish, duplicates, validation)
  • templates/tests/scenePublish.test.js: 11 editor/viewer tests (badges, button states, save-before-publish, error + retry, viewer filter)
  • Updated viewerTransition.test.js for the published-only filter
  • npm test: all suites pass; npm run lint: clean

Manual check

Created a scene → Draft, and no link in the viewer → published → link appears → unpublished → link gone.

image image

Subomiadekunle and others added 5 commits October 11, 2026 17:54
fetchBoneDataResult() returns ok, missing (404), or error (network/5xx). The viewer shows 'no images yet' only for missing content; failures show an error with a Try again button. Added regression tests and updated the dropdowns test mock.
…ss-slu#459)

New scenes and duplicates start as drafts. PATCH /api/scenes/:id/status publishes or unpublishes without changing content, and GET /api/scenes?status=published lists published scenes for the bone viewer. The editor shows a Draft/Published badge, a visibility note, and a Publish/Unpublish button that requires saving first. Part of oss-slu#457.

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes

Thank you Subomi for the substantial work on this feature. The draft/published lifecycle is clearly represented in the API and editor, the viewer correctly filters out drafts, publishing does not change scene content or updatedAt, and the tests cover the main publish/unpublish flows well.

I found one state-synchronization issue that should be fixed before approval.

[P2] Save-as-new recovery must adopt the replacement scene’s draft status

File:

  • templates/js/scenes.js - saveAsNewScene(), around line 1032

When a scene is deleted externally and the user saves their working copy as a new scene, the API creates the replacement scene as a draft. However, saveAsNewScene() only copies the new id, name, createdAt, and updatedAt onto the existing working copy:

Object.assign(scene, {
    id: created.id,
    name: created.name,
    createdAt: created.createdAt,
    updatedAt: created.updatedAt
});

The existing scene.status and publishedAt values are left unchanged. If the deleted scene was published, the new server-side scene is correctly created as a draft, but the editor still displays it as Published and shows the Unpublish button. This leaves the UI inconsistent with the saved scene and can prevent the user from publishing the replacement normally.

Please update the working copy’s status metadata from the response without overwriting edits made while the save request was in flight. For example, copy created.status and either copy or remove publishedAt according to the response.

Please add a regression test in templates/tests/scenePublish.test.js that:

  1. Opens and publishes a scene.
  2. Makes an unsaved edit.
  3. Simulates the original scene being deleted before save.
  4. Saves the working copy as a new scene.
  5. Verifies that the new active scene and UI show Draft and that the available action is Publish.

There are also two cleanup items needed for the repository checks:

  • Remove the trailing whitespace in templates/js/scenes.js around line 349.
  • Remove the extra blank line at the end of templates/tests/viewerTransition.test.js.

The database/storage changes remain out of scope for this PR.

Thank you again for the thoughtful implementation and the strong test coverage.

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.

[Small Rock] Publish and Unpublish Scenes [Small Rock] Define Draft Scenes

3 participants