refactor(shell): extract @etherpad/shell + Platform injection seam (Phase 2a)#32
Merged
Merged
Conversation
Plan for Phase 2a of the mobile rollout: move renderer + shared code into a new @etherpad/shell workspace package and introduce a Platform injection seam (setPlatform/getPlatform). The abstract Platform sub-interfaces (storage/padView/events) from spec §4 are intentionally deferred to Phase 2b once mobile is a real consumer driving the shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move ipc/api.ts to platform/ipc.ts. Rename the internal RuntimeApi to the public Platform interface and add setPlatform()/getPlatform()/ __resetPlatformForTests(). Desktop's renderer index.tsx now calls setPlatform(createElectronPlatform()) before mounting App, decoupling shell from window.etherpadDesktop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Set up shell's own jsdom vitest project with a buildMockPlatform() helper
in tests/setup.ts. Install a compatibility shim that routes legacy
`window.etherpadDesktop = {...}` mutations through setPlatform() so the
existing test code continues to work unchanged.
Drop the renderer project from desktop vitest config — desktop only runs
the main project now. tsconfig.tests.json widened to include the new
spec files. Fixed pre-existing latent type errors in 4 tests that vitest
was silently tolerating (JSX.Element → React.JSX.Element, Settings
literal missing fields).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
typecheck/test/lint now run across both @etherpad/shell and @etherpad/desktop via `pnpm -r --workspace-concurrency=1 <script>`. Adds shell's eslint config + devDeps so the new package participates in CI lint. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Root CLAUDE.md monorepo section lists both packages now. Desktop's AGENTS.md drops the dead `src/renderer/` / `src/shared/` paths and points at packages/shell for shell-side code. New packages/shell/AGENTS.md gives the package its own orientation doc. Root README lists shell in the package table. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
App.tsx no longer reads window.etherpadDesktop.e2eFlags. Shell now exports a pure attachE2EHelpers(target) function and desktop's renderer/index.tsx invokes it conditionally when the preload reports e2eFlags.enabled. Shell src/ is now fully decoupled from runtime-specific globals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2a of the mobile rollout (spec §11.2, plan
docs/superpowers/plans/2026-05-11-etherpad-mobile-phase2a-shell-extract.md):@etherpad/shellcontaining the renderer code(
App.tsx, components, dialogs, rail, sidebar, state, tabs, i18n, styles)and the previously-shared modules (
ipc,types,validation,locales,url.ts).Platforminterface andsetPlatform()/getPlatform()/__resetPlatformForTests()seam inpackages/shell/src/platform/ipc.ts.Shape mirrors today's preload API verbatim — abstract sub-interfaces
(
storage/padView/events) from spec §4 are intentionally deferredto Phase 2b once mobile is a real consumer driving the shape.
packages/desktop/src/renderer/index.tsxwires a thincreateElectronPlatform()adapter at boot before mounting the shell<App />.E2E test seam moved out of
App.tsxinto a pureattachE2EHelpers()exportthat desktop invokes conditionally — shell src is now fully decoupled from
runtime-specific globals.
packages/shell/tests/with their own vitestjsdom project and a
buildMockPlatform()helper. Legacywindow.etherpadDesktop = {...}test patterns still work via acompatibility shim that routes assignments through
setPlatform().Fixed 4 pre-existing latent type errors that vitest was silently tolerating.
pnpm typecheck/test/lintnow recurse across both packagesvia
pnpm -r --workspace-concurrency=1 <script>.CLAUDE.mdmonorepo section,README.mdpackagetable,
packages/desktop/AGENTS.mdshell pointers, newpackages/shell/AGENTS.md.Zero behavioural change to the desktop app. Both packages typecheck, lint,
and test cleanly. The shell's stylesheet + entry point still mount inside
desktop's Vite renderer build exactly as before.
Stacked plan: this branch was cut off
mainafter PR #30 (Phase 1 recovery)merged. Phase 2b will introduce the abstract
Platformsub-interfacesonce
packages/mobileexists to drive their shape.Test plan
pnpm typecheck(composite project refs across shell + desktop)pnpm test(204 shell + 281 desktop = 485, same total as pre-refactor)pnpm test:e2e(Playwright Electron, unchanged surface)window.etherpadDesktopreads insidepackages/shell/src/(only a doc comment)electron/@capacitor/*insidepackages/shell/src/🤖 Generated with Claude Code