Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): support Escape navigation in plugin details
qsoyq419433bf550a
diff --git a/apps/desktop/src/renderer/features/plugin/PluginDetailTopBar.tsx b/apps/desktop/src/renderer/features/plugin/PluginDetailTopBar.tsxindex 7259659385..3e7f5abd16 100644--- a/apps/desktop/src/renderer/features/plugin/PluginDetailTopBar.tsx+++ b/apps/desktop/src/renderer/features/plugin/PluginDetailTopBar.tsx@@ -6,11 +6,12 @@* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md*/-import { useCallback, useState, type UIEvent } from 'react';+import { useCallback, useEffect, useState, type UIEvent } from 'react';import { ArrowLeft } from 'lucide-react';import { WINDOW_DRAG_STYLE, WINDOW_NO_DRAG_STYLE } from '@/components/layout/windowDrag';import { useMacFullscreen } from '@/hooks/useMacFullscreen';+import { isEditableKeyboardTarget } from '@/lib/editableKeyboardTarget';import { cn } from '@/lib/utils';interface PluginDetailTopBarProps {@@ -67,6 +68,29 @@ export function usePluginDetailScrolled(): {export function PluginDetailTopBar({ label, onBack, scrolled }: PluginDetailTopBarProps) {const { isMac } = useMacFullscreen();+ // Both installed and market detail surfaces share this escape hatch. Let+ // nested dialogs and editable controls consume Escape first.+ useEffect(() => {+ const onKeyDown = (event: KeyboardEvent) => {+ if (+ event.key !== 'Escape' ||+ event.defaultPrevented ||+ event.isComposing ||+ event.altKey ||+ event.ctrlKey ||+ event.metaKey ||+ event.shiftKey ||+ isEditableKeyboardTarget(event.target)+ ) {+ return;+ }+ event.preventDefault();+ onBack();+ };+ window.addEventListener('keydown', onKeyDown);+ return () => window.removeEventListener('keydown', onKeyDown);+ }, [onBack]);+return (<divdata-testid="plugin-detail-top-bar"diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/PluginDetailTopBar.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/PluginDetailTopBar.test.tsxindex b77c957613..b69a9a94e7 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/PluginDetailTopBar.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/PluginDetailTopBar.test.tsx@@ -42,6 +42,38 @@ function Harness({ onBack = () => {} }: { onBack?: () => void }) {}describe('PluginDetailTopBar', () => {+ it('returns to the owning list when Escape is pressed', () => {+ stubPlatform('darwin');+ const onBack = vi.fn();++ render(<Harness onBack={onBack} />);++ const event = new KeyboardEvent('keydown', { key: 'Escape', cancelable: true });+ window.dispatchEvent(event);++ expect(onBack).toHaveBeenCalledTimes(1);+ expect(event.defaultPrevented).toBe(true);+ });++ it('leaves Escape to editable controls, modifiers, and consumed events', () => {+ stubPlatform('darwin');+ const onBack = vi.fn();+ render(<Harness onBack={onBack} />);++ fireEvent.keyDown(window, { key: 'Escape', metaKey: true });++ const input = document.createElement('input');+ document.body.appendChild(input);+ fireEvent.keyDown(input, { key: 'Escape' });+ input.remove();++ const consumed = new KeyboardEvent('keydown', { key: 'Escape', cancelable: true });+ consumed.preventDefault();+ window.dispatchEvent(consumed);++ expect(onBack).not.toHaveBeenCalled();+ });+it('carries the window drag region on macOS and keeps the back button clickable', () => {stubPlatform('darwin');const onBack = vi.fn();