Skip to content

refactor(studio): decompose App.tsx non-React corpus into feature modules and shared utilities#1608

Merged
mateicanavra merged 4 commits into
mainfrom
design/app-decompose
Jun 12, 2026
Merged

refactor(studio): decompose App.tsx non-React corpus into feature modules and shared utilities#1608
mateicanavra merged 4 commits into
mainfrom
design/app-decompose

Conversation

@mateicanavra

Copy link
Copy Markdown
Owner

This PR performs a behavior-preserving structural extraction of the non-React helper corpus from App.tsx into focused feature modules, reducing the file from a 3,000+ line god-module to a leaner authoring closure.

The ~535 lines of inline helpers — fetch wrappers, config builders, deterministic merge/path utilities, preset adapters, Civ7 setup option helpers, localStorage key constants, and shared predicates — are moved verbatim into named modules under features/* and shared/:

  • features/mapConfigSave/api.tstoConfigId, saveRepoBackedConfig, fetchMapConfigSaveDeployStatus, MAP_CONFIG_SAVE_LAST_REQUEST_KEY
  • features/runInGame/api.tsrunCurrentConfigInGame, fetchRunInGameStatus
  • features/runInGame/sourceSnapshotStorage.tsreadStoredRunInGameSourceSnapshot and the RUN_IN_GAME_LAST_* localStorage keys
  • features/runInGame/liveSource.tsliveSourceMatchesStudio, LastRunSnapshot
  • features/civ7Setup/api.tsfetchCiv7SetupConfig, fetchCiv7SavedSetupConfigs, fetchCiv7SetupCatalog, requestCiv7Autoplay, and the Civ7SetupCatalog types
  • features/civ7Setup/setupOptions.tsfindSetupParameterLike, ensureSelectOption, mergeSelectOptions, setupCatalogOptions
  • features/civ7Setup/livePreset.tsLIVE_GAME_PRESET_ID, LIVE_GAME_PRESET_KEY
  • features/configOverrides/configBuilders.tsisPlainObject, mergeDeterministic, setAtPath, buildConfigSkeleton, buildDefaultConfig, applyPresetConfig, formatPresetErrors, and related types
  • features/presets/repoBacked.tsmergeBuiltInPresets, toRepoBackedPreset
  • features/presets/dialogState.tsPresetErrorState
  • shared/async.tsdelay, isAbortLikeError
  • shared/number.tsclampNumber

App.tsx replaces all inline definitions with imports. No logic is rewritten; the AppContent closure is unchanged except at import sites. localStorage key strings are preserved verbatim to maintain the persistence contract across dev-server reloads.

An accompanying OpenSpec change set documents the decomposition design, requirements, and task checklist. The FRAME constraint document is updated to record the directive that all API communication must go through oRPC rather than hand-rolled fetch, with the existing /api/* middleware to be lifted into effect-orpc procedures in a later supervised step.

The container/presentational store-reading split for RecipeConfigPanel, ExploreController, and AppFooter is explicitly deferred to the post-stores decomposition slice, as it depends on the not-yet-landed Zustand/TanStack Query client-data layer.

mateicanavra commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions

Copy link
Copy Markdown

Railway preview (MapGen Studio): not provisioned for this PR.

Policy (Graphite stacks): previews are created only for the top-of-stack PR by default.

  • To force a preview for this PR: add label railway-preview
  • To suppress a preview: add label no-railway-preview

Debug: {"isClosed":false,"isFork":false,"suppress":false,"force":false,"isTopOfStack":false,"hasToken":true,"draft":false}

This was referenced Jun 12, 2026

mateicanavra commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

Merge activity

  • Jun 12, 8:50 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 12, 8:58 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 12, 8:58 PM UTC: @mateicanavra merged this pull request with Graphite.

@mateicanavra
mateicanavra changed the base branch from design/shell-reskin to graphite-base/1608 June 12, 2026 20:55
@mateicanavra
mateicanavra changed the base branch from graphite-base/1608 to main June 12, 2026 20:56
mateicanavra and others added 4 commits June 12, 2026 20:57
…g extraction

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… feature modules

Behavior-preserving MOVE of the ~535 LoC of non-React helpers from the top of
App.tsx into focused feature modules. No logic changes: every helper is byte-for-
byte identical, only relocated, and App.tsx re-imports them.

- features/mapConfigSave/api.ts: toConfigId, saveRepoBackedConfig,
  fetchMapConfigSaveDeployStatus, MAP_CONFIG_SAVE_LAST_REQUEST_KEY
- features/runInGame/{api,sourceSnapshotStorage,liveSource}.ts
- features/civ7Setup/{api,setupOptions,livePreset}.ts
- features/configOverrides/configBuilders.ts (merge/path/config builders)
- features/presets/{repoBacked,dialogState}.ts
- shared/{async,number}.ts

localStorage key strings preserved verbatim (persistence contract). tsc clean;
prod build + worker-bundle check pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ever hand-roll fetch

User directive 2026-06-09. Studio talks to CIV through the control-oRPC client +
contract behind one typed LiveControlPort (oRPC-native TanStack Query; studio-server
proxies control-oRPC, never re-implements CIV API calls). No new manual /api fetch;
existing /api/civ7/* middleware wrapped behind the port then deleted when the client
lands. No FireTuner.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…C too, server un-deferred

User reaffirmed: no manual fetch of our own /api either. Studio exposes its own
effect-orpc contract+server (contracts already scaffolded), client consumes via
oRPC client + oRPC-native TanStack Query. Server NOT deferred (uses direct-control,
on main). Existing /api lifted verbatim into effect-orpc procedures (parity); Bun
topology + prod parity = later supervised step. Data layer precedes decomposition.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mateicanavra
mateicanavra force-pushed the design/app-decompose branch from 5af226e to e4e7c87 Compare June 12, 2026 20:57
@mateicanavra
mateicanavra merged commit 252e64b into main Jun 12, 2026
This was referenced Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant