fix: activate extension on startup so eager connect() actually runs

The previous commit added connectionService.connect() in activate(), but
activate() itself never ran without the sidebar open because
activationEvents was empty. VS Code only triggered activation when the
sidebar view was shown.

Add 'onStartupFinished' to activationEvents so the extension activates
after VS Code startup completes. Guard the eager connect() behind the
autocomplete enableAutoTrigger setting to avoid spawning a CLI server
process when autocomplete is disabled.
This commit is contained in:
Mark IJbema
2026-03-23 16:00:06 +01:00
parent af2b900035
commit 021f4171dc
2 changed files with 10 additions and 11 deletions
+1 -7
View File
@@ -45,13 +45,7 @@
"kilocode"
],
"activationEvents": [
"onWebviewPanel:kilo-code.new.AgentManagerPanel",
"onWebviewPanel:kilo-code.new.TabPanel",
"onWebviewPanel:kilo-code.new.settingsPanel",
"onWebviewPanel:kilo-code.new.profilePanel",
"onWebviewPanel:kilo-code.new.marketplacePanel",
"onWebviewPanel:kilo-code.new.DiffViewerPanel",
"onWebviewPanel:kilo-code.new.SubAgentViewerPanel"
"onStartupFinished"
],
"main": "./dist/extension.js",
"contributes": {
+9 -4
View File
@@ -257,10 +257,15 @@ export function activate(context: vscode.ExtensionContext) {
// Start the CLI backend server eagerly so autocomplete works without opening a Kilo tab.
// connectionService.connect() is idempotent — when a webview later calls connect(), it's a no-op.
const workspaceDir = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? process.cwd()
connectionService.connect(workspaceDir).catch((error) => {
console.error("[Kilo New] Extension: Failed to eagerly start CLI backend:", error)
})
// Only start eagerly if autocomplete is enabled to avoid spawning a server process unnecessarily.
const autocompleteEnabled =
vscode.workspace.getConfiguration("kilo-code.new.autocomplete").get<boolean>("enableAutoTrigger") ?? true
if (autocompleteEnabled) {
const workspaceDir = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? process.cwd()
connectionService.connect(workspaceDir).catch((error) => {
console.error("[Kilo New] Extension: Failed to eagerly start CLI backend:", error)
})
}
// Register commit message generation
registerCommitMessageService(context, connectionService)