diff --git a/src/app/workspace/cmdinput/aichat.tsx b/src/app/workspace/cmdinput/aichat.tsx index 47ca309c..f3a71f47 100644 --- a/src/app/workspace/cmdinput/aichat.tsx +++ b/src/app/workspace/cmdinput/aichat.tsx @@ -5,7 +5,7 @@ import * as React from "react"; import * as mobxReact from "mobx-react"; import * as mobx from "mobx"; import { GlobalModel } from "@/models"; -import { isBlank } from "@/util"; +import { isBlank } from "@/util/util"; import { boundMethod } from "autobind-decorator"; import cn from "classnames"; import { For } from "tsx-control-statements/components"; @@ -92,7 +92,7 @@ class AIChat extends React.Component<{}, {}> { if (checkKeyPressed(waveEvent, "Escape")) { e.preventDefault(); e.stopPropagation(); - inputModel.closeAIAssistantChat(); + inputModel.closeAIAssistantChat(true); } if (checkKeyPressed(waveEvent, "Ctrl:l")) { diff --git a/src/app/workspace/cmdinput/textareainput.tsx b/src/app/workspace/cmdinput/textareainput.tsx index 14e57546..6ca454e0 100644 --- a/src/app/workspace/cmdinput/textareainput.tsx +++ b/src/app/workspace/cmdinput/textareainput.tsx @@ -232,7 +232,7 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: () if (inputModel.inputMode.get() != null) { inputModel.resetInputMode(); } - inputModel.closeAIAssistantChat(); + inputModel.closeAIAssistantChat(true); return; } if (checkKeyPressed(waveEvent, "Cmd:e")) { diff --git a/src/models/input.ts b/src/models/input.ts index 1aef5923..96ea01c6 100644 --- a/src/models/input.ts +++ b/src/models/input.ts @@ -618,13 +618,17 @@ class InputModel { })(); } - closeAIAssistantChat(): void { + // pass true to give focus to the input (e.g. if this is an 'active' close of the chat) + // when resetting the input (when switching screens, don't give focus) + closeAIAssistantChat(giveFocus: boolean): void { if (!this.aIChatShow.get()) { return; } mobx.action(() => { this.aIChatShow.set(false); - this.giveFocus(); + if (giveFocus) { + this.giveFocus(); + } })(); } @@ -726,7 +730,7 @@ class InputModel { resetInput(): void { mobx.action(() => { this.setHistoryShow(false); - this.closeAIAssistantChat(); + this.closeAIAssistantChat(false); this.infoShow.set(false); this.inputMode.set(null); this.resetHistory();