Skip to content

feat(id): #2146 phase 2 — program-only surface in id serve (#5537) - #5606

Merged
dezren39 merged 2 commits into
mainfrom
queue/9681-5537-program-only-surface
Nov 4, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/9681-5537-program-only-surface

Conversation

@dezren39

@dezren39 dezren39 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Implements design #2146 phase 2 for #5537 (phase 1: PR #5590, merged).

What lands

  • Program-only router (create_program_router in pkgs/id/src/web/routes.rs): for a Program(world) binding it serves the world program frontend at /, the static assets the trusted presenter loads, and the world session bridge (shared world HTTP surface + live channel at the app's socket) — and nothing else. Explorer pages/APIs (/files, /settings, /peers, /api/files, /api/save, /api/identity/*, collab/tags) are absent from this router, verified by test.
  • Program page (render_program_page): guest surface for exactly one world — world pinned server-side (data-world-program, read-only world input), no Explorer chrome (the shared wrapper links /files, /peers, /settings, which do not exist on a program listener), no host controls (admin token, invite minting, module install, host view). Root 404s when the hub does not host the named world — never a lobby for a different world.
  • Listener wiring: serve threads each binding's WebContentTarget through to web_routers, which builds the per-listener router for its declared surface; the startup status line names the program URL for program bindings. Explorer listeners are unchanged.
  • Frontend (world.ts): host controls are now optional wiring (guarded), and a server-pinned data-world-program wins over the ?world= parameter. The Explorer world page is byte-identical in behaviour (full web suite green).

Authority (design invariants 5/6)

No new authority: the program surface adds no session path of its own. A program session still requires a valid world guest capability over the existing bridge; the web token and the world admin token do not satisfy it (the invite endpoint on the program router still refuses without the admin secret — 401, tested). Rendering stays the trusted text/screen presenter; guest output is inert data.

Tests

  • Rust (--features web): program_* 20 passed (incl. 3 new router tests + 2 template tests); web:: 545 passed; commands::serve 41 passed.
  • Web: full vitest suite 644 passed / 9 skipped, incl. new world-program.test.ts (presenter initializes without host controls, join frame carries the pinned world, text view renders, chat flows). tsc --noEmit clean.
  • Note: a fresh worktree needs bun install && bun run build in pkgs/id/web before the Rust web tests compile (web/dist is gitignored) — done on the laptop for this run.

Out of scope (later phases): mixed-listener browser round-trip polish is phase 3's test focus (router construction per surface lands here; serve binds each listener with its own router already), path mounts are phase 4, #2147 publication integration is phase 5. Issue #5537 stays open for phases 3–4.

Queue: task 9681 (repo-health-code-pilot), lane code-y.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 4, 2026 17:53
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 851003e3-8326-4965-a280-3d67b79c16d9
Commits

Reviewing files that changed from the base of the PR and between 7912457 and a4a9563.

Files selected for processing: 8
  • pkgs/id/src/commands/serve.rs
  • pkgs/id/src/web/mod.rs
  • pkgs/id/src/web/routes.rs
  • pkgs/id/src/web/templates.rs
  • pkgs/id/web/src/main.ts
  • pkgs/id/web/src/world-program-main.test.ts
  • pkgs/id/web/src/world-program.test.ts
  • pkgs/id/web/src/world.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T18:05:57.556149Z a4a9563 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bde2ec004f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment on lines +1079 to +1080
" <script type=\"module\" src=\"{}\"></script>\n",
assets.main_js

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip Explorer initialization on the program-only page

Every program-page visit loads the full Explorer entry point through assets.main_js. In pkgs/id/web/src/main.ts, init() unconditionally calls ensureIdentity() and app.connectTagsWs(), but this listener deliberately omits /api/identity/register and /ws/tags. Consequently, visiting the program produces failed identity requests and starts an endless WebSocket reconnection loop against a nonexistent endpoint (eventually every 30–36 seconds per open tab). Use a program-specific entry point or guard Explorer initialization when data-world-program is present; the new frontend test imports only ./world, so it does not cover this behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a4a9563: main.ts init() now detects the program-only surface ([data-world-program]) and skips both Explorer-only calls — ensureIdentity() (no /api/identity/* on a program listener) and app.connectTagsWs() (no /ws/tags there, so no reconnect loop). The world presenter initialization is untouched.

Regression coverage added as world-program-main.test.ts: it loads the real program-page markup through the full main.ts entry point with fetch/WebSocket stubbed and asserts no identity fetch, no /ws/tags socket, and that the world presenter still initializes. Full web suite: 645 passed / 9 skipped; tsc --noEmit clean.

@codex review

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: a4a9563084

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@dezren39
dezren39 merged commit 4733d59 into main Nov 4, 2026
1 check passed
@dezren39
dezren39 deleted the queue/9681-5537-program-only-surface branch November 4, 2026 18:07
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