[PR #5070] [MERGED] refactor: continue behavior-preserving code cleanup #6614

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5070
Author: @Xelvanis
Created: 8/15/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @SpicyMarinara

Base: staging ← Head: cleanup/code-cleanup


📝 Commits (9)

  • e9baaca refactor: remove unreachable committed stream state
  • efde9f4 refactor: remove dead chat Zustand mirrors
  • 6e25f31 refactor: remove redundant generation setup lock
  • 2a11231 refactor: use lexical active generation registry
  • ddfba94 refactor: remove unused token-only SSE parser
  • ad2266b refactor: collapse update check success response
  • 2f8b886 fix: preserve active generation ownership during setup
  • dbc6eaf Merge branch 'staging' into cleanup/code-cleanup
  • 53d26f6 Merge branch 'staging' into cleanup/code-cleanup

📊 Changes

13 files changed (+87 additions, -276 deletions)

View changed files

📝 .github/bunny-review/reviewer-prompt.md (+1 -1)
📝 .github/bunny-review/rules.json (+2 -2)
📝 docs/development/frontend.md (+0 -1)
📝 packages/client/.instructions.md (+1 -1)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+1 -2)
📝 packages/client/src/components/chat/ConversationView.tsx (+1 -2)
📝 packages/client/src/hooks/use-generate.ts (+5 -47)
📝 packages/client/src/lib/api-client.ts (+0 -74)
📝 packages/client/src/lib/generation-stream-policy.ts (+1 -2)
📝 packages/client/src/stores/chat.store.ts (+10 -55)
📝 packages/server/src/routes/generate.routes.ts (+11 -15)
📝 packages/server/src/routes/updates.routes.ts (+51 -71)
📝 scripts/regressions/roleplay-streaming.regression.ts (+3 -3)

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

Why this change

  • Remove newly confirmed dead compatibility and state mirrors so the active chat and streaming ownership is easier to understand and maintain.
  • Keep the cleanup series reviewable and reversible by using one focused commit per independently verified cleanup.

What changed

  • Removed the unreachable committedStreamChatIds state/action/branches while retaining streamedMessageIds as the real durable-row shadow owner.
  • Removed unused Zustand transcript and swipe-index mirrors now owned by React Query and durable Message.activeSwipeIndex.
  • Removed the redundant generation setup Set after making abort-controller claims atomically clear the Illustrator-tail exception.
  • Made the main generation handler capture the typed active-generation registry directly, removing untyped Fastify decoration readback and impossible missing-map branches.
  • Removed the zero-consumer token-only api.stream parser and its orphaned helper, retaining streamEvents as the sole active generation SSE client and correcting stale contributor/reviewer guidance.
  • Collapsed duplicate cached/fetched update-check success responses into one construction path without changing cache timing, failure payloads, channel calculations, or apply metadata.
  • Preserved each cleanup as a separate commit. This draft will be updated as further approved cleanup items are added.

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

  • Focused ESLint passed for all changed client source files after branch integration.
  • A disposable synchronous store-subscriber oracle failed against the pre-fix stale-tail publication and passed after the atomic repair; it was not committed.
  • Exact removed-symbol searches and git diff --check passed.
  • Focused server TypeScript and the exact active-generation registry ownership oracle passed for the fourth cleanup; fresh independent review found no actionable issue.
  • Focused client ESLint, exact tracked consumer/contract exhaustion, retained-helper checks, JSON parsing, and independent review passed for the token-only parser deletion.
  • Focused server TypeScript, the launcher-update regression suite, exact success/failure response equivalence, and independent review passed for the update-check response deduplication.
  • message-page-cache.regression.ts and regeneration-context.regression.ts passed for the Zustand mirror cleanup.
  • Disposable desktop Conversation and mobile Roleplay streaming/regeneration checks completed without duplicate presentation rows or browser-console errors for the committed-stream cleanup.
  • pnpm regression:roleplay remains blocked by an unrelated inherited textarea-resize source assertion after advancing past the task-adjacent extractor repair.
  • Local pnpm check passed on final head 2f8b88663; final-head CI pnpm-validate, container build, JavaScript/TypeScript analysis, and CodeQL also passed.

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] <paths> follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Contributor and reviewer guidance was updated only to remove the stale api.stream contract. No user-facing documentation, localization, release metadata, or changelog change is needed for these six internal behavior-preserving cleanups. origin/docs-i18n has no development/frontend.md counterpart in any language pack.

Known pre-existing limitation

activeGenerations is still decorated inside the generateRoutes Fastify plugin. Fastify encapsulation prevents sibling route plugins and the root scheduler from observing that child decoration. This predates this PR, and the lexical-registry cleanup does not introduce or worsen it. Fixing it requires a typed parent-owned or injected registry and would activate currently ineffective guards, so it is intentionally deferred as a separate correctness change rather than hidden inside this behavior-preserving cleanup.

UI evidence (if applicable)

No retained screenshots or recordings. Passing browser runs intentionally retained no trace.

Summary by CodeRabbit

  • New Features

    • Standardized streaming interactions around typed event streams, including fallback and error notifications.
    • Improved generation concurrency handling and live-stream state tracking.
  • Bug Fixes

    • Improved update checks across cached and newly retrieved release data.
    • Fixed generation setup and retry behavior for more consistent streaming results.
  • Documentation

    • Updated development guidance to document the supported event-streaming interface and remove obsolete references.

