Skip to content

feat(cloud-agent-next): support multiple chats per worktree - #5751

Merged
eshurakov merged 14 commits into
mainfrom
eshurakov/dreamy-marsh
Sep 1, 2026
Merged

feat(cloud-agent-next): support multiple chats per worktree#5751
eshurakov merged 14 commits into
mainfrom
eshurakov/dreamy-marsh

Conversation

@eshurakov

@eshurakov eshurakov commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add browser worktree groups with independent chats sharing a checkout, lazy sibling creation, durable ownership, closable/reopenable tabs, custom names, and whole-worktree deletion.
  • Integrate exact physical allocation references, bounded lifecycle and fenced outcomes, mandatory managed-credential containment, and per-worktree Kilo processes from the lower stack.
  • Preserve credential revocation and surviving roots/worktrees during deletion. Fix the deletion-probe/watchdog race, preserve server-registered platform provenance during ingestion, and replay root-scoped pending questions immediately after connected.
  • Regenerate the feature migration as 0234_amused_sasquatch, preserving main migration 0233, concurrent-index boundaries, and the ownership backfill.

Native PR stack

Stack #5752: main -> #5670 hidden-summit -> #5623 glossy-gull -> #5552 eager-hollow -> #5751 dreamy-marsh.

All source/test changes are committed and pushed. Untracked PLAN.md is unchanged and excluded.

Automated verification

  • Final-HEAD Cloud Agent CI: 4,322 Node tests (3 existing skips), 504 Workers tests, and 775 wrapper tests passed with Bun 1.3.14.
  • Final-HEAD TruffleHog passed: zero verified/unverified findings across the complete PR commit range. The three synthetic URI fixture corrections were folded into their original commits, preserving assertions; no scanner bypass or allowlist.
  • Broker: 553; ingest Node: 1,002 (3 existing skips); ingest Workers: 93; SDK: 1,275; affected Web: 775 across 17 suites; changed mobile fixtures: 20 passed.
  • Reconnect fix additionally passed 238 service tests, 666 focused SDK tests, and a Workers root/child-filtering and replay-ordering regression.
  • All affected lint/typechecks, explicit fixture/harness/integration lint, formatting, wrapper build, generated-schema consistency, and disposable-database migration bootstrap passed.
  • CI-only restack preserved every production-code blob, mode, and path exactly. Additional read-only Linux Bun 1.3.14 attachment/runtime suites passed 79/79.

Real local runtime and browser verification

  • Authorized private GitHub clone, mandatory native credential redemption, opaque guest auth carriers, cold/warm turns, persisted ingest, and same-session compute recovery. No raw-token fallback or disabled containment.
  • Real UI first session and ingestion retain cloud-agent-web provenance. Lazy sibling creation does not invoke a model. Concurrent A/B write/read/edit operations share the checkout and complete independently.
  • Exact runtime proof: A/B share one physical allocation, Kilo PID, HOME, directory and credential alias; separate worktrees use distinct processes/auth contexts.
  • Questions remain root-isolated, reappear after connected on reload without a new inference, and complete after answering.
  • Verified + append, /new replacement, persisted closed-tab ordering, rename, terminal context and background activity.
  • Deleting B revokes its runtime access while A completes another turn in the same process/allocation. Whole-worktree deletion removes A/B/empty C, supports replay, rejects resurrection, and preserves an unrelated worktree.
  • All owned test fixtures and live test infrastructure have been stopped/cleaned. No production deployment or remote Git writes.

Remaining limits

  • Local native workerd/egress cancellation can leave a silent upstream request open after canonical interruption. Reproduced independently of Kilo; repository forwarding preserves signals and is unchanged by composition. Production transport behavior remains unverified.
  • No live Vercel acceptance. Rollout/image compatibility and lower-layer lifecycle caveats still require review.
  • Local full Web run exceeded 900 seconds, but the complete GitHub Web test and build jobs passed on the final published HEAD 19b0f14. All current Actions CI jobs are successful; superseded duplicate runs are excluded.
  • Unchanged standalone DB schema test references missing 0204_brainy_baron_strucker.sql (51 passed, 1 failed); generated-schema consistency and bootstrap pass.
  • Mobile sheet focus restoration, terminal-tab restoration after hard reload, and observed billing/hydration diagnostics were not expanded into this integration.

