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({