Skip to content

fix(vscode): handle fragmented CLI startup output - #13466

Merged
marius-kilocode merged 1 commit into
mainfrom
investigate-connection-failures-root-cause
Aug 27, 2026
Merged

fix(vscode): handle fragmented CLI startup output#13466
marius-kilocode merged 1 commit into
mainfrom
investigate-connection-failures-root-cause

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The VS Code extension discovers its local CLI backend by parsing the kilo serve --port 0 listening announcement from stdout. Process stream chunks do not preserve message boundaries, so a split announcement can make the extension wait 30 seconds for a server that is already running. A split inside the port number is worse: port 43123 can be accepted prematurely as 43, sending the client to the wrong local address.

This is the exact defect documented in #7649. The earlier fix in #7650 was closed without merging.

Open reports with matching extension startup or backend-unavailable symptoms:

These reports do not contain enough diagnostics to prove stdout fragmentation individually. They are linked as potentially affected reports, not as confirmed duplicates or automatic closures. Reports with a confirmed unrelated cause, such as SQLite migration failures or filesystem permissions, are intentionally excluded.

Why This Change Was Made

Buffer startup stdout across chunk boundaries, require a complete LF or CRLF-terminated listening line before accepting its port, and retain only a bounded 1 KB rolling buffer. Parse the complete combined output before trimming it so a valid announcement is not discarded when the same chunk also contains a large amount of subsequent output.

User Impact

Prevent intermittent "Server connection failed" banners, incorrect localhost port connections, and 30-second startup timeouts when opening the VS Code extension. The stream handling is platform-independent and explicitly covers Windows line endings.

Evidence

  • Reproduced the partial-port regression before the fix: 43 was accepted instead of waiting for 43123.
  • Reproduced the oversized-output regression before the fix: a valid announcement followed by 1,024 bytes returned null instead of 43123.
  • Added coverage for split URLs, split port digits, CRLF startup lines, oversized stdout chunks, and bounded retained output.
  • bun run test:unit: 4,208 passing tests across 353 files.
  • bun run compile: extension and webview typechecks, lint, and bundling passed.
  • bun run knip and bun run check-kilocode-change passed.
  • Manually launched the rebuilt extension in an isolated VS Code instance and verified the Kilo sidebar connected without a startup error or timeout.

@kilo-code-bot

kilo-code-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • .changeset/fix-vscode-server-startup-output.md
  • packages/kilo-vscode/src/services/cli-backend/server-manager.ts
  • packages/kilo-vscode/src/services/cli-backend/server-utils.ts
  • packages/kilo-vscode/tests/unit/server-manager-utils.test.ts

Reviewed by grok-4.6 · Input: 83.1K · Output: 11K · Cached: 482.2K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 3308bf5 into main Aug 27, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the investigate-connection-failures-root-cause branch August 27, 2026 07:32
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