[PR #7119] [MERGED] feat(scene): let package threads be scene origins (capability API 1.66) #7484

Closed
opened 2026-10-23 04:20:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7119
Author: @Gunterlie
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @Gunterlie

Base: staging ← Head: feat/package-scene-origins


📝 Commits (9)

  • 0756977 feat(scene): let package threads be scene origins (capability API 1.66)
  • 0f18083 fix(scene): review fixes; let a package hand over its own scene plan
  • 727b747 docs(changelog): link scene origins issue #7118
  • 1f1a928 feat(scene): claim and release are optional for packages that only start scenes
  • 5b96407 feat(scene): per-scene packageData handed to claim and release
  • dd48bbe fix(scene): time limit on package scene-origin calls; disconnect before convert removes
  • 580ab5f Merge remote-tracking branch 'origin/staging' into feat/package-scene-origins
  • c062919 Merge remote-tracking branch 'origin/staging' into feat/package-scene-origins
  • 66a4aec fix(scene): release a package claim that answers after the deadline; qualify the changelog

📊 Changes

22 files changed (+1108 additions, -149 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/optional-agent-packages.md (+73 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+3 -1)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+1 -0)
📝 packages/client/src/components/chat/ConversationView.tsx (+3 -0)
📝 packages/client/src/components/chat/HomeBrowserHub.tsx (+41 -0)
📝 packages/client/src/components/chat/SceneBanner.tsx (+44 -11)
📝 packages/client/src/hooks/use-scene.ts (+17 -14)
📝 packages/client/src/lib/scene-generation.ts (+72 -31)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/client/src/stores/ui.store.ts (+6 -0)
📝 packages/server/src/routes/chats.routes.ts (+20 -1)
📝 packages/server/src/routes/scene.routes.ts (+267 -76)
📝 packages/server/src/services/capability-packages/capability-module-runtime.service.ts (+12 -0)
➕ packages/server/src/services/capability-packages/capability-scene-origin.service.ts (+92 -0)
📝 packages/server/src/services/import/st-chat.importer.ts (+2 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+18 -1)
📝 packages/shared/src/types/chat-preset.ts (+2 -0)
📝 packages/shared/src/types/scene.ts (+97 -10)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+4 -4)

...and 2 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7118

Why this change

  • A roleplay scene can only branch from an Engine Conversation. Plan reads it, create locks it, conclude writes the recap into it, and Back returns to it.
  • A package with its own conversations, such as Slurp's DM threads with Creators, cannot start a real scene from them. It has no lock, no way back and no recap.
  • This PR adds a package-neutral extension point. A package thread becomes a scene origin in the same way a Conversation is, so the package does not need a workaround such as a stuffed prompt or a hidden fake Conversation.

What changed

  • Capability API 1.66: adds the scenes permission and api.registerSceneOrigin(provider).
    • The provider contract is SceneOriginProvider in shared/src/types/scene.ts: getContext, claim and release.
    • The manifest schema refuses scenes below 1.66.
    • Only getContext is required. A package that only starts scenes leaves out claim (no lock, many scenes at once) and release (no outcome); either one can be used alone.
    • Per-scene settings: packageData on create (data on startScene) is stored with the scene and handed to claim and release, so a package decides per scene whether to lock and what to do with the recap.
  • Scene routes:
    • /scene/plan and /scene/create accept packageOrigin in place of chatId / originChatId.
    • Conclude, abandon, fork-convert and chat delete send the outcome to the package through release. Conclude includes the recap, and a concluded scene also keeps sceneSummary for packages that missed the release.
    • The thread unlocks only after the scene chat is gone.
    • /scene/create checks the plan fields it builds the chat from, because a package can send its own plan.
  • Conversation scenes are unchanged. The same code runs under if (origin.chat).
  • Client:
    • startSceneWithPromptPreferences accepts packageOrigin and an optional prepared plan. A prepared plan skips the dialog and the planner.
    • returnToSceneOrigin and a transient sceneOriginFocus open the package's Home browser tab at the thread.
    • The scene bars show Back to .
    • The browser element gets startScene, openChat, focusSceneOriginId and onFocusSceneOriginHandled.
  • Sanitizers: the ST importer and the chat-preset exclude list also drop scenePackageOrigin.
  • Docs: a new Capability API 1.66 section in docs/development/optional-agent-packages.md, and a CHANGELOG entry.
  • Regression: scripts/regressions/scene-package-origin.regression.ts covers:
    • plan context, and the lock race (one 200 and one 409);
    • conclude with the recap, abandon, delete and convert outcomes, and unlocking only after removal;
    • a plan the package wrote;
    • refused origins, plans and claims;
    • a package that went away (reconcile through sceneSummary);
    • the permission gate.
    • capability-package-lifecycle follows the version bump.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Agent-run, not manual. These regressions pass: scene-package-origin (new), scene-participants, capability-package-lifecycle, chat-branch-lineage, agent-scene-check, capability-tool-runtime and open-issues.
  • Client and server tsc pass, eslint on the changed client files passes, and localization:check passes.
  • A full pnpm check is running locally. Its result follows in a comment.
  • An Opus review of the diff found no blocking issues, and its six low or medium findings are fixed in the second commit.
  • No manual browser check yet. No package uses the API until the Slurp side ships, so for now only the Conversation /scene flow can be clicked through, and that flow is unchanged.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

  • The only visible change for existing users is none: Conversation scenes show the same Back to conversation button. Back to appears only for scenes started by a package.

