fix(events): put every generated hook execution on the Flight render path - #292
Merged
Conversation
…rker Standalone and fallback event-route wrappers no longer evaluate route components with a manual element walker: the bundle emits one shared hooks-flight.mjs react-server worker per target, and the wrapper dispatches the same kind:'event' render request the warm runtime uses, then projects the resulting Agent Document into the unchanged native hook envelope.
…event routes The composite plugin artifact's event runtime validated and projected with the literal 'plugin' target, which projectEventDocument rejects, and the shared wrapper's host detection had no Cursor branch. The Cursor wrapper variant now bakes its concrete target, the shared runtime validates request.target against the artifact's allowed hosts, and props, host identity, and projection all use the concrete host.
🦋 Changeset detectedLatest commit: 0ca8e11 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
Audit + close-out for the USER directive "ensure flight loader used for all the hooks etc like we discussed and planned and mentioned in the git issues", against the #107 Revision 3 architecture (MCP tools and host hooks are internal Flight render requests against the warm runtime; Flight stays internal; standalone is an explicit degraded mode, never a different renderer).
Two hook execution paths violated the plan; both are fixed here:
Standalone event routes now render through the real Flight renderer.
runtime: 'standalone'/fallback: 'standalone'wrappers previously evaluated route components with a manual element walker (resolveServerNode) — the exact sync-element-walker pattern Build a real RSC Agent Document renderer with streaming semantics #96 retired; it could not execute Suspense/async React semantics. The bundle now emits one sharedhooks/hooks-flight.mjsreact-server worker per target, and the wrapper dispatches the samekind: 'event'render request the warm runtime uses (createAgentRenderDispatcher→ Flight render →AgentDocument→projectEventDocument), with the same request-identity axes (host/session/workspace) the warm path derives. The manual walker is deleted. Native hook envelopes are unchanged.Composite
pluginartifacts can now execute shared event routes at all. The wrapper's host detection had no Cursor branch, andstartEventRuntimeignored the IPC request'starget, projecting with the literal'plugin'— whichprojectEventDocumentrejects by design. The Cursor wrapper variant now bakestarget = "cursor"at codegen; the shared Claude/Codex wrapper keeps evidence-based detection (PLUGIN_ROOTis pinned Codex capability data); the event runtime validatesrequest.targetagainst the artifact's allowed hosts (fail-closed transport error otherwise) and uses the concrete host for props, request host identity, and projection. Endpoint identity derivation is unchanged.Audit result (path → Flight or bypass)
renderGeneratedRoute→ dispatcher →createFlightWorkerHost)requestEventRuntimeIPC → warm runtimeplugin'plugin'target; no Cursor detection)workspace/openunavailableeverywhere (#221)nativeHooks.tsx),routes.mcpCommands, rendered scripts.ts)runRscCli/createRscMcpServersync lowerersPositive pins added (regressions now fail red)
tool/afterandsession/start— sameprocessLifetime.instanceIdobserved across four consecutive events, per-host exact native output envelopes, and a disallowedtargetrejected as a transport failure.hooks-flight.mjsreference, and dispatcher usage.tests/route-unit/event-project.test.ts) instead of the walker.Parity notes
examples/rsc-agent-runtime's standalonetool/afterroute passes unchanged.Test plan
pnpm typecheckpnpm lintpnpm test(unit + route-unit + projection + integration)pnpm test:packed(packed journey pool)Pre-existing failure on main (not from this PR)
packages/workbench/tests/examples-real.e2e.test.ts:635fails on cleanorigin/main(verified in a pristine worktree at9c767c98b) exactly as it does on this branch: the audiobook Workbench "CLI commands" table renders 30 rows where the pin expects 15 (an exact doubling). This lane's diff does not touch CLI command projection or the Workbench; the drift comes from one of today's installer/bin landings. Reported for a fixer lane; not addressed here.