Click from a file name in chat to editor (#5422)

This commit is contained in:
Igor Tceglevskii authored and GitHub committed 2025-08-09 15:48:12 -07:00
1 parent e04cbea504
commit 3b19c2ec95
7 files changed
+350 -2

No files matched your search

@@ -0,0 +1,30 @@
import * as path from "path"
import { Controller } from ".."
import { Empty, StringRequest } from "@shared/proto/cline/common"
import { openFile as openFileIntegration } from "@integrations/misc/open-file"
import { getWorkspacePath } from "@utils/path"
/**
* Opens a file in the editor by a relative path
* @param controller The controller instance
* @param request The request message containing the relative file path in the 'value' field
* @returns Empty response
*/
export async function openFileRelativePath(_controller: Controller, request: StringRequest): Promise<Empty> {
const workspacePath = await getWorkspacePath()
if (!workspacePath) {
console.error("Error in openFileRelativePath: No workspace path available")
return Empty.create()
}
if (request.value) {
// Resolve the relative path to absolute path
const absolutePath = path.resolve(workspacePath, request.value)
// Open the file using the existing integration
openFileIntegration(absolutePath)
}
return Empty.create()
}