Skip to content

Conversation

@markijbema
Copy link
Contributor

#134

Github forgot to rewriet the base.....

Implement CLI backend integration to enable communication between the
VSCode extension and the Kilo CLI backend server.

New files:
- src/services/cli-backend/types.ts - Type definitions for API requests/responses
- src/services/cli-backend/server-manager.ts - Server lifecycle management
- src/services/cli-backend/http-client.ts - REST API client for backend communication
- src/services/cli-backend/sse-client.ts - SSE streaming client for real-time events
- src/services/cli-backend/index.ts - Main exports
- src/types/eventsource.d.ts - EventSource type declarations

Modified files:
- package.json - Added eventsource dependency
- src/KiloProvider.ts - Integrated with CLI backend services
- src/extension.ts - Updated to pass extension context
- .vscodeignore - Updated exclusions

Key features:
- Server lifecycle management (start/stop/health checks)
- HTTP client for REST API communication
- SSE client for streaming responses
- Webview integration for message passing
Update all debug console.log statements to use the prefix '[Kilo New]'
followed by the component name for consistent logging across the CLI
backend integration.

Changed prefixes:
- [KiloProvider] -> [Kilo New] KiloProvider:
- [ServerManager] -> [Kilo New] ServerManager:
- [CLI Server] -> [Kilo New] ServerManager:
- [SSEClient] -> [Kilo New] SSE:
- [Webview/App] -> [Kilo New] App:
The path was using '../../../opencode/bin/kilo' which resolved to
'kilo-with-vscode/opencode/bin/kilo' instead of the correct
'kilo-with-vscode/packages/opencode/bin/kilo'.

Fixed by changing to '../../opencode/bin/kilo' which correctly navigates
from packages/kilo-vscode/dist/ to packages/opencode/bin/kilo.
@markijbema markijbema marked this pull request as ready for review February 5, 2026 15:11
@markijbema markijbema enabled auto-merge February 5, 2026 15:13
@@ -0,0 +1,180 @@
import EventSource from "eventsource"
Copy link
Contributor

Choose a reason for hiding this comment

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

CRITICAL: eventsource import style likely breaks with current TS config

packages/kilo-vscode/src/types/eventsource.d.ts declares the module with export =, but packages/kilo-vscode/src/services/cli-backend/sse-client.ts uses a default import. With esModuleInterop not enabled in packages/kilo-vscode/tsconfig.json, this can fail type-checking and/or runtime interop.

Suggested change
import EventSource from "eventsource"
import EventSource = require("eventsource")

});

// Initialize connection to CLI backend
this.initializeConnection();
Copy link
Contributor

Choose a reason for hiding this comment

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

WARNING: Potential duplicate SSE connections / leaked clients if the webview is resolved more than once

KiloProvider.resolveWebviewView() calls initializeConnection() each time it runs, and initializeConnection() creates a new SSEClient instance without disposing any prior one. If VS Code re-resolves the view (reload window, view recreated, etc.), the previous SSEClient can remain connected and events may be duplicated. Consider disposing/closing any existing SSE connection before creating a new one, or reusing the existing client/server instance.

});
break;

case 'session.created':
Copy link
Contributor

Choose a reason for hiding this comment

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

WARNING: session.created can bind currentSession to an unrelated session

In handleSSEEvent(), the session.created case sets currentSession whenever it’s currently null. Since the SSE stream appears directory-scoped (not session-scoped), a session.created event from another source could arrive first and cause the extension to attach UI actions to the wrong session. It’s safer to only set currentSession from the explicit createSession() response (or gate this assignment on some correlation/intent).

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 5, 2026

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

CRITICAL

File Line Issue
packages/kilo-vscode/src/services/cli-backend/sse-client.ts 1 eventsource default import likely incompatible with current TS config (export = typing, no esModuleInterop)

WARNING

File Line Issue
packages/kilo-vscode/src/KiloProvider.ts 63 initializeConnection() can run multiple times without disposing prior SSEClient, causing duplicate connections / leaks
packages/kilo-vscode/src/KiloProvider.ts 246 session.created handler can set currentSession from an unrelated directory-scoped event
Files Reviewed (16 files)

@markijbema markijbema merged commit a885e56 into dev Feb 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants