Repository navigation
Per-Workspace Environments (on-demand disposable runtimes) + Add Project remote host setup - #6320
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ephemeral VM recipe parsing, doctoring, provisioning, runtime storage, CLI, IPC, preload, settings, composer, worktree, and trust flows, plus remote host selector and dialog updates with SSH connect and add-server actions. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 90cb604f-34dc-4514-8f99-d7d1ccd02f3f
📒 Files selected for processing (13)
src/renderer/src/components/sidebar/AddRemoteHostDialog.tsxsrc/renderer/src/components/sidebar/AddRemoteHostFields.tsxsrc/renderer/src/components/sidebar/AddRepoHostSelector.test.tsxsrc/renderer/src/components/sidebar/AddRepoHostSelector.tsxsrc/renderer/src/components/sidebar/AddRepoHostSelectorSlot.tsxsrc/renderer/src/components/sidebar/add-repo-host-availability.tssrc/renderer/src/components/sidebar/use-add-repo-host-selection.test.tssrc/renderer/src/components/sidebar/use-add-repo-host-selection.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
| toast.success( | ||
| translate( | ||
| 'auto.components.sidebar.AddRemoteHostDialog.sshImportSynced', | ||
| 'Synced {{value0}} host{{value1}}.', | ||
| { value0: synced.length, value1: synced.length > 1 ? 's' : '' } | ||
| ) | ||
| ) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
fd -t f 'i18n.ts' src/renderer/src/i18n --exec sed -n '1,80p' {}
rg -nP 'pluralSeparator|_one|_other|count' src/renderer/src/i18nRepository: stablyai/orca
Length of output: 50370
Replace manual pluralization with i18next count handling.
The current code uses manual suffix logic (value1) for plurals, which fails in non-English locales (e.g., es, ja, zh). Use the count option to leverage i18next's built-in pluralization rules via _one and _other keys.
♻️ Suggested approach
Update the translation call to pass count and define plural keys in the locale files:
- toast.success(
- translate(
- 'auto.components.sidebar.AddRemoteHostDialog.sshImportSynced',
- 'Synced {{value0}} host{{value1}}.',
- { value0: synced.length, value1: synced.length > 1 ? 's' : '' }
- )
- )
+ toast.success(
+ translate(
+ 'auto.components.sidebar.AddRemoteHostDialog.sshImportSynced',
+ 'Synced {{count}} host.',
+ { count: synced.length }
+ )
+ )Add auto.components.sidebar.AddRemoteHostDialog.sshImportSynced_one and auto.components.sidebar.AddRemoteHostDialog.sshImportSynced_other entries to src/renderer/src/i18n/locales/en.json (and other locales) to handle singular and plural forms correctly.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| toast.success( | |
| translate( | |
| 'auto.components.sidebar.AddRemoteHostDialog.sshImportSynced', | |
| 'Synced {{value0}} host{{value1}}.', | |
| { value0: synced.length, value1: synced.length > 1 ? 's' : '' } | |
| ) | |
| ) | |
| toast.success( | |
| translate( | |
| 'auto.components.sidebar.AddRemoteHostDialog.sshImportSynced', | |
| 'Synced {{count}} host.', | |
| { count: synced.length } | |
| ) | |
| ) |
There was a problem hiding this comment.
Actionable comments posted: 10
🧹 Nitpick comments (8)
src/shared/ephemeral-vm-runtime-store.ts (1)
122-137: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winCatch-all relabels every read failure as corruption.
hardenExistingSecureFile,readFileSync, andJSON.parseall funnel into the sameruntime_error"file is invalid" message. A transient permission/IO error (e.g.hardenExistingSecureFilefailing) is then surfaced to the user as data corruption, and the original cause is discarded with no logging. Consider preserving the original error viacause(or logging it) so genuine corruption can be distinguished from environmental failures.src/main/ephemeral-vm-runtime-service.ts (1)
139-153: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueFinal status updates ignore the injected
now, reducing test determinism.The
cleanup_failed/cleanedtransitions callDate.now()directly while thecleanup_pendingtransition (Line 124-126) honorsargs.now. For consistency and deterministic tests, consider threadingnow(or a fresh injected timestamp) through these updates as well.src/main/ipc/ephemeral-vm-runtime-handlers.ts (1)
49-77: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCleanup resolution duplicates
getRuntimeRecipeContext.The runtime/repo/recipe lookup here mirrors
getRuntimeRecipeContextinephemeral-vm-recipe-context.ts(used bygetCleanupCommandbelow). The difference is that this path converts each failure into acleanup_failedstatus update instead of throwing. Consider factoring the shared lookup into a helper that returns a discriminated result, letting both call sites branch on it — keeping the failure-to-status mapping local here while removing the copied resolution logic.src/renderer/src/components/settings/EphemeralVmRecipeDialogs.tsx (1)
19-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUser-facing strings are not localized.
Recipe doctor,ready, andneeds attentionare hardcoded English, whereas the rest of this pane (andEphemeralVmsPane) routes user-facing copy throughtranslate(...). Wrap these for i18n consistency.♻️ Proposed localization
- <DialogTitle>Recipe doctor</DialogTitle> + <DialogTitle> + {translate('auto.components.settings.EphemeralVmRecipeDialogs.title', 'Recipe doctor')} + </DialogTitle> </DialogHeader> {result ? ( <div className="space-y-2"> <div className="text-sm"> - {result.recipeId} · {result.ok ? 'ready' : 'needs attention'} + {result.recipeId} ·{' '} + {result.ok + ? translate('auto.components.settings.EphemeralVmRecipeDialogs.ready', 'ready') + : translate( + 'auto.components.settings.EphemeralVmRecipeDialogs.needsAttention', + 'needs attention' + )}(Requires importing
translatefrom@/i18n/i18n.)src/renderer/src/components/settings/EphemeralVmRecipeRow.tsx (1)
25-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLocalize the
cleanupLabelstrings.The button labels below use
translate(...), but these status strings are hardcoded English. Route them throughtranslatefor consistency with the rest of the row.src/renderer/src/components/NewWorkspaceComposerCard.tsx (1)
254-261: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
CommandEmptyis unreachable here.
Commandhas noCommandInput, so cmdk never enters a filtered/empty state andCommandEmpty(thenoVmRecipesmessage) will never render. The parent already gates this combobox onephemeralVmRecipes.length > 0, so the dead branch is harmless but can be dropped to reduce noise.src/shared/orca-yaml.ts (1)
106-114: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional:
cleanup: nonesentinel collides with a literal command namednone.A recipe whose cleanup command is literally
nonewould be silently treated as cleanup-disabled rather than executingnone. This is almost certainly a non-issue in practice, but worth a one-line doc note thatnoneis reserved as a disable sentinel.src/cli/handlers/vm.ts (1)
193-196: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
loadRecipere-reads and re-parsesorca.yamlalready parsed indoctorRecipe.In the provision path,
orca.yamlis read+parsed indoctorRecipe(Line 59) and again here. Beyond the redundant I/O, the two parse paths can drift if file contents change between reads. Consider threading the parsedhooks/recipe out ofdoctorRecipeso a single parse feeds both the checks and the recipe lookup.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 328399e1-b299-4ea2-be15-e7253360b328
📒 Files selected for processing (73)
skills/ephemeral-vms/SKILL.mdsrc/cli/args.tssrc/cli/dispatch.tssrc/cli/handlers/core.tssrc/cli/handlers/vm.tssrc/cli/help.tssrc/cli/index.test.tssrc/cli/index.tssrc/cli/runtime/launch.test.tssrc/cli/runtime/launch.tssrc/cli/specs/core.tssrc/cli/specs/index.tssrc/cli/specs/serve.tssrc/cli/specs/vm.tssrc/main/ephemeral-vm-recipe-runner.test.tssrc/main/ephemeral-vm-recipe-runner.tssrc/main/ephemeral-vm-runtime-service.test.tssrc/main/ephemeral-vm-runtime-service.tssrc/main/hooks.test.tssrc/main/hooks.tssrc/main/index.tssrc/main/ipc/ephemeral-vm-recipe-context.tssrc/main/ipc/ephemeral-vm-runtime-handlers.tssrc/main/ipc/ephemeral-vm.test.tssrc/main/ipc/ephemeral-vm.tssrc/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/NewWorkspaceComposerCard.tsxsrc/renderer/src/components/NewWorkspaceComposerModal.tsxsrc/renderer/src/components/settings/EphemeralVmRecipeDialogs.tsxsrc/renderer/src/components/settings/EphemeralVmRecipeRow.tsxsrc/renderer/src/components/settings/EphemeralVmRuntimesSection.test.tsxsrc/renderer/src/components/settings/EphemeralVmRuntimesSection.tsxsrc/renderer/src/components/settings/EphemeralVmsPane.test.tsxsrc/renderer/src/components/settings/EphemeralVmsPane.tsxsrc/renderer/src/components/settings/RuntimeEnvironmentsPane.tsxsrc/renderer/src/components/settings/Settings.tsxsrc/renderer/src/components/settings/ephemeral-vms-search.tssrc/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsxsrc/renderer/src/components/worktree-creation/WorktreeCreationPanel.test.tsxsrc/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsxsrc/renderer/src/hooks/useComposerState.tssrc/renderer/src/hooks/useSettingsNavigationMetadata.tssrc/renderer/src/lib/agent-feature-install-commands.tssrc/renderer/src/lib/ensure-hooks-confirmed.test.tssrc/renderer/src/lib/ensure-hooks-confirmed.tssrc/renderer/src/lib/ephemeral-vm-workspace-target.integration.test.tssrc/renderer/src/lib/ephemeral-vm-workspace-target.test.tssrc/renderer/src/lib/ephemeral-vm-workspace-target.tssrc/renderer/src/lib/ephemeral-vm-worktree-creation.tssrc/renderer/src/lib/orca-hook-trust.tssrc/renderer/src/lib/pending-worktree-creation.tssrc/renderer/src/lib/settings-navigation-types.tssrc/renderer/src/lib/worktree-creation-flow.test.tssrc/renderer/src/lib/worktree-creation-flow.tssrc/renderer/src/store/slices/worktree-helpers.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.tssrc/shared/agent-feature-install-commands.test.tssrc/shared/agent-feature-install-commands.tssrc/shared/ephemeral-vm-recipe-diagnostics.tssrc/shared/ephemeral-vm-recipe-doctor.tssrc/shared/ephemeral-vm-recipe-process.tssrc/shared/ephemeral-vm-recipe-runner.tssrc/shared/ephemeral-vm-recipes.test.tssrc/shared/ephemeral-vm-recipes.tssrc/shared/ephemeral-vm-runtime-store.test.tssrc/shared/ephemeral-vm-runtime-store.tssrc/shared/ephemeral-vm-runtimes.tssrc/shared/orca-yaml.tssrc/shared/types.ts
✅ Files skipped from review due to trivial changes (1)
- src/cli/help.ts
| listRecipes: (args: { repoId: string }) => Promise<{ | ||
| status: 'ok' | 'error' | ||
| repoPath: string | null | ||
| recipes: OrcaHooks['vmRecipes'] | ||
| diagnostics: NonNullable<OrcaHooks['vmRecipeDiagnostics']> | ||
| message?: string | ||
| }> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
recipes type is wider than the handler return; inconsistent with listRecipeCatalog.
The IPC handler (EphemeralVmRecipeListResult.recipes) always returns an OrcaVmRecipe[] (defaulting via ?? []), but OrcaHooks['vmRecipes'] is OrcaVmRecipe[] | undefined. This forces renderer callers to null-check a value that is never undefined, and it diverges from listRecipeCatalog just below which correctly uses NonNullable<OrcaHooks['vmRecipes']>.
Proposed fix
- recipes: OrcaHooks['vmRecipes']
+ recipes: NonNullable<OrcaHooks['vmRecipes']>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| listRecipes: (args: { repoId: string }) => Promise<{ | |
| status: 'ok' | 'error' | |
| repoPath: string | null | |
| recipes: OrcaHooks['vmRecipes'] | |
| diagnostics: NonNullable<OrcaHooks['vmRecipeDiagnostics']> | |
| message?: string | |
| }> | |
| listRecipes: (args: { repoId: string }) => Promise<{ | |
| status: 'ok' | 'error' | |
| repoPath: string | null | |
| recipes: NonNullable<OrcaHooks['vmRecipes']> | |
| diagnostics: NonNullable<OrcaHooks['vmRecipeDiagnostics']> | |
| message?: string | |
| }> |
| const text = result.command | ||
| ? `${result.command}\n\n# Cleanup payload:\n${result.payloadJson}` | ||
| : result.payloadJson |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Copy only the runnable cleanup command here.
When result.command is present, this copies the command plus a comment header and raw JSON payload. That makes the clipboard contents non-runnable if the user pastes them straight into a shell, despite the button and toast both saying “Copy command”. Copy just result.command here, and expose the payload through a separate action if it still needs to be available.
Suggested fix
- const text = result.command
- ? `${result.command}\n\n# Cleanup payload:\n${result.payloadJson}`
- : result.payloadJson
+ const text = result.command ?? result.payloadJson📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const text = result.command | |
| ? `${result.command}\n\n# Cleanup payload:\n${result.payloadJson}` | |
| : result.payloadJson | |
| const text = result.command ?? result.payloadJson |
| </div> | ||
| </div> | ||
|
|
||
| <EphemeralVmRuntimesSection /> |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find EphemeralVmRuntimesSection definition
find src -type f -name "*.tsx" -o -name "*.ts" | xargs grep -l "EphemeralVmRuntimesSection" | head -5Repository: find_file
Length of output: 2011
🏁 Script executed:
#!/bin/bash
# Search for window.api usage in the section
grep -r "window\.api" src/renderer/src/components/ | grep -i "ephemeral" | head -10Repository: find_api_usage
Length of output: 2026
🏁 Script executed:
#!/bin/bash
# Find the file defining EphemeralVmRuntimesSection
grep -r "const EphemeralVmRuntimesSection" src --include="*.tsx" --include="*.ts"Repository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
# Search for window.api usage in EphemeralVmRuntimesSection specifically
find src -type f \( -name "*.tsx" -o -name "*.ts" \) -exec grep -l "EphemeralVmRuntimesSection" {} \; | xargs grep -n "window\.api"Repository: stablyai/orca
Length of output: 2658
🏁 Script executed:
#!/bin/bash
# Check Settings.tsx for how RuntimeEnvironmentsPane is rendered
grep -n "RuntimeEnvironmentsPane\|isWebClient" src/renderer/pages/Settings.tsx 2>/dev/null || grep -n "RuntimeEnvironmentsPane\|isWebClient" src/renderer/src/pages/Settings.tsx 2>/dev/nullRepository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
# Find Settings.tsx location
find src -type f -name "Settings.tsx" -o -name "Settings.ts"Repository: stablyai/orca
Length of output: 201
🏁 Script executed:
#!/bin/bash
# Once path is found, grep for RuntimeEnvironmentsPane usage and isWebClient
# Will update this after finding the fileRepository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
# Check how RuntimeEnvironmentsPane is used in Settings.tsx and if isWebClient affects it
grep -n "RuntimeEnvironmentsPane\|isWebClient" src/renderer/src/components/settings/Settings.tsx | head -30Repository: stablyai/orca
Length of output: 597
🏁 Script executed:
#!/bin/bash
# Also check if there's any web guard pattern in the codebase for window.api
grep -r "isWebClient\|canGeneratePairingUrl" src/renderer/src --include="*.tsx" --include="*.ts" | grep -v "test" | head -20Repository: stablyai/orca
Length of output: 2190
🏁 Script executed:
#!/bin/bash
# Check if EphemeralVmRuntimesSection has any internal web checks or accepts isWebClient prop
grep -n "isWebClient\|window\.api" src/renderer/src/components/settings/EphemeralVmRuntimesSection.tsx | head -20Repository: stablyai/orca
Length of output: 468
🏁 Script executed:
#!/bin/bash
# Check how EphemeralVmRuntimesSection is rendered in RuntimeEnvironmentsPane to see if it receives props
grep -B5 -A5 "EphemeralVmRuntimesSection" src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsxRepository: stablyai/orca
Length of output: 781
Confirm web-client behavior for the cleanup section.
RuntimeEnvironmentsPane is rendered on both desktop and web clients. The EphemeralVmRuntimesSection component unconditionally accesses window.api.ephemeralVm.listRuntimes() on mount (line 60 of EphemeralVmRuntimesSection.tsx), which will throw a runtime error (Cannot read properties of undefined) when the window.api bridge is unavailable on web.
While Settings.tsx gates specific pairing features via the canGeneratePairingUrl prop, the cleanup section remains unconditionally rendered. Gate the <EphemeralVmRuntimesSection /> render in RuntimeEnvironmentsPane using the existing canGeneratePairingUrl prop (or pass isWebClient explicitly) to prevent execution on web clients.
Snippet
// src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
// Current (line ~994):
<EphemeralVmRuntimesSection />
// Suggested:
{canGeneratePairingUrl && <EphemeralVmRuntimesSection />}| <SettingsSection | ||
| id="ephemeral-vms" | ||
| title={translate( | ||
| 'auto.components.settings.Settings.ephemeralVms', | ||
| 'Ephemeral VMs' | ||
| )} | ||
| badge="Beta" | ||
| description={translate( | ||
| 'auto.components.settings.Settings.ephemeralVmsDescription', | ||
| 'Use repo-owned recipes to create one temporary cloud runtime per workspace.' | ||
| )} | ||
| searchEntries={getSectionSearchEntries('ephemeral-vms')} | ||
| > | ||
| {isSectionMounted('ephemeral-vms') ? <EphemeralVmsPane /> : null} | ||
| </SettingsSection> |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check whether ephemeralVm API is exposed in the web/browser preload shim
rg -nP "ephemeralVm" --type=ts -g '!**/*.test.*' | rg -i "web|browser|shim|stub"
# Confirm how other desktop-only panes are gated vs ephemeral-vms
rg -nP "showDesktopOnlySettings \?" src/renderer/src/components/settings/Settings.tsxRepository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
# Find EphemeralVmsPane file
fd "EphemeralVmsPane" --type f -e ts,tsx
# Search for window.api usage in EphemeralVmsPane if found
# Check definition of showDesktopOnlySettings
rg -n "showDesktopOnlySettings" src/renderer/src/components/settings/Settings.tsx | head -20
# Check if there is a web preload or shim for window.api
find src -name "*shim*" -o -name "*web*" -o -name "*preload*" | grep -E "(preload|shim|web)"Repository: stablyai/orca
Length of output: 3398
🏁 Script executed:
#!/bin/bash
# Find the EphemeralVmsPane component
fd "EphemeralVmsPane" --type f -e ts,tsx
# Check the web preload API to see if ephemeralVm is exposed
cat src/renderer/src/web/web-preload-api.ts | grep -i "ephemeral"
# Re-check the specific lines in Settings.tsx to confirm the missing wrapper
sed -n '1505,1530p' src/renderer/src/components/settings/Settings.tsxRepository: stablyai/orca
Length of output: 1247
🏁 Script executed:
#!/bin/bash
# Locate EphemeralVmsPane
fd "EphemeralVmsPane" --type f
# Check web-preload-api.ts for ephemeralVm
grep -i "ephemeral" src/renderer/src/web/web-preload-api.ts
# If EphemeralVmsPane is found, check its content
find . -name "EphemeralVmsPane*" -type f -exec head -50 {} \;Repository: stablyai/orca
Length of output: 3574
🏁 Script executed:
#!/bin/bash
# Confirm ephemeralVm is missing in web-preload-api.ts
cat src/renderer/src/web/web-preload-api.ts
# Check if isSectionMounted for ephemeral-vms returns true on web
grep -n "isSectionMounted" src/renderer/src/components/settings/Settings.tsx | head -10Repository: stablyai/orca
Length of output: 50370
Gate the Ephemeral VMs section with showDesktopOnlySettings.
The ephemeral-vms section (lines 1510-1524) is rendered on web clients, but EphemeralVmsPane relies on window.api.ephemeralVm, which is not exposed in the web preload API. This causes a crash or error toast on web.
Wrap the section in {showDesktopOnlySettings ? ... : null} to match the pattern used for computer-use, voice, ssh, and mobile sections (e.g., lines 1151, 1332, 1526).
Current code
<SettingsSection
id="ephemeral-vms"
title={translate(
'auto.components.settings.Settings.ephemeralVms',
'Ephemeral VMs'
)}
badge="Beta"
description={translate(
'auto.components.settings.Settings.ephemeralVmsDescription',
'Use repo-owned recipes to create one temporary cloud runtime per workspace.'
)}
searchEntries={getSectionSearchEntries('ephemeral-vms')}
>
{isSectionMounted('ephemeral-vms') ? <EphemeralVmsPane /> : null}
</SettingsSection>| useEffect(() => { | ||
| let cancelled = false | ||
| setEphemeralVmRecipes([]) | ||
| setSelectedEphemeralVmRecipeId(null) | ||
| setEphemeralVmRecipeError(null) | ||
| if (!selectedRepo || !selectedRepoIsGit || selectedRepo.connectionId || isProjectGroupTarget) { | ||
| return () => { | ||
| cancelled = true | ||
| } | ||
| } | ||
| void window.api.ephemeralVm | ||
| .listRecipes({ repoId: selectedRepo.id }) | ||
| .then((result) => { | ||
| if (cancelled) { | ||
| return | ||
| } | ||
| setEphemeralVmRecipes(result.recipes ?? []) | ||
| setSelectedEphemeralVmRecipeId( | ||
| initialEphemeralVmRecipeId && | ||
| result.recipes?.some((recipe) => recipe.id === initialEphemeralVmRecipeId) | ||
| ? initialEphemeralVmRecipeId | ||
| : null | ||
| ) | ||
| const diagnosticMessages = (result.diagnostics ?? []).map((diagnostic) => { | ||
| const recipeLabel = `vmRecipes[${diagnostic.index}]` | ||
| const fieldLabel = diagnostic.field ? `.${diagnostic.field}` : '' | ||
| return `${recipeLabel}${fieldLabel}: ${diagnostic.message}` | ||
| }) | ||
| setEphemeralVmRecipeError( | ||
| [result.status === 'error' ? result.message : null, ...diagnosticMessages] | ||
| .filter((message): message is string => Boolean(message)) | ||
| .join('\n') || null | ||
| ) | ||
| }) | ||
| .catch((error) => { | ||
| if (cancelled) { | ||
| return | ||
| } | ||
| setEphemeralVmRecipes([]) | ||
| setEphemeralVmRecipeError(error instanceof Error ? error.message : String(error)) | ||
| }) | ||
| return () => { | ||
| cancelled = true | ||
| } | ||
| }, [initialEphemeralVmRecipeId, isProjectGroupTarget, selectedRepo, selectedRepoIsGit]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check the context around the hook to see how selectedRepo and initialEphemeralVmRecipeId are obtained
# and if selectedRepo might change reference.
grep -n "selectedRepo" src/renderer/src/hooks/useComposerState.ts | head -30Repository: use-_state
Length of output: 2048
Preserve user-selected recipe ID when the recipe list refreshes.
The useEffect currently clears selectedEphemeralVmRecipeId to null on every run and subsequently restores only initialEphemeralVmRecipeId. If selectedRepo changes reference (triggering a re-run due to background updates), any user selection that differs from the initial value is silently lost.
Modify the resolution logic to check if the current selectedEphemeralVmRecipeId still exists in the result.recipes list. Prioritize preserving the current selection if valid, falling back to initialEphemeralVmRecipeId only if the current selection is invalid or absent.
// Proposed logic change
setSelectedEphemeralVmRecipeId((currentSelection) => {
// Prefer current selection if it still exists in the new list
if (currentSelection && result.recipes?.some((r) => r.id === currentSelection)) {
return currentSelection
}
// Fallback to initial if valid
if (
initialEphemeralVmRecipeId &&
result.recipes?.some((recipe) => recipe.id === initialEphemeralVmRecipeId)
) {
return initialEphemeralVmRecipeId
}
return null
})| const abort = (): void => { | ||
| if (settled) { | ||
| return | ||
| } | ||
| child.kill() | ||
| } | ||
|
|
||
| args.signal?.addEventListener('abort', abort, { once: true }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Pre-aborted signal won't terminate the child.
The abort listener is registered with { once: true }, so if args.signal is already aborted when runRecipeCommand runs, the handler never fires and the command runs to completion. Guard the already-aborted case.
Proposed fix
args.signal?.addEventListener('abort', abort, { once: true })
+ if (args.signal?.aborted) {
+ abort()
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const abort = (): void => { | |
| if (settled) { | |
| return | |
| } | |
| child.kill() | |
| } | |
| args.signal?.addEventListener('abort', abort, { once: true }) | |
| const abort = (): void => { | |
| if (settled) { | |
| return | |
| } | |
| child.kill() | |
| } | |
| args.signal?.addEventListener('abort', abort, { once: true }) | |
| if (args.signal?.aborted) { | |
| abort() | |
| } |
🧰 Tools
🪛 ast-grep (0.44.0)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
| function appendBounded(current: string, chunk: string, maxBytes: number): string { | ||
| const next = current + chunk | ||
| if (Buffer.byteLength(next, 'utf8') <= maxBytes) { | ||
| return next | ||
| } | ||
| return next.slice(-maxBytes) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
appendBounded mixes byte budget with character slicing.
maxBytes is a byte count, but next.slice(-maxBytes) slices by UTF-16 code units. For multibyte output the retained tail can exceed maxBytes bytes, so the capture bound isn't actually enforced. Truncate against the byte length instead.
Proposed fix
-function appendBounded(current: string, chunk: string, maxBytes: number): string {
- const next = current + chunk
- if (Buffer.byteLength(next, 'utf8') <= maxBytes) {
- return next
- }
- return next.slice(-maxBytes)
-}
+function appendBounded(current: string, chunk: string, maxBytes: number): string {
+ const next = current + chunk
+ const buf = Buffer.from(next, 'utf8')
+ if (buf.length <= maxBytes) {
+ return next
+ }
+ return buf.subarray(buf.length - maxBytes).toString('utf8')
+}🧰 Tools
🪛 ast-grep (0.44.0)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
d6c707a to
9ccec47
Compare
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
…ject An SSH-mode per-workspace-env's workspace is the runtime repo's main worktree, so deleting it routes through removeProject, not removeWorktree. removeProject never tore down the ephemeral runtime, leaking the live Docker/VM and its hidden SSH target on every delete. - Extract the runtime-cleanup-by-workspace logic into a shared module that matches runtimes by workspace id AND by a removed repo's runtime-owned SSH connectionId, so both delete paths tear the runtime down. - removeProject now cleans up the backing runtime when the repo's connectionId is a runtime-owned SSH target. - The orphan-project purge now also removes a repo whose only host was the destroyed runtime even when its project-host-setup was already pruned, so no dead, never-connectable project lingers in the sidebar/composer. Co-authored-by: Orca <[email protected]>
After creating a per-workspace-env, its runtime-owned SSH repo became the active repo. The composer seeds its project from the active repo, so the next 'Create workspace' selected that repo — which has a connectionId, so recipe loading is suppressed — hiding the 'Run on' host/recipe picker entirely with no way to pick a different host or recipe. Exclude runtime-owned SSH repos from the dialog's eligible repos (they're hidden plumbing, like every other user-facing surface already treats them), so the composer falls back to the project's real local repo and the host/ recipe picker stays available. Co-authored-by: Orca <[email protected]>
On failure the panel showed only the short status (e.g. 'Recipe exited with code 1'), discarding the recipe output we already captured — leaving the user with nothing to act on. Surface the captured recipe stderr in the same fixed-height log panel below the error + Retry/Dismiss, so the real cause (and what to fix) is visible. Non-VM creation failures, which have no recipe output, render unchanged. Co-authored-by: Orca <[email protected]>
A failed VM recipe now renders in the same centered 'Provisioning VM' layout — the recipe log stays in the same place and style; only the spinner header swaps to the error + Retry/Dismiss. Previously the failure jumped to a separate top-left error style, moving the log. Non-VM creation failures keep the original compact error line (they have no recipe log). Co-authored-by: Orca <[email protected]>
The run-target row had only a label, so it rendered shorter than the
two-line host options. Add a one-line subtitle ('Provision an on-demand
environment from a recipe') so it matches their height and hints what the
submenu opens.
Co-authored-by: Orca <[email protected]>
The provisioning view said 'Cancel stops provisioning' but had no visible Cancel control (only the tiny tab X) — add a Cancel button under the header. The recipe log now follows the tail as output streams, unless the user scrolls up (then it holds their position until they scroll back down). Co-authored-by: Orca <[email protected]>
…e-env After creating a per-workspace-env, its runtime-owned SSH repo becomes the active repo, but that repo is excluded from the composer's eligible repos, so seeding from activeRepoId failed and fell back to the first eligible repo (a different project). Map an active runtime-owned SSH repo to its local same-project sibling so the composer stays on that project. Co-authored-by: Orca <[email protected]>
The 'Cancel stops provisioning. Cleanup runs if a runtime was created.' line was unneeded — the Cancel button speaks for itself. Co-authored-by: Orca <[email protected]>
Mirror improvements made to the installed skill after live use: - §1: verify a provider's SSH mode exposes a real dialable target, not an interactive-only shell. - §3/§4 + §10: don't bind-mount/copy the host agent home (e.g. ~/.codex) as the auth snapshot — its sqlite/hook/cache state breaks in a disposable runtime; authenticate inside the runtime and commit that layer. - New §7h worked example: local Docker SSH (auth image via docker commit, random localhost port, entrypoint reset); old Windows section renumbered §7i. - §9: SSH/Docker smoke-test steps before declaring a recipe ready. - §10: failure modes for host-copied auth and a Docker auth image that exits immediately. Co-authored-by: Orca <[email protected]>
A recipe added to orca.yaml only on a branch/worktree won't appear as a Run-on option in the workspace composer until that change is merged to the project's primary branch (loadHooks reads orca.yaml from the project's main checkout). doctor/--provision still validate from the working copy on any branch; only picker creation needs it on primary. Co-authored-by: Orca <[email protected]>
Resolve 4 import conflicts (node: protocol migration from main's oxlint autofix): keep the symbols this branch added (statSync/isAbsolute in index.ts; execFileSync in orca-runtime.test; fs/os imports in cli/index.test; node:fs in hooks) under main's node:-prefixed convention, and drop a dead 'yaml' import. pnpm install picks up main's new @testing-library deps. Co-authored-by: Orca <[email protected]>
main's oxlint upgrade made unicorn/prefer-node-protocol an error; these branch-only files still used bare fs/os/path imports and tripped the full-repo lint in CI. Autofixed to node:-prefixed specifiers. Co-authored-by: Orca <[email protected]>
The user-facing feature is 'Per-Workspace Environments', so the config contract should match: a Docker container / SSH host / cloud sandbox isn't literally a VM. Hard-rename the orca.yaml key, the OrcaHooks type field (vmRecipes/vmRecipeDiagnostics -> environmentRecipes/ environmentRecipeDiagnostics), and all user-facing copy (doctor diagnostics, remediations, trust-confirmation labels, CLI help, skill, vercel doc). Internal ephemeralVm-prefixed plumbing (symbols, filenames, IPC channels) is left unchanged. The CLI verb stays 'orca vm recipe doctor' because an 'orca environment ...' command already exists for runtime environments (the Orca-server pairing concept) and reusing it would conflate two concepts. Co-authored-by: Orca <[email protected]>
…utton - Shorten the section description and remove the trailing 'The skill sets it up for this repo.' so it no longer wraps awkwardly; widen the shared settings-section description cap (max-w-2xl -> max-w-3xl) so descriptions stop breaking early under the wider title row. - Remove the per-recipe Doctor button (and its now-orphaned RecipeDoctorDialog + pane state); recipe rows keep just 'Use in workspace'. The CLI 'vm recipe doctor' self-test the skill uses is unaffected. Co-authored-by: Orca <[email protected]>
Show just the copy icon by default (with an aria-label for accessibility); on click show the 'Copied' text with no checkmark. Co-authored-by: Orca <[email protected]>
Icon-only Copy button by default; on click show a checkmark + 'Copied'. Co-authored-by: Orca <[email protected]>
'Appear here once your agent adds them...' read as a fragment; replace with 'Recipes your agent adds to orca.yaml show up here, ready to launch a workspace on.' Co-authored-by: Orca <[email protected]>
The orca-per-workspace-env skill is now the maintained source of truth for setup; docs/ephemeral-vm-recipes.md and docs/vercel-sandbox-ephemeral-vms.md were earlier design-era artifacts that overlapped with it and risked drift. Co-authored-by: Orca <[email protected]>
…very tests Post-merge adjustments: executeWorktreeCreation now flows through prepareRequestForCreate (#6320), so thread issueCommand from the prepared request, and assert delivery via vi.waitFor — the fixed two-tick flush starved once main added awaits ahead of the activation branches, which is exactly how the merge-build verify check failed. Co-authored-by: Orca <[email protected]>
…arate projects (#7237) * fix(sidebar): keep independent same-host checkouts of one repo as separate projects Re-regression of #5374: PR #6320 removed the per-host-surface separation added by #5375, so independent local clones of the same repo (shared origin => same github:owner/repo identity) collapse into one sidebar project again. Restore the surface-key separation in worktree-list-groups.ts, scoped by ProjectHostSetup.setupMethod: 'provisioned' (ephemeral-VM runtime copies) still nest under the project header (preserving #6320), while real user checkouts (legacy-repo / imported-existing-folder / cloned) each get their own header when duplicated on one host surface. Revert the two tests #6320 inverted and add coverage for a provisioned copy nesting alongside a same-host user checkout. * test(cmd-j): update palette grouping tests for same-host checkout split The Cmd+J palette shares getProjectGroupingForRepo (via getProjectHeaderRevealTarget) with the sidebar, so restoring same-host checkout separation also splits independent `cloned` checkouts into per-setup palette entries. Update the multi-setup test to assert the split and add coverage that a `provisioned` runtime copy still nests under one project key. * test(sidebar): cover split + provisioned-nest on one host together Guard the intersection of #5374 and #6320: when a project has two real same-host user checkouts AND a provisioned copy, the real checkouts each get their own per-setup header while the provisioned copy stays under the plain project key (never a path-scoped ::setup: header). Locks the two features' combined behavior so a future change can't silently regress either half. * refactor(sidebar): reuse shared Windows-path helper, single-pass surface count Take-over polish of #7237: - Use shared isWindowsAbsolutePathLike instead of an inline drive-letter regex, deduplicating the pattern and also bucketing UNC \\server\share paths as a Windows surface instead of falling through to default. - Collapse buildProjectGroupingIndex's two passes over projectHostSetups into one, computing each surface key once and flagging ambiguous projects from the aggregated counts. - Tighten why-comments to AGENTS.md's two-line rule. No behavior change to the fix; all 123 sidebar/palette grouping tests pass. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Neil <[email protected]> Co-authored-by: Orca <[email protected]>
…ect remote host setup (stablyai#6320) Co-authored-by: Orca <[email protected]>
…arate projects (stablyai#7237) * fix(sidebar): keep independent same-host checkouts of one repo as separate projects Re-regression of stablyai#5374: PR stablyai#6320 removed the per-host-surface separation added by stablyai#5375, so independent local clones of the same repo (shared origin => same github:owner/repo identity) collapse into one sidebar project again. Restore the surface-key separation in worktree-list-groups.ts, scoped by ProjectHostSetup.setupMethod: 'provisioned' (ephemeral-VM runtime copies) still nest under the project header (preserving stablyai#6320), while real user checkouts (legacy-repo / imported-existing-folder / cloned) each get their own header when duplicated on one host surface. Revert the two tests stablyai#6320 inverted and add coverage for a provisioned copy nesting alongside a same-host user checkout. * test(cmd-j): update palette grouping tests for same-host checkout split The Cmd+J palette shares getProjectGroupingForRepo (via getProjectHeaderRevealTarget) with the sidebar, so restoring same-host checkout separation also splits independent `cloned` checkouts into per-setup palette entries. Update the multi-setup test to assert the split and add coverage that a `provisioned` runtime copy still nests under one project key. * test(sidebar): cover split + provisioned-nest on one host together Guard the intersection of stablyai#5374 and stablyai#6320: when a project has two real same-host user checkouts AND a provisioned copy, the real checkouts each get their own per-setup header while the provisioned copy stays under the plain project key (never a path-scoped ::setup: header). Locks the two features' combined behavior so a future change can't silently regress either half. * refactor(sidebar): reuse shared Windows-path helper, single-pass surface count Take-over polish of stablyai#7237: - Use shared isWindowsAbsolutePathLike instead of an inline drive-letter regex, deduplicating the pattern and also bucketing UNC \\server\share paths as a Windows surface instead of falling through to default. - Collapse buildProjectGroupingIndex's two passes over projectHostSetups into one, computing each surface key once and flagging ambiguous projects from the aggregated counts. - Tighten why-comments to AGENTS.md's two-line rule. No behavior change to the fix; all 123 sidebar/palette grouping tests pass. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Neil <[email protected]> Co-authored-by: Orca <[email protected]>
Summary
Adds Per-Workspace Environments (formerly "Ephemeral VMs"): repo-owned recipes that provision an on-demand, disposable runtime — a cloud sandbox, a VM, or a local container — fresh for each workspace and torn down after. Orca stays a thin wrapper: it sequences setup, detects what's detectable, scaffolds provider-templated lifecycle scripts, and drives validation; it never owns the user's cloud account, images, or credentials.
This branch also includes an earlier improvement to the Add Project remote-host setup flow (first commit on the branch).
Per-Workspace Environments
vmRecipesinorca.yamlwith acreate/suspend/resume/destroylifecycle contract; recipes surface in the New Workspace composer under a "Run on" → Per-Workspace Environment submenu.orca serveand Orca pairs over its pairing URL (registered as a runtime environment).suspend/resume(gracefully skipped when a recipe defines no suspend hook); deleting a workspace or removing the project tears down the backing runtime and its hidden SSH target, and purges the orphaned runtime-backed project so it can't linger as a dead, never-connectable entry.orca vm recipe doctor— a free static check plus a--provisionlive self-test loop (create → validate → destroy) that returns a full transcript so an agent can diagnose and fix recipes itself.orca-per-workspace-envagent skill — drives first-time setup end to end (prerequisites → reusable base snapshot → coding-agent auth snapshot → state file → per-workspace scripts), with worked examples (Vercel Sandbox, existing SSH host, local Docker SSH, Windows).Add Project remote host setup (earlier work on this branch)
~/.ssh/configfrom the SSH setup dialog; refresh host metadata after saves/imports.Notable behavior / limitations
vmRecipesfrom the project's primary checkout oforca.yaml, so a recipe added only on a branch won't appear in the picker until it's merged to primary (doctor/--provisionstill validate from the working copy on any branch).relayGracePeriodSeconds.Validation
🤖 Generated with Claude Code