Skip to content

feat(orcastrator): supervising dot for background-active directors - #6115

Closed
zaridan wants to merge 29 commits into
stablyai:mainfrom
zaridan:feat/orcastrator-supervising-dot
Closed

zaridan wants to merge 29 commits into
stablyai:mainfrom
zaridan:feat/orcastrator-supervising-dot

Conversation

@zaridan

@zaridan zaridan commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Adds a supervising state to an Orcastrator's sidebar dot so a director that has handed control back (its agent hook fired done) but is still running background workers reads as working in the background — not finished.

Why

The sidebar dot derives from the per-pane agent hook, which reports done the moment the director's foreground turn ends. The dashboard's AgentStateDot renders done as a green completion check. But an Orcastrator is a long-lived supervisor: when it dispatches workers and a background watcher is waiting on worker_done, the director's turn is over while the run is very much alive. The result is a green checkmark that implies the mission is complete when it isn't.

done from a hook means "my turn ended", not "the mission is complete" — and for a supervisor those are very different.

How

The orchestration DB already knows a run is in flight; surface that as a distinct, DB-backed signal independent of the per-pane hook:

  • Main — buildOrchestrationActivityByPaneKey() emits one record per running coordinator run, keyed by the coordinator's own pane, carrying outstanding-task / active-dispatch / stale-dispatch counts (db.listCoordinatorRuns + count helpers). Returned on the syncWindowGraph result alongside the existing agentOrchestrationByPaneKey.
  • Renderer — a small orchestration-activity store slice receives it via the existing graph-sync channel (reference-stable so high-frequency title ticks don't churn). deriveOrcastratorDotState applies a precedence ladder: foreground attention (blocked/waiting) → working → supervising (in-flight run, calm emerald pulse) / stalled (a dispatched worker's heartbeat is hung past the coordinator's threshold, amber pulse) → idle (truly standing by). A finished turn with no live run now shows a neutral dot — never the completion check.

The sidebar row gains a count-aware hover tooltip (e.g. "Supervising · 2 tasks, 1 worker"). The dashboard's AgentStateDot done check is intentionally unchanged — that divergence is the point: the dashboard lists agents whose turns finished; the Orcastrator nav reflects a supervisor's run.

Tests

  • orcastrator-dot-state.test.ts — precedence ladder, never-done, supervising/stalled, foreground precedence, cross-worktree isolation
  • DB query tests — running-run listing + outstanding/active counts
  • Two orca-runtime integration tests — activity keyed by coordinator pane; omitted when no run is running

Full typecheck clean; feature + orchestration suites green.

Stacking

Builds on the Orcastrator stack — depends on #6036 (core) and #6099 (inline rename). Best reviewed/merged after them; the diff narrows to just this feature once they land.

Note on the DB model

Counts come from the global orchestration DB (one namespace, no per-run association), so with multiple concurrent runs the counts are shared across runs while runId / coordinator attribution stays per-run accurate.

🤖 Generated with Claude Code

zaridan and others added 23 commits June 20, 2026 22:22
Captures the proposed "Orcastrators" sidebar section + create-flow,
build phases, settings (mapped to coordinator TUNABLES + external-LLM
adversarial review), multi-coordinator isolation, and integration points.
Planning doc for the feat/orcastrators-sidebar prototype.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ggle

First slice of the Orcastrators feature (see ORCASTRATORS-SPEC.md): the
GlobalSettings.experimentalOrchestrators flag, an Experimental-pane toggle
(extracted to OrchestratorsExperimentalToggle to respect max-lines), and a
settings-search entry (extracted to orchestrators-search-entry). Gates the
upcoming sidebar section; no behavior yet beyond the toggle.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Records the traced, confirmed renderer call sequence for spawning a
coordinator in a repo's existing primary worktree with /orcastrate seeded
(primary-worktree lookup, createTab, startup payload, ensureAgentStartup-
InTerminal / pasteDraftWhenAgentReady), plus the two args left to copy from
the composer submit path. De-risks the launch slice.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds the experimental "Orcastrators" section above Projects with a + that
opens a project picker; selecting a project launches a coordinator agent in
that project's primary worktree and seeds /orcastrate.

- orchestrator-launch.ts: resolves the project's primary worktree, builds the
  agent startup plan, activates the worktree with that startup command, and
  paste-submits /orcastrate when the TUI is ready (reuses the verified
  launch-work-item-direct agent helpers).
- OrchestratorsSidebarSection.tsx: the gated section + picker, wired into the
  sidebar above the project list.

Gated behind experimentalOrchestrators. typecheck + lint clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Locks the revised design from the working session: the Orcastrator is a
persistent *director* (lives in the ORCASTRATORS section, no worktree shown,
runs in the primary checkout but display-decoupled), survives restart, allows
several per project, and uses disposition (delegate / decide-done / adversarial
review / write-as-last-resort) rather than a permission sandbox. Adds an
ordered v2 build plan (launch robustness, registry, persistence/reattach,
display-decoupling) with a verify-before-commit risk note.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replaces the activation-startup approach (which no-ops when the worktree is
already active, so relaunch spawned nothing) with createTab +
queueTabStartupCommand: forces a fresh agent tab and queues the launch command
directly onto it, working whether or not the worktree is already open. Also
delivers /orcastrate via pasteDraftWhenAgentReady with a 90s window so a cold
agent boot no longer drops the prompt with a "took too long" toast.

Verified live: relaunch into an open worktree spawns a fresh director and
/orcastrate auto-runs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds an OrchestratorsSlice tracking launched directors (id/project/worktree/
tab/launchedAt); launchOrchestratorForProject registers one on launch. The
ORCASTRATORS sidebar section now lists live directors as clickable entries
(project name, no worktree shown) and drops entries whose tab was closed.
Wired the slice into the store + both test-store helpers.

Verified live: launching shows a persistent "my-project" entry under
ORCASTRATORS.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Display-decoupling (step 4, part 1): exclude an Orcastrator's agent tab from
the worktree card's agent rows so the director no longer appears under
Projects, and show the director's live state (working spinner / ready dot) on
its ORCASTRATORS entry instead.

Verified live: the /orcastrate agent row is gone from under the worktree and
the section entry shows a status indicator.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Make the ORCASTRATORS list a navigator: highlight the active director's entry
with the worktree card's exact active-surface styling — adds an
`.orcastrator-active-surface` class to the shared active-surface CSS rule group
in main.css (single source of truth) and reuses `worktree-sidebar-card-hover`
for hover. Status now renders via the shared AgentStateDot. No invented styles.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The Orcastrator is now a first-class director, fully decoupled from the
project's primary checkout: launch creates a *dedicated* worktree via
createWorktree (skip-setup), runs the coordinator + /orcastrate there, and
registers it by worktree id. WorktreeList excludes director worktrees so they
never appear under Projects — they live only in the ORCASTRATORS section.

Verified live: launching spawns a director in its own worktree
(workspaces/<project>/orcastrator-<project>), shown only under ORCASTRATORS,
with nothing leaking into Projects.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Step 3 + lifecycle. The in-memory registry doesn't survive a reload, so on
load (and when worktrees change) reattachOrchestrators rebuilds it by detecting
director worktrees via the ORCASTRATOR_DISPLAY_PREFIX displayName marker —
re-hiding them from Projects and re-showing them under ORCASTRATORS, reattached
to their still-running agent. The section now keys off worktree existence
(robust to tab-id drift on reattach) and derives status from the worktree's
tabs. Adds closeOrchestrator (X-on-hover) which tears down the director's
dedicated worktree and drops it from the registry.

Note: pending live verification (author away); typecheck + lint clean and gated
behind experimentalOrchestrators.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Covers register/dedupe/remove, reattach detection (by displayName prefix,
project mapping, fallback to repo id + stripped name, idempotency, skipping
non-directors), and closeOrchestrator teardown (incl. the worktree-removal-
failure path). 7 tests, all passing.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tores

The Orcastrator feature reads new store fields (orchestrators registry,
worktreesByRepo) in WorktreeList, WorktreeCardAgents, and the section. Older
component test mocks build partial stores without these, so the reads threw.
Guard them (?? [] / ?? {}). Fixes 49 renderer test regressions; full renderer
suite green. (Remaining failures are pre-existing main/relay PTY/bash/relay
env tests, unrelated to this branch.)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Records the implemented state of the director rearchitect (flag, launch,
registry/navigator, dedicated worktree, reattach, close/cleanup), the
dedicated-worktree design decision, and known follow-ups.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… + task)

