Skip to content

fix: make package app routes and runs diagnosable - #1308

Merged
kody-bot merged 2 commits into
mainfrom
cursor/kody-fr-package-apps-d3da
Aug 8, 2026
Merged

kody-bot merged 2 commits into
mainfrom
cursor/kody-fr-package-apps-d3da

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Aug 8, 2026 •

Copy link
Copy Markdown
Owner

Intent

Make hosted package apps self-aware of their public mount and make routing/run failures actionable, addressing field-report findings K-02, K-03, and K-06.

Summary

  • expose hostedUrl and appBasePath through package apps' packageContext, derived from the current serving username, Kody id, and origin
  • replace unmatched package-app-origin bare 404s with the package URL contract
  • retain app fetch query parameter names (never values) and terminal HTTP response status in run metadata
  • document mount-relative link construction in package usage and authoring guidance

Testing

  • focused Node: 25 tests passed
  • focused Workers: 4 tests passed
  • real-worker MCP package app: 1 test passed
  • npm run validate passed after implementation and again after reviewer fix
  • post-fix CI passed: Node, Workers, E2E, MCP, static, preview, CodeRabbit, and Bugbot
  • production deploy passed its healthcheck and execute smoke check

System changes

System recap — extends existing primitives (medium risk)

Mode: recap · Base: main @ 1916ffea · Head: b4159e58

Classification: extends — package app runtime context, routing diagnostics, and run-record metadata contracts change; no primitive is added.

Primitives touched

Primitive Group Impact
package-apps assistant extends — public mount context and fetch observability
package-runtime runtime extends — generated app worker context and finish metadata
app-ui surfaces extends — diagnostic package-origin 404
repo-sessions runtime extends — authored package runtime type declarations
mcp-server surfaces composes — end-to-end package app runtime coverage

System map

A hosted request is parsed by the browser-app routing layer, enters the package runtime with its public mount context, and writes richer run metadata.

Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).

flowchart LR
	appUi["app-ui<br/>Browser app (Remix 3)"]:::extended
	packageApps["package-apps<br/>Package apps"]:::extended
	packageRuntime["package-runtime<br/>Package runtime"]:::extended
	runRecords["run-records<br/>Run records"]:::untouched
	appUi -->|"serving username, origin, and mounted path"| packageApps
	packageApps -->|"hostedUrl + appBasePath runtime context"| packageRuntime
	packageRuntime -->|"query parameter names + terminal httpStatus"| runRecords
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading

Before / after

Contract Before After
App public base unavailable to package code packageContext.hostedUrl and appBasePath
Escaped mount bare Not Found diagnostic 404 with URL contract
app_fetch history pathname + method pathname + method + query parameter names + HTTP status

Conductor report

Track B report: STATUS(done); PR #1308; merged commit 0407c4b; deploy result success https://github.com/kentcdodds/kody/actions/runs/31244778124; evidence: CodeRabbit privacy finding fixed, local validate green, post-fix CI/CodeRabbit/Bugbot green, production healthcheck and execute smoke check passed; remains: none.

Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Package apps now receive public routing details, including their hosted URL and app base path.
    • Links, redirects, sharing URLs, and OAuth callbacks can use consistent package app routing information.
    • Runtime results include query parameter names and successful HTTP response status metadata.
  • Bug Fixes

    • Unmatched requests on package app origins now return a clear explanatory 404 response instead of a generic message.
  • Documentation

    • Added guidance covering package app mount paths, URL handling, and routing context availability.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Package apps now receive computed appBasePath and hostedUrl values, record query parameter names and HTTP statuses, return explanatory unmatched-path responses, and document hosted routing requirements.

Changes

Package app routing

