From fab53472a931b49d7f0c19af22263df6b54bc292 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 22 May 2025 15:39:21 -0700 Subject: [PATCH] fix: navigation bug --- gui/src/components/History/index.tsx | 2 -- gui/src/components/Layout.tsx | 1 + gui/src/components/ModeSelect/ModeIcon.tsx | 4 +--- gui/src/components/ModeSelect/ModeSelect.tsx | 4 ++-- .../components/mainInput/TipTapEditor/utils/editorConfig.ts | 2 -- gui/src/hooks/ParallelListeners.tsx | 2 +- gui/src/hooks/useNavigationListener.tsx | 1 - 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gui/src/components/History/index.tsx b/gui/src/components/History/index.tsx index 8d96715cf..e51dc45eb 100644 --- a/gui/src/components/History/index.tsx +++ b/gui/src/components/History/index.tsx @@ -13,7 +13,6 @@ import Shortcut from "../gui/Shortcut"; import { XMarkIcon } from "@heroicons/react/24/solid"; import { useNavigate } from "react-router-dom"; import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { useNavigationListener } from "../../hooks/useNavigationListener"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { newSession, @@ -38,7 +37,6 @@ const HEADER_CLASS = "flex user-select-none pt-2 pb-3 opacity-75 text-center font-bold items-center justify-center sticky h-6"; export function History() { - useNavigationListener(); const dispatch = useAppDispatch(); const navigate = useNavigate(); const searchInputRef = React.useRef(null); diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 6a08a9f8c..2ad91f1b5 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -147,6 +147,7 @@ const Layout = () => { useWebviewListener( "focusEdit", async () => { + navigate(ROUTES.HOME); await ideMessenger.request("edit/addCurrentSelection", undefined); await dispatch(enterEdit({})); mainEditor?.commands.focus(); diff --git a/gui/src/components/ModeSelect/ModeIcon.tsx b/gui/src/components/ModeSelect/ModeIcon.tsx index 0b95ff4bc..83201d5ae 100644 --- a/gui/src/components/ModeSelect/ModeIcon.tsx +++ b/gui/src/components/ModeSelect/ModeIcon.tsx @@ -6,7 +6,7 @@ interface ModeIconProps { className?: string; } -function ModeIcon({ +export function ModeIcon({ mode, className = "xs:h-3 xs:w-3 h-3 w-3", }: ModeIconProps) { @@ -17,5 +17,3 @@ function ModeIcon({ return ; } } - -export default ModeIcon; diff --git a/gui/src/components/ModeSelect/ModeSelect.tsx b/gui/src/components/ModeSelect/ModeSelect.tsx index b0fd1eee1..331e562f2 100644 --- a/gui/src/components/ModeSelect/ModeSelect.tsx +++ b/gui/src/components/ModeSelect/ModeSelect.tsx @@ -13,7 +13,7 @@ import { ListboxOption, ListboxOptions, } from "../ui/Listbox"; -import ModeIcon from "./ModeIcon"; +import { ModeIcon } from "./ModeIcon"; export function ModeSelect() { const dispatch = useAppDispatch(); @@ -76,7 +76,7 @@ export function ModeSelect() {
diff --git a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts index 4b50f26ea..774a95446 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts @@ -81,8 +81,6 @@ export function createEditorConfig(options: { const isStreaming = useAppSelector((state) => state.session.isStreaming); const useActiveFile = useAppSelector(selectUseActiveFile); const historyLength = useAppSelector((store) => store.session.history.length); - const mode = useAppSelector((store) => store.session.mode); - const modeRef = useUpdatingRef(mode); const codeToEdit = useAppSelector((store) => store.editModeState.codeToEdit); const isInEdit = useAppSelector((store) => store.session.isInEdit); const isInEditRef = useUpdatingRef(isInEdit); diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index dabf7dc63..216937e59 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -270,7 +270,7 @@ function ParallelListeners() { ); useEffect(() => { - if (isInEdit) { + if (!isInEdit) { dispatch(setLastNonEditSessionEmpty(history.length === 0)); } }, [isInEdit, history]); diff --git a/gui/src/hooks/useNavigationListener.tsx b/gui/src/hooks/useNavigationListener.tsx index 9ff9c8ea2..3c09dc2d0 100644 --- a/gui/src/hooks/useNavigationListener.tsx +++ b/gui/src/hooks/useNavigationListener.tsx @@ -8,7 +8,6 @@ const openGUITypes: (keyof ToWebviewProtocol)[] = [ "focusContinueInput", "focusContinueInputWithoutClear", "newSession", - "focusEdit", ]; export const useNavigationListener = () => {