[PR #4535] [MERGED] Fix World Maps movement for /impersonate #6414

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4535
Author: @thetopham
Created: 8/3/2026
Status: ✅ Merged
Merged: 8/3/2026
Merged by: @thetopham

Base: staging ← Head: agent/4433-impersonate-map-movement


📝 Commits (9)

  • ef2f02b fix: commit queued map moves after impersonate
  • 2d759ff fix: recover already-applied impersonate moves
  • 8375ebf Merge remote-tracking branch 'origin/staging' into agent/4433-impersonate-map-movement
  • 63b2b41 Merge branch 'staging' into agent/4433-impersonate-map-movement
  • 076a3c2 fix: make impersonate movement recovery idempotent
  • 640d311 Merge remote-tracking branch 'origin/agent/4433-impersonate-map-movement' into agent/4433-impersonate-map-movement
  • 3b53da5 fix: preflight repeated impersonate moves
  • 157b0a9 fix: recover committed moves before busy guard
  • 7d06b59 Merge branch 'staging' into agent/4433-impersonate-map-movement

📊 Changes

7 files changed (+397 additions, -25 deletions)

View changed files

📝 packages/client/src/components/chat/ChatInput.tsx (+9 -1)
📝 packages/client/src/hooks/use-generate.ts (+26 -2)
📝 packages/client/src/hooks/use-spatial-context.ts (+12 -0)
📝 packages/server/src/routes/generate.routes.ts (+159 -22)
➕ packages/server/src/routes/generate/spatial-transition-request.ts (+85 -0)
📝 packages/server/src/services/spatial-context/owner-turn.ts (+12 -0)
📝 scripts/regressions/spatial-context.regression.ts (+94 -0)

📄 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 #4433

Paired World Maps package change: Pasta-Devs/Marinara-Agents#220

Why this change

  • After #4534 merged into staging, the Roleplay World Maps regression remained reproducible when the owner used /impersonate and NPC turns used /guided.
  • /guided must leave the browser-local queued owner move untouched. /impersonate must generate the user-role prose and atomically commit that exact message with the queued destination.
  • A retry of an already committed movement command must return the authoritative saved turn without rerunning providers, agents, memory work, or post-processing.

What changed

  • Attach a ready Roleplay spatial transition only to owner-origin /impersonate generation; reject guided, autonomous, turn-game, regeneration, continuation, and non-Roleplay movement submissions.
  • Defer the atomic owner-message plus spatial-snapshot commit until impersonation text has been generated.
  • Emit explicit spatial commit/rejection events, preserve a queued move after provider failure or abort, and prevent non-atomic partial-message fallback.
  • Preflight repeated command IDs before connection, prompt, provider, or agent work and return the persisted message as an idempotent success.
  • Retain the transactional duplicate check as a race guard; its fallback clears retry reasoning, suppresses retry commands/post-processing, and keeps parallel-agent events deferred until settlement.
  • Notify capability packages when the non-generation owner-turn endpoint commits a move.

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

Automated evidence:

  • pnpm check passes, including Impeccable context, localization, shared/server type checking, client ESLint, and production builds.
  • pnpm regression:spatial passes.
  • The paired exact-artifact lifecycle regression passes and proves a repeated /impersonate command makes zero provider requests while preserving the original message, metadata, and location.
  • git diff --check passes.

Manual verification notes

  • Manually verify the exact paired Engine and World Maps artifacts after World Maps 1.3.1 is installed.
  • Queue a Roleplay move, run /guided for an NPC reply, and verify the move remains ready and the location does not change.
  • Post with /impersonate and verify the generated user message and destination commit exactly once.
  • Abort or fail an impersonation and verify the move remains ready; submit a stale move and verify it changes to Needs review.

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)

  • Pending exact-head local installation and manual browser verification.

Summary by CodeRabbit

  • New Features

    • Improved spatial transition handling during impersonated conversations.
    • Added recovery for interrupted or retried spatial updates without duplicating messages or actions.
    • Added clearer validation for unsupported spatial generation requests.
  • Bug Fixes

    • Prevented incomplete generated messages from being saved when spatial transitions are pending.
    • Spatial transition rejections now flag the transition for review and refresh the conversation context.
    • Successfully completed spatial updates now notify connected features immediately.
  • Tests

    • Added regression coverage for valid, invalid, rejected, and previously completed spatial transitions.

