[APPS-2792] Add: dev:verify mode-aware routing for local execution (build-plugins half) - #490
Conversation
There was a problem hiding this comment.
Pull request overview
Friend, this PR adds mode-aware cloud verification routing to the Vite development server.
Changes:
- Adds the
dev-verifymode constant. - Routes the standard execution endpoint through cloud execution in verification mode.
- Adds coverage for the new routing behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
constants.ts |
Defines the verification mode. |
dev-server.ts |
Implements mode-aware routing. |
dev-server.test.ts |
Tests cloud routing in verification mode. |
index.ts |
Passes Vite’s resolved mode to the middleware. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This comment was marked as resolved.
This comment was marked as resolved.
6822e55 to
c37ab18
Compare
e979af2 to
e30cf71
Compare
e30cf71 to
2626d97
Compare
2626d97 to
7ec3cae
Compare
7ec3cae to
44b7d0c
Compare
44b7d0c to
6f4c565
Compare
6f4c565 to
cb7626e
Compare
cb7626e to
5196d11
Compare
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🔗 Commit SHA: 7c99f7f | Docs | View more details | Give us feedback! |
5196d11 to
5ec8c6e
Compare
47ede41 to
13015d1
Compare
13015d1 to
62a4d6f
Compare
62a4d6f to
ac8855c
Compare
ac8855c to
1089c4c
Compare
1089c4c to
cca298b
Compare
cca298b to
68bb17f
Compare
68bb17f to
9c45d6e
Compare
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. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
🔵 Needs a closer look
The middleware’s mode remains optional, allowing callers to silently bypass mode-aware routing.
Review details
Suppressed comments (1)
packages/plugins/apps/src/vite/dev-server.ts:589
- The default initializer still makes
modeoptional at TypeScript call sites, so an omitted value silently selects local execution even though routing now depends on this argument. Makemoderequired as described and have the test helper pass an explicit'development'value when no override is supplied.
mode: string = 'development',
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
- Review effort level: Balanced
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… mode Adds `npm run dev:verify`, which starts the dev server with Vite's mode set to `dev-verify` so `/__dd/executeAction` calls route through the same queue + Deno subprocess round trip as production instead of the local in-process path, for pre-publish parity checks.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
Motivation
npm run dev:verifyCLI milestone described in the Kickoff doc.npm run dev:verifydoesn't exist yet — pre-publish parity checking against the real cloud round trip currently requires manually curling/__dd/executeActionViaCloud.dev:verify(added to the scaffold template in a separate web-ui PR) can route through the same/__dd/executeActionURL the frontend already calls, without the frontend needing to know which mode it's in.dev-server-transport.ts) mode-aware viaimport.meta.env.MODE.ts-jest) has no CommonJS equivalent forimport.meta— introducing it breaks the transform for any file that imports it.--mode, avoids this and keeps the client transport unchanged.Architecture
/__dd/executeActionViaCloudremains directly reachable — this only adds a second way to reach the same cloud behavior, gated by mode, at the URL the client already calls by default.Changes
9 changes across 6 files
DEV_VERIFY_MODEconstant ('dev-verify'), the Vite--modevaluedev:verifywill use.createDevServerMiddlewaretakes a new requiredmode: stringparameter (no default —index.tsalways passesserver.config.mode), computingisDevVerifyModeonce above the returned request handler instead of re-comparingmodeon every request.routeToCloudHandlerso both cloud-bound routes share one auth/error path.req.url === '/__dd/executeAction'andmode === DEV_VERIFY_MODE, delegates to the same cloud-execution logic/__dd/executeActionViaClouduses (including the existing "auth not configured" 400 guard) instead of running locally.configureServer(server)passesserver.config.mode(Vite's own resolved mode, read via the plugin API — noimport.meta.envinvolved) through tocreateDevServerMiddleware.mode: DEV_VERIFY_MODEroutes/__dd/executeActionthrough the realpreview-asyncround trip (vianock) and never callsloadModule.configureServer-level test: confirms the cloud path is taken through the real plugin wiring, not just the middleware in isolation, whenconfig.modeisDEV_VERIFY_MODE.createDevServerMiddleware(...)call sites into onecreateTestMiddleware()factory taking only the overrides each test actually varies.createDevServerMiddlewarecall sites now pass an explicit'development'mode, since it's the one test file that exercises the plugin through real Vite build config rather than thecreateTestMiddlewarefactory above.QA Instructions
yarn test:unit packages/plugins/apps/src/vite/dev-server.test.ts # Expected: Test Suites: 1 passed / Tests: 48 passed ✅ VERIFIEDyarn test:unit # Expected: Test Suites: 88 passed / Tests: 2163 passed, 2 skipped ✅ VERIFIEDyarn workspace @dd/apps-plugin run typecheck # Expected: no output, clean exit ✅ VERIFIEDManual QA against a real scaffolded app (invoking
vite dev --mode dev-verifydirectly, ahead of the web-ui half'sdev:verifyscript landing), per the Testing and QA Guide:Confirmed it's genuinely routing to the cloud, not local in-process execution:
console.logdid not print in the local terminal (unlike the same call under defaultnpm run dev, where it does).Bundling backend function...Executing action via cloud...Calling Datadog API: https://api.datad0g.com/api/v2/app-builder/queries/preview-asyncQuery execution started with receipt: ...Long-poll attempt 1/10...Long-poll response, done: trueBlast Radius
npm run dev(default mode) —modeis required with no code-level default, butindex.tsalways passesserver.config.mode, Vite's own resolved mode, which itself defaults to'development'when Vite doesn't otherwise set it. Either way it never equalsDEV_VERIFY_MODE, so the existing local-execution branch is unchanged./__dd/executeActionViaCloudis untouched.--modeflag, which the web-ui template'sdev:verifyscript will set.Out of Scope / Follow-ups
3 items deferred
dev:verifyscript (vite dev --mode dev-verify) and a minimal example backend function to the create-apps templatedev:verifycommanddev:verifyin the publish flow beforedatadog-apps publishdatadog-appsCLIDocumentation