Summary by CodeRabbit

  • New Features
    • Packages can start roleplay scenes from their threads using thread context and optional scene plans.
    • When requested by a package, its thread stays locked during the scene. The Back action returns to the originating thread, and the scene recap is sent to the package when the scene ends.
    • Capability API 1.66 supports scene-origin registration for packages with the scenes permission.
  • Documentation
    • Added guidance on scene origins, thread handling, validation, and API requirements.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7119 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `feat/package-scene-origins` --- ### 📝 Commits (9) - [`0756977`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0756977049c8fedcd2d1065830b215be86f16222) feat(scene): let package threads be scene origins (capability API 1.66) - [`0f18083`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0f18083bf4ad1473042fb7fca47b03363197337c) fix(scene): review fixes; let a package hand over its own scene plan - [`727b747`](https://github.com/Pasta-Devs/Marinara-Engine/commit/727b747161d6f7ce1e93b18853fbf1969c9fc00b) docs(changelog): link scene origins issue #7118 - [`1f1a928`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1f1a9283847b67f228eca8da55f6ea597442ba75) feat(scene): claim and release are optional for packages that only start scenes - [`5b96407`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5b96407fbdafbc30eea1ea7506e94ec0d359e565) feat(scene): per-scene packageData handed to claim and release - [`dd48bbe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dd48bbe49cf82637e569643d664a82e84766eceb) fix(scene): time limit on package scene-origin calls; disconnect before convert removes - [`580ab5f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/580ab5f628830c65c72e20f68496131a0a17e1ec) Merge remote-tracking branch 'origin/staging' into feat/package-scene-origins - [`c062919`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c0629193089336576e4ea83c41e05d0cf67f7a25) Merge remote-tracking branch 'origin/staging' into feat/package-scene-origins - [`66a4aec`](https://github.com/Pasta-Devs/Marinara-Engine/commit/66a4aec373fb0751e99ce71ac8ad9262407129aa) fix(scene): release a package claim that answers after the deadline; qualify the changelog ### 📊 Changes **22 files changed** (+1108 additions, -149 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/optional-agent-packages.md` (+73 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+3 -1) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+1 -0) 📝 `packages/client/src/components/chat/ConversationView.tsx` (+3 -0) 📝 `packages/client/src/components/chat/HomeBrowserHub.tsx` (+41 -0) 📝 `packages/client/src/components/chat/SceneBanner.tsx` (+44 -11) 📝 `packages/client/src/hooks/use-scene.ts` (+17 -14) 📝 `packages/client/src/lib/scene-generation.ts` (+72 -31) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/client/src/stores/ui.store.ts` (+6 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+20 -1) 📝 `packages/server/src/routes/scene.routes.ts` (+267 -76) 📝 `packages/server/src/services/capability-packages/capability-module-runtime.service.ts` (+12 -0) ➕ `packages/server/src/services/capability-packages/capability-scene-origin.service.ts` (+92 -0) 📝 `packages/server/src/services/import/st-chat.importer.ts` (+2 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+18 -1) 📝 `packages/shared/src/types/chat-preset.ts` (+2 -0) 📝 `packages/shared/src/types/scene.ts` (+97 -10) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+4 -4) _...and 2 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #7118 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - A roleplay scene can only branch from an Engine Conversation. Plan reads it, create locks it, conclude writes the recap into it, and **Back** returns to it. - A package with its own conversations, such as Slurp's DM threads with Creators, cannot start a real scene from them. It has no lock, no way back and no recap. - This PR adds a package-neutral extension point. A package thread becomes a scene origin in the same way a Conversation is, so the package does not need a workaround such as a stuffed prompt or a hidden fake Conversation. ## What changed <!-- List the key changes in this PR --> - **Capability API 1.66:** adds the `scenes` permission and `api.registerSceneOrigin(provider)`. - The provider contract is `SceneOriginProvider` in `shared/src/types/scene.ts`: `getContext`, `claim` and `release`. - The manifest schema refuses `scenes` below 1.66. - Only `getContext` is required. A package that only starts scenes leaves out `claim` (no lock, many scenes at once) and `release` (no outcome); either one can be used alone. - Per-scene settings: `packageData` on create (`data` on `startScene`) is stored with the scene and handed to `claim` and `release`, so a package decides per scene whether to lock and what to do with the recap. - **Scene routes:** - `/scene/plan` and `/scene/create` accept `packageOrigin` in place of `chatId` / `originChatId`. - Conclude, abandon, fork-convert and chat delete send the outcome to the package through `release`. Conclude includes the recap, and a concluded scene also keeps `sceneSummary` for packages that missed the release. - The thread unlocks only after the scene chat is gone. - `/scene/create` checks the plan fields it builds the chat from, because a package can send its own plan. - **Conversation scenes are unchanged.** The same code runs under `if (origin.chat)`. - **Client:** - `startSceneWithPromptPreferences` accepts `packageOrigin` and an optional prepared `plan`. A prepared plan skips the dialog and the planner. - `returnToSceneOrigin` and a transient `sceneOriginFocus` open the package's Home browser tab at the thread. - The scene bars show **Back to <package>**. - The browser element gets `startScene`, `openChat`, `focusSceneOriginId` and `onFocusSceneOriginHandled`. - **Sanitizers:** the ST importer and the chat-preset exclude list also drop `scenePackageOrigin`. - **Docs:** a new `Capability API 1.66` section in `docs/development/optional-agent-packages.md`, and a CHANGELOG entry. - **Regression:** `scripts/regressions/scene-package-origin.regression.ts` covers: - plan context, and the lock race (one 200 and one 409); - conclude with the recap, abandon, delete and convert outcomes, and unlocking only after removal; - a plan the package wrote; - refused origins, plans and claims; - a package that went away (reconcile through `sceneSummary`); - the permission gate. - `capability-package-lifecycle` follows the version bump. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Agent-run, not manual. These regressions pass: `scene-package-origin` (new), `scene-participants`, `capability-package-lifecycle`, `chat-branch-lineage`, `agent-scene-check`, `capability-tool-runtime` and `open-issues`. - Client and server `tsc` pass, `eslint` on the changed client files passes, and `localization:check` passes. - A full `pnpm check` is running locally. Its result follows in a comment. - An Opus review of the diff found no blocking issues, and its six low or medium findings are fixed in the second commit. - No manual browser check yet. No package uses the API until the Slurp side ships, so for now only the Conversation `/scene` flow can be clicked through, and that flow is unchanged. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) <!-- Add before/after screenshots or recordings for UI changes --> - The only visible change for existing users is none: Conversation scenes show the same **Back to conversation** button. **Back to <package>** appears only for scenes started by a package. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Packages can start roleplay scenes from their threads using thread context and optional scene plans. * When requested by a package, its thread stays locked during the scene. The Back action returns to the originating thread, and the scene recap is sent to the package when the scene ends. * Capability API 1.66 supports scene-origin registration for packages with the `scenes` permission. * **Documentation** * Added guidance on scene origins, thread handling, validation, and API requirements. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:20:15 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7484
No description provided.