diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index e590c0ec9..96342c4bf 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -99,6 +99,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { ControlPlaneSessionInfo | undefined, ]; logoutOfControlPlane: [undefined, void]; + closeSidebar: [undefined, void]; }; export type ToWebviewOrCoreFromIdeProtocol = { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index f76a41574..677d0bd84 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -24,6 +24,7 @@ import com.intellij.openapi.project.DumbAware import com.intellij.openapi.project.Project import com.intellij.openapi.util.TextRange import com.intellij.openapi.vfs.VirtualFileManager +import com.intellij.openapi.wm.ToolWindowManager import kotlinx.coroutines.* import java.awt.Toolkit import java.awt.datatransfer.StringSelection @@ -334,6 +335,14 @@ class IdeProtocolClient( respond(result) } + "closeSidebar" -> { + ApplicationManager.getApplication().invokeLater { + val toolWindowManager = ToolWindowManager.getInstance(project) + val toolWindow = toolWindowManager.getToolWindow("Continue") + toolWindow?.hide() + } + } + "getSearchResults" -> { val params = Gson().fromJson( dataElement.toString(), @@ -430,24 +439,28 @@ class IdeProtocolClient( ) val filepath = params.filepath - continuePluginService.sendToWebview("updateApplyState", mapOf( - "streamId" to params.streamId, - "status" to "streaming", - "fileContent" to params.text, - "toolCallId" to params.toolCallId, - "filepath" to filepath - )) - - - fun closeStream () { - continuePluginService.sendToWebview("updateApplyState", mapOf( - "numDiffs" to 0, + continuePluginService.sendToWebview( + "updateApplyState", mapOf( "streamId" to params.streamId, - "status" to "closed", + "status" to "streaming", "fileContent" to params.text, "toolCallId" to params.toolCallId, "filepath" to filepath - )) + ) + ) + + + fun closeStream() { + continuePluginService.sendToWebview( + "updateApplyState", mapOf( + "numDiffs" to 0, + "streamId" to params.streamId, + "status" to "closed", + "fileContent" to params.text, + "toolCallId" to params.toolCallId, + "filepath" to filepath + ) + ) } var editor: Editor? = null; @@ -493,7 +506,7 @@ class IdeProtocolClient( val selectedModels = config["selectedModelByRole"] as? Map<*, *> var applyCodeBlockModel = selectedModels?.get("apply") as? Map<*, *> - + // If "apply" role model is not found, try "chat" role if (applyCodeBlockModel == null) { applyCodeBlockModel = selectedModels?.get("chat") as? Map<*, *> @@ -555,8 +568,8 @@ class IdeProtocolClient( editor, rif?.range?.start?.line ?: 0, rif?.range?.end?.line ?: (editor.document.lineCount - 1), - {}, - {}, + {}, + {}, params.streamId, params.toolCallId ) diff --git a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts index 9c56819e3..c4a70bb51 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts @@ -30,7 +30,7 @@ import { import { AppDispatch } from "../../../../redux/store"; import { exitEditMode } from "../../../../redux/thunks"; import { loadLastSession } from "../../../../redux/thunks/session"; -import { getFontSize } from "../../../../util"; +import { getFontSize, isJetBrains } from "../../../../util"; import * as ContinueExtensions from "../extensions"; import { TipTapEditorProps } from "../TipTapEditor"; import { handleImageFile } from "./imageUtils"; @@ -267,6 +267,12 @@ export function createEditorConfig(options: { return false; }, Escape: () => { + // In JetBrains, this is how we close the sidebar when the input box is focused + if (isJetBrains()) { + ideMessenger.post("closeSidebar", undefined); + return true; + } + if (inDropdownRef.current || !isInEditModeRef.current) { ideMessenger.post("focusEditor", undefined); return true;