Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/build/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe("generatePackageJson", () => {
{
command: "roo-code-nightly.plusButtonClicked",
title: "%command.newTask.title%",
icon: "$(edit)",
icon: "$(add)",
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

This icon change from 'edit' to 'add' appears unrelated to the PR's context functionality and should be marked with kilocode_change comments.

Copilot generated this review using guidance from repository custom instructions.

},
{
command: "roo-code-nightly.openInNewTab",
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const commandIds = [
"handleExternalUri", // kilocode_change - for JetBrains plugin URL forwarding
"focusPanel",
"toggleAutoApprove",
"addFileToContext", // kilocode_change
] as const

export type CommandId = (typeof commandIds)[number]
Expand Down
16 changes: 5 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from "vscode"
import * as path from "path" // kilocode_change
import delay from "delay"

import type { CommandId } from "@roo-code/types"
Expand Down Expand Up @@ -289,6 +290,86 @@ const getCommandsMap = ({ context, outputChannel }: RegisterCommandOptions): Rec
action: "toggleAutoApprove",
})
},
// kilocode_change: Add files/folders to context from Explorer context menu
addFileToContext: async (...args: any[]) => {
// Helper to extract URIs from many possible shapes passed by VS Code
const tryExtractUris = (val: any): vscode.Uri[] => {
const out: vscode.Uri[] = []
if (!val) return out
// Direct Uri
if (val instanceof vscode.Uri) {
out.push(val)
return out
}
// Arrays
if (Array.isArray(val)) {
for (const item of val) out.push(...tryExtractUris(item))
return out
}
// Explorer items
if (val.resourceUri instanceof vscode.Uri) out.push(val.resourceUri)
if (val.uri instanceof vscode.Uri) out.push(val.uri)
if (val.resource instanceof vscode.Uri) out.push(val.resource)
return out
}

const uris: vscode.Uri[] = []
// VS Code commonly passes (resource, allSelectedResources) for Explorer multi-select
if (args.length > 0) uris.push(...tryExtractUris(args[0]))
if (args.length > 1) uris.push(...tryExtractUris(args[1]))

// Fallback: active editor if nothing extracted
if (uris.length === 0) {
const activeEditor = vscode.window.activeTextEditor
if (activeEditor?.document?.uri) {
uris.push(activeEditor.document.uri)
}
}

if (uris.length === 0) {
vscode.window.showInformationMessage("No file or folder selected.")
return
}

// Convert to mention strings for context pills (use workspace-relative with leading '@/')
const workspaceFolders = vscode.workspace.workspaceFolders ?? []
const asMention = async (uri: vscode.Uri) => {
const folder = workspaceFolders.find((f) => uri.fsPath.startsWith(f.uri.fsPath))
let isFolder = false
try {
const stat = await vscode.workspace.fs.stat(uri)
isFolder = stat.type === vscode.FileType.Directory
} catch {
// ignore stat errors; fall back to heuristics
isFolder = uri.path.endsWith("/") || uri.fsPath.endsWith(path.sep)
}
if (folder) {
// Compute relative path and normalize
let rel = uri.fsPath.substring(folder.uri.fsPath.length).replace(/\\/g, "/")
// Remove any leading slashes from rel to avoid double slashes
rel = rel.replace(/^\/+/, "")
return `@/${rel}${isFolder ? "/" : ""}`
}
// Fall back to basename with '@/'
const base = path.basename(uri.fsPath)
return `@/${base}${isFolder ? "/" : ""}`
}

const mentionList = await Promise.all(uris.map(asMention))
const mentions = Array.from(new Set(mentionList))

const visibleProvider = getVisibleProviderOrLog(outputChannel)
if (!visibleProvider) return

// Add mentions directly to pills bar in the webview
await visibleProvider.postMessageToWebview({
type: "action",
action: "addContextMentions",
values: { mentions },
})

vscode.window.setStatusBarMessage(`Added ${mentions.length} item(s) to Kilo context`, 2000)
},
})

export const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
Expand Down
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ export async function activate(context: vscode.ExtensionContext) {
`[authStateChangedHandler] remoteControlEnabled(false) failed: ${error instanceof Error ? error.message : String(error)}`,
)
}
try {
await BridgeOrchestrator.disconnect()
} catch (error) {
cloudLogger(
`[authStateChangedHandler] BridgeOrchestrator.disconnect() failed: ${error instanceof Error ? error.message : String(error)}`,
)
}
Comment on lines +173 to +179
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

This code block appears to be unrelated to the PR's purpose and should be marked with kilocode_change comments according to the project's merge guidelines.

Copilot generated this review using guidance from repository custom instructions.

}
}

Expand Down
13 changes: 12 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,20 @@
"command": "kilo-code.ghost.goToPreviousSuggestion",
"title": "%ghost.commands.goToPreviousSuggestion%",
"category": "%configuration.title%"
},
{
"command": "kilo-code.addFileToContext",
"title": "%command.addFileToContext.title%",
"category": "%configuration.title%"
}
],
"menus": {
"explorer/context": [
{
"command": "kilo-code.addFileToContext",
"group": "navigation@9"
}
],
"editor/context": [
{
"submenu": "kilo-code.contextMenu",
Expand Down Expand Up @@ -764,4 +775,4 @@
"vitest": "^3.2.3",
"zod-to-ts": "^1.2.0"
}
}
}
1 change: 1 addition & 0 deletions src/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"command.fixCode.title": "Fix Code",
"command.improveCode.title": "Improve Code",
"command.addToContext.title": "Add To Context",
"command.addFileToContext.title": "Add File(s) to Context",
"command.focusInput.title": "Focus Input Field",
"command.setCustomStoragePath.title": "Set Custom Storage Path",
"command.importSettings.title": "Import Settings",
Expand Down
1 change: 1 addition & 0 deletions src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export interface ExtensionMessage {
| "focusInput"
| "switchTab"
| "focusChatInput" // kilocode_change
| "addContextMentions" // kilocode_change: add mentions directly to pills bar
| "toggleAutoApprove"
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
state?: ExtensionState
Expand Down
Loading