🔄 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/5070 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 8/15/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `cleanup/code-cleanup` --- ### 📝 Commits (9) - [`e9baaca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e9baacaa7ee37c20ae249dc81a30cd3ce589372f) refactor: remove unreachable committed stream state - [`efde9f4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/efde9f45f26967ca935100a38132771e6e308aee) refactor: remove dead chat Zustand mirrors - [`6e25f31`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6e25f31c9e01f0b2d08438fa59169d60156a25ef) refactor: remove redundant generation setup lock - [`2a11231`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2a1123186fb4cf9e6ae3198f5fc48fea9ec643b7) refactor: use lexical active generation registry - [`ddfba94`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ddfba943f093218f8fa8facc61b760b27e580fa5) refactor: remove unused token-only SSE parser - [`ad2266b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ad2266b988d642a442cb1d5086729d1f75559131) refactor: collapse update check success response - [`2f8b886`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2f8b88663cd5e503e465528d6bee1c01491d6356) fix: preserve active generation ownership during setup - [`dbc6eaf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dbc6eaf4001093130015ad1521cbcb27d1bc2d75) Merge branch 'staging' into cleanup/code-cleanup - [`53d26f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/53d26f6b4d9674480e00c8ba511c7ec919d72a90) Merge branch 'staging' into cleanup/code-cleanup ### 📊 Changes **13 files changed** (+87 additions, -276 deletions) <details> <summary>View changed files</summary> 📝 `.github/bunny-review/reviewer-prompt.md` (+1 -1) 📝 `.github/bunny-review/rules.json` (+2 -2) 📝 `docs/development/frontend.md` (+0 -1) 📝 `packages/client/.instructions.md` (+1 -1) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+1 -2) 📝 `packages/client/src/components/chat/ConversationView.tsx` (+1 -2) 📝 `packages/client/src/hooks/use-generate.ts` (+5 -47) 📝 `packages/client/src/lib/api-client.ts` (+0 -74) 📝 `packages/client/src/lib/generation-stream-policy.ts` (+1 -2) 📝 `packages/client/src/stores/chat.store.ts` (+10 -55) 📝 `packages/server/src/routes/generate.routes.ts` (+11 -15) 📝 `packages/server/src/routes/updates.routes.ts` (+51 -71) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+3 -3) </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 Closes #5069 ## Why this change - Remove newly confirmed dead compatibility and state mirrors so the active chat and streaming ownership is easier to understand and maintain. - Keep the cleanup series reviewable and reversible by using one focused commit per independently verified cleanup. ## What changed - Removed the unreachable `committedStreamChatIds` state/action/branches while retaining `streamedMessageIds` as the real durable-row shadow owner. - Removed unused Zustand transcript and swipe-index mirrors now owned by React Query and durable `Message.activeSwipeIndex`. - Removed the redundant generation setup Set after making abort-controller claims atomically clear the Illustrator-tail exception. - Made the main generation handler capture the typed active-generation registry directly, removing untyped Fastify decoration readback and impossible missing-map branches. - Removed the zero-consumer token-only `api.stream` parser and its orphaned helper, retaining `streamEvents` as the sole active generation SSE client and correcting stale contributor/reviewer guidance. - Collapsed duplicate cached/fetched update-check success responses into one construction path without changing cache timing, failure payloads, channel calculations, or apply metadata. - Preserved each cleanup as a separate commit. This draft will be updated as further approved cleanup items are added. ## 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) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Focused ESLint passed for all changed client source files after branch integration. - A disposable synchronous store-subscriber oracle failed against the pre-fix stale-tail publication and passed after the atomic repair; it was not committed. - Exact removed-symbol searches and `git diff --check` passed. - Focused server TypeScript and the exact active-generation registry ownership oracle passed for the fourth cleanup; fresh independent review found no actionable issue. - Focused client ESLint, exact tracked consumer/contract exhaustion, retained-helper checks, JSON parsing, and independent review passed for the token-only parser deletion. - Focused server TypeScript, the launcher-update regression suite, exact success/failure response equivalence, and independent review passed for the update-check response deduplication. - `message-page-cache.regression.ts` and `regeneration-context.regression.ts` passed for the Zustand mirror cleanup. - Disposable desktop Conversation and mobile Roleplay streaming/regeneration checks completed without duplicate presentation rows or browser-console errors for the committed-stream cleanup. - `pnpm regression:roleplay` remains blocked by an unrelated inherited textarea-resize source assertion after advancing past the task-adjacent extractor repair. - Local `pnpm check` passed on final head `2f8b88663`; final-head CI `pnpm-validate`, container build, JavaScript/TypeScript analysis, and CodeQL also passed. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n] <paths>` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Contributor and reviewer guidance was updated only to remove the stale `api.stream` contract. No user-facing documentation, localization, release metadata, or changelog change is needed for these six internal behavior-preserving cleanups. `origin/docs-i18n` has no `development/frontend.md` counterpart in any language pack. ## Known pre-existing limitation `activeGenerations` is still decorated inside the `generateRoutes` Fastify plugin. Fastify encapsulation prevents sibling route plugins and the root scheduler from observing that child decoration. This predates this PR, and the lexical-registry cleanup does not introduce or worsen it. Fixing it requires a typed parent-owned or injected registry and would activate currently ineffective guards, so it is intentionally deferred as a separate correctness change rather than hidden inside this behavior-preserving cleanup. ## UI evidence (if applicable) No retained screenshots or recordings. Passing browser runs intentionally retained no trace. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Standardized streaming interactions around typed event streams, including fallback and error notifications. * Improved generation concurrency handling and live-stream state tracking. * **Bug Fixes** * Improved update checks across cached and newly retrieved release data. * Fixed generation setup and retry behavior for more consistent streaming results. * **Documentation** * Updated development guidance to document the supported event-streaming interface and remove obsolete references. <!-- 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:12:04 +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#6614
No description provided.