Skip to content

Comments

refactor: decompose App.ts into focused modules#336

Open
koala73 wants to merge 1 commit intomainfrom
refactor/decompose-app-ts
Open

refactor: decompose App.ts into focused modules#336
koala73 wants to merge 1 commit intomainfrom
refactor/decompose-app-ts

Conversation

@koala73
Copy link
Owner

@koala73 koala73 commented Feb 24, 2026

Summary

  • Breaks the 4,597-line monolithic App.ts class (97 methods, 60+ properties) into 7 focused modules under src/app/, leaving App.ts as a ~460-line thin orchestrator
  • Each module implements the AppModule lifecycle contract (init/destroy) and communicates via a shared AppContext state object with narrow callback interfaces — no circular dependencies
  • All cross-module calls use constructor-injected callbacks (e.g., DataLoaderCallbacks, SearchManagerCallbacks), so modules never import each other

Modules extracted

Module Lines Responsibility
app-context.ts 88 Shared state types (AppContext, AppModule, etc.)
desktop-updater.ts 198 Desktop version checking + update badge
country-intel.ts 530 Country briefs, timeline, CII signals
search-manager.ts 448 Search modal, result routing, index updates
refresh-scheduler.ts 108 Periodic data refresh with jitter/backoff
panel-layout.ts 853 Panel creation, grid layout, drag-drop
data-loader.ts 1,522 All 36 data loading methods
event-handlers.ts 685 DOM events, shortcuts, idle detection, URL sync

Test plan

  • tsc --noEmit — zero errors
  • npm run build:full — passes
  • npm run build:tech — passes
  • npm run build:finance — passes
  • Runtime smoke test: app loads, panels render, map layers toggle
  • Search (Cmd+K): modal opens, returns results
  • Variant switch (WORLD → TECH): correct panels + layers load
  • Console errors: only pre-existing API/CORS issues, no regressions
  • Module call chains confirmed in console stack traces (data-loader.ts, search-manager.ts, event-handlers.ts)
  • Deep links (?country=UA, /story?c=UA) — requires production data availability
  • Desktop (Tauri) update badge flow

Break the 4,597-line monolithic App class into 7 focused modules plus a
~460-line thin orchestrator. Each module implements the AppModule lifecycle
(init/destroy) and communicates via a shared AppContext state object with
narrow callback interfaces — no circular dependencies.

Modules extracted:
- app-context.ts: shared state types (AppContext, AppModule, etc.)
- desktop-updater.ts: desktop version checking + update badge
- country-intel.ts: country briefs, timeline, CII signals
- search-manager.ts: search modal, result routing, index updates
- refresh-scheduler.ts: periodic data refresh with jitter/backoff
- panel-layout.ts: panel creation, grid layout, drag-drop
- data-loader.ts: all 36 data loading methods
- event-handlers.ts: DOM events, shortcuts, idle detection, URL sync

Verified: tsc --noEmit (zero errors), all 3 variant builds pass
(full, tech, finance), runtime smoke test confirms no regressions.
@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Ready Ready Preview, Comment Feb 24, 2026 6:41pm
worldmonitor-finance Ready Ready Preview, Comment Feb 24, 2026 6:41pm
worldmonitor-happy Ready Ready Preview, Comment Feb 24, 2026 6:41pm
worldmonitor-startup Ready Ready Preview, Comment Feb 24, 2026 6:41pm

Request Review

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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