🔄 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/4535 **Author:** [@thetopham](https://github.com/thetopham) **Created:** 8/3/2026 **Status:** ✅ Merged **Merged:** 8/3/2026 **Merged by:** [@thetopham](https://github.com/thetopham) **Base:** `staging` ← **Head:** `agent/4433-impersonate-map-movement` --- ### 📝 Commits (9) - [`ef2f02b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ef2f02bb21efd3542a4f87eb4d58f4b04e46f575) fix: commit queued map moves after impersonate - [`2d759ff`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2d759ffd4ca866b8fc79161c745997daffff4820) fix: recover already-applied impersonate moves - [`8375ebf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8375ebf6c26a8aab7cfddeaf4883d5b0b499b95c) Merge remote-tracking branch 'origin/staging' into agent/4433-impersonate-map-movement - [`63b2b41`](https://github.com/Pasta-Devs/Marinara-Engine/commit/63b2b41ab353cf1333ced0224b265e93ecba2795) Merge branch 'staging' into agent/4433-impersonate-map-movement - [`076a3c2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/076a3c240072931b9ef5db6cbc8f907a15860325) fix: make impersonate movement recovery idempotent - [`640d311`](https://github.com/Pasta-Devs/Marinara-Engine/commit/640d311f2ce6a85163af89a1fd59718a51ef2032) Merge remote-tracking branch 'origin/agent/4433-impersonate-map-movement' into agent/4433-impersonate-map-movement - [`3b53da5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3b53da5b1d5d60e43107190b2282a5f6a368d7cf) fix: preflight repeated impersonate moves - [`157b0a9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/157b0a99dbfcb5c6b499ebcf38dc223525815543) fix: recover committed moves before busy guard - [`7d06b59`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7d06b592f5f9241621740e47dc75c29aa88ee46a) Merge branch 'staging' into agent/4433-impersonate-map-movement ### 📊 Changes **7 files changed** (+397 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatInput.tsx` (+9 -1) 📝 `packages/client/src/hooks/use-generate.ts` (+26 -2) 📝 `packages/client/src/hooks/use-spatial-context.ts` (+12 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+159 -22) ➕ `packages/server/src/routes/generate/spatial-transition-request.ts` (+85 -0) 📝 `packages/server/src/services/spatial-context/owner-turn.ts` (+12 -0) 📝 `scripts/regressions/spatial-context.regression.ts` (+94 -0) </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`. ## Linked issue Closes #4433 Paired World Maps package change: Pasta-Devs/Marinara-Agents#220 ## Why this change - After #4534 merged into `staging`, the Roleplay World Maps regression remained reproducible when the owner used `/impersonate` and NPC turns used `/guided`. - `/guided` must leave the browser-local queued owner move untouched. `/impersonate` must generate the user-role prose and atomically commit that exact message with the queued destination. - A retry of an already committed movement command must return the authoritative saved turn without rerunning providers, agents, memory work, or post-processing. ## What changed - Attach a ready Roleplay spatial transition only to owner-origin `/impersonate` generation; reject guided, autonomous, turn-game, regeneration, continuation, and non-Roleplay movement submissions. - Defer the atomic owner-message plus spatial-snapshot commit until impersonation text has been generated. - Emit explicit spatial commit/rejection events, preserve a queued move after provider failure or abort, and prevent non-atomic partial-message fallback. - Preflight repeated command IDs before connection, prompt, provider, or agent work and return the persisted message as an idempotent success. - Retain the transactional duplicate check as a race guard; its fallback clears retry reasoning, suppresses retry commands/post-processing, and keeps parallel-agent events deferred until settlement. - Notify capability packages when the non-generation owner-turn endpoint commits a move. ## Validation - [x] `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` Automated evidence: - `pnpm check` passes, including Impeccable context, localization, shared/server type checking, client ESLint, and production builds. - `pnpm regression:spatial` passes. - The paired exact-artifact lifecycle regression passes and proves a repeated `/impersonate` command makes zero provider requests while preserving the original message, metadata, and location. - `git diff --check` passes. ### Manual verification notes - Manually verify the exact paired Engine and World Maps artifacts after World Maps 1.3.1 is installed. - Queue a Roleplay move, run `/guided` for an NPC reply, and verify the move remains ready and the location does not change. - Post with `/impersonate` and verify the generated user message and destination commit exactly once. - Abort or fail an impersonation and verify the move remains ready; submit a stale move and verify it changes to Needs review. ## Docs and release impact - [x] 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) - Pending exact-head local installation and manual browser verification. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved spatial transition handling during impersonated conversations. * Added recovery for interrupted or retried spatial updates without duplicating messages or actions. * Added clearer validation for unsupported spatial generation requests. * **Bug Fixes** * Prevented incomplete generated messages from being saved when spatial transitions are pending. * Spatial transition rejections now flag the transition for review and refresh the conversation context. * Successfully completed spatial updates now notify connected features immediately. * **Tests** * Added regression coverage for valid, invalid, rejected, and previously completed spatial transitions. <!-- 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:10:12 +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#6414
No description provided.