diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 41bcc2941..991c89d86 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -42,7 +42,7 @@ class IntelliJIDE( private val project: Project, private val continuePluginService: ContinuePluginService, -) : IDE { + ) : IDE { private val gitService = GitService(project, continuePluginService) @@ -57,6 +57,19 @@ class IntelliJIDE( val os = getOS() ripgrep = Paths.get(pluginPath.toString(), "ripgrep", "bin", "rg" + if (os == OS.WINDOWS) ".exe" else "").toString() + + // Make ripgrep executable if on Unix-like systems + try { + if (os == OS.LINUX || os == OS.MAC) { + val file = File(ripgrep) + if (!file.canExecute()) { + file.setExecutable(true) + } + } + } catch (e: Throwable) { + e.printStackTrace() + } + } /** @@ -311,7 +324,7 @@ class IntelliJIDE( val ideInfo = this.getIdeInfo() if (ideInfo.remoteName == "local") { val command = GeneralCommandLine( - ripgrep, + ripgrep, "--files", "--iglob", pattern, @@ -320,37 +333,37 @@ class IntelliJIDE( "--ignore-file", ".gitignore", ) - + command.setWorkDirectory(project.basePath) val results = ExecUtil.execAndGetOutput(command).stdout return results.split("\n") } else { - throw NotImplementedError("Ripgrep not supported, this workspace is remote") + throw NotImplementedError("Ripgrep not supported, this workspace is remote") - // Leaving in here for ideas - // val projectBasePath = project.basePath ?: return emptyList() - // val scope = GlobalSearchScope.projectScope(project) - // - // // Get all ignore patterns from .continueignore files - // val ignorePatterns = mutableSetOf() - // VirtualFileManager.getInstance().findFileByUrl("file://$projectBasePath")?.let { root -> - // VfsUtil.collectChildrenRecursively(root).forEach { file -> - // if (file.name == ".continueignore") { - // file.inputStream.bufferedReader().useLines { lines -> - // ignorePatterns.addAll(lines.filter { it.isNotBlank() && !it.startsWith("#") }) - // } - // } - // } - // } - // - // return FilenameIndex.getAllFilesByExt(project, "*", scope) - // .filter { file -> - // val relativePath = file.path.removePrefix("$projectBasePath/") - // // Check if file matches pattern and isn't ignored - // PatternUtil.(relativePath, pattern) && - // !ignorePatterns.any { PatternUtil.matchesGlob(relativePath, it) } - // } - // .map { it.path.removePrefix("$projectBasePath/") } + // Leaving in here for ideas + // val projectBasePath = project.basePath ?: return emptyList() + // val scope = GlobalSearchScope.projectScope(project) + // + // // Get all ignore patterns from .continueignore files + // val ignorePatterns = mutableSetOf() + // VirtualFileManager.getInstance().findFileByUrl("file://$projectBasePath")?.let { root -> + // VfsUtil.collectChildrenRecursively(root).forEach { file -> + // if (file.name == ".continueignore") { + // file.inputStream.bufferedReader().useLines { lines -> + // ignorePatterns.addAll(lines.filter { it.isNotBlank() && !it.startsWith("#") }) + // } + // } + // } + // } + // + // return FilenameIndex.getAllFilesByExt(project, "*", scope) + // .filter { file -> + // val relativePath = file.path.removePrefix("$projectBasePath/") + // // Check if file matches pattern and isn't ignored + // PatternUtil.(relativePath, pattern) && + // !ignorePatterns.any { PatternUtil.matchesGlob(relativePath, it) } + // } + // .map { it.path.removePrefix("$projectBasePath/") } } } @@ -358,20 +371,20 @@ class IntelliJIDE( val ideInfo = this.getIdeInfo() if (ideInfo.remoteName == "local") { val command = GeneralCommandLine( - ripgrep, - "-i", + ripgrep, + "-i", "--ignore-file", ".continueignore", "--ignore-file", - ".gitignore", - "-C", - "2", - "--heading", - "-e", - query, + ".gitignore", + "-C", + "2", + "--heading", + "-e", + query, "." ) - + command.setWorkDirectory(project.basePath) return ExecUtil.execAndGetOutput(command).stdout } else { @@ -415,7 +428,7 @@ class IntelliJIDE( // return searchResults.toString() } } - + override suspend fun subprocess(command: String, cwd: String?): List { val commandList = command.split(" ") diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx index a50c953f4..6154b3452 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx @@ -2,6 +2,7 @@ import { CommandLineIcon } from "@heroicons/react/24/outline"; import { useContext } from "react"; import { lightGray, vscForeground } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { isJetBrains } from "../../../util"; interface RunInTerminalButtonProps { command: string; @@ -10,16 +11,21 @@ interface RunInTerminalButtonProps { export function RunInTerminalButton({ command }: RunInTerminalButtonProps) { const ideMessenger = useContext(IdeMessengerContext); + if (isJetBrains()) { + // JetBrains plugin doesn't currently have a way to run the command in the terminal for the user + return null; + } + // Extract just the command line (the line after $ or the first line) function extractCommand(cmd: string): string { // If the command contains a $ prompt, extract the line after it - if (cmd.includes('$')) { + if (cmd.includes("$")) { const match = cmd.match(/\$\s*([^\n]+)/); - return match ? match[1].trim() : ''; + return match ? match[1].trim() : ""; } - + // Otherwise, just take the first line - return cmd.split('\n')[0].trim(); + return cmd.split("\n")[0].trim(); } function runInTerminal() { diff --git a/gui/src/components/mainInput/Lump/LumpToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar.tsx index f2e0d8c6f..45064a814 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar.tsx @@ -8,7 +8,12 @@ import { selectCurrentToolCall } from "../../../redux/selectors/selectCurrentToo import { callCurrentTool } from "../../../redux/thunks/callCurrentTool"; import { cancelCurrentToolCall } from "../../../redux/thunks/cancelCurrentToolCall"; import { cancelStream } from "../../../redux/thunks/cancelStream"; -import { getFontSize, getMetaKeyLabel } from "../../../util"; +import { + getAltKeyLabel, + getFontSize, + getMetaKeyLabel, + isJetBrains, +} from "../../../util"; import { EnterButton } from "../InputToolbar/EnterButton"; import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar"; @@ -40,18 +45,20 @@ export function LumpToolbar() { const ideMessenger = useContext(IdeMessengerContext); const ttsActive = useAppSelector((state) => state.ui.ttsActive); const isStreaming = useAppSelector((state) => state.session.isStreaming); + const jetbrains = isJetBrains(); const toolCallState = useSelector(selectCurrentToolCall); const handleKeyDown = (event: KeyboardEvent) => { if (toolCallState?.status === "generated") { const metaKey = event.metaKey || event.ctrlKey; + const altKey = event.altKey; if (metaKey && event.key === "Enter") { event.preventDefault(); event.stopPropagation(); dispatch(callCurrentTool()); - } else if (metaKey && event.key === "Backspace") { + } else if ((jetbrains ? altKey : metaKey) && event.key === "Backspace") { event.preventDefault(); event.stopPropagation(); dispatch(cancelCurrentToolCall()); @@ -92,7 +99,8 @@ export function LumpToolbar() { dispatch(cancelStream()); }} > - {getMetaKeyLabel()} ⌫ Cancel + {/* JetBrains overrides cmd+backspace, so we have to use another shortcut */} + {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel ); @@ -109,7 +117,8 @@ export function LumpToolbar() { onClick={() => dispatch(cancelCurrentToolCall())} data-testid="reject-tool-call-button" > - {getMetaKeyLabel()} ⌫ Cancel + {/* JetBrains overrides cmd+backspace, so we have to use another shortcut */} + {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel state.ui.hasDismissedExploreDialog, ); + const jetbrains = isJetBrains(); useEffect(() => { // Cmd + Backspace to delete current step const listener = (e: any) => { if ( - e.key === "Backspace" && - isMetaEquivalentKeyPressed(e) && - !e.shiftKey + e.key === "Backspace" && jetbrains + ? e.altKey + : isMetaEquivalentKeyPressed(e) && !e.shiftKey ) { dispatch(cancelStream()); } @@ -339,8 +340,8 @@ export function Chat() { inputId={item.message.id} /> - ) : item.message.role === "tool" ? null : // /> // toolCallId={item.message.toolCallId} // contextItems={item.contextItems} // // toolCallId={item.message.toolCallId} // contextItems={item.contextItems} //