Skip to content

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

Open
eshurakov wants to merge 9 commits into
eshurakov/eager-hollowfrom
eshurakov/dreamy-marsh
Open

feat(cloud-agent-next): support multiple chats per worktree#5751
eshurakov wants to merge 9 commits into
eshurakov/eager-hollowfrom
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: 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 Summaries (2 snapshots, latest commit 8ec8242)

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

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: 141K · Output: 6.7K · Cached: 261.9K

Review guidance: REVIEW.md from base branch eshurakov/eager-hollow

return;
}
if (this.pendingRuntimeCleanup()) return;
if (queued.deliveryRetryScope !== undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: Clearing deliveryRetryScope before ensureReady/attach lets interrupt quarantine a shared runtime

interruptExecution only skips shared-runtime cleanup when the live queued record still has deliveryRetryScope === 'message'. This block writes undefined before the first await, so a concurrent interrupt during ensureReady or the uncontained re-attach sees undefined !== 'message' and quarantines wrapperInstanceId. After session_busy the waiting sibling already has that wrapper id, so cancelling it tears down the accepted peer on the same worktree. Keep the message scope until recordDeliveryFailure overwrites it, or treat undefined like 'message' unless unresolvedDispatch is set.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

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.

1 participant