Merge branch 'main' into sawka/layout

This commit is contained in:
sawka 2024-02-20 23:44:25 -08:00
commit 9a9ee68604
3 changed files with 13 additions and 6 deletions

View File

@ -5,7 +5,7 @@ import * as React from "react";
import * as mobxReact from "mobx-react"; import * as mobxReact from "mobx-react";
import * as mobx from "mobx"; import * as mobx from "mobx";
import { GlobalModel } from "@/models"; import { GlobalModel } from "@/models";
import { isBlank } from "@/util"; import { isBlank } from "@/util/util";
import { boundMethod } from "autobind-decorator"; import { boundMethod } from "autobind-decorator";
import cn from "classnames"; import cn from "classnames";
import { For } from "tsx-control-statements/components"; import { For } from "tsx-control-statements/components";
@ -92,7 +92,7 @@ class AIChat extends React.Component<{}, {}> {
if (checkKeyPressed(waveEvent, "Escape")) { if (checkKeyPressed(waveEvent, "Escape")) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
inputModel.closeAIAssistantChat(); inputModel.closeAIAssistantChat(true);
} }
if (checkKeyPressed(waveEvent, "Ctrl:l")) { if (checkKeyPressed(waveEvent, "Ctrl:l")) {

View File

@ -232,7 +232,7 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
if (inputModel.inputMode.get() != null) { if (inputModel.inputMode.get() != null) {
inputModel.resetInputMode(); inputModel.resetInputMode();
} }
inputModel.closeAIAssistantChat(); inputModel.closeAIAssistantChat(true);
return; return;
} }
if (checkKeyPressed(waveEvent, "Cmd:e")) { if (checkKeyPressed(waveEvent, "Cmd:e")) {

View File

@ -618,10 +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(() => { mobx.action(() => {
this.aIChatShow.set(false); this.aIChatShow.set(false);
if (giveFocus) {
this.giveFocus(); this.giveFocus();
}
})(); })();
} }
@ -723,7 +730,7 @@ class InputModel {
resetInput(): void { resetInput(): void {
mobx.action(() => { mobx.action(() => {
this.setHistoryShow(false); this.setHistoryShow(false);
this.closeAIAssistantChat(); this.closeAIAssistantChat(false);
this.infoShow.set(false); this.infoShow.set(false);
this.inputMode.set(null); this.inputMode.set(null);
this.resetHistory(); this.resetHistory();