From 0bfd12ed1a38debac5f4bd120de066b611c02a81 Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 27 Jul 2026 00:59:20 +0800 Subject: [PATCH] fix(pet): surface context menu failures instead of swallowing them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right-clicking the pet showed the native WebView menu and never the application's own menu. The handler was a bare void invoke(...) with no catch, so any failure to build or pop the menu was completely invisible and indistinguishable from preventDefault not taking effect. Report the error in the pet window and stop propagation as well as the default action. This does not yet explain which of the two is happening — it makes the difference observable, which is the prerequisite for fixing the right one. Co-Authored-By: Claude Opus 5 --- src/features/pet/DesktopPetView.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/features/pet/DesktopPetView.tsx b/src/features/pet/DesktopPetView.tsx index 0c65e4f..188deea 100644 --- a/src/features/pet/DesktopPetView.tsx +++ b/src/features/pet/DesktopPetView.tsx @@ -3,6 +3,7 @@ import { listen } from "@tauri-apps/api/event"; import { getCurrentWindow } from "@tauri-apps/api/window"; import { useEffect, useRef, useState } from "react"; +import { errorMessage } from "../../lib/errorMessage"; import { boundRuntimeEventSchema, connectionRuntimeStatusSchema, @@ -31,6 +32,7 @@ export function DesktopPetView({ embedded = false }: { embedded?: boolean }) { const [frameIndex, setFrameIndex] = useState(0); const [spriteReady, setSpriteReady] = useState(false); const [spriteError, setSpriteError] = useState(null); + const [menuError, setMenuError] = useState(null); const [gameMode, setGameMode] = useState(false); const spriteImageRef = useRef(null); const spriteCanvasRef = useRef(null); @@ -221,7 +223,13 @@ export function DesktopPetView({ embedded = false }: { embedded?: boolean }) { }} onContextMenu={(event) => { event.preventDefault(); - void invoke("show_pet_context_menu"); + event.stopPropagation(); + // Previously a bare `void invoke(...)`, so a failure to build or pop + // the menu was invisible and looked like the native WebView menu had + // simply won. Surface it instead. + void invoke("show_pet_context_menu").catch((reason) => { + setMenuError(errorMessage(reason)); + }); }} >
+ {menuError ? ( + + {menuError} + + ) : null} {spriteError ? ( {spriteError} ) : null}