mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7869] [MERGED] feat(packages): agent packages use the Engine's own stores and libraries #7977
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7977
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7869
Author: @SpicyMarinara
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/ready-engine-ui-store-guard📝 Commits (8)
db92312fix(ui): repair UI settings an old package's bundled store drops36091d2Merge remote-tracking branch 'origin/staging' into fix/ready-engine-ui-store-guard617a4b2Merge remote-tracking branch 'origin/staging' into fix/ready-engine-ui-store-guard5450b07fix(ui): load the Engine's own UI save over an older package's blobcda64c6Merge remote-tracking branch 'origin/staging' into fix/ready-engine-ui-store-guardef17849Merge remote-tracking branch 'origin/staging' into fix/ready-engine-ui-store-guard851d165feat(packages): agent packages use the Engine's own stores and libraries3916996Merge remote-tracking branch 'origin/staging' into fix/ready-engine-ui-store-guard📊 Changes
22 files changed (+1479 additions, -25 deletions)
View changed files
📝
docs/development/optional-agent-packages.md(+101 -0)📝
e2e/assigned-chat-sweep.e2e.ts(+2 -0)➕
e2e/host-package-fixture.ts(+116 -0)➕
e2e/marinara-host-namespace.e2e.ts(+383 -0)➕
e2e/ui-store-foreign-write.e2e.ts(+293 -0)📝
packages/client/.instructions.md(+2 -2)📝
packages/client/package.json(+1 -0)📝
packages/client/src/App.tsx(+2 -0)📝
packages/client/src/components/ui/AppDialogRenderer.tsx(+2 -0)📝
packages/client/src/components/ui/Modal.tsx(+4 -1)📝
packages/client/src/hooks/use-capability-packages.ts(+5 -1)📝
packages/client/src/hooks/use-dialog-focus-scope.ts(+3 -3)➕
packages/client/src/lib/marinara-host-contract.ts(+202 -0)➕
packages/client/src/lib/marinara-host.ts(+116 -0)➕
packages/client/src/lib/query-client.ts(+12 -0)📝
packages/client/src/lib/ui-persistence.ts(+27 -0)📝
packages/client/src/main.tsx(+2 -11)📝
packages/client/src/stores/ui.store.ts(+24 -3)📝
packages/client/src/styles/mari.css(+4 -3)📝
pnpm-lock.yaml(+3 -0)...and 2 more files
📄 Description
Linked issue
Closes #7858
Part of #7858. This is the client part (E-client) of the de-duplication work: the first of three Engine PRs. The Agents side is Pasta-Devs/Marinara-Agents#1487, and it also closes Pasta-Devs/Marinara-Agents#1478.
Merge order: merge this first, before the E-server PR, which bumps the capability API to 1.341. Every Engine PR of this work merges to
stagingbefore the Agents PR.Why this change
The user problem. Agent package clients bundle copies of Engine client code, and some of those copies keep state of their own:
[youtube]command does nothing, and Calls' sticker dialogs hang (no dialog renderer). There are 12 separate React Query caches, and Escape can close two modals at once.How big the duplication is. The audit unzipped and hashed all 41 catalog packages. 16 code packages ship 26.25 MB of code, and about 16.2 MB of it (≈62%) copies something the Engine already has:
What this PR does about it. It gives package clients one place to take the Engine's live stores, services and libraries from,
globalThis.__MARINARA_HOST__. The Agents PR then rebuilds the packages to use it instead of carrying copies.Lead decisions (binding; made by the lead while the maintainer was away):
globalThis.__MARINARA_HOST__ = { version: 1, ... }. There is no__MARINARA_HOST_UI_STORE__alias, because it was never published. The in-flight bridge is renamed here.engine.min. Engines without the members never install them and keep their installed version working. Theuiandchatstore adapters keep a read-only fallback that never writes. A package never falls back to a bundled copy of a stateful Engine service; it reports the feature unavailable instead.session.chatId). Noodle and Slurp hide the chat-scoped emoji-selection settings. (Agents side.)versions/.stagingbefore the Agents PR.Contract decisions this PR relies on:
initReactI18next,setI18norsetDefaults(documented).Closes #7858, because the PR template check needs a closing keyword and merges intostagingdo not close issues.Choices made in this PR (conservative; please check):
import()for the whole namespace.lib/marinara-host.tsimports its members statically, and the package loader loads that module with oneimport()before the first package client. The in-flight draft used oneimport()per member instead. Both keep every member out of startup, but per-memberimport()made Vite warn thatui.store.tsandModal.tsx"will not move into another chunk". An Engine with no package clients never loads the module.origin/stagingbuild:moduleshas to be the whole library namespace, so the build can no longer drop the unused exports of framer-motion, React Query, zod,zustand/middlewareand tailwind-merge.vite.config.tsputs allnode_modulescode in the vendor chunks, and those load at startup.vite.config.tswarns about.packages/clientnow depends onzoddirectly (^3.25.76, the same rangepackages/shareduses), and pnpm resolves both tozod@3.25.76. The production build still has exactly one copy:grep -c ZodErrormatches 1 line in 1 file, and there is onename="ZodError"class, the same asstaging.tsconfig.client-lanes.json, which now sets"jsx": "react-jsx"because the contract type refers toModal. That pulleduse-dialog-focus-scope.tsinto anoUncheckedIndexedAccesscompile. I rewrote its empty-list check to testfirstandlastdirectly, which behaves the same.openCharacteris not pinned among the UI store fields: Noodle reads it from its own capability props, not from the Engine's UI store.fix/ready-engine-ui-store-guard), as the lead's task asked, rather than the contract's suggestedfix/7858-host-namespace.What changed
globalThis.__MARINARA_HOST__(version 1). The property is not writable or configurable, and the namespace is frozen. It contains:ui,chat,agent,sidecar,dialog,gallery,encounter,gameStateandbackfillstoresservices.ttsandservices.dialogsmodules(React, React DOM, React Query, zustand, sonner, zod, i18next, react-i18next, framer-motion, tailwind-merge, clsx and their listed subpaths)queryClientcomponents.Modal,data.emojiCatalogandapipackages/client/src/lib/marinara-host-contract.tsis the exported contract for package authors. It holds:MarinaraHostV1typeMARINARA_HOST_STORE_FIELDS, which pins withPick<>every store field published packages read, so dropping one fails the buildmain.tsxtolib/query-client.ts. It is still one instance, and its defaults are unchanged.marinara-engine-ui:hostcopy.docs/development/optional-agent-packages.mdreplaces "Host UI settings store" with "Host client namespace". It covers:<Toaster>orQueryClient, the i18n rule, the D4 major rule)scripts/regressions/marinara-host-namespace.regression.tse2e/marinara-host-namespace.e2e.tse2e/ui-store-foreign-write.e2e.tsreads the namespace and gets write-origin checkse2e/host-package-fixture.tsValidation
pnpm checkpasses locallyCONTRIBUTING.mdWhat the agent ran (the boxes above are left for a human):
pnpm install --frozen-lockfile --prefer-offline: the lockfile is unchanged apart from thezodimporter line.pnpm check: passes. One lint warning remains, and it was already there (HomeProfessorMariChat.tsx).pnpm localization:check: passes. There is no new UI copy.node scripts/run-regressions.mjs --filter scripts/regressions/marinara-host-namespace.regression.tspasses. Its two negative controls fail as they should:tscwith TS2344.command-center(the omnibar layer),capability-package-lifecycle,setup-escape-overlay-guardandtts-safari-play-guard.--project=desktop-chromium --workers=2, against my own dev server pair with its own data folder): all 8 tests pass, 3 ine2e/marinara-host-namespace.e2e.tsand 5 ine2e/ui-store-foreign-write.e2e.ts./src/stores/*.tsmodule, andqueryClientis the app's instance. All 14 libraries give their sample exports. The property cannot be overwritten, and the namespace is frozen.stores.chatfollows the chat the user opens. It sees the user open another chat from the sidebar. It also seesisStreamingandstreamingChatIdwhile a stub OpenAI-compatible server holds the reply open.z-index: 10020overlay is visible, focused and topmost, and it can be clicked.Storage.prototype.setItemandremoveItemand keeps the calling frame of every write. No write tomarinara-engine-ui,marinara-active-chat-id,marinara-input-draftsor another Engine-owned key came from the package's code. The Engine's own store and chat store did make the expected writes.marinara-engine-uiitself.topLayer, the dialog test fails because the overlay is on top.assigned-chat-sweep,capability-permissions,game-experience-setup,game-experience-startup,agent-apps-category,command-paletteandconversation-video-galleryload fixture package clients through the new path. 48 tests passed, and 3 mobile-only ones were skipped.pnpm build, then the production server):react-dom/client. It used a host zustand store and the host React Query, and its query landed in the Engine's cache.sonnertoast showed in the Engine's only Toaster ([data-sonner-toaster]count 1).__MARINARA_HOST__.modules.react.useStateis a function, and there were no page errors.Manual verification notes
Claim boundary (compatibility path):
useCapabilityClientModules,main.tsx,AppDialogRenderer/Modal, and the UI store's persist storage.globalThis.ReactandReactDOM, which are keptDocs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Docs:
docs/development/optional-agent-packages.md: the "Host client namespace" section.packages/client/.instructions.md: the QueryClient is now inlib/query-client.ts.No
CHANGELOG.mdentry and no version bump. The held release translation PR covers the translated docs, so no[docs-i18n]issue was opened.UI evidence (if applicable)
There is no visual change, except that app dialogs now sit on the top layer.
e2e/marinara-host-namespace.e2e.tschecks a confirm dialog over a package overlay.Summary by CodeRabbit
New Features
Bug Fixes
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.