Skip to content

(MOT-4258) feat(worktree,console): ship the worktrees page as injectable console UI - #610

Merged
rohitg00 merged 3 commits into
mainfrom
feat/worktrees-injectable-ui
Jul 28, 2026
Merged

(MOT-4258) feat(worktree,console): ship the worktrees page as injectable console UI#610
rohitg00 merged 3 commits into
mainfrom
feat/worktrees-injectable-ui

Conversation

@rohitg00

@rohitg00 rohitg00 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What

Moves the console's worktrees page to an injectable UI shipped by the worktree worker, per docs/sops/injectable-console-ui.md (state worker as the reference), mirroring the github port. Part of the console injectable-UI migration (MOT-4256).

worktree/ui (injectable)

  • page.tsx: setup(host) registers the worktrees page (#/ext/worktree, nav label worktrees).
  • src/page/: the graph (WorktreeGraph), detail panel, and pure layout.ts geometry ported to @iii-dev/console-ui + host.iii.trigger; useWorktreesLive re-subscribes on the six worktree::{created,claimed,released,removed,landed,land-blocked} events (tab-scoped, unmount cleanup). Inline SVG icons.
  • styles.css scoped [data-iii-ui="worktree"], tokens only. build.mjs esbuild with the five shared externals.
  • Rust: iii-console-ui crate, ConsoleUi::new("worktree").script(...).style(...).register(&iii); build.rs respects SKIP_UI_BUILD. pnpm-workspace.yaml joins worktree/ui.

console (deletions)

  • Deleted the whole pages/Worktrees/ (page + graph + detail + layout + live hook + Storybook story). Edited App.tsx, use-hash-route.ts, nav-options.ts, use-worktree-events.ts (page-only lifecycle hook). Kept the chat-shell worktree bits (use-worktree-status, WorktreeBadge, DirectoryPicker, worktreeAvailable) that ChatView uses.

Verification

  • worker: cargo build / fmt / clippy / test (44 pass, incl. 3 new ui:: tests).
  • ui: tsc + esbuild build clean.
  • console: tsc -b exit 0, biome clean on changed files.

Closes MOT-4258.

Summary by CodeRabbit

  • New Features

    • Added a worktree console page provided directly by the worktree worker.
    • View worktree relationships in a graph, inspect details, refresh data, and monitor lifecycle/status indicators.
    • Added live updates with polling fallback when event delivery is unavailable.
    • Scoped styling improves visual consistency and prevents interference with other console pages.
  • Changes

    • Removed the previous built-in Worktrees navigation route in favor of the worker-provided extension page.
    • Improved handling of incomplete or invalid worktree data.

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview, Comment Jul 28, 2026 2:02pm
workers-tech-spec Ready Ready Preview, Comment Jul 28, 2026 2:02pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 49 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@rohitg00, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1cee66d5-730a-4fdd-bf5d-8c5108d2b736

📥 Commits

Reviewing files that changed from the base of the PR and between 9cb2118 and 31cc377.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • console/web/src/App.tsx
  • console/web/src/hooks/use-hash-route.test.ts
  • console/web/src/hooks/use-hash-route.ts
  • console/web/src/lib/nav-options.test.ts
  • console/web/src/lib/nav-options.ts
  • pnpm-workspace.yaml
📝 Walkthrough

Walkthrough

The PR moves the worktree console UI into the worker as an injected frontend, adds RPC-backed live data and embedded asset registration, and removes the former first-party worktrees route, navigation option, page, and lifecycle subscription hook.

Changes

Worktree UI migration

Layer / File(s) Summary
UI package and worktree data contract
pnpm-workspace.yaml, worktree/ui/..., worktree/ui/src/page/worktree-data.ts, worktree/ui/src/page/layout.*
Adds the workspace package, esbuild configuration, TypeScript settings, typed worktree schemas, RPC listing, lifecycle constants, parsing helpers, and layout type wiring.
Live data and page rendering
worktree/ui/src/page/*, worktree/ui/styles.css
Adds lifecycle-trigger refresh and polling, the injected worktrees page, graph and detail views, local icons, and scoped styling.
Worker asset build and registration
worktree/Cargo.toml, worktree/build.rs, worktree/src/*
Builds or validates UI assets, embeds them in Rust, and registers the worktree console UI during worker startup.
First-party route and navigation removal
console/web/src/App.tsx, console/web/src/hooks/*, console/web/src/lib/*
Removes direct worktree rendering, hash routing, navigation availability, lifecycle subscription state, and obsolete navigation test cases.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • iii-hq/workers#390 — Adds the earlier first-party worktrees route and UI that this PR replaces.
  • iii-hq/workers#601 — Updates CI handling for frontend distribution assets used by the injected UI.
  • iii-hq/workers#609 — Changes adjacent console routing and injected-page navigation plumbing.

Poem

A rabbit watched the worktrees hop,
From console roots to a worker shop.
New graphs bloom in scoped CSS light,
Embedded pages register right.
The old route fades—ears twitch with cheer!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.24% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: moving the worktrees page into an injectable console UI.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/worktrees-injectable-ui

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.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
console/web/src/hooks/use-hash-route.ts (1)

94-99: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve existing #/worktrees deep links.

routeFromHash('#/worktrees') now returns null, so useHashRoute falls back to traces while leaving the old hash in the URL. Existing bookmarks and links therefore open the traces view instead of the injected #/ext/worktree page. Add an explicit compatibility redirect and a regression test.

🤖 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 `@console/web/src/hooks/use-hash-route.ts` around lines 94 - 99, Update
routeFromHash in useHashRoute to recognize the legacy `#/worktrees` hash and
redirect it to the injected `#/ext/worktree` route, preserving existing deep-link
behavior. Add a regression test covering routeFromHash('`#/worktrees`') and verify
it resolves to the worktree page rather than falling back to traces.
🧹 Nitpick comments (1)
console/web/src/hooks/use-hash-route.ts (1)

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

Keep the routing comment aligned with View.

The comment omits the still-supported memory, github, and ext views. Update it to describe the complete routed-view set.

🤖 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 `@console/web/src/hooks/use-hash-route.ts` at line 6, Update the routed-views
comment in use-hash-route.ts to include the supported memory, github, and ext
views alongside traces, workers, browser, and configuration, keeping it aligned
with the View definition.
🤖 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 `@worktree/build.rs`:
- Around line 47-60: Register SKIP_UI_BUILD, PNPM, and PATH as build-script
rerun inputs at the start of the build logic, using Cargo’s rustc-env change
directives. Keep the existing locate_pnpm and asset-generation behavior
unchanged.

---

Outside diff comments:
In `@console/web/src/hooks/use-hash-route.ts`:
- Around line 94-99: Update routeFromHash in useHashRoute to recognize the
legacy `#/worktrees` hash and redirect it to the injected `#/ext/worktree` route,
preserving existing deep-link behavior. Add a regression test covering
routeFromHash('`#/worktrees`') and verify it resolves to the worktree page rather
than falling back to traces.

---

Nitpick comments:
In `@console/web/src/hooks/use-hash-route.ts`:
- Line 6: Update the routed-views comment in use-hash-route.ts to include the
supported memory, github, and ext views alongside traces, workers, browser, and
configuration, keeping it aligned with the View definition.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a812978a-773c-4e42-9c6f-2524f6d838fc

📥 Commits

Reviewing files that changed from the base of the PR and between a88137b and 9cb2118.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • worktree/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (27)
  • console/web/src/App.tsx
  • console/web/src/hooks/use-hash-route.ts
  • console/web/src/hooks/use-worktree-events.ts
  • console/web/src/lib/nav-options.test.ts
  • console/web/src/lib/nav-options.ts
  • console/web/src/pages/Worktrees/components/WorktreeGraph.stories.tsx
  • console/web/src/pages/Worktrees/hooks/useWorktreesLive.ts
  • console/web/src/pages/Worktrees/index.tsx
  • pnpm-workspace.yaml
  • worktree/Cargo.toml
  • worktree/build.rs
  • worktree/src/lib.rs
  • worktree/src/main.rs
  • worktree/src/ui.rs
  • worktree/ui/build.mjs
  • worktree/ui/package.json
  • worktree/ui/page.tsx
  • worktree/ui/src/page/WorktreeDetailPanel.tsx
  • worktree/ui/src/page/WorktreeGraph.tsx
  • worktree/ui/src/page/icons.tsx
  • worktree/ui/src/page/index.tsx
  • worktree/ui/src/page/layout.test.ts
  • worktree/ui/src/page/layout.ts
  • worktree/ui/src/page/useWorktreesLive.ts
  • worktree/ui/src/page/worktree-data.ts
  • worktree/ui/styles.css
  • worktree/ui/tsconfig.json
💤 Files with no reviewable changes (4)
  • console/web/src/pages/Worktrees/index.tsx
  • console/web/src/pages/Worktrees/components/WorktreeGraph.stories.tsx
  • console/web/src/pages/Worktrees/hooks/useWorktreesLive.ts
  • console/web/src/lib/nav-options.ts

Comment thread worktree/build.rs
Comment on lines +47 to +60
if std::env::var_os("SKIP_UI_BUILD").is_some() {
for asset in &dist_assets {
if !asset.exists() {
panic!(
"SKIP_UI_BUILD set but {} is missing — build the UI manually \
(cd ui && pnpm install && pnpm build) or unset the env var",
asset.display()
);
}
}
return;
}

let pnpm = locate_pnpm();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n 'var_os\("SKIP_UI_BUILD"\)|var\("PNPM"\)|var_os\("PATH"\)|rerun-if-env-changed' worktree/build.rs

Repository: iii-hq/workers

Length of output: 327


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)worktree/(build\.rs|.*toml)$|^Cargo\.lock$|^Cargo\.toml$'

echo "== build.rs outline =="
ast-grep outline worktree/build.rs --view expanded || true

echo "== build.rs relevant lines =="
sed -n '1,220p' worktree/build.rs

echo "== cargo env rerun mentions =="
rg -n 'cargo:rerun-if-env-changed|SKIP_UI_BUILD|run_ui_pnpm|locate_pnpm|PATH|PNPM' worktree/build.rs worktree/Cargo.toml Cargo.toml

Repository: iii-hq/workers

Length of output: 144


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== tracked relevant files =="
git ls-files | awk '$1 ~ /^(worktree\/build\.rs|.*Cargo\.toml|Cargo\.lock)$/ {print}' | sed -n '1,80p'

echo "== relevant text search =="
rg -n 'var_os\("SKIP_UI_BUILD"\)|var\("PNPM"\)|var_os\("PATH"\)|cargo:rerun-if-env-changed|worktree' worktree/build.rs worktree/Cargo.toml Cargo.toml 2>/dev/null || true

echo "== build.rs line count =="
wc -l worktree/build.rs 2>/dev/null || true

echo "== build.rs snippets =="
sed -n '1,220p' worktree/build.rs 2>/dev/null || true

Repository: iii-hq/workers

Length of output: 7278


Track build-control environment changes.

SKIP_UI_BUILD, PNPM, and PATH affect whether this build script regenerates or embeds assets, but Cargo does not rerun it when they change unless registered.

Proposed fix
 fn main() {
+    println!("cargo:rerun-if-env-changed=SKIP_UI_BUILD");
+    println!("cargo:rerun-if-env-changed=PNPM");
+    println!("cargo:rerun-if-env-changed=PATH");
+
     println!(
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if std::env::var_os("SKIP_UI_BUILD").is_some() {
for asset in &dist_assets {
if !asset.exists() {
panic!(
"SKIP_UI_BUILD set but {} is missing — build the UI manually \
(cd ui && pnpm install && pnpm build) or unset the env var",
asset.display()
);
}
}
return;
}
let pnpm = locate_pnpm();
println!("cargo:rerun-if-env-changed=SKIP_UI_BUILD");
println!("cargo:rerun-if-env-changed=PNPM");
println!("cargo:rerun-if-env-changed=PATH");
if std::env::var_os("SKIP_UI_BUILD").is_some() {
for asset in &dist_assets {
if !asset.exists() {
panic!(
"SKIP_UI_BUILD set but {} is missing — build the UI manually \
(cd ui && pnpm install && pnpm build) or unset the env var",
asset.display()
);
}
}
return;
}
let pnpm = locate_pnpm();
🤖 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 `@worktree/build.rs` around lines 47 - 60, Register SKIP_UI_BUILD, PNPM, and
PATH as build-script rerun inputs at the start of the build logic, using Cargo’s
rustc-env change directives. Keep the existing locate_pnpm and asset-generation
behavior unchanged.

…able-ui

# Conflicts:
#	console/web/src/App.tsx
#	console/web/src/hooks/use-hash-route.ts
#	console/web/src/lib/nav-options.test.ts
#	pnpm-lock.yaml
@rohitg00

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@rohitg00
rohitg00 merged commit cb08760 into main Jul 28, 2026
19 checks passed
@rohitg00
rohitg00 deleted the feat/worktrees-injectable-ui branch July 28, 2026 14:12
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