Repository navigation
refactor(core): tidy plugin host and config reload wiring - #61176
Conversation
There was a problem hiding this comment.
Looks good. It's a behaviour-preserving refactor as described. I checked each extraction against the old code: snapshot() reads discovered, which equals failures at both rebuilds that used it, and PluginModule.source matches both old call sites. Built-ins tagged in PluginInternal.list reach the supervisor unchanged. observeSources keeps the subscribe-before-scan order. tsc -b passes, the config and plugin tests pass (836 pass, 1 skip), and a TUI smoke test with a project-local agent and command behaves the same as on the base.
Public API: unchanged (all changes are internal to packages/core).
One small fix: a comment ended up above the wrong function in module.ts (inline).
| @@ -60,6 +60,12 @@ export const make = Effect.fn("PluginModule.make")(function* () { | |||
|
|
|||
| // A missing dependency may have missing parents too. Watch the nearest existing | |||
There was a problem hiding this comment.
The "A missing dependency may have missing parents too…" comment describes watchTarget, but it now sits above source(), so it reads as documentation for the wrong function. Could you move those two lines back above watchTarget?
Problem
The plugin host and a couple of config plugins had the same code copied in a few places, so a fix to one copy could easily miss the others.
Change
I pulled each repeat into one place. Behavior should be the same.
observeSourceskeeps the old order: it subscribes to config changes andconfig.updatedbefore the first scan.Out of scope
methodImplementationin host.ts: merging thecommandandexternalbranches, or theenvbranch with the fallback, doesn't typecheck without casts, so I left them separate.builtin/server: truedefaults for duplicate-ID failures in supervisor.ts: there are only two short copies in different modules, and sharing them would need a new export.Verification
bun typecheckin packages/corebun test test/config test/plugin test/plugin.test.ts test/plugin-failure.test.ts test/model-plugins.test.tsin packages/core: 837 passbun run checkfrom the root