[GH-ISSUE #1575] [Feature]: Make AppShell startup imports use lightweight mode and catalog entrypoints #815

Closed
opened 2026-10-21 05:21:27 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Xelvanis on GitHub (May 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1575

Originally assigned to: @cha1latte on GitHub.

What problem does this solve?

pnpm build still emits the Vite large chunk warning. Rollup module metadata shows the startup entry includes heavy game, shared chat UI, and catalog/chat modules that should stay behind lazy route or panel boundaries.

Observed eager paths:

  • src/features/shell/notifications/components/ChatNotificationBubbles.tsx imports useGameModeStore from ../../../modes/game.
  • src/features/modes/game/index.ts re-exports GameSurface, GameModeRoute, game stores, and game asset helpers from one broad barrel.
  • src/app/shell/AppShell.tsx imports useClearAutonomousUnread from ../../features/catalog/chats/index.
  • src/features/catalog/chats/index.ts re-exports hooks/use-chats.ts, which imports prompt preview, summary backfill, transcript export, storage APIs, and other heavy chat utilities.

This makes shell startup pay for route/editor/runtime code that should be loaded only when the relevant mode or panel is used.

Proposed behavior

Add focused lightweight public entrypoints for startup-safe APIs and update shell imports to use them.

Examples of the desired shape:

  • expose the game setup/reset store API from a small game-owned entrypoint instead of the full game mode barrel;
  • expose useClearAutonomousUnread from a narrow chat-owned module instead of the full use-chats.ts barrel;
  • import catalog query keys and character invalidation helpers from narrow modules instead of broad catalog barrels where startup code only needs cache keys or invalidation;
  • keep GameSurface, ConversationView, ChatMessage, editor panels, and route components behind their existing lazy route/panel imports.

Expected owner or impact area

  • App shell, navigation, startup, or providers
  • Catalog resources: chats, characters, personas, lorebooks, presets, connections, agents, gallery, or knowledge
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Refactor branch considerations

Keep the public entrypoints feature-owned and narrow. Avoid solving this by deep-importing feature internals from the app shell or by creating a new broad compatibility barrel.

Acceptance checks:

  • pnpm build passes.
  • The largest startup entry no longer includes src/features/modes/game/components/GameSurface.tsx, GameNarration.tsx, GameSetupWizard.tsx, or src/features/modes/game/api/game-api.ts through shell notification imports.
  • Chat notification navigation still clears game setup state when appropriate.
  • Clearing autonomous unread still updates chat detail/list query state.

Alternatives considered

Leaving the broad barrels in place and only adding manualChunks would hide part of the symptom but keep startup imports coupled to unrelated feature owners.

Additional context

This is one implementation slice under #1532.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1575 Originally assigned to: @cha1latte on GitHub. ## What problem does this solve? `pnpm build` still emits the Vite large chunk warning. Rollup module metadata shows the startup entry includes heavy game, shared chat UI, and catalog/chat modules that should stay behind lazy route or panel boundaries. Observed eager paths: - `src/features/shell/notifications/components/ChatNotificationBubbles.tsx` imports `useGameModeStore` from `../../../modes/game`. - `src/features/modes/game/index.ts` re-exports `GameSurface`, `GameModeRoute`, game stores, and game asset helpers from one broad barrel. - `src/app/shell/AppShell.tsx` imports `useClearAutonomousUnread` from `../../features/catalog/chats/index`. - `src/features/catalog/chats/index.ts` re-exports `hooks/use-chats.ts`, which imports prompt preview, summary backfill, transcript export, storage APIs, and other heavy chat utilities. This makes shell startup pay for route/editor/runtime code that should be loaded only when the relevant mode or panel is used. ## Proposed behavior Add focused lightweight public entrypoints for startup-safe APIs and update shell imports to use them. Examples of the desired shape: - expose the game setup/reset store API from a small game-owned entrypoint instead of the full game mode barrel; - expose `useClearAutonomousUnread` from a narrow chat-owned module instead of the full `use-chats.ts` barrel; - import catalog query keys and character invalidation helpers from narrow modules instead of broad catalog barrels where startup code only needs cache keys or invalidation; - keep `GameSurface`, `ConversationView`, `ChatMessage`, editor panels, and route components behind their existing lazy route/panel imports. ## Expected owner or impact area - [x] App shell, navigation, startup, or providers - [x] Catalog resources: chats, characters, personas, lorebooks, presets, connections, agents, gallery, or knowledge - [x] Chat mode - [ ] Roleplay mode - [x] Game mode - [x] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [ ] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Refactor branch considerations Keep the public entrypoints feature-owned and narrow. Avoid solving this by deep-importing feature internals from the app shell or by creating a new broad compatibility barrel. Acceptance checks: - `pnpm build` passes. - The largest startup entry no longer includes `src/features/modes/game/components/GameSurface.tsx`, `GameNarration.tsx`, `GameSetupWizard.tsx`, or `src/features/modes/game/api/game-api.ts` through shell notification imports. - Chat notification navigation still clears game setup state when appropriate. - Clearing autonomous unread still updates chat detail/list query state. ## Alternatives considered Leaving the broad barrels in place and only adding `manualChunks` would hide part of the symptom but keep startup imports coupled to unrelated feature owners. ## Additional context This is one implementation slice under #1532. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@cha1latte commented on GitHub (May 29, 2026):

Triage note: labeling this as normal-scope because it narrows eager AppShell imports behind existing lightweight mode and catalog entrypoints without changing product behavior.

A good next step is a focused startup-bundle cleanup with build-size proof.

<!-- gh-comment-id:4578272206 --> @cha1latte commented on GitHub (May 29, 2026): Triage note: labeling this as `normal-scope` because it narrows eager AppShell imports behind existing lightweight mode and catalog entrypoints without changing product behavior. A good next step is a focused startup-bundle cleanup with build-size proof.
Author
Owner

@cha1latte commented on GitHub (May 31, 2026):

#1711 fixed the chat-side narrow entrypoint and moved notification bubbles behind a lazy AppShell boundary, so startup no longer eagerly pays for that optional surface.

Leaving this open for the remaining intended fix: ChatNotificationBubbles still imports useGameModeStore from the broad game barrel, and src/features/modes/game/index.ts still re-exports GameSurface/GameModeRoute alongside stores. The original issue asked for a small game-owned startup-safe entrypoint for setup/reset state, so that structural piece is not done yet.

<!-- gh-comment-id:4587892250 --> @cha1latte commented on GitHub (May 31, 2026): #1711 fixed the chat-side narrow entrypoint and moved notification bubbles behind a lazy AppShell boundary, so startup no longer eagerly pays for that optional surface. Leaving this open for the remaining intended fix: ChatNotificationBubbles still imports useGameModeStore from the broad game barrel, and src/features/modes/game/index.ts still re-exports GameSurface/GameModeRoute alongside stores. The original issue asked for a small game-owned startup-safe entrypoint for setup/reset state, so that structural piece is not done yet.
Author
Owner

@cha1latte commented on GitHub (May 31, 2026):

fixed in #1746

<!-- gh-comment-id:4587978991 --> @cha1latte commented on GitHub (May 31, 2026): fixed in #1746
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#815
No description provided.