Layer / File(s) Summary
Public package context
packages/worker/src/package-runtime/package-app.ts, packages/worker/src/app/handlers/package-app.ts, packages/worker/src/repo/checks.ts, packages/worker/src/package-runtime/package-app.node.test.ts
Workers compute and expose appBasePath and hostedUrl. Runtime declarations and cache keys include these values.
Fetch and completion metadata
packages/worker/src/package-runtime/package-app.ts, packages/worker/src/package-runtime/package-app.node.test.ts
Fetch runs record query parameter names and HTTP statuses. Completion metadata is merged before run records finish.
Unmatched package-app paths
packages/worker/src/app/package-app-origin.ts, packages/worker/src/app/package-app-origin.workers.test.ts
Unmatched paths return a no-store plain-text 404 that explains the valid package-app mount format.
Routing documentation and integration coverage
docs/guides/package-authoring.md, docs/use/packages.md, packages/worker/src/mcp/package-app-storage.mcp-e2e.test.ts
Documentation describes hosted routing and URL construction. End-to-end coverage verifies package context, query strings, and HTTP 201 responses.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant packageAppHandler
  participant buildPackageAppWorker
  participant packageContext
  participant generatedPackageApp
  participant packageRuntimeRunFinish
  participant finishRunRecord
  packageAppHandler->>buildPackageAppWorker: servingUsername and hostedOrigin
  buildPackageAppWorker->>packageContext: compute appBasePath and hostedUrl
  buildPackageAppWorker->>generatedPackageApp: expose packageContext
  generatedPackageApp->>packageRuntimeRunFinish: query parameter names and HTTP status
  packageRuntimeRunFinish->>finishRunRecord: persist merged run metadata
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main changes to package app routing and run diagnostics.
Description check ✅ Passed The description includes all template sections with clear intent, changes, testing results, and system impact.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/kody-fr-package-apps-d3da

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kody-bot
kody-bot marked this pull request as ready for review August 8, 2026 05:39
@github-actions

github-actions Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-1308.kody-a99.workers.dev

Worker: kody-pr-1308
D1: kody-pr-1308-db
KV: kody-pr-1308-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/worker/src/package-runtime/package-app.ts`:
- Around line 642-648: Stop persisting raw query values in the app fetch
metadata created by the runtime run flow: update the request metadata near
startRuntimeRun to store only query parameter names or use the established
query-value redaction policy. In
packages/worker/src/package-runtime/package-app.node.test.ts lines 588-658, add
coverage using sensitive OAuth callback parameters and assert their values are
absent from persisted run metadata.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: df9c1711-5f96-4b4f-b6b3-69d4d90fff20

📥 Commits

Reviewing files that changed from the base of the PR and between 1916ffe and 5635146.

📒 Files selected for processing (9)
  • docs/guides/package-authoring.md
  • docs/use/packages.md
  • packages/worker/src/app/handlers/package-app.ts
  • packages/worker/src/app/package-app-origin.ts
  • packages/worker/src/app/package-app-origin.workers.test.ts
  • packages/worker/src/mcp/package-app-storage.mcp-e2e.test.ts
  • packages/worker/src/package-runtime/package-app.node.test.ts
  • packages/worker/src/package-runtime/package-app.ts
  • packages/worker/src/repo/checks.ts

Comment thread packages/worker/src/package-runtime/package-app.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/worker/src/package-runtime/package-app.node.test.ts (1)

68-87: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid evaluating raw source text in the test helper.

collectQueryParamNamesForTest reads package-app.ts, rewrites its text, and executes it with new Function. The URL is passed as an argument, so this is not request-driven code injection. The helper still depends on exact source delimiters and escape rules. It can also test a reconstructed function instead of the implementation used by the generated wrapper.

Extract collectQueryParamNames into a normal pure module or expose a test seam. Use the same implementation from production and the test.

Also applies to: 682-689

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/worker/src/package-runtime/package-app.node.test.ts` around lines 68
- 87, Replace the source-reading and new Function logic in
collectQueryParamNamesForTest with a shared testable implementation: extract
collectQueryParamNames into a pure module or expose an explicit test seam, then
import or invoke that same symbol from both package-app.ts and the test. Remove
the source delimiter, escape-rewriting, and dynamic evaluation dependencies
while preserving the helper’s existing URL-to-name-array behavior.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/worker/src/package-runtime/package-app.node.test.ts`:
- Around line 68-87: Replace the source-reading and new Function logic in
collectQueryParamNamesForTest with a shared testable implementation: extract
collectQueryParamNames into a pure module or expose an explicit test seam, then
import or invoke that same symbol from both package-app.ts and the test. Remove
the source delimiter, escape-rewriting, and dynamic evaluation dependencies
while preserving the helper’s existing URL-to-name-array behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a71e33cd-a9cb-441b-bb86-f97aa60faec3

📥 Commits

Reviewing files that changed from the base of the PR and between 5635146 and b4159e5.

📒 Files selected for processing (2)
  • packages/worker/src/package-runtime/package-app.node.test.ts
  • packages/worker/src/package-runtime/package-app.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/worker/src/package-runtime/package-app.ts

@kody-bot
kody-bot merged commit 0407c4b into main Aug 8, 2026
10 checks passed
@kody-bot
kody-bot deleted the cursor/kody-fr-package-apps-d3da branch August 8, 2026 06:43
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.

3 participants