MCPcopy Create free account
hub / github.com/anomalyco/opencode / WindowsAppMenu

Function WindowsAppMenu

packages/app/src/components/windows-app-menu.tsx:12–104  ·  view source on GitHub ↗
(props: {
  command: ReturnType<typeof useCommand>
  platform: ReturnType<typeof usePlatform>
  variant?: "legacy" | "v2"
})

Source from the content-addressed store, hash-verified

10import { usePlatform } from "@/context/platform"
11
12export function WindowsAppMenu(props: {
13 command: ReturnType<typeof useCommand>
14 platform: ReturnType<typeof usePlatform>
15 variant?: "legacy" | "v2"
16}) {
17 let lastFocused: HTMLElement | undefined
18
19 const rememberFocus = () => {
20 const active = document.activeElement
21 lastFocused = active instanceof HTMLElement ? active : undefined
22 }
23 const commandDisabled = (id: string) => {
24 const option = props.command.options.find((option) => option.id === id)
25 if (!option) return true
26 return option.disabled ?? false
27 }
28 const runCommand = (id: string) => {
29 if (commandDisabled(id)) return
30 props.command.trigger(id)
31 }
32 const runAction = (action: DesktopMenuAction) => {
33 if (action.startsWith("edit.") && lastFocused?.isConnected) lastFocused.focus({ preventScroll: true })
34 void props.platform.runDesktopMenuAction?.(action)
35 }
36 const runEntry = (entry: DesktopMenuEntry) => {
37 if (entry.type === "separator") return
38 if (entry.command) {
39 runCommand(entry.command)
40 return
41 }
42 if (entry.action) {
43 runAction(entry.action)
44 return
45 }
46 if (entry.href) props.platform.openLink(entry.href)
47 }
48
49 return (
50 <DropdownMenu gutter={4} modal={false} placement="bottom-start">
51 {props.variant === "v2" ? (
52 <div
53 data-component="desktop-icon-button"
54 class="flex h-7 w-9 shrink-0 items-center justify-center rounded-[6px] px-1"
55 >
56 <DropdownMenu.Trigger
57 as={IconButtonV2}
58 variant="ghost-muted"
59 size="large"
60 icon={<IconV2 name="menu" />}
61 aria-label="OpenCode menu"
62 onPointerDown={rememberFocus}
63 onKeyDown={rememberFocus}
64 />
65 </div>
66 ) : (
67 <DropdownMenu.Trigger
68 as={IconButton}
69 icon="menu"

Callers

nothing calls this directly

Calls 3

desktopMenuVisibleFunction · 0.90
commandDisabledFunction · 0.85
runEntryFunction · 0.85

Tested by

no test coverage detected