Kept draft for review of these remaining rollout/verification limits.

@eshurakov
eshurakov force-pushed the eshurakov/dreamy-marsh branch from f4e47ab to 19b0f14 Compare August 30, 2026 12:46
@eshurakov
eshurakov force-pushed the eshurakov/dreamy-marsh branch from 3368f8d to 1a882bb Compare August 31, 2026 12:45
@eshurakov
eshurakov marked this pull request as ready for review August 31, 2026 13:41
@kilo-code-bot

kilo-code-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • apps/web/src/components/cloud-agent-next/CloudAgentWorkspaceTabs.test.ts
Previous Review Summaries (5 snapshots, latest commit 2f43e06)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 2f43e06)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • services/cloud-agent-next/src/sandbox-session/SandboxSession.ts
  • services/cloud-agent-next/src/sandbox-session/session-message-queue.test.ts
  • apps/mobile/src/components/agents/session-list-content.mounted.test.tsx
  • apps/mobile/src/components/agents/session-row.mounted.test.tsx

Previous review (commit 262983b)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

Clearing deliveryRetryScope before ensureReady/attach lets interrupt quarantine a shared worktree runtime and kill an accepted sibling chat.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/cloud-agent-next/src/sandbox-session/SandboxSession.ts 1350 Clearing deliveryRetryScope before the first await lets interrupt quarantine a shared runtime
Files Reviewed (16 files)
  • .specs/cloud-agent-session.md
  • apps/web/src/components/cloud-agent-next/CloudAgentProvider.tsx
  • apps/web/src/components/cloud-agent-next/CloudAgentWorkspaceTabs.tsx
  • services/cloud-agent-next/src/router/handlers/session-worktree.test.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.ts
  • services/cloud-agent-next/src/sandbox-session/SandboxSession.ts - 1 issue
  • services/cloud-agent-next/src/session/session-prepare.test.ts
  • services/cloud-agent-next/src/session/session-registration.ts
  • services/cloud-agent-next/test/e2e/client.ts
  • services/cloud-agent-next/test/e2e/lifecycle.ts
  • services/cloud-agent-next/test/integration/sandbox-control.test.ts
  • services/cloud-agent-next/test/unit/wrapper/auto-commit.test.ts
  • services/cloud-agent-next/wrapper/src/control/apply-attach.test.ts
  • services/cloud-agent-next/wrapper/src/control/apply-attach.ts
  • services/cloud-agent-next/wrapper/src/control/sandbox-control-handlers.test.ts
  • services/session-ingest/wrangler.test.jsonc

Fix these issues in Kilo Cloud

Previous review (commit b8e88cd)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

Clearing deliveryRetryScope before ensureReady/attach lets interrupt quarantine a shared worktree runtime and kill an accepted sibling chat.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/cloud-agent-next/src/sandbox-session/SandboxSession.ts 1355 Clearing deliveryRetryScope before the first await lets interrupt quarantine a shared runtime
Files Reviewed (2 files)
  • services/cloud-agent-next/wrapper/src/kilo-api.ts
  • services/cloud-agent-next/test/unit/wrapper/kilo-api.test.ts

Fix these issues in Kilo Cloud

Previous review (commit 8ec8242)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

Clearing deliveryRetryScope before ensureReady/attach lets interrupt quarantine a shared worktree runtime and kill an accepted sibling chat.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/cloud-agent-next/src/sandbox-session/SandboxSession.ts 1355 Clearing deliveryRetryScope before the first await lets interrupt quarantine a shared runtime
Files Reviewed (36 files)
  • services/cloud-agent-next/src/sandbox-session/SandboxSession.ts - 1 issue
  • services/cloud-agent-next/src/sandbox-session/control-dispatch.ts
  • services/cloud-agent-next/src/sandbox-session/session-message-queue.ts
  • services/cloud-agent-next/src/sandbox-control/session-credentials.ts
  • services/cloud-agent-next/src/persistence/SandboxControl.ts
  • services/cloud-agent-next/src/persistence/session-metadata.ts
  • services/cloud-agent-next/src/sandbox-control/cloudflare-provider.ts
  • services/cloud-agent-next/src/sandbox-control/physical-lifecycle.ts
  • services/cloud-agent-next/src/sandbox-control/terminal-billing.ts
  • services/cloud-agent-next/src/session/session-registration.ts
  • services/cloud-agent-next/src/shared/sandbox-control-protocol.ts
  • services/cloud-agent-next/wrapper/src/control/worktree-runtime.ts
  • services/cloud-agent-next/wrapper/src/control/apply-attach.ts
  • services/cloud-agent-next/wrapper/src/control/main.ts
  • services/cloud-agent-next/wrapper/src/control/sandbox-control-handlers.ts
  • services/cloud-agent-next/wrapper/src/control/sandbox-control-runtime.ts
  • Remaining incremental test, e2e, and README files in commit 8ec8242c

