Skip to content

URI handler (1/3): route-map refactor + deep-link constants#1625

Closed
amitjoshi438 wants to merge 1 commit into
microsoft:mainfrom
amitjoshi438:amitjoshi-power-pages-uri-handlers
Closed

URI handler (1/3): route-map refactor + deep-link constants#1625
amitjoshi438 wants to merge 1 commit into
microsoft:mainfrom
amitjoshi438:amitjoshi-power-pages-uri-handlers

Conversation

@amitjoshi438

@amitjoshi438 amitjoshi438 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

PR 1 of 3 — Phase 0–1 foundation for the Power Pages → VS Code "create" deep links. Behavior-preserving refactor; no user-facing change.

Why

We're adding two new deep links launched from the Power Pages home page that open VS Code into a create experience:

  • vscode://…/agenticCreate — agentic flow (terminal CLI agent host carrying the Power Pages plugin)
  • vscode://…/pacCreate — PAC CLI flow

Before wiring any of that behavior, this PR lays the routing + contract foundation so the follow-ups stay small and reviewable. Everything in the full effort ships dark (ECS-gated, off by default); this PR alone changes no behavior at all.

What changed

  • uriHandler/uriHandler.ts — replaced the handleUri if/else chain with a ReadonlyMap<string, UriRouteHandler> route table built in the constructor and dispatched by uri.path. Unknown paths are a no-op (forward-compatible). Exported the UriHandler class so it's unit-addressable. /open and /pcfInit dispatch to the exact same code as before.
  • uriHandler/constants/uriConstants.ts — added the versioned, secret-free deep-link contract: new paths (/agenticCreate, /pacCreate), params (region, tenantid, source, agenthost, v), value/version constants (SOURCE_VALUES, AGENT_HOST_VALUES, CONTRACT_VERSION), and the matching UriPath enum members. No handlers consume the new paths yet.

Tests

  • test/unit/uriConstants.test.ts (new) — pure/no-vscode unit coverage of the contract constants.
  • test/integration/uriHandler.test.ts (new) — asserts /open and /pcfInit still route to their handlers and unknown paths are ignored.

Design notes

  • The vscode:// URL is treated as a versioned contract (v=1) so the Power Pages home page and the extension can evolve independently.
  • Route-map dispatch makes adding a path a one-line registration (used by PRs 2–3) instead of growing a conditional.

Validation

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

Risk / rollout

Effectively zero: no new path is wired to behavior in this PR, and the two existing paths are dispatched identically. New paths become active only in PR 3, behind ECS gates that default off.

Stack (merge in order)

  1. this PR (URI handler (1/3): route-map refactor + deep-link constants #1625)main — router refactor + deep-link constants
  2. URI handler (2/3): extract shared auth/environment service #1626 → auth/environment service extraction
  3. URI handler (3/3): dark gated create deep-link handlers #1627 → dark, ECS-gated create handlers + telemetry

Branches are pushed from the fork amitjoshi438/powerplatform-vscode; since intermediate branches can't be pushed upstream, #1626/#1627 target main and show cumulative diffs until earlier PRs merge (each body names its focus commit). They auto-rebase to a clean single-commit diff and flip to ready once the preceding PR merges.

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

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>
@amitjoshi438
amitjoshi438 marked this pull request as ready for review July 21, 2026 11:33
@amitjoshi438
amitjoshi438 requested review from a team as code owners July 21, 2026 11:33
@amitjoshi438

Copy link
Copy Markdown
Contributor Author

Superseded: re-raised directly against the base repo (no fork) so CI secrets are available and the stack has proper isolated per-PR diffs. Replaced by #1628 / #1629 / #1630.

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