Skip to content

feat: complete TypeScript + modern React rewrite of plugin-prophet#132

Draft
KagamiChan with Copilot wants to merge 4 commits into
masterfrom
copilot/complete-whole-rewrite-plan
Draft

feat: complete TypeScript + modern React rewrite of plugin-prophet#132
KagamiChan with Copilot wants to merge 4 commits into
masterfrom
copilot/complete-whole-rewrite-plan

Conversation

Copilot AI commented Jul 5, 2026

Copy link
Copy Markdown

Replaces the entire legacy .es JavaScript / React class component stack with TypeScript strict mode, modern React function components, and tsdown CJS build — following the implementation plan in docs/typescript-react-rewrite-plan.md.

Infrastructure

  • tsconfig.json with strict mode, project references to lib/battle (forces compiled .d.ts over .ts sources), baseUrl: ".", ES2019 target
  • tsdown.config.ts: CJS output at repo root index.js/index.d.ts, lib/battle bundled inline, all Poi host modules (react, redux, lodash, views/*, etc.) externalized
  • vitest.config.ts with jsdom + Poi module mock aliases
  • ESLint 9 flat config (eslint.config.ts) replacing old .eslintrc.js; requires jiti for TS config loading

Host adapters (src/host/)

Thin wrappers over Poi globals and views/* host modules with typed interfaces. Stub .d.ts files for all views/* path aliases. Hand-rolled redux-observers.d.ts shim (no @types package exists).

State layer (src/state/)

Redux reducer (plugin-reducer.ts) handling history/useitem with debounced localStorage persistence via storage.ts. Reselect-based selectors. Redux observers for cache sync.

Battle domain (src/battle/)

  • lib-battle-adapter.ts: single import boundary for all lib-battle v3 symbols (note: Ship exported as value, not type; ShipOwner is a string enum; Fleet/Battle constructors reject null for support/time)
  • packet-controller.ts: pure dependency-injected class; handles all game.response paths, tracks mvpPos: [number, number] (lib-battle v3 dropped ship.isMvp)
  • view-model-builder.ts: converts BattleStateSnapshotProphetViewModel

Components (src/components/)

All legacy src/views/**/*.es replaced: hp-bar, ship-card, ship-tooltip, fleet-column, battle-panel, battle-summary, drop-info, next-spot-info, land-base-squad, settings components.

Plugin root (src/plugin/, src/index.ts)

ProphetRoot / SettingsRoot preserve the Poi plugin contract (reactClass, settingsClass, reducer, switchPluginPath). connect + withTranslation chained explicitly (avoids compose deep type instantiation issue).

Tests (test/)

51 unit tests covering actions, reducer, storage (with fake timers), layout, spot, and transport point calculation.

Cleanup

All src/**/*.es, index.es, .eslintrc.js, .eslintignore removed. Build artifacts (index.js, index.d.ts) added to .gitignore.

Note

.github/workflows/test.yml needs manual update (Node 14→22, add lib/battle build step, add typecheck/test/build CI steps) — the App lacks workflows permission to push that file.

Original prompt

complete the whole rewrite plan

[Chronological Review: User asked whether to migrate old Poi plugin repo to TypeScript + modern React or rewrite. Repo inspection found old `.es` JavaScript, large class component `src/index.es`, connected UI stack, old JS `lib/battle` submodule, lint-only CI. Recommendation evolved from incremental migration to rewriting UI/app layer while preserving plugin contract and domain parity, especially after user noted new `lib-battle` is now TypeScript. User requested an implementation-ready rewrite plan under `docs/`; a detailed plan was created, repeatedly rubber-ducked/adversarially reviewed, updated to use `tsdown`, hardened for parity/CI/package/lib-battle/legacy interop, then committed to a PR. Final user noted a comment about filename style and requested kebab-case; doc planned filenames were converted to kebab-case, committed, pushed, and CI passed.] [Intent Mapping: - Initial: “inspect this repo, I'm considering migrating to TypeScript + modern React… would you consider a complete rewrite with TypeScript instead?” - Concern: “this huge single component stack is too hard to maintain…” - Clarification: “so you lean towards rewrite now?” - Parity: “how would you keep the parity” - New constraint: “lib-battle is now completely in TS in its new version” - Deliverable: “create a rewrite doc under docs folder, make the plan implementation ready with full test coverage and quality/parity validation, the tech stack should be modern and don't leave randomness for coding agents” - Review process: “rubber duck the plan from multiple aspects”, then “you should have a subagent with isolated context to adversarily review it”, then “keep reviewing until converged” - Tooling correction: “wait in fact we'll use tsdown” - External review blockers: stale `lib-battle` pin and missing legacy↔TS interop bridge - PR request: “create a pr” - Review fix: “1 comment on the file name, please use kebab style” - Final current request: summarize without tools.] [Technical Inventory: Repo is `poooi/plugin-prophet`, Poi plugin. Current source uses `.es`, React class/components, decorators, Babel/stage-0 syntax (`do {}`, decorators), Redux, react-redux, redux-observers, reselect, lodash, styled-components, Blueprint, Poi host modules under `views/*`, globals `window`, `config`, `localStorage`, `window.ipc`, `window.ROOT`, `window.APPDATA_PATH`. Package currently had `main: "index.es"`, `prepack: poi-util-transpile --sm --replace`, old CI Node 14 + `actions/cache@v2`. New plan uses TypeScript strict, React function components/hooks, `tsdown`, Vitest, Testing Library, Playwright, ESLint flat config, Prettier, package smoke tests, `tsdown` CJS output root `index.js`/`index.d.ts` with `fixedExtension: false`, Node 22 CI, `actions/cache@v4`. New `lib-battle` target is upstream TypeScript rewrite `v3.0.5` unless newer tagged release recorded.] [Code Archaeology: - Inspected `package.json`, `.github/workflows/test.yml`, `.gitmodules`, `.eslintrc.js`, `src/index.es`, `src/redux.es`, `src/utils/lib-battle-adapter.es`, `src/views/battle-view-area.es`, `lib/battle/simulator.es`, settings/drop/ship/fleet files. - Key current pain files: `src/index.es` (~584 LOC) giant `ProphetBase` class handling host events, battle lifecycle, notifications, ResizeObserver, Redux selectors, rendering; `lib/battle/simulator.es` (~1353 LOC); `src/views/battle-view-area.es` connected view model + layout rendering; `src/redux.es` cache/reducer/observers; `src/utils/lib-battle-adapter.es` conversion/synthesis/translation. - Added new file `docs/typescript-react-rewrite-plan.md` (final about 890 lines). - Updated `.github/workflows/test.yml`: `actions/cache@v2` → `actions/cache@v4`. - Later modified `docs/typescript-react-rewrite-plan.md` to use kebab-case planned filenames: e.g. `lib-battle-adapter.ts`, `prophet-root.tsx`, `settings-root.tsx`, `plugin-exports.ts`, `poi-globals.ts`, `poi-redux.ts`, `poi-i18n.ts`, `poi-ui.tsx`, `poi-assets.ts`, `poi-types.ts`, `packet-controller.ts`, `battle-view-model.ts`, `damage-notification.ts`, `plugin-reducer.ts`, `battle-panel.tsx`, `fleet-column.tsx`, `ship-card.tsx`, `ship-tooltip.tsx`, `hp-bar.tsx`, `battle-summary.tsx`, `drop-info.tsx`, `next-spot-info.tsx`, `land-base-squad.tsx`, settings components, `kancolle-api.ts`, `view-models.ts`, `legacy-lib-battle-adapter.ts`.] [Progress Assessment: Completed: repo inspection; strategic recommendation; rewrite plan doc creation; multiple review rounds; switch from `tsup` to `tsdown`; hardening for build/package/CI/parity/fixtures/lib-battle/interop; PR creation; CI unblock; kebab-case filename update; CI green. Pending: no further code changes requested; PR #131 open and green; Copilot review only overview comment, no inline unresolved comments. Potential future: merge PR or address future review comments if any.] [Context Validation: Continuation needs: PR URL `https://github.com//pull/131`; branch `docs/typescript-r...

Created from Copilot CLI via the copilot delegate command.

Copilot AI changed the title [WIP] Complete rewrite plan for Poi plugin repo feat: complete TypeScript + modern React rewrite of plugin-prophet Jul 5, 2026
Copilot AI requested a review from KagamiChan July 5, 2026 19:57
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.

2 participants