Skip to content

feat(08.6): one row per repo + branch picker on launch#84

Merged
finedesignz merged 1 commit into
mainfrom
feat/phase-08-6-repo-collapse
May 27, 2026
Merged

feat(08.6): one row per repo + branch picker on launch#84
finedesignz merged 1 commit into
mainfrom
feat/phase-08-6-repo-collapse

Conversation

@finedesignz
Copy link
Copy Markdown
Owner

Summary

  • Sidebar collapses to one row per GitHub repo. When a session has a repo_key, the UI defensively dedupes to the most-recently-active row (DB-level partial unique index on (user_id, repo_key) is still the primary mechanism). When the running cwd is known to the inventory, the caption shows on <branch> · <path>.
  • Launch button now has a worktree/branch picker. GET /api/sessions enriches each row with local_paths[] (cap 20, canonical first) from the per-user inventory cache. LaunchButton renders a <select> next to the button when local_paths.length > 1; option labels are <basename> · <branch> [worktree]. Selected path is sent as local_path in the launch body and validated against the inventory (400 invalid_local_path if the path is not in the supervisor inventory for this repo_key).
  • Supervisor reports current branch per repo. git-introspect.ts runs git symbolic-ref --short HEAD (null on detached HEAD). Wire field is optional + back-compat — pre-0.5 supervisors keep working; picker just omits the branch suffix.

Diagnosis (root cause confirmed)

Per the user's QC report and code reading: the V2 dedupe at findOrCreateAgentSessionV2 is correct. The visible clutter came from (a) GitHub-keyed rows whose worktree captions made them look like separate rows, and (b) legacy / local-only rows with no repo_key mixed in. The fix collapses (a) at the API + UI layer and surfaces worktree choice through the dropdown instead of distinct sidebar rows.

Versions

Supervisor + Tauri bumped 0.4.3 → 0.5.0 in all 5 places:

  • supervisor/src/index.ts
  • supervisor/src/hub-client.ts
  • supervisor/tauri/src-tauri/Cargo.toml
  • supervisor/tauri/src-tauri/tauri.conf.json
  • supervisor/tauri/ui/package.json

Test plan

  • cd hub && bun test — no NEW failures (8 fail in this branch all pre-existing on origin/main: insertRunV2 ×4, insertDeploymentRun, supervisor-registry reconnect race ×2, 1 unnamed). 374 pass total. 6 new tests for getKnownLocalPathsForRepoKey + 2 new tests for launch's local_path body all pass.
  • cd web && bun run build — clean, 2.11s.
  • Supervisor TS typecheck via bunx tsc --noEmit on changed files — clean.
  • After deploy: connect a supervisor with two worktrees of the same repo on different branches → verify only ONE sidebar row appears and the LaunchButton dropdown lists both with <basename> · <branch> [worktree] labels.
  • Verify /health 200 on Coolify deploy after merge.
  • Tag supervisor-v0.5.0 after merge (separate step — Tauri release CI).

Files

  • Hub: hub/src/api/sessions.ts, hub/src/ws/supervisor-protocol.ts, hub/src/ws/supervisor-registry.ts
  • Supervisor: supervisor/src/git-introspect.ts, supervisor/src/repo-scanner.ts, supervisor/src/hub-client.ts, supervisor/src/index.ts, supervisor/tauri/{src-tauri/Cargo.toml,src-tauri/tauri.conf.json,ui/package.json}
  • Web: web/src/components/LaunchButton.tsx, web/src/components/Sidebar.tsx, web/src/hooks/useSessions.ts
  • Tests: hub/test/known-paths-registry.test.ts (new), hub/test/sessions-launch.test.ts (extended)
  • Docs: docs/github-session-keying.md

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

🤖 Generated with Claude Code

Collapse worktrees in the Sidebar so the session list shows ONE row per
GitHub repo, and surface a worktree/branch picker dropdown in the Launch
button so users choose WHICH local checkout to spawn against.

Hub:
- GET /api/sessions enriches each row with `local_paths[]` from the
  inventory cache (cap 20, canonical first). Empty for legacy/local-only
  sessions.
- POST /api/sessions/:id/launch accepts `local_path` in the body;
  validated against the inventory for the session's repo_key (400
  invalid_local_path otherwise). Falls back to canonical → project_dir.
- New `getKnownLocalPathsForRepoKey(userId, repoKey)` helper in
  supervisor-registry.

Supervisor (v0.5.0):
- git-introspect.ts reads `git symbolic-ref --short HEAD` per repo
  (branch nullable on detached HEAD). Forwarded through scanRoots →
  hub-client → supervisor.repo_inventory wire payload (optional /
  back-compat for pre-0.5 hubs).

Web:
- Sidebar collapses any duplicate `repo_key` rows (defensive UI dedupe,
  keep most-recently-active). When the running cwd is in `local_paths`,
  the row caption shows `on <branch> · <path>`.
- LaunchButton renders a `<select>` next to the button when
  `session.local_paths.length > 1`; option labels are
  `<basename> · <branch> [worktree]`. Single-path UX unchanged.
- CodeSession type gains `local_paths?`. `launchSession()` accepts a
  `local_path` in the body.

Tests:
- hub/test/known-paths-registry.test.ts (6 new) covers canonical-first
  sort, case-insensitive repo_key match, 20-entry cap, null-branch
  tolerance, and resolveLocalPathForRepoKey parity.
- hub/test/sessions-launch.test.ts adds two cases: local_path body pins
  worktree cwd; unknown local_path → 400.

Diagnosis (per QC report from user): no duplicate-row bug in the V2
dedupe — the visible clutter was a mix of (a) GitHub-keyed rows showing
multiple worktree captions and (b) legacy local-only rows with no
repo_key. The fix collapses (a) at the API + UI layer and surfaces
worktree choice via the dropdown instead of distinct rows.

Version bump 0.4.3 → 0.5.0 in all 5 places (supervisor/src/index.ts,
supervisor/src/hub-client.ts, supervisor/tauri/src-tauri/Cargo.toml,
supervisor/tauri/src-tauri/tauri.conf.json, supervisor/tauri/ui/package.json).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@finedesignz finedesignz merged commit 4de7ed7 into main May 27, 2026
1 check passed
@finedesignz finedesignz deleted the feat/phase-08-6-repo-collapse branch May 27, 2026 15:14
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