Replaces the +-dropdown with a native modal matching the "Create worktree"
composer (same Dialog + ProjectCombobox + AgentCombobox). Fields: Name (shown
in the ORCASTRATORS list), Project, Agent, and a task prompt — the prompt is
seeded after /orcastrate so the director starts planning the task instead of
asking for it. Also adds a gated "Create Orcastrator" button to the Landing
empty state next to Add Project / Create worktree.

launchOrchestratorForProject now takes { name, agent, prompt }. Verified live:
a named director ("Build Site") launched with a task, planned it, and spun up
worker worktrees under the project while staying in the ORCASTRATORS section.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…", design polish

- Source Control: show a director explainer instead of the publish/PR empty state for an Orcastrator's worktree (it has no branch of its own to publish).
- Suppress the "local main is behind" suggestion toast for director worktrees.
- Send to Orcastrator: hand a tracked issue (GitHub/GitLab/Linear/Jira) to a director from the GitHub issue-row menu and the New Workspace composer footer; opens the launch modal prefilled, pre-selecting the project when the issue is repo-bound.
- Launch modal: read prefill from modalData; align with the Create-worktree composer (max-w-lg, auto-focus Name, matching textarea focus/shadow tokens).
- Experimental toggle: use the shared SettingsSwitch for the focus ring + a11y.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FNy4vrv3mvyjpPnhJMZr82
… shipped history, and PR links

