From 59189ea6b7f987fcf2b4daf18d61d1f7bce8a7f7 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 23:37:08 -0800 Subject: [PATCH] fix(cloud): Run menu suggestions re-read package.json on menu open, hover and window focus (LC2-P3) --- .../TabBarQuickCommandItem.fixture.tsx | 49 +++++++++++++ .../tab-bar/TabBarQuickCommandsButton.tsx | 15 +++- ...ud-suggested-run-commands.refresh.test.tsx | 72 +++++++++++++++++++ .../hooks/use-cloud-suggested-run-commands.ts | 43 +++++++++-- 4 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 src/renderer/src/components/tab-bar/TabBarQuickCommandItem.fixture.tsx create mode 100644 src/renderer/src/hooks/use-cloud-suggested-run-commands.refresh.test.tsx diff --git a/src/renderer/src/components/tab-bar/TabBarQuickCommandItem.fixture.tsx b/src/renderer/src/components/tab-bar/TabBarQuickCommandItem.fixture.tsx new file mode 100644 index 00000000000..98ff9e53b32 --- /dev/null +++ b/src/renderer/src/components/tab-bar/TabBarQuickCommandItem.fixture.tsx @@ -0,0 +1,49 @@ +import { defineFixture } from '../../component-fixtures/component-fixture' +import { suggestedRunCommands } from '@/hooks/use-cloud-suggested-run-commands' +import type { HostedTerminalQuickCommand } from '@/hooks/use-terminal-quick-command-hosts' +import { TabBarQuickCommandItem } from './TabBarQuickCommandItem' + +const HOST = { hostId: 'runtime:env' as const, label: 'Orca Cloud' } +const noop = (): void => {} + +const saved: HostedTerminalQuickCommand = { + command: { + id: 'saved-dev', + label: 'dev server', + command: 'pnpm dev --port 3000', + appendEnter: true + }, + hostId: HOST.hostId, + hostLabel: HOST.label, + key: 'runtime:env\0saved-dev' +} + +// The Run menu's rows in a cloud workspace: a saved command, then package.json suggestions +// (Copy only, "From package.json"). Suggestions are re-read when the menu opens (LC2-P3). +export const cloudRunMenuRows = defineFixture({ + width: 420, + render: () => ( +
+ {[ + saved, + ...suggestedRunCommands( + JSON.stringify({ + packageManager: 'pnpm@9.0.0', + scripts: { test: 'vitest', typecheck: 'tsc', lint: 'eslint .' } + }), + HOST + ) + ].map((entry, index) => ( + + ))} +
+ ) +}) diff --git a/src/renderer/src/components/tab-bar/TabBarQuickCommandsButton.tsx b/src/renderer/src/components/tab-bar/TabBarQuickCommandsButton.tsx index db832175f6b..962719cfda9 100644 --- a/src/renderer/src/components/tab-bar/TabBarQuickCommandsButton.tsx +++ b/src/renderer/src/components/tab-bar/TabBarQuickCommandsButton.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from 'react' +import { useCallback, useMemo, useState } from 'react' import { Play } from 'lucide-react' import { useAppStore } from '@/store' import { getTerminalQuickCommandHostPromptMaxLength } from '@/lib/terminal-quick-command-host-prompt-limit' @@ -64,7 +64,14 @@ export function TabBarQuickCommandsButton({ cloudEnvironmentId && hosts.length === 1 && hosts[0].hostId === executionHostId ? { hostId: hosts[0].hostId, label: hosts[0].label, environmentId: cloudEnvironmentId } : null - const suggestedCommands = useCloudSuggestedRunCommands(worktreeId, cloudHost) + const { commands: suggestedCommands, refresh: refreshSuggestions } = useCloudSuggestedRunCommands( + worktreeId, + cloudHost + ) + const handleMenuOpen = useCallback((): void => { + refreshRemoteHost() + refreshSuggestions() + }, [refreshRemoteHost, refreshSuggestions]) // Floating terminals have a synthetic workspace ID without a repo; never treat that sentinel as a run target. const repoId = useMemo(() => { if (worktreeId === FLOATING_TERMINAL_WORKTREE_ID) { @@ -199,6 +206,8 @@ export function TabBarQuickCommandsButton({