feat(chat): add ACP session CLI, history, and automation routing

Merged
HA
1mo ago
+7566-2196

What & why

Clean stack on #8585. This branch starts directly at dedbb1fa9242a3eb097b05fb4e6ffe0105e79efb (saddlepaddle/restrict-main-pane-types-b3b96db4) and contains 11 linear local commits, with no merge commits or main-only commits. It is intended to merge into #8585's branch. If #8585 lands first, retarget this PR to main.

The comparison is now 172 files, down from 894 in the previous mixed-history stack. The additional files since the clean-stack rebuild are the intentional fork-safety workflow fix and its documentation/tests. Unrelated marketing, mobile, sharing, database/migration, workflow, plugin, lockfile, and release-version changes from the main synchronizations have been removed.

Chat history and editing

  • Add history only to chat panel headers, scoped to the panel's current provider and workspace directory. Search Superset-saved sessions and native ACP session/list history where supported, with capability gating and pagination.
  • Reuse an existing matching pane instead of duplicating it. No provider selector or New chat button in the history picker.
  • Preserve the local sent-message editing and file-restore confirmation changes, checkpoint worker/safety fixes, pdev 0.1.3 bundle update, and removal of the CLI/Chat surface toggle.
  • Older hosts without file-change previews now edit the conversation while keeping files untouched. Restoration requires explicit confirmation.
  • Preserve the local right-pane, expanded-pane restoration, split, and MCP-chip review fixes.

Chat-only sessions

  • Add host sessions.capabilities/create/list/get/read/send/close/resume procedures backed by the existing ACP runtime and shared creation logic.
  • Add superset sessions create/list/read/send/close/resume/open, with workspace/host targeting and exact-session desktop links.
  • Require the ACP flag and provider support. The new CLI has no terminal fallback; older hosts and unavailable flag verification produce explicit errors.
  • Add optional before cursor support to sessions.read, exposed as superset sessions read --before '<nextBefore JSON>'.
  • Scope session access and retry command IDs to the workspace/conversation; reject dead adapters as live targets.
  • Carry the narrow provider-identity matching needed to continue a second configuration of a provider, without importing the rest of main. A regression test covers this clean-stack dependency.

Automations

  • Eligible runs use sessions.create. Keep terminal launches for flag-off/unsupported cases and narrowly scoped compatibility paths for older hosts and legacy continuation records.
  • Save the actual chat session ID plus its terminal-compatible binding. Register chat metadata before linking the existing foreign key; no database migration.
  • Bind fresh cloud workspaces to their automation run before provisioning, carry the run ID through first boot, and accept launch reports only for the matching sandbox, organization, creator, and run.
  • Run links prefer exact chat IDs and retain terminal fallback for older viewers. Chat history and run links share pane-opening logic.
  • Match terminal-style pane behavior for now: continue a live session, avoid duplicate panes, do not reopen deliberately closed/backgrounded panes, and create a fresh session when automation continuation is no longer possible. Explicit sessions resume is separate.

Fork-safe checks (0d8bf8a062)

  • Skip secret-backed preview database/deployment, preview comments, and cleanup for fork/Dependabot runs, where GitHub withholds the required credentials and write token.
  • Skip only the R2 bucket-comparison dry run in the sandbox job on those PRs. Manifest tests, bundle build, Docker image build, real boot-twice checks, and the synthetic runner check remain enabled.
  • Keep all privileged steps enabled for normal same-repository PRs; missing credentials there still fail rather than being hidden.
  • Add seven workflow-policy regression cases to CI, covering fork/Dependabot/trusted conditions, dependency gating, and retained sandbox coverage. The sandbox unit suite also passes (17 tests).
  • CI on clean-stack head 8d961dd917 passed Test, Typecheck, Lint, and the Linux CLI build. CI on workflow follow-up 0d8bf8a062 is also green: Test, Typecheck, Lint, Linux CLI build, and the complete Sandbox Boot twice job all passed. Privileged preview jobs are correctly skipped on this fork.

Earlier review scope

The marketing-headline finding came entirely from the removed main synchronization. Marketing now matches #8585 exactly; this PR no longer introduces that experiment or changes its fallback. File-restore safety and session-pagination review fixes are retained.

How I tested the clean stack

Using the base branch's pinned Bun 1.4.2:

  • 8,477 desktop tests passed, including message-edit safety, exact run links, pane reuse, and pane-area fixes.
  • 467 targeted backend/CLI/runtime tests passed; 2 credentialed live-provider tests skipped. This includes ACP discovery, chat session lifecycle and pagination, agent compatibility, checkpoints, the main-loop blocking guard, automation routing/reporting, and cloud launch/boot contracts.
  • Full repository bun run lint passed.
  • bun run check:i18n passed without additional catalog changes.
  • git diff --check passed.
  • Typechecking was attempted and still encounters the existing local Better Auth type mismatches. No errors were reported in the changed session/runtime/pane code. CI on the current head passed the complete build/typecheck and test checks.
  • Verified that the merge base is exactly #8585's current head, the stack has zero merge commits, and marketing/mobile/database/plugin/lockfile/root-version files match the base. Workflow differences are limited to the explicit fork-safety follow-up above.

Previous mixed-history test results are not being substituted for this clean-stack validation. No live automation or deployed sandbox was triggered.

Rollout / known limits

  • Deploy the API flag endpoint and reporting procedure before releasing the new host-service/CLI.
  • Cloud chat launches remain Claude-only. Sandbox changes require a published host-service/sandbox bundle; this PR does not deploy one.
  • Failed first-boot launch reports are retained for retry on host-service restart. A crash between creating the session and writing its report can still lose the run link; documented in docs/cloud-sandbox-mismatches.md.
  • Existing agents.run, terminal APIs, and older terminal run links remain supported.
  • No database migrations or release-version changes.

Checklist

  • PR title follows conventional commits
  • Clean, linear stack directly on #8585; no main merge commits
  • Full repository lint and i18n checks pass
  • Full CI/typecheck passes on 0d8bf8a062; privileged preview jobs skip correctly on this fork
  • Allow edits from maintainers