Skip to content

feat(automations): host selector for remote environment automations - #10347

Open
innocarpe wants to merge 4 commits into
stablyai:mainfrom
innocarpe:fix/automations-environment-selector
Open

feat(automations): host selector for remote environment automations#10347
innocarpe wants to merge 4 commits into
stablyai:mainfrom
innocarpe:fix/automations-environment-selector

Conversation

@innocarpe

@innocarpe innocarpe commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a host selector on the Automations page (Local + each connected runtime environment).
  • Prefer the page’s explicit host when listing automations/runs, so remote automations are visible without changing the global active runtime.
  • Pending run navigation still overrides the selection temporarily.

Fixes #9964.

Why

CLI orca automations list --environment server-01 already works, but the UI always listed via activeRuntimeEnvironmentId (or local). Projects from a connected remote could show in the sidebar while the Automations page stayed empty.

Test plan

  • automation-host-client unit tests (resolve host target + option list)
  • Manual: connect a remote environment with automations → open Automations → switch host selector to that environment → list populates; Local still shows local automations

Note: Re-opened as a new PR after an accidental empty force-push during local rebase cleanup closed the original #10187 (no code intent to withdraw). Branch tip restored with an empty recovery commit.

ELI5

Automations UI always used the globally active runtime, so remote automations were hard to see. A host selector lets you pick Local or each connected environment without changing global focus.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change centralizes automation host key validation, target resolution, and runtime host option construction. The Automations page now validates host selections, refreshes against the resolved target, rejects stale refresh results, preserves explicit selections during pending navigation, resets related state when the host changes, and displays a host selector when multiple hosts exist. Unit tests cover precedence, normalization, invalid entries, and unavailable selections.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and links issue #9964, but it omits required template sections and complete testing, review, security, and platform details. Add Screenshots, Testing, AI Review Report, Security Audit, and Notes sections with the required platform checks and test results.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a host selector for remote environment automations.
Linked Issues check ✅ Passed The implementation addresses #9964 by adding host selection and resolving local or remote automation targets without changing the global runtime.
Out of Scope Changes check ✅ Passed The code changes remain within scope for #9964 and support host selection, validation, refresh behavior, and remote automation access.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/automations/AutomationsPage.tsx (1)

1003-1048: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Make host switches race-safe.

After Line 1055 changes the target, old automations remain actionable until refresh completes, and an older request can later overwrite the newer host’s data at Lines 1034-1046. Invalidate host-scoped results synchronously and gate every refresh commit with a monotonically increasing request ID.

Proposed sequencing guard
+ const refreshGenerationRef = useRef(0)

 const refresh = useCallback(async () => {
+  const generation = ++refreshGenerationRef.current
   setIsLoading(true)
   // ...
   try {
     const [nextAutomations, nextRuns, nextExternalManagers] = await Promise.all([
       // ...
     ])
+    if (generation !== refreshGenerationRef.current) return
     // commit results
   } finally {
-    setIsLoading(false)
+    if (generation === refreshGenerationRef.current) {
+      setIsLoading(false)
+    }
   }
 }, [automationHostTargetKey, selectAutomationId, settings])

 const handleAutomationHostTargetChange = useCallback((nextKey: string) => {
+  refreshGenerationRef.current += 1
+  // Clear or suppress prior host's automation selection/data here.
   setAutomationHostTargetKey(nextKey)

Also applies to: 1050-1058


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0559b7ad-3e9a-4f20-bd33-aef877b071a1

📥 Commits

Reviewing files that changed from the base of the PR and between 981653f and 394765e.

📒 Files selected for processing (3)
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-host-client.test.ts
  • src/renderer/src/components/automations/automation-host-client.ts

Comment thread src/renderer/src/components/automations/AutomationsPage.tsx
@innocarpe
innocarpe force-pushed the fix/automations-environment-selector branch from 394765e to 5ce2c7e Compare July 24, 2026 08:59
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (5ce2c7e8f)

Rebased onto upstream/main to clear merge conflicts (kept host-selector feature + main startupWorktreeRefreshCompleted deps). Empty restore tip commit dropped.

@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (5313338e7a)

Rebase onto latest upstream/main: host selector for remote automations + empty environment key reject + keep pending-nav from overwriting selector.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8905574e-1227-4486-86fc-3256bd62eb31

📥 Commits

Reviewing files that changed from the base of the PR and between 3838f6f and 5313338.

📒 Files selected for processing (3)
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-host-client.test.ts
  • src/renderer/src/components/automations/automation-host-client.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-host-client.test.ts

Comment thread src/renderer/src/components/automations/automation-host-client.ts Outdated
Comment thread src/renderer/src/components/automations/automation-host-client.ts
The Automations page listed only through the global active runtime focus,
so connected remote environments with automations stayed invisible.

Add a Local + connected-runtime selector on the page and prefer that
selection when listing, without changing the global active runtime.

Closes stablyai#9964
Bare "environment:" must not override the global list fallback. Fall
through to getAutomationListTarget instead.

Addresses CodeRabbit review on stablyai#10187.
@innocarpe
innocarpe force-pushed the fix/automations-environment-selector branch from 5313338 to 9f67efd Compare August 6, 2026 03:40
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (9f67efd37b)

Addressed CodeRabbit: normalize and validate environment host keys, omit invalid IDs, and clear selections that disappear from runtime environments. Focused automation host tests (9 passed), typecheck, changed-file lint, React Doctor, and Oxfmt pass.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d53920dc-cdcb-427b-b64c-11c57d4481fa

📥 Commits

Reviewing files that changed from the base of the PR and between ff01fad and 9f67efd.

📒 Files selected for processing (3)
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-host-client.test.ts
  • src/renderer/src/components/automations/automation-host-client.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/automations/automation-host-client.test.ts

Comment thread src/renderer/src/components/automations/AutomationsPage.tsx
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (e1f7030a85)

Addressed CodeRabbit follow-up: host refreshes now use a generation guard, discard stale responses before any state commit, keep newer loads active, and clear host-scoped automations/runs immediately on host switch. Focused automation host tests (9 passed), typecheck, changed-file lint, React Doctor, and Oxfmt pass.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/renderer/src/components/automations/AutomationsPage.tsx (1)

837-841: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Track the loaded host for pending navigation.

Lines 837-841 retain the explicit selector value during pending navigation. The completion effect then compares the pending target with that explicit value at Line 469 and returns.

If the user selects Local and opens a pending remote run, the page loads the remote data but never selects the automation or run. Record the target committed by the current refresh generation. Use that loaded target to complete pending navigation. Add a regression for Local selection with a pending remote run.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 86d106bf-8a8d-4b6d-b040-af71b04ca7c4

📥 Commits

Reviewing files that changed from the base of the PR and between 9f67efd and e1f7030.

📒 Files selected for processing (1)
  • src/renderer/src/components/automations/AutomationsPage.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Automations UI cannot display or manage automations from a saved remote environment

3 participants