Skip to content

URI handler (3/3): dark gated create deep-link handlers#1630

Draft
amitjoshi438 wants to merge 3 commits into
amitjoshi-power-pages-uri-handlers-pr2from
amitjoshi-power-pages-uri-handlers-pr3
Draft

URI handler (3/3): dark gated create deep-link handlers#1630
amitjoshi438 wants to merge 3 commits into
amitjoshi-power-pages-uri-handlers-pr2from
amitjoshi-power-pages-uri-handlers-pr3

Conversation

@amitjoshi438

Copy link
Copy Markdown
Contributor

PR 3 of 3 - Phase 0-1 foundation. Introduces the dark, flag-gated create handlers. Stacked on PR 2 (base branch = amitjoshi-power-pages-uri-handlers-pr2), so the diff shows only this PR's commit.

Focus commit

b4c53b73 - Add dark, flag-gated skeleton handlers for the two Power Pages create deep links.

What changed

  • ECS gates EnableAgenticCreateFromHome / EnablePacCreateFromHome (fallback off).
  • Handlers agenticCreateHandler.ts / pacCreateHandler.ts wired into the PR 1 route map. Flag off = no-op that emits a *_Disabled telemetry event; flag on = parse deep-link params + emit *_Triggered. Actual create behavior (auth -> environment -> folder -> PAC CLI / agent-host bootstrap) is deferred to follow-ups.
  • createFlowParams.ts - shared param parsing + a redacted telemetry builder that records only low-cardinality values and presence flags, never raw org URLs / tenant IDs.
  • Telemetry - 6 new events (triggered/disabled/failed for each flow).

Tests

  • test/integration/createHandlers.test.ts (new) - flag-off no-op path and flag-on parse+telemetry path for both handlers.
  • test/integration/uriHandler.test.ts - updated to assert the new paths dispatch to their handlers.

Validation

gulp lint clean; compile-tests clean; npm test 106 passing; npm run build OK.

Rollout

Ships dark: both gates default off, telemetry-only, no user-facing behavior. Merge last (after PRs 1 and 2).

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

Amit Joshi and others added 3 commits July 21, 2026 16:18
Convert `UriHandler.handleUri` from an if/else chain into a
`ReadonlyMap<string, UriRouteHandler>` built in the constructor. The two
existing paths (`/pcfInit`, `/open`) keep identical behavior; unrecognized
paths are now ignored for forward compatibility instead of falling through.

Add the versioned deep-link contract constants that the Power Pages home
page will use to launch VS Code:
- reserved paths `/agenticCreate` and `/pacCreate` (registered but not yet
  wired to any handler)
- shared params `region`, `tenantid`, `source`, `agenthost`, `v`
- enumerated `SOURCE_VALUES`, `AGENT_HOST_VALUES`, and `CONTRACT_VERSION`

Export the `UriHandler` class so dispatch can be covered by an integration
test. Adds a pure unit test asserting the constants contract and an
integration test asserting each path routes correctly (including the
reserved/unknown no-op paths).

This change is behavior-preserving and ships dark: no new user-facing
behavior. Follow-up PRs extract shared auth/env helpers and add the
flag-gated skeleton handlers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move the PAC CLI authentication, environment-selection, and process-reset
logic out of the `UriHandler` class into a new
`utils/authEnvironment.ts` `AuthEnvironmentService` that takes a
`PacWrapper`. `UriHandler` now composes the service and delegates:
- `handleOpenPowerPages` (`/open`) calls
  `authEnvironmentService.prepareAuthenticationAndEnvironment(...)`
- `executeDownload` calls `authEnvironmentService.resetPacProcessSafely(...)`

This is a behavior-preserving refactor: the moved methods
(`prepareAuthenticationAndEnvironment`, `ensureAuthentication`,
`ensureCorrectEnvironment`, `resetPacProcessAndThrow`,
`resetPacProcessSafely`) keep identical logic, telemetry, prompts, and
error handling. Extracting them lets the upcoming `/pacCreate` and
`/agenticCreate` handlers reuse the exact same auth/environment flow
instead of duplicating it.

Adds an integration test (`test/integration/authEnvironment.test.ts`)
covering the no-prompt happy path, the environment-switch path, and the
reset-safely / reset-and-throw error behaviors with a stubbed PacWrapper.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PR-3 of 3 (stacked on the auth/env extraction). Introduces the dark
scaffolding for the two new Power Pages "create" deep links launched from
the Power Pages home page:

  - vscode://.../agenticCreate  (agentic / terminal CLI agent-host flow)
  - vscode://.../pacCreate      (PAC CLI flow)

Both ship OFF by default and change no user-facing behavior. When their
ECS flag is off the handler is a no-op that emits a "disabled" telemetry
event; when on it parses the versioned, secret-free deep-link parameters
and emits a "triggered" telemetry event. The actual create behavior
(auth -> environment -> folder -> PAC CLI / agent-host bootstrapping) is
intentionally deferred to follow-up changes.

Changes:
  - ecs-features/ecsFeatureGates.ts: add EnableAgenticCreateFromHome and
    EnablePacCreateFromHome gates (fallback = off).
  - uriHandler/telemetry/uriHandlerTelemetryEvents.ts: add triggered /
    disabled / failed events for both flows.
  - uriHandler/handlers/createFlowParams.ts: shared param parsing plus a
    redacted telemetry builder (records only low-cardinality, non-secret
    values and presence flags — never raw org URLs or tenant IDs).
  - uriHandler/handlers/{agenticCreateHandler,pacCreateHandler}.ts: gated
    dark handlers wired into the PR-1 route map.
  - uriHandler/uriHandler.ts: construct and register both handlers.
  - test/integration/createHandlers.test.ts: covers gated no-op (flag off)
    and enabled-parse (flag on) paths for both handlers.
  - test/integration/uriHandler.test.ts: assert routing dispatches the new
    paths to their handlers now that they are wired up.

Validated: gulp lint, compile-tests, npm test (106 unit passing), build.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant