Skip to content

fix(cloud-agent-next): stop terminal retries while sandbox sleeps - #8144

Merged
eshurakov merged 2 commits into
mainfrom
kilo/virtual-heron-s51
Oct 19, 2026
Merged

eshurakov merged 2 commits into
mainfrom
kilo/virtual-heron-s51

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

A restored terminal tab called createTerminal every ~5 seconds while the sandbox was asleep. The route-not-ready path reused the generic "until the workspace is prepared" result, which the web client treats as retryable.

  • Return the distinct sandbox_stopped message from the Session DO terminal projection when the sandbox is sleeping.
  • Classify that result as sleeping on the web and stop the reconnect loop.
  • Subscribe to sandbox status while the terminal tab is active, and create a fresh PTY when the sandbox becomes active instead of reusing the stale one.
  • Disable terminal stdin and show "The sandbox is sleeping. Send a message to resume." while asleep.
  • Surface real terminal RPC failures instead of mapping them to the workspace-preparation message.

The chat send/resume path is unchanged.

Verification

  • pnpm --filter cloud-agent-next typecheck
  • pnpm --filter web typecheck
  • pnpm --filter cloud-agent-next exec vitest run src/control-plane/session/terminals.test.ts
  • pnpm --filter cloud-agent-next exec vitest run src/router.test.ts -t "router terminal procedures"
  • terminal-utils.test.ts (12 tests) with a minimal Jest config; the repository Jest global setup requires a local Postgres instance that was not available here.

@kilo-code-bot

kilo-code-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Both prior findings are resolved in abb63805: the sandbox-status subscription now stays mounted for the lifetime of the terminal (enabled && cloudAgentSessionId), so hidden tabs also receive the sleeping snapshot, and code-less transport failures now retry instead of terminating the reconnect loop. The incremental changes introduce no new defects or memory leaks; verification was static only (no commands executed).

Files Reviewed (3 files)
  • apps/web/src/components/cloud-agent-next/terminal-utils.ts - 0 issues
  • apps/web/src/components/cloud-agent-next/terminal-utils.test.ts - 0 issues
  • apps/web/src/components/cloud-agent-next/useCloudAgentTerminal.ts - 0 issues

Targeted context checks: CloudChatPage.tsx keeps inactive terminal panes mounted (CSS hidden), so the now-ungated status subscription does reach backgrounded tabs; the new status subscription, its retry timer, and applySandboxStatusRef handler are still cleared in effect cleanup.

Previous Review Summary (commit b22992e)

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

Previous review (commit b22992e)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

The confirmed regression remains for backgrounded terminal tabs, and the new terminal-error default can turn a single transient network failure into a dead terminal.

Overview

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

WARNING

File Line Issue
apps/web/src/components/cloud-agent-next/useCloudAgentTerminal.ts 172 Sandbox-status subscription is gated on active, so open but hidden terminal tabs keep the ~5s reconnect loop while the sandbox sleeps.
apps/web/src/components/cloud-agent-next/terminal-utils.ts 121 Unknown errors, including transient transport failures, now resolve to final-error and stop reconnecting instead of retrying.
Files Reviewed (10 files)
  • apps/web/src/components/cloud-agent-next/CloudAgentTerminalDock.tsx - 0 issues
  • apps/web/src/components/cloud-agent-next/CloudAgentWorkspaceTabs.tsx - 0 issues
  • apps/web/src/components/cloud-agent-next/terminal-utils.ts - 1 issue
  • apps/web/src/components/cloud-agent-next/terminal-utils.test.ts - 0 issues
  • apps/web/src/components/cloud-agent-next/useCloudAgentTerminal.ts - 1 issue
  • services/cloud-agent-next/src/control-plane/session/session-do.ts - 0 issues
  • services/cloud-agent-next/src/control-plane/session/terminals.ts - 0 issues
  • services/cloud-agent-next/src/control-plane/session/terminals.test.ts - 0 issues
  • services/cloud-agent-next/src/router.test.ts - 0 issues
  • services/cloud-agent-next/src/router/handlers/session-terminal.ts - 0 issues

No memory leaks found in the changed client code: the new status subscription, its retry timer, and the applySandboxStatusRef handler are all cleared in effect cleanup. Verification was static only (no commands executed), per the review constraints.

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 46.4K · Output: 7.2K · Cached: 382.5K

Review guidance: REVIEW.md from base branch main

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