Skip to content

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

Closed
innocarpe wants to merge 0 commit into
stablyai:mainfrom
innocarpe:fix/automations-environment-selector
Closed

feat(automations): host selector for remote environment automations#10187
innocarpe wants to merge 0 commit into
stablyai:mainfrom
innocarpe:fix/automations-environment-selector

Conversation

@innocarpe

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

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c25f997-0f59-4f5e-b9cd-dc8b033e460e

📥 Commits

Reviewing files that changed from the base of the PR and between e67dc55 and 01d36b3.

📒 Files selected for processing (2)
  • 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.ts

📝 Walkthrough

Walkthrough

The Automations page now supports selecting local or runtime environment hosts through a conditional dropdown. Host targets are keyed, parsed, resolved with pending navigation and selection precedence, and used by the shared refresh path. Changing hosts clears selected automation and run state. The host-target utilities and option construction include expanded unit tests covering precedence and generated option shapes.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers summary, motivation, and test plan, but it omits several required template sections. Add the missing Screenshots, AI Review Report, Security Audit, and Notes sections, and complete any unchecked test items with results or rationale.
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% 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 is concise and accurately reflects the main change: adding a host selector for automations in remote environments.
Linked Issues check ✅ Passed The changes add a host selector, prioritize explicit/pending hosts, and preserve local visibility, matching #9964.
Out of Scope Changes check ✅ Passed The code changes stay focused on automations host selection and related tests, with no obvious unrelated additions.

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 | ⚡ Quick win

Prevent stale refreshes from overwriting a newer host selection.

If a local refresh resolves after a newly selected remote refresh, its state setters restore the local list and key. Track a refresh generation and ignore stale completions.

Proposed fix
+const refreshRequestRef = useRef(0)

 const refresh = useCallback(async () => {
+  const requestId = ++refreshRequestRef.current
   setIsLoading(true)
   // ...
   const nextSelectedRuns = nextSelectedId
     ? await listAutomationRunsForTarget(automationHostTarget, nextSelectedId)
     : []
+  if (requestId !== refreshRequestRef.current) {
+    return
+  }
   setAutomations(nextAutomations)
   setRuns(nextRuns)
   setAutomationHostTargetKey(getAutomationHostTargetKey(automationHostTarget))
   // ...
 } finally {
-  setIsLoading(false)
+  if (requestId === refreshRequestRef.current) {
+    setIsLoading(false)
+  }
 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6709ca9c-c506-4f37-91ed-2ecaf1ecc7e2

📥 Commits

Reviewing files that changed from the base of the PR and between 8f40ddf and e67dc55.

📒 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/automation-host-client.ts Outdated
innocarpe added a commit to innocarpe/orca that referenced this pull request Jul 23, 2026
Bare "environment:" must not override the global list fallback. Fall
through to getAutomationListTarget instead.

Addresses CodeRabbit review on stablyai#10187.
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (01d36b324)

Address CodeRabbit: reject empty environment: host keys so global fallback still applies.

@innocarpe

Copy link
Copy Markdown
Contributor Author

Accidentally closed when a bad rebase helper force-pushed an empty tip. Restored and continued as #10347.

innocarpe added a commit to innocarpe/orca that referenced this pull request Jul 24, 2026
Bare "environment:" must not override the global list fallback. Fall
through to getAutomationListTarget instead.

Addresses CodeRabbit review on stablyai#10187.
innocarpe added a commit to innocarpe/orca that referenced this pull request Aug 6, 2026
Bare "environment:" must not override the global list fallback. Fall
through to getAutomationListTarget instead.

Addresses CodeRabbit review on stablyai#10187.
innocarpe added a commit to innocarpe/orca that referenced this pull request Aug 6, 2026
Bare "environment:" must not override the global list fallback. Fall
through to getAutomationListTarget instead.

Addresses CodeRabbit review on stablyai#10187.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

1 participant