Replaces the misleading publish/PR view for a director's worktree with a Mission Control console, consistent across the right-sidebar panels:

- Source Control: director header + 'no branch to publish' summary, plus the worker worktrees it spawned (linked via lineage parent) with each worker's live agent-state dot and a clickable PR badge.
- Checks (and other branch/PR panels): a director notice with an 'Open Mission Control' jump, routed centrally so directors read correctly on every tab.
- Shipped: the director's completed work, read from its own .orcastrate/log.jsonl so it survives worker teardown. Each branch is matched to its merged PR by head ref — prefix-agnostic, so branch-rename-on-push still resolves — with a direct PR link.
- PR state renders as GitHub-styled pills (merged/open/closed/draft) with an external-link affordance.

Shared logic (lineage worker selection, agent-dot derivation, PR-badge derivation, log parsing, branch matching, PR-search-URL fallback) is extracted into pure, unit-tested helpers.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FNy4vrv3mvyjpPnhJMZr82
…feat/orcastrator-upstream

# Conflicts:
#	src/renderer/src/store/slices/worktrees.ts
The runtime node_modules closure bundles x86_64 copies of @parcel/watcher and
node-pty alongside the arm64 ones. They're never loaded on Apple silicon, but
recent macOS warns that the app 'includes an Intel component'. Remove them in
afterPack for darwin/arm64 builds.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FNy4vrv3mvyjpPnhJMZr82
…astrator-upstream

# Conflicts:
#	src/renderer/src/i18n/locales/zh.json
Resolves the 9 CodeRabbit findings on stablyai#6036:

- launch: tear down the created worktree when activation fails, so a failed
  launch doesn't leave an orphaned hidden director workspace.
- close: surface (log) teardown failures instead of swallowing every error.
- reattach: skip directors with no live tab — a blank tabId created orphan
  entries unreachable from the sidebar (+ tests for the new contract).
- worktrees: key the Orcastrator toast suppression off the authoritative
  result.worktree.displayName, not the input displayName.
- sidebar: gate director-worktree exclusion behind experimentalOrchestrators,
  so disabling the flag keeps those worktrees reachable.
- mission control: move PR-state pill colors to theme-scoped --pr-state-*
  tokens in main.css (no raw hex in the renderer); clear stale prItems when
  fetch preconditions fail; localize the "PR #N" label.
- launch modal: seed form state only on open (don't clobber in-progress
  edits), and keep the modal open when launch fails.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…-implement gap

Ship the orcastrate skill (SKILL.md) and its coordinator spec as a bundled
skill under skills/orcastrate/, instead of leaving them honor-system in
~/.claude. This makes the Orcastrator's director behavior part of the build.

Tightening: the skill front-door framed the whole decision around worktree
*count*, so a single-PR task read as "no split needed → do it inline" — the
exact failure where an Orcastrator resolved a conflict and applied review
fixes itself. SKILL.md now separates two questions (how many PRs vs who does
the work), and the coordinator calls out "one PR" as the most common trap:
one PR still means one worktree with one worker, never zero workers.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
(cherry picked from commit a4a83f2)
…ch landed

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces Orcastrators as a first-class persistent coordinator concept in Orca, gated behind an experimentalOrchestrators feature flag. A new shared OrchestrationActivity type carries live run metrics (pending tasks, active dispatches, stale dispatches) from the main process to the renderer via orchestrationActivityByPaneKey. Six new OrchestrationDb methods support per-coordinator and global task/dispatch counting and stale-dispatch queries. A new buildOrchestrationActivityByPaneKey computation in OrcaRuntimeService queries running coordinator runs and maps each to its renderer pane key with aggregated metrics. Two Zustand slices—OrchestrationActivitySlice and OrchestratorsSlice—manage activity state and a persistent orchestrator registry (keyed by ORCASTRATOR_DISPLAY_PREFIX display names) with reattach-on-reload via useReattachOrchestrators. A launchOrchestratorForProject function creates a hidden director worktree, activates it with an agent startup plan, registers it in the store, and asynchronously pastes the /orcastrate command with a 90-second timeout. An OrchestratorLaunchModal provides project/agent/name/task selection. New supervising and stalled AgentDotState values are rendered by updated AgentStateDot with deriveOrcastratorDotState arbitrating foreground-over-background precedence. An OrchestratorsSidebarSection renders live directors above Projects with inline renaming and close buttons, while WorktreeList and WorktreeCardAgents filter orchestrator worktrees from the standard worktree view. OrchestratorMissionControl replaces the SourceControl right panel for director worktrees, showing spawned workers with PR badges and shipped branches parsed from .orcastrate/log.jsonl. Launch entry points are added to the Landing page, TaskPage issue/PR menus, and the workspace composer card, all conditionally gated on the experimental flag. CSS tokens for PR state badges and warning color are added. Comprehensive i18n strings are added across en/es/ja/ko/zh. Skill documents define the director and coordinator roles, decision log format, and review loop; a design spec documents the feature architecture and build plan.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% 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
Title check ✅ Passed The title 'feat(orcastrator): supervising dot for background-active directors' accurately describes the main change—adding a supervising state to the Orcastrator's sidebar indicator to reflect background-active directors.
Description check ✅ Passed The description comprehensively explains what was added (supervising state), why it was needed (distinguish foreground turn end from background run), and how it works (orchestration activity signals). It is directly related to the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Tools execution failed with the following error:

