Skip to content

Commit 5845e21

Browse files
authored
Merge pull request #6310 from uinstinct/fix-backspace-focus
fix: prevent focus out on mod backspace in chat area
2 parents 3cd9379 + 5116eb2 commit 5845e21

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

gui/src/pages/gui/Chat.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ import {
4242
setDialogMessage,
4343
setShowDialog,
4444
} from "../../redux/slices/uiSlice";
45-
import { cancelStream } from "../../redux/thunks/cancelStream";
4645
import { streamEditThunk } from "../../redux/thunks/edit";
4746
import { loadLastSession } from "../../redux/thunks/session";
4847
import { streamResponseThunk } from "../../redux/thunks/streamResponse";
4948
import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util";
5049

50+
import { cancelStream } from "../../redux/thunks/cancelStream";
5151
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
5252
import { EmptyChatBody } from "./EmptyChatBody";
5353
import { ExploreDialogWatcher } from "./ExploreDialogWatcher";
@@ -125,22 +125,22 @@ export function Chat() {
125125

126126
useEffect(() => {
127127
// Cmd + Backspace to delete current step
128-
const listener = (e: any) => {
128+
const listener = (e: KeyboardEvent) => {
129129
if (
130130
e.key === "Backspace" &&
131131
(jetbrains ? e.altKey : isMetaEquivalentKeyPressed(e)) &&
132132
!e.shiftKey
133133
) {
134-
dispatch(cancelStream());
135-
ideMessenger.post("rejectDiff", {}); // just always cancel, if not in applying won't matter
134+
void dispatch(cancelStream());
135+
if (isInEdit) ideMessenger.post("rejectDiff", {});
136136
}
137137
};
138138
window.addEventListener("keydown", listener);
139139

140140
return () => {
141141
window.removeEventListener("keydown", listener);
142142
};
143-
}, [isStreaming, jetbrains]);
143+
}, [isStreaming, jetbrains, isInEdit]);
144144

145145
const { widget, highlights } = useFindWidget(
146146
stepsDivRef,

gui/src/util/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { MessageModes, ModelDescription } from "core";
22
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
3-
import _ from "lodash";
4-
import { KeyboardEvent } from "react";
5-
import { getLocalStorage } from "./localStorage";
63
import {
7-
DEFAULT_CHAT_SYSTEM_MESSAGE,
84
DEFAULT_AGENT_SYSTEM_MESSAGE,
5+
DEFAULT_CHAT_SYSTEM_MESSAGE,
96
} from "core/llm/constructMessages";
7+
import _ from "lodash";
8+
import { KeyboardEvent as ReactKeyboardEvent } from "react";
9+
import { getLocalStorage } from "./localStorage";
1010

1111
export type Platform = "mac" | "linux" | "windows" | "unknown";
1212

@@ -26,7 +26,7 @@ export function getPlatform(): Platform {
2626
export function isMetaEquivalentKeyPressed({
2727
metaKey,
2828
ctrlKey,
29-
}: KeyboardEvent): boolean {
29+
}: KeyboardEvent | ReactKeyboardEvent): boolean {
3030
const platform = getPlatform();
3131
switch (platform) {
3232
case "mac":

0 commit comments

Comments
 (0)