Skip to content

fix: prevent ao start from spawning duplicate orchestrators#909

Open
harshitsinghbhandari wants to merge 12 commits intoComposioHQ:mainfrom
harshitsinghbhandari:fix/prevent-duplicate-orchestrators
Open

fix: prevent ao start from spawning duplicate orchestrators#909
harshitsinghbhandari wants to merge 12 commits intoComposioHQ:mainfrom
harshitsinghbhandari:fix/prevent-duplicate-orchestrators

Conversation

@harshitsinghbhandari
Copy link
Copy Markdown
Collaborator

When ao start is run and existing orchestrator sessions exist for the project, the CLI now skips spawning a new one. Instead:

  • Detects existing orchestrator sessions before spawning
  • Opens the dashboard to a new /orchestrators page for session selection
  • Users can resume an existing orchestrator or start a new one

Changes:

  • packages/cli/src/commands/start.ts: Check for existing orchestrators, redirect to selection page if found
  • packages/web/src/app/api/orchestrators/route.ts: Add GET endpoint to list orchestrators for a project
  • packages/web/src/app/orchestrators/page.tsx: New page for orchestrator selection
  • packages/web/src/components/OrchestratorSelector.tsx: UI component for selecting or spawning orchestrators
  • packages/web/src/components/tests/OrchestratorSelector.test.tsx: Tests for the selector component

When ao start is run and existing orchestrator sessions exist for the
project, the CLI now skips spawning a new one. Instead:

- Detects existing orchestrator sessions before spawning
- Opens the dashboard to a new /orchestrators page for session selection
- Users can resume an existing orchestrator or start a new one

Changes:
- packages/cli/src/commands/start.ts: Check for existing orchestrators,
  redirect to selection page if found
- packages/web/src/app/api/orchestrators/route.ts: Add GET endpoint to
  list orchestrators for a project
- packages/web/src/app/orchestrators/page.tsx: New page for orchestrator
  selection
- packages/web/src/components/OrchestratorSelector.tsx: UI component for
  selecting or spawning orchestrators
- packages/web/src/components/__tests__/OrchestratorSelector.test.tsx:
  Tests for the selector component

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates ao start to avoid spawning duplicate orchestrator sessions when one (or more) already exists for a project, and introduces a dashboard selection flow so users can resume an existing orchestrator or start a new one.

Changes:

  • CLI: detect existing orchestrator sessions before spawning and, if found, open the dashboard’s new orchestrator-selection page.
  • Web API: add GET /api/orchestrators?project=<id> to list orchestrator sessions for a project.
  • Web UI: add /orchestrators page plus OrchestratorSelector component and tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/cli/src/commands/start.ts Avoid spawning when existing orchestrators are present; open selection page instead.
packages/web/src/app/api/orchestrators/route.ts Adds GET endpoint to list orchestrators for a project (POST remains spawn).
packages/web/src/app/orchestrators/page.tsx New server-rendered selection page that loads orchestrator sessions for a project.
packages/web/src/components/OrchestratorSelector.tsx Client UI to display existing sessions and spawn a new orchestrator.
packages/web/src/components/tests/OrchestratorSelector.test.tsx Component tests for the selector UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

harshitsinghbhandari and others added 7 commits April 4, 2026 21:52
Guard against NaN timestamps from invalid ISO date strings and handle
future timestamps gracefully by returning "Just now" instead of
negative values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The projects prop was declared and passed but never used, causing
unnecessary data fetching and serialization. Removed the prop from
the component interface, page, and tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The sm.list() call was outside the existing try/catch that handles
orchestrator setup failures. If listing sessions throws, the spinner
could be left running and the dashboard process could leak.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When --no-dashboard is used and existing orchestrators are found,
auto-select the most recently active one instead of deferring to
dashboard selection (which isn't available). This ensures the CLI
remains usable without the dashboard.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests to verify proper handling of:
- Invalid date strings (returns "Unknown")
- Future timestamps (returns "Just now")
- Null dates (returns "Unknown")

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update existing test to verify the new --no-dashboard auto-select
behavior and add a separate test for dashboard-enabled selection
message.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Export Orchestrator interface from OrchestratorSelector component
and import it in page.tsx to avoid silent divergence risk.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5255f99. Configure here.

- Fix tmux target to use session ID when runtimeHandle is missing,
  preventing references to non-existent sessions
- Extract mapSessionsToOrchestrators helper to eliminate duplicate
  orchestrator listing logic between page.tsx and API route

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove phantom `projects` prop from test setup (was dead code)
- Deduplicate test coverage: consolidate component tests into
  OrchestratorSelector.test.tsx, keep only page route tests in
  orchestrators.test.tsx
- Fix useRouter mock to capture and assert router.push calls
- Add finally block to handleSpawnNew for resilience (ensures
  isSpawning is reset even if router.push fails)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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