Failed to run tools: 8 RESOURCE_EXHAUSTED: Received message larger than max (301697982 vs 209715200)


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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 13

🧹 Nitpick comments (1)
src/renderer/src/lib/orcastrator-dot-state.ts (1)

9-20: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Avoid first-match activity selection; make stalled precedence deterministic.

Returning on the first matching pane key makes dot state dependent on object entry order when multiple matches exist. Prefer scanning all matches and short-circuiting on any staleDispatches > 0.

Suggested refactor
 function findOrchestrationActivityForTabs(
   tabIds: readonly string[],
   orchestrationActivityByPaneKey: Record<string, OrchestrationActivity>
 ): OrchestrationActivity | null {
+  let candidate: OrchestrationActivity | null = null
   for (const [paneKey, activity] of Object.entries(orchestrationActivityByPaneKey)) {
     const colon = paneKey.indexOf(':')
     if (colon <= 0 || !tabIds.includes(paneKey.slice(0, colon))) {
       continue
     }
-    return activity
+    if (activity.staleDispatches > 0) {
+      return activity
+    }
+    candidate = candidate ?? activity
   }
-  return null
+  return candidate
 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 54d19fc7-9a0e-4c27-a184-2c971d94107c

📥 Commits

Reviewing files that changed from the base of the PR and between cea8d97 and f06e6c2758794b25d820474755c9fcf9075990b8.

📒 Files selected for processing (65)
  • .nvmrc
  • ORCASTRATORS-SPEC.md
  • config/electron-builder.config.cjs
  • skills/orcastrate/SKILL.md
  • skills/orcastrate/orcastrate-coordinator.md
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration/db.test.ts
  • src/main/runtime/orchestration/db.ts
  • src/renderer/src/App.tsx
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/AgentStateDot.tsx
  • src/renderer/src/components/Landing.tsx
  • src/renderer/src/components/NewWorkspaceComposerCard.tsx
  • src/renderer/src/components/NewWorkspaceComposerModal.tsx
  • src/renderer/src/components/OrchestratorLaunchModal.tsx
  • src/renderer/src/components/TaskPage.tsx
  • src/renderer/src/components/right-sidebar/OrchestratorMissionControl.tsx
  • src/renderer/src/components/right-sidebar/OrchestratorPanelNotice.tsx
  • src/renderer/src/components/right-sidebar/SourceControl.tsx
  • src/renderer/src/components/right-sidebar/right-sidebar-panel-content.tsx
  • src/renderer/src/components/settings/ExperimentalPane.tsx
  • src/renderer/src/components/settings/OrchestratorsExperimentalToggle.tsx
  • src/renderer/src/components/settings/experimental-search.ts
  • src/renderer/src/components/settings/orchestrators-search-entry.ts
  • src/renderer/src/components/sidebar/OrchestratorsSidebarSection.tsx
  • src/renderer/src/components/sidebar/WorktreeCardAgents.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/index.tsx
  • src/renderer/src/components/sidebar/worktree-card-agent-summary.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/github-pr-search-url.test.ts
  • src/renderer/src/lib/github-pr-search-url.ts
  • src/renderer/src/lib/orcastrate-log-shipped-work.test.ts
  • src/renderer/src/lib/orcastrate-log-shipped-work.ts
  • src/renderer/src/lib/orcastrator-dot-state.test.ts
  • src/renderer/src/lib/orcastrator-dot-state.ts
  • src/renderer/src/lib/orchestrator-launch.ts
  • src/renderer/src/lib/orchestrator-mission-control-data.test.ts
  • src/renderer/src/lib/orchestrator-mission-control-data.ts
  • src/renderer/src/lib/orchestrator-work-item-prompt.test.ts
  • src/renderer/src/lib/orchestrator-work-item-prompt.ts
  • src/renderer/src/lib/orchestrator-worker-pr-badge.test.ts
  • src/renderer/src/lib/orchestrator-worker-pr-badge.ts
  • src/renderer/src/lib/send-work-item-to-orchestrator.ts
  • src/renderer/src/lib/shipped-branch-pr-match.test.ts
  • src/renderer/src/lib/shipped-branch-pr-match.ts
  • src/renderer/src/lib/use-orchestrator-active-worktree.ts
  • src/renderer/src/lib/worktree-agent-dot-state.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/store/index.ts
  • src/renderer/src/store/slices/diffComments.test.ts
  • src/renderer/src/store/slices/orchestration-activity.ts
  • src/renderer/src/store/slices/orchestrators.test.ts
  • src/renderer/src/store/slices/orchestrators.ts
  • src/renderer/src/store/slices/store-test-helpers.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/store/slices/worktrees.ts
  • src/renderer/src/store/types.ts
  • src/shared/runtime-types.ts
  • src/shared/types.ts

Comment thread src/main/runtime/orca-runtime.ts Resolved
Comment on lines +83 to +87
// Skip reattachment until a live tab exists for this director — a blank
// tabId would create an orphan entry that can't be activated from the sidebar.
const tabId = state.tabsByWorktree[worktree.id]?.[0]?.id
if (!tabId) {
continue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Avoid one-shot reattach skips when tabs hydrate after worktrees.

Lines [83]-[87] hard-skip entries with missing tabId. Combined with the current sidebar lifecycle (reattachOrchestrators() triggered from worktree changes), an orchestrator can be skipped once and never reattached until another worktree change/reload.

Comment thread src/shared/runtime-types.ts Resolved
zaridan and others added 5 commits June 22, 2026 21:35
…c fence langs

closeOrchestrator removed the registry entry optimistically and only logged on
removeWorktree failure, so a real teardown error (fs locked, perms) left the
director gone from the sidebar while its worktree survived on disk — unreachable
for retry. Restore the entry on failure (dedupe-safe). Update the test to assert
rollback. Add text language identifiers to the remaining bare fenced blocks in
the orcastrate skill docs (CodeRabbit markdownlint nits).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Double-click an Orcastrator's name in the sidebar to edit it inline,
matching the existing worktree-title rename UX. Reuses
WorktreeTitleInlineRename (Enter commits, Escape cancels, blur commits,
empty/unchanged guarded).

The rename updates both sources of truth: an optimistic in-memory
updateOrchestrator for instant UI, then the durable worktree displayName
(prefixed with ORCASTRATOR_DISPLAY_PREFIX) via the existing
updateWorktreeMeta path so reattachOrchestrators reconstructs the name
after a reload. The activate target became a role="button" div because an
Input nested in a <button> is invalid HTML; Enter/Space keep it
keyboard-accessible and the close (X) button is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ayName

reattachOrchestrators preferred project?.displayName over the persisted
worktree displayName, so a renamed Orcastrator with a matching project
reverted to the project name on reload — silently discarding the rename.

Treat the prefix-stripped worktree displayName as the durable source of
truth (it's `prefix + project.displayName` at launch, so un-renamed
directors reconstruct identically), falling back to project/repo only
when no name survives the prefix. Adds a test that fails against the old
precedence, and a "why" note on the optimistic rename update.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- OrchestratorLaunchModal: guard against rapid Enter/double-click firing
  concurrent launches (in-flight isLaunching flag) so one intent produces
  one worktree/director.
- orchestrator-launch: surface a toast when the backgrounded /orcastrate
  seed times out or rejects, instead of silently leaving the session idle.
- OrchestratorsSidebarSection: persist the rename to durable worktree
  metadata FIRST (new throwOnPersistError option) and only mirror it into
  the in-memory entry on success, so the sidebar name can't diverge.
- OrchestratorsSidebarSection: give the close button keyboard focus
  visibility (group-focus-within + focus-visible ring).
- i18n: register the new seed_failed key across all locales.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
An Orcastrator's sidebar dot rendered the agent hook's `done` state as a
green completion check, even while the director was still supervising
background workers — reading as "finished" when the run was mid-flight.

Surface the in-flight orchestration run as a distinct signal:

- Main: buildOrchestrationActivityByPaneKey() emits per running coordinator
  run, keyed by the coordinator's pane, with outstanding-task / active- and
  stale-dispatch counts (db.listCoordinatorRuns + count helpers). Returned
  on the syncWindowGraph result.
- Renderer: new orchestration-activity store slice receives it via the
  existing graph-sync channel; deriveOrcastratorDotState prefers the run
  signal once the foreground turn ends, so a supervising director shows a
  calm emerald pulse ('supervising'), a hung worker shows amber ('stalled'),
  and a truly idle one shows a neutral dot — never the completion check.

The dashboard's AgentStateDot 'done' check is intentionally unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Scope per-pane orchestration activity to each run by the coordinator handle
  that owns its tasks/dispatches, so concurrent Orcastrators report independent
  metrics and one run's stale worker can't mark another's pane stalled.
- Match worktree-attributed agent statuses by worktreeId (not just tab prefix)
  so worktree-level dots don't show idle before tabs attach.
- Run orchestrator reattach from the sidebar root (always mounted) keyed on
  tabsByWorktree too, so a collapsed sidebar / late tab hydration can't leave
  stale or skipped orchestrator state.
- Gate WorktreeCardAgents director filtering behind experimentalOrchestrators.
- Use status-success/status-warning design tokens for the supervising/stalled
  dots instead of raw Tailwind palette values.
- Add visible focus-visible state to the Orcastrator row activator.
- Key Mission Control's PR refresh on the shipped branch set, not its length.
- Make orcastrator dot-state stalled precedence deterministic across panes.
- Tear down the director worktree when activation throws, not only on falsy.
- Gate director worktrees to Mission Control before SourceControlInner mounts
  so its branch/PR effect graph never runs for them.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@zaridan
zaridan force-pushed the feat/orcastrator-supervising-dot branch from f06e6c2 to da3ebc7 Compare June 23, 2026 05:12
@zaridan

zaridan commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

CodeRabbit feedback addressed

Rebased onto the updated feat/orcastrator-rename (parent #6099) first, then applied every actionable + nitpick comment from the latest review.

Core bug — per-run pane activity (orca-runtime.ts + runtime-types.ts, also flagged at db.ts)

  • Per-pane orchestration counts were aggregated globally and copied to every run, so concurrent Orcastrators showed identical metrics and one run's stale dispatch marked others stalled. There is no run_id column on tasks/dispatch_contexts, but each task carries its coordinator's handle (created_by_terminal_handle) and each concurrent run has a distinct coordinator handle. Added run-scoped DB methods — countOutstandingTasksForCoordinator, countActiveDispatchesForCoordinator, getStaleDispatchesForCoordinator (the dispatch ones join through tasks) — and buildOrchestrationActivityByPaneKey now scopes every count to run.coordinator_handle. Updated the doc comment in runtime-types.ts to match. Added db + runtime tests.

worktree-agent-dot-state.ts — now matches by entry.worktreeId as well as tab prefix, so worktree-level dots don't show idle before tabs attach. Threaded worktreeId through deriveWorktreeAgentDotState / deriveOrcastratorDotState and all call sites; added a test.

sidebar/index.tsx (+ orchestrators.ts reattach skip) — moved the reattach effect out of OrchestratorsSidebarSection (which only mounts when the sidebar is open) into a new useReattachOrchestrators hook called at the sidebar root, so reattach runs regardless of sidebar open/closed. Keyed it on tabsByWorktree too, so an entry skipped because its tab hadn't hydrated is reattached the instant the tab appears (addresses the one-shot-skip comment).

WorktreeCardAgents.tsx — director-row filtering is now gated behind experimentalOrchestrators.

AgentStateDot.tsx — supervising/stalled dots use bg-status-success/70 and bg-status-warning design tokens. Added a --status-warning token (light/dark + @theme inline exposure) mirroring --status-success.

OrchestratorsSidebarSection.tsx — added a visible focus-visible ring to the row activator (the close button already had focus styling).

OrchestratorMissionControl.tsx — PR refresh effect now keys on shippedWork (memoized) instead of shippedWork.length, so a same-size branch-set change still refetches.

orcastrator-dot-state.ts — findOrchestrationActivityForTabs now scans all matches and short-circuits on staleDispatches > 0, so stalled precedence is deterministic regardless of entry order. Added a test.

SourceControl.tsx — gated director worktrees to Mission Control in a new outer SourceControlGate wrapper before SourceControlInner mounts, so its branch/PR/git effect graph never runs for a director (the old gate ran at the end, after all hooks mounted).

OrchestratorLaunchModal.tsx dup-launch guard and orchestrators.ts teardown-restore — verified already resolved via the rebase from the parent fix; left as-is.

orchestrator-launch.ts — activation cleanup now also runs when activateAndRevealWorktree throws (previously only the falsy return was handled), via a shared teardownAfterFailedLaunch helper, so a thrown activation can't leak an orphaned director worktree.

No remaining open markdown/doc nits in this review. Verified locally: pnpm run typecheck, pnpm run lint, and the full pnpm run test suite (19,851 passed) all green.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/runtime/orchestration/db.test.ts (1)

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

Add a non-stale assertion for a “current” threshold.

This block only checks the positive stale case with a far-future threshold. Add one near-now negative assertion so fresh dispatches are proven non-stale in this test path.

Suggested test addition
       d.createDispatchContext(aTask.id, 'worker_a')
       expect(d.countActiveDispatchesForCoordinator('coord_a')).toBe(1)
       expect(d.countActiveDispatchesForCoordinator('coord_b')).toBe(0)

+      const now = new Date().toISOString()
+      expect(d.getStaleDispatchesForCoordinator('coord_a', now)).toHaveLength(0)
+
       // A future threshold reads the only dispatched worker as stale, but the
       // staleness is attributed solely to the run that owns it.
       const future = '2999-01-01T00:00:00.000Z'
       expect(d.getStaleDispatchesForCoordinator('coord_a', future)).toHaveLength(1)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7f00e280-9527-47bb-922a-2f6fc7ffcf4d

📥 Commits

Reviewing files that changed from the base of the PR and between f06e6c2758794b25d820474755c9fcf9075990b8 and da3ebc7.

📒 Files selected for processing (36)
  • skills/orcastrate/SKILL.md
  • skills/orcastrate/orcastrate-coordinator.md
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration/db.test.ts
  • src/main/runtime/orchestration/db.ts
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/AgentStateDot.tsx
  • src/renderer/src/components/OrchestratorLaunchModal.tsx
  • src/renderer/src/components/right-sidebar/OrchestratorMissionControl.tsx
  • src/renderer/src/components/right-sidebar/SourceControl.tsx
  • src/renderer/src/components/sidebar/OrchestratorsSidebarSection.tsx
  • src/renderer/src/components/sidebar/WorktreeCardAgents.tsx
  • src/renderer/src/components/sidebar/index.tsx
  • src/renderer/src/components/sidebar/use-reattach-orchestrators.ts
  • src/renderer/src/components/sidebar/worktree-card-agent-summary.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/orcastrator-dot-state.test.ts
  • src/renderer/src/lib/orcastrator-dot-state.ts
  • src/renderer/src/lib/orchestrator-launch.ts
  • src/renderer/src/lib/worktree-agent-dot-state.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/store/index.ts
  • src/renderer/src/store/slices/diffComments.test.ts
  • src/renderer/src/store/slices/orchestration-activity.ts
  • src/renderer/src/store/slices/orchestrators.test.ts
  • src/renderer/src/store/slices/orchestrators.ts
  • src/renderer/src/store/slices/store-test-helpers.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/renderer/src/store/slices/worktrees.ts
  • src/renderer/src/store/types.ts
  • src/shared/runtime-types.ts
✅ Files skipped from review due to trivial changes (3)
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/ko.json
🚧 Files skipped from review as they are similar to previous changes (22)
  • src/renderer/src/components/sidebar/worktree-card-agent-summary.ts
  • src/shared/runtime-types.ts
  • skills/orcastrate/SKILL.md
  • src/renderer/src/store/slices/store-test-helpers.ts
  • src/renderer/src/lib/orcastrator-dot-state.test.ts
  • src/renderer/src/components/AgentStateDot.tsx
  • src/renderer/src/components/sidebar/WorktreeCardAgents.tsx
  • src/renderer/src/store/slices/diffComments.test.ts
  • src/renderer/src/store/slices/orchestration-activity.ts
  • src/renderer/src/store/index.ts
  • src/renderer/src/components/sidebar/OrchestratorsSidebarSection.tsx
  • src/renderer/src/assets/main.css
  • src/renderer/src/store/slices/worktrees.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/right-sidebar/OrchestratorMissionControl.tsx
  • src/renderer/src/components/OrchestratorLaunchModal.tsx
  • src/renderer/src/store/types.ts
  • src/renderer/src/lib/orchestrator-launch.ts
  • skills/orcastrate/orcastrate-coordinator.md
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/es.json

Comment on lines +704 to +723
// Why: run-scoped variant of getStaleDispatches. A dispatch belongs to a run
// via the task's coordinator handle (the coordinator that created the task),
// so joining through tasks keeps concurrent runs from seeing each other's
// stale workers — without it, one hung run marks every Orcastrator stalled.
getStaleDispatchesForCoordinator(
coordinatorHandle: string,
thresholdIso: string
): DispatchContextRow[] {
return this.db
.prepare(
`SELECT d.* FROM dispatch_contexts d
JOIN tasks t ON t.id = d.task_id
WHERE d.status = 'dispatched'
AND d.dispatched_at IS NOT NULL
AND d.dispatched_at < ?
AND (d.last_heartbeat_at IS NULL OR d.last_heartbeat_at < ?)
AND t.created_by_terminal_handle = ?`
)
.all(thresholdIso, thresholdIso, coordinatorHandle) as DispatchContextRow[]
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify mixed timestamp formats and raw TEXT comparisons in stale-dispatch queries.
rg -n -C2 "INSERT INTO dispatch_contexts|dispatched_at < \\?|last_heartbeat_at < \\?" src/main/runtime/orchestration/db.ts

python - <<'PY'
import sqlite3
db = sqlite3.connect(":memory:")
a = "2026-06-23 23:59:59"          # sqlite datetime('now') shape
b = "2026-06-23T00:00:00.000Z"     # ISO shape
print("raw_text_compare (a < b):", db.execute("SELECT ? < ?", (a, b)).fetchone()[0])
print("normalized_compare:", db.execute("SELECT datetime(?) < datetime(?)", (a, b)).fetchone()[0])
PY

Repository: stablyai/orca

Length of output: 1989


🌐 Web query:

SQLite TEXT comparison datetime('now') vs ISO 8601 format timestamp mismatch

💡 Result:

In SQLite, datetime('now') returns a string in the format YYYY-MM-DD HH:MM:SS [1][2]. While SQLite supports various ISO 8601 strings (including those with a 'T' separator, like YYYY-MM-DDTHH:MM:SS) [1][3], discrepancies in comparisons between these formats typically arise because SQLite performs binary string comparisons when it treats them as plain text [4]. If you are encountering a "mismatch" or unexpected results during comparison, it is usually due to one of the following reasons: 1. Lexicographical Comparison Issues: SQLite compares TEXT values lexicographically [4]. The string YYYY-MM-DD HH:MM:SS (space separator) and YYYY-MM-DDTHH:MM:SS ('T' separator) will not sort or compare identically because the character 'T' does not have the same ASCII/binary value as a space [4][5][6]. 2. Format Mismatches in Comparisons: If you compare a column containing ISO 8601 strings (e.g., '2026-06-23T12:00:00') against a literal that does not follow the exact same format (e.g., '2026-06-23 12:00:00'), the comparison may fail or produce incorrect results because the strings differ at the separator position [5][6]. To ensure robust and accurate comparisons: - Normalize your inputs: Use SQLite's date/time functions to convert both operands into a consistent format before comparing [7][8]. For example, wrap both sides of the comparison in the datetime() function: SELECT * FROM my_table WHERE datetime(my_column) = datetime('now'); [5] - Use consistent storage: Decide on one format (e.g., always YYYY-MM-DD HH:MM:SS or always ISO 8601 with 'T') and enforce this format when inserting data or using literals [9][8]. - Understand the affinity: Remember that SQLite does not have a dedicated date/time type [10][11]. Columns containing dates are typically TEXT, and operations on them are standard text operations unless explicitly parsed by SQLite's built-in date/time functions [10][7]. Using the datetime() function is the safest way to perform comparisons, as it acts as a "Swiss Army knife" that understands both ISO 8601 strings and other supported formats, normalizing them for logical comparison [7][8].

Citations:


Normalize timestamp comparisons in stale-dispatch queries.

dispatched_at is written with datetime('now') (SQLite format: YYYY-MM-DD HH:MM:SS with space separator), while thresholdIso is ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ with T separator). Comparing these as raw TEXT performs lexicographic comparison in SQLite, which fails because the separator characters differ ('T' vs space), potentially marking fresh dispatches as stale.

Suggested fix
  getStaleDispatches(thresholdIso: string): DispatchContextRow[] {
    return this.db
      .prepare(
        `SELECT * FROM dispatch_contexts
         WHERE status = 'dispatched'
           AND dispatched_at IS NOT NULL
-          AND dispatched_at < ?
-          AND (last_heartbeat_at IS NULL OR last_heartbeat_at < ?)`
+          AND datetime(dispatched_at) < datetime(?)
+          AND (last_heartbeat_at IS NULL OR datetime(last_heartbeat_at) < datetime(?))`
      )
      .all(thresholdIso, thresholdIso) as DispatchContextRow[]
  }
...
  getStaleDispatchesForCoordinator(
    coordinatorHandle: string,
    thresholdIso: string
  ): DispatchContextRow[] {
    return this.db
      .prepare(
        `SELECT d.* FROM dispatch_contexts d
         JOIN tasks t ON t.id = d.task_id
         WHERE d.status = 'dispatched'
           AND d.dispatched_at IS NOT NULL
-          AND d.dispatched_at < ?
-          AND (d.last_heartbeat_at IS NULL OR d.last_heartbeat_at < ?)
+          AND datetime(d.dispatched_at) < datetime(?)
+          AND (d.last_heartbeat_at IS NULL OR datetime(d.last_heartbeat_at) < datetime(?))
           AND t.created_by_terminal_handle = ?`
      )
      .all(thresholdIso, thresholdIso, coordinatorHandle) as DispatchContextRow[]
  }

@zaridan

zaridan commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Folded into the consolidated Orcastrator PR #6293.

@zaridan zaridan closed this Jun 24, 2026
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.

2 participants