refactor(desktop): share the feature services context and pass bridge namespaces through - #4590
refactor(desktop): share the feature services context and pass bridge namespaces through#4590chihumyum wants to merge 1 commit into
Conversation
… namespaces through Add application/contracts/feature-services.tsx with createServicesContext, and derive every feature slice's ServicesProvider/useServices pair from it instead of restating the same createContext boilerplate nine times; every exported name, type, and error message is unchanged. Where a Desktop adapter's port is a structural subset of one bridge namespace, hand the namespace through (sessions, newTasks, scheduledTasks, shellRuns, todo, attachments) instead of restating each method. Blocks that rename, guard, filter, or translate stay hand-written: the adapter tests drive Proxy-based bridge recorders without own keys, so a spread would copy nothing there, and passing the object keeps late binding everywhere. Generated-by: Claude Code
512b255 to
ccc75c1
Compare
|
The first CI run failed only in Desktop e2e, on Automated update from Claude Code on behalf of the PR author. |
Summary
Nine feature slices each restate the same twenty-line services context and hand-write Desktop adapter forwarders whose signatures equal the bridge methods they forward to (the per-slice join cost Astro-Han measured on #3439: identical
services-context.tsxfiles, and adapters equivalent to{ sessions: bridge.sessions }). This PR removes the restatement without changing any port, consumer, or behavior.application/contracts/feature-services.tsxexportscreateServicesContext<S>(providerName), returning the Provider/hook pair.application/contractsis the one renderer zone every feature may import. Each slice'sservices-context.tsxis now four lines; every exported name, type, and error message (<Feature>ServicesProvider is missing) is unchanged, andconnection-settingskeeps its two extra components.sessions: bridge.sessions(Session Navigation),catalog: bridge.newTasks(Task Entry),scheduledTasks: bridge.scheduledTasks(Module Hub), andterminal: bridge.shellRuns,todo: bridge.todo,attachments: bridge.attachments(Workbar) — 33 identity forwarders gone. Blocks that rename, guard, filter, or translate (goal,skills,dailyReview,browser,artifacts,inspector,review,sideChat,sessionCollaboration,peerMesh) stay hand-written. I tried{ ...bridge.ns, <adaptation> }for those and backed it out: the adapter tests drive Proxy-based bridge recorders that have no own keys, so a spread copies nothing, and the same would hold for any bridge double built that way. Passing the namespace object itself keeps late binding and works with every double.thisusage, so passing one through is runtime-safe, and the port types stay narrow, so nothing new is reachable from feature code.Net: 91 lines removed across 17 files.
composition/desktop-feature-services.tsxis deliberately untouched; the tenth slice from refactor(desktop): move App Update controller below AppShell #4498 can adopt the factory after it lands.Refs #4582
Verification
On the exact head, under Node 24, all green:
npm --workspace @maka/desktop run test:dist— 1969/1969npm --workspace @maka/desktop run typecheck— preload, main, renderer, storybooknpm run lint,npm run format:checknpm run check:renderer-architecture -- --base upstream/main,npm run check:app-shell-hooks(42 hooks / 78 call sites, unchanged)npm run astryx:surface-inventory(regenerated for the new file),npx knip --workspace apps/desktop,npm run check:asf-headers,git diff --checknpm --workspace @maka/desktop run build:rendererrenderer-architecture.jsonneeded no regeneration beyond the rebase:application/contractsis an explicit owner zone, so the new file is governed by zone rules rather than recorded as debt.AI use
Select exactly one:
Tool(s) and scope: Claude Code — implementation and local validation. The commit carries a
Generated-by: Claude Codetrailer.Checklist
Does this PR entail a change in behavior?