fix: prevent ao start from spawning duplicate orchestrators#909
Open
harshitsinghbhandari wants to merge 12 commits intoComposioHQ:mainfrom
Open
fix: prevent ao start from spawning duplicate orchestrators#909harshitsinghbhandari wants to merge 12 commits intoComposioHQ:mainfrom
harshitsinghbhandari wants to merge 12 commits intoComposioHQ:mainfrom
Conversation
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>
Contributor
There was a problem hiding this comment.
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
/orchestratorspage plusOrchestratorSelectorcomponent 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.
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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>
7 tasks
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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