Fix these issues in Kilo Cloud

Previous review (commit 1a882bb)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (177 files)
  • packages/db/src/schema.ts
  • packages/db/src/migrations/0234_amused_sasquatch.sql
  • apps/web/src/lib/user/index.ts
  • apps/web/src/lib/cloud-agent-next/worktree-chat.ts
  • apps/web/src/lib/cloud-agent-next/cloud-agent-client.ts
  • apps/web/src/routers/cli-sessions-v2-router.ts
  • apps/web/src/routers/cloud-agent-next-router.ts
  • apps/web/src/routers/cloud-agent-next-schemas.ts
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx
  • apps/web/src/components/cloud-agent-next/CloudAgentWorkspaceTabs.tsx
  • apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx
  • apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
  • apps/web/src/components/cloud-agent-next/worktree-chat-tabs.ts
  • apps/web/src/components/cloud-agent-next/hooks/useSidebarSessions.ts
  • apps/web/src/components/cloud-agent-next/hooks/useClosedWorktreeChatTabs.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.ts
  • services/cloud-agent-next/src/router/handlers/worktree-deletion.ts
  • services/cloud-agent-next/src/sandbox-session/SandboxSession.ts
  • services/cloud-agent-next/src/sandbox-control/worktree-ownership.ts
  • services/cloud-agent-next/src/sandbox-control/worktree-deletion.ts
  • services/cloud-agent-next/src/persistence/SandboxControl.ts
  • services/cloud-agent-next/src/kilo-facade/user-kilo-facade.ts
  • services/cloud-agent-next/wrapper/src/control/apply-attach.ts
  • services/cloud-agent-next/wrapper/src/control/sandbox-control-handlers.ts
  • services/cloud-agent-next/wrapper/src/control/delete-worktree.ts
  • services/cloud-agent-next/wrapper/src/control/session-directories.ts
  • services/cloud-agent-next/wrapper/src/control/worktree-runtime.ts
  • services/cloud-agent-next/wrapper/src/control/worktree-operations.ts
  • services/cloud-agent-next/wrapper/src/control/feed.ts
  • services/session-ingest/src/services/worktree-deletion.ts
  • services/session-ingest/src/services/worktree-allocation.ts
  • services/session-ingest/src/dos/SessionIngestDO.ts
  • services/session-ingest/src/dos/UserConnectionDO.ts
  • services/session-ingest/src/routes/cloud-agent-session-scope.ts
  • packages/session-ingest-contracts/src/rpc-contract.ts
  • Remaining changed production, test, spec, and config files in the PR (excluding generated 0234_snapshot.json)

Reviewed by grok-4.6 · Input: 57.9K · Output: 5.4K · Cached: 267.1K

Review guidance: REVIEW.md from base branch main

Comment thread services/cloud-agent-next/src/sandbox-session/SandboxSession.ts Outdated
Base automatically changed from eshurakov/eager-hollow to main September 1, 2026 11:41
@eshurakov
eshurakov force-pushed the eshurakov/dreamy-marsh branch from b8e88cd to 262983b Compare September 1, 2026 12:11
@eshurakov
eshurakov force-pushed the eshurakov/dreamy-marsh branch from 262983b to 2f43e06 Compare September 1, 2026 13:57
@eshurakov
eshurakov merged commit 9034dc0 into main Sep 1, 2026
55 checks passed
@eshurakov
eshurakov deleted the eshurakov/dreamy-marsh branch September 1, 2026 18:23
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