Skip to content

Refresh automation run history reliably - #31375

Closed
AmethystLiang wants to merge 2 commits into
mainfrom
fix-automation-history-reload
Closed

AmethystLiang wants to merge 2 commits into
mainfrom
fix-automation-history-reload

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​655 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​655
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​196 $\color{#cf222e}{\Huge{\mathbf{−}}}$​53 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​143

Problem

Automation run history could stay stale after a run, rerun, or host update. Refreshing the dashboard could also discard loaded run pages or refresh unrelated hosts.

Solution

Refresh only the selected automation's history when it changes, preserve valid history during temporary read failures, and show a recoverable unavailable state when a run has been removed. Manual refresh now reloads the selected history without disrupting dashboard state.

ELI5

Run history now updates like the rest of the automation page, without making unrelated computers or already-loaded dashboard pages start over.

What Changed

  • Reload selected run history after Run Now, rerun, relevant host events, recovery actions, and manual refresh.
  • Keep the current run list visible when the same host temporarily cannot be reached.
  • Show a clear unavailable page with Back and recovery actions when a selected run no longer exists.
  • Scope history reads to the selected row's actual host, including remote and orphaned rows.
  • Prevent older in-flight history reads from replacing newer results.

Why

Previously, several refresh paths updated the broader automation state but not the selected run history, leaving stale results visible. Targeted history refreshes keep the page current while avoiding unnecessary reads and preserving dashboard pagination.

Linked Issue

TODO: No linked issue.

Visual Proof

TODO: Attach before/after proof for this UI behavior change.

Testing

  • Added coverage for dashboard refresh isolation, run history after Run Now and rerun, missing or failed history reads, host-scoped refreshes, remote history, and stale response handling.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No known issues in security, cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, backwards compatibility, or performance. Remote history refreshes are scoped to the selected host.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

- Preserve loaded run pages and unrelated host caches on change events
- Retain visible history during same-host refresh failures
- Show recovery notices on run details and avoid retrying pruned runs
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The changes update selected run-history authority and request identity, retain matching history after eligible read failures, and reload history after page refreshes and host invalidations. Run details now display notices and recovery actions. A new unavailable-run page provides fallback content and navigation. Added tests cover history refresh, host scoping, recovery, unavailable reads, and dashboard refresh behavior.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 486c9

The run-history change cannot pass the required CI check until the ref update moves out of render. Fix that assignment before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the problem, solution, user-visible changes, rationale, testing coverage, and compatibility considerations. However, it leaves the required linked issue and visual proof as TO… Add a valid linked issue under "Linked Issue". Attach before-and-after screenshots or video for the UI behavior change. Report manual testing and the status of pnpm lint, pnpm typecheck, pnpm test, and pnpm build, or state that CI will cove…
Docstring Coverage Warning Docstring coverage is 23.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 18 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: reliable automation run history refreshes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, solution, user-visible changes, rationale, testing coverage, and compatibility considerations. However, it leaves the required linked issue and visual proof as TODOs, and it does not report manual testing or validation results for the listed commands.

Resolution

Add a valid linked issue under "Linked Issue". Attach before-and-after screenshots or video for the UI behavior change. Report manual testing and the status of pnpm lint, pnpm typecheck, pnpm test, and pnpm build, or state that CI will cover them where applicable.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 546e501f-6aaa-4072-9bc9-c9a266d54aa8
📥 Commits

Reviewing files that changed from the base of the PR and between 411b5c0 and 486c92e.

📒 Files selected for processing: 18
  • src/renderer/src/components/automations/AutomationRunDetailsPage.tsx
  • src/renderer/src/components/automations/AutomationRunPageFrame.tsx
  • src/renderer/src/components/automations/AutomationRunUnavailablePage.tsx
  • src/renderer/src/components/automations/AutomationsPage.dashboard-refresh.test.tsx
  • src/renderer/src/components/automations/AutomationsPage.run-history.test.tsx
  • src/renderer/src/components/automations/AutomationsPage.run-visibility.test.tsx
  • src/renderer/src/components/automations/AutomationsPageListPanel.tsx
  • src/renderer/src/components/automations/AutomationsPageSurface.tsx
  • src/renderer/src/components/automations/automation-host-cache-controller.test.ts
  • src/renderer/src/components/automations/automation-host-cache-controller.ts
  • src/renderer/src/components/automations/automation-run-actions.ts
  • src/renderer/src/components/automations/automations-page-test-harness.tsx
  • src/renderer/src/components/automations/use-automation-host-catalog.ts
  • src/renderer/src/components/automations/use-automation-runs-dashboard-payload.test.tsx
  • src/renderer/src/components/automations/use-automations-page-refresh.ts
  • src/renderer/src/components/automations/use-automations-page-setup-state.ts
  • src/renderer/src/components/automations/use-selected-automation-run-history.test.tsx
  • src/renderer/src/components/automations/use-selected-automation-run-history.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment on lines +49 to +50
const selectedRowRef = useRef(selectedRow)
selectedRowRef.current = selectedRow

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,215p' src/renderer/src/components/automations/use-automations-page-refresh.ts
rg -n 'check-react-doctor-changed|react-doctor/no-ref-current-in-render' .github config package.json

Repository: stablyai/orca

Length of output: 8132


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- React Doctor gate/config ---'
sed -n '1,240p' config/scripts/check-react-doctor-changed.mjs
sed -n '365,410p' package.json
sed -n '315,345p' .github/workflows/pr.yml
printf '%s\n' '--- refreshRunHistory references ---'
rg -n -F --glob '*.{ts,tsx}' -e 'refreshRunHistory' -e 'useAutomationsPageRefresh' src/renderer/src
printf '%s\n' '--- relevant consumer excerpts ---'
rg -l -F --glob '*.{ts,tsx}' 'refreshRunHistory' src/renderer/src | while read -r f; do
  echo "### $f"
  sed -n '1,260p' "$f"
done

Repository: stablyai/orca

Length of output: 26506


Move the selectedRowRef update out of render.

The current assignment fails the repository’s blocking React Doctor check. Use useLayoutEffect, not useEffect, so the ref updates after commit and before passive effects or user events can invoke refreshRunHistory or the host invalidation callback.

🔧 Suggested fix
-import { useCallback, useEffect, useRef, useState } from 'react'
+import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
@@
   // Async completions and host events must use the current selection.
   const selectedRowRef = useRef(selectedRow)
-  selectedRowRef.current = selectedRow
+  useLayoutEffect(() => {
+    selectedRowRef.current = selectedRow
+  }, [selectedRow])
🧰 Tools
🪛 GitHub Actions: PR 31375 | source 2339740cb15f517f2505bfaaed33122fd77702f0 | workflow 2339740cb15f517f2505bfaaed33122fd77702f0 | unit full / static analysis and typecheck

[error] 50-50: React Doctor: Ref was mutated during render (react-doctor/no-ref-current-in-render). Command 'node config/scripts/check-react-doctor-changed.mjs' failed with exit code 1.

@AmethystLiang

Copy link
Copy Markdown
Contributor Author

Closing as superseded: selected-history refresh on host events, keeping last-known runs on a failed read, ordering of in-flight reads, and re-reading on reopen all landed in #31617 (use-selected-automation-run-history.ts). One small gap remains (an open run page whose run was pruned keeps showing a loading skeleton). It'll be fixed separately and narrowly from main.

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.

1 participant