agent-orchestrator/packages/core/src
Harshit Singh Bhandari 94981dc0fd
feat(web,core): "Launch Orchestrator (clean context)" button (#1904)
* feat(web,core): "Launch Orchestrator (clean context)" button

Adds a dashboard action that replaces the project's canonical
orchestrator with a fresh one — killing any existing orchestrator,
deleting its metadata, and spawning a new session with no carryover.

Why: users had no way to start an orchestrator with a clean slate from
the dashboard. Previous orchestrator context (conversation history,
stale state) silently carried over via the existing "Open Orchestrator"
flow, which only worked for first-time spawn anyway.

- core: new SessionManager.relaunchOrchestrator(config) that kills +
  deletes existing metadata then calls spawnOrchestrator. Ignores
  project.orchestratorSessionStrategy — replacement is the whole point.
  Coalesces concurrent calls via a dedicated relaunchOrchestratorPromises
  map (separate from ensureOrchestratorPromises since the semantics
  differ — a relaunch behind an ensure must not return the existing
  session).
- web: POST /api/orchestrators accepts { clean: true } to route to the
  new method. OrchestratorSelector renders a "Launch Orchestrator
  (clean context)" button that uses window.confirm() before discarding
  an existing orchestrator; no confirm when none exists.

Closes #1900, closes #1080.


* fix(core,web): address PR #1904 review

- core: cross-map race between ensureOrchestrator and relaunchOrchestrator.
  Each now awaits the other's in-flight promise (keyed by sessionId) before
  proceeding. Prevents (a) relaunch skipping the kill while ensure's
  spawnOrchestrator is mid-reservation, and (b) ensure returning a session
  that relaunch is about to kill. Adds two race regression tests.

- web: align handleSpawnNew with handleRelaunchClean via the void expression
  form; add "Launching..." in-progress label to the clean-context button and
  a test that asserts it renders during POST.


* refactor(web): rip out Orchestrator Selector page; relocate clean-launch action

There is only ever one orchestrator per project, so the /orchestrators
selector page is meaningless. Delete it along with its component, tests,
and the unused mapSessionsToOrchestrators util. Drop GET /api/orchestrators
(only consumer was the deleted page). Remove /orchestrators from project
revalidate lists.

The "Launch Orchestrator (clean context)" action that previously lived on
the deleted page now appears in two places:

- Dashboard header: a "Relaunch (clean)" button renders alongside the
  Orchestrator link whenever a project orchestrator exists. Uses
  window.confirm before discarding state.
- Orchestrator session page: a "Relaunch (clean)" button in the
  SessionDetailHeader for live orchestrator sessions, calling
  POST /api/orchestrators with clean:true and reloading the session view.

* refactor(web): remove Relaunch (clean) action from the Dashboard

Keep the clean-launch action only on the orchestrator session page —
that's where the user has the context to decide on a destructive
restart. The Dashboard header just links to the orchestrator (or shows
the existing Spawn Orchestrator button when none exists).

* fix(web): surface relaunch failures with an inline error banner

After confirm + POST /api/orchestrators with clean:true, the previous
implementation only logged failures to console.error — leaving the user
on a stale page with no signal that the destructive action partially
executed. relaunchOrchestrator kills before respawning, so a failed
respawn means the server has no orchestrator while the client still
renders the old session view.

Add local relaunchError state, set it on catch (parsed from the JSON
error response when available), and render a dismissible error banner
above the terminal area. The banner explicitly warns the user that the
previous orchestrator may already be terminated and points them at the
project dashboard to retry.

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

* fix(web,core): address PR #1904 review from @i-trytoohard

- web: navigate to the new orchestrator's session path (from POST
  response) instead of window.location.reload(). Orchestrator session
  IDs are fixed per project so the path is the same in practice, but
  reading from the response is the right contract and a hard nav forces
  the terminal WebSocket to reconnect cleanly against the new tmux.

- web: remove the `!terminalEnded` gate on the Relaunch (clean) button
  in SessionDetailHeader. Terminated orchestrators are exactly when the
  user wants to relaunch — hiding the button there was wrong.

- core: log a warning instead of silently swallowing when an in-flight
  cross-map promise (ensure waiting on relaunch, or relaunch waiting on
  ensure) rejects before its caller proceeds. The catch-and-continue
  semantics are correct (the caller will re-check state anyway) but
  invisible failures were a debugging hazard.

Adds a regression test that the button stays visible on terminated
orchestrator sessions and that successful relaunch navigates via
window.location.href.
2026-05-17 21:16:25 +05:30
..
__tests__ feat(web,core): "Launch Orchestrator (clean context)" button (#1904) 2026-05-17 21:16:25 +05:30
migration refactor(core): storage redesign — projectId-based paths, JSON metadata (#1466) 2026-04-28 17:55:53 +05:30
prompts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
recovery fix(agent-plugins,lifecycle): distinguish indeterminate probe from "not found" + bump ps timeout (closes #1838) (#1839) 2026-05-14 21:50:39 +05:30
utils refactor(core): storage redesign — projectId-based paths, JSON metadata (#1466) 2026-04-28 17:55:53 +05:30
activity-events.ts feat(core): wire activity events into lifecycle-manager failure paths (#1511) (#1620) 2026-05-06 22:14:21 +05:30
activity-log.ts fix(core): keep actionable activity sticky (#1902) 2026-05-17 20:03:56 +05:30
activity-signal.ts fix: address lifecycle review feedback (#122) 2026-04-17 19:38:32 +05:30
agent-report.ts refactor(core): storage redesign — projectId-based paths, JSON metadata (#1466) 2026-04-28 17:55:53 +05:30
agent-selection.ts fix(core): forward allSessionPrefixes in resolveSessionRole 2026-04-06 23:11:59 -07:00
agent-workspace-hooks.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
atomic-write.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
cleanup-stack.ts refactor(core): replace spawn rollback ladder with CleanupStack (#1616) 2026-05-03 22:43:21 +05:30
config-generator.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
config.ts feat(lifecycle): inject failed-job/step + log tail into CI-failure agent messages (closes #1807) (#1810) 2026-05-15 05:48:45 +05:30
daemon-children.ts fix(cli): reap daemon children on stop+SIGINT, sweep orphans on start (closes #1848) (#1849) 2026-05-15 03:38:09 +05:30
events-db.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
feature-flags.ts Add multi-project storage, resolution, and project settings support (#1343) 2026-04-21 17:45:55 +05:30
feedback-tools.ts feat(core): add feedback tools contracts, validation, storage, and dedupe 2026-03-10 22:31:39 +05:30
file-lock.ts Add multi-project storage, resolution, and project settings support (#1343) 2026-04-21 17:45:55 +05:30
format-automated-comments.ts fix(core): dispatch detailed bugbot review comments to agents (#1334) 2026-04-22 22:18:13 +05:30
gh-trace.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
git-activity.ts refactor(core): extract hasRecentCommits helper into @aoagents/ao-core (#1437) 2026-05-05 18:58:53 +05:30
global-config.ts feat(release): weekly release train — channels, onboarding, dashboard banner, cron (#1781) 2026-05-12 23:11:09 +05:30
index.ts fix(cli): reap daemon children on stop+SIGINT, sweep orphans on start (closes #1848) (#1849) 2026-05-15 03:38:09 +05:30
key-value.ts feat(core): add feedback tools contracts, validation, storage, and dedupe 2026-03-10 22:31:39 +05:30
lifecycle-manager.ts feat(lifecycle): inject failed-job/step + log tail into CI-failure agent messages (closes #1807) (#1810) 2026-05-15 05:48:45 +05:30
lifecycle-state.ts fix(core): clear terminatedAt/completedAt when restoring a session out of terminal state (closes #1831) (#1834) 2026-05-15 04:46:35 +05:30
lifecycle-status-decisions.ts refactor(core): storage redesign — projectId-based paths, JSON metadata (#1466) 2026-04-28 17:55:53 +05:30
lifecycle-transition.ts fix(core): clear terminatedAt/completedAt when restoring a session out of terminal state (closes #1831) (#1834) 2026-05-15 04:46:35 +05:30
markdown.d.ts build(core): bundle prompt templates with rollup 2026-04-13 14:55:01 +05:30
metadata.ts feat(web): allow renaming worker sessions in the sidebar (#1748) 2026-05-10 19:41:48 +05:30
notifier-resolution.ts fix: merge upstream main and resolve conflicts for cursor agent 2026-04-10 11:48:27 +05:30
observability.ts fix: close remaining pr1300 follow-ups 2026-04-18 15:18:24 +05:30
opencode-agents-md.ts feat(opencode): enhance AGENTS.md handling 2026-04-11 18:58:04 +05:30
opencode-config.ts feat (core): inject worker prompt as instructions file (#1302) 2026-04-26 15:44:39 +05:30
opencode-session-id.ts feat: OpenCode session lifecycle and CLI controls (#315) 2026-03-08 09:55:44 +05:30
opencode-shared.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
orchestrator-prompt.ts fix(core): validate template placeholders before render 2026-04-16 20:13:58 +05:30
orchestrator-session-strategy.ts Fix orchestrator identity to use one canonical session per project (#1487) 2026-04-25 18:57:31 +05:30
paths.ts refactor(core): storage redesign — projectId-based paths, JSON metadata (#1466) 2026-04-28 17:55:53 +05:30
platform.ts fix(cli): reap daemon children on stop+SIGINT, sweep orphans on start (closes #1848) (#1849) 2026-05-15 03:38:09 +05:30
plugin-registry.ts feat(plugin): implement kimicode agent plugin (#1390) 2026-05-01 14:11:30 +05:30
portfolio-projects.ts Add multi-project storage, resolution, and project settings support (#1343) 2026-04-21 17:45:55 +05:30
portfolio-registry.ts refactor(core): storage redesign — projectId-based paths, JSON metadata (#1466) 2026-04-28 17:55:53 +05:30
portfolio-routing.ts Add multi-project storage, resolution, and project settings support (#1343) 2026-04-21 17:45:55 +05:30
portfolio-session-service.ts refactor(core): storage redesign — projectId-based paths, JSON metadata (#1466) 2026-04-28 17:55:53 +05:30
process-cache.ts refactor(spawn): plugin-owned preflight + collapse project resolution (#1622) 2026-05-04 14:03:26 +05:30
project-resolver.ts Add multi-project storage, resolution, and project settings support (#1343) 2026-04-21 17:45:55 +05:30
prompt-builder.ts feat: enable worker→orchestrator dialogue via `ao send` with auto-sender prefix (#1787) 2026-05-10 21:50:43 +05:30
query-activity-events.ts feat: add SQLite-backed activity event logging layer (#1528) 2026-05-01 21:13:20 +05:30
report-watcher.ts fix: address PR #1300 requested changes 2026-04-18 11:13:53 +05:30
scm-webhook-utils.ts feat: add SCM webhook lifecycle triggers (#394) 2026-03-11 10:34:41 +05:30
session-manager.ts feat(web,core): "Launch Orchestrator (clean context)" button (#1904) 2026-05-17 21:16:25 +05:30
spawn-target.ts fix(cli): derive projectId from prefixed issue id on spawn (#1330) 2026-04-22 22:18:39 +05:30
storage-key.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
tmux.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
types.ts feat(web,core): "Launch Orchestrator (clean context)" button (#1904) 2026-05-17 21:16:25 +05:30
update-cache.ts feat(release): weekly release train — channels, onboarding, dashboard banner, cron (#1781) 2026-05-12 23:11:09 +05:30
utils.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
version-compare.ts feat(release): weekly release train — channels, onboarding, dashboard banner, cron (#1781) 2026-05-12 23:11:09 +05:30
windows-pty-registry.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30