fix(frontend): disable view toggle when no automations exist#749
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📸 Snapshot Test ReportWarning Snapshot comparison step crashed (timeout, OOM, or runner error) — diff results below may be incomplete or absent. ✅ 1 snapshot changed — acknowledged via the
✅ Unchanged snapshots (72)
Generated by the Snapshot Tests workflow. This comment was created by an AI agent (OpenHands) on behalf of the repo maintainers. |
|
PR Review by OpenHands / pr-review (pull_request) is failing. I will merge this pull request for now. If any issues are found, I will address them in follow-up pull requests. Thank you! 🙏 |



Why
Summary
On the
/automationspage, the grid/list view-mode toggle next to the search input remains clickable even when the user has not created any automations. Toggling between grid and list has no visible effect (the page only renders<EmptyState />), so the affordance is misleading and inaccessible — assistive tech still announces it as an active control.Steps to reproduce
agent-canvasand runnpm run dev.http://localhost:3001/automationswith an account / backend that has zero automations.Current behaviour
The toggle opens its menu and
onChangefires. The selected view mode is persisted tolocalStorage, but the page still shows<EmptyState />. The control reports as enabled in the accessibility tree.Expected behaviour
When
data.automations.length === 0after a successful load, the toggle is disabled:disabledandaria-disabledare set on the trigger button.onChange.cursor-not-allowed).Acceptance criteria
localStorage).Notes
The empty condition already gates
<EmptyState />atsrc/routes/automations-list.tsx:211. The fix should hoist that condition into a single variable and reuse it for the toggle so the two stay in lockstep.Summary
<AutomationViewToggle />now accepts an optionaldisabledprop that forwardsdisabled+aria-disabledto the trigger button and short-circuits the click handler so the menu cannot open.automations-list.tsxderiveshasNoAutomations = !isLoading && !isError && data?.automations.length === 0once and reuses it for both the toggle'sdisabledprop and the existing<EmptyState />branch, so the two affordances can never disagree.Why
On
/automationswith zero automations, the user saw<EmptyState />but the view-toggle button next to the search input was still active. Clicking it opened a grid/list menu that had no effect on the page and was announced as an active control by assistive tech. The toggle should be inactive whenever there is nothing to view.Changes
src/components/features/automations/automation-view-toggle.tsx— adddisabled?: booleanprop; forward to the<button>, setaria-disabled, no-op theonClick, and add disabled-state classes viacn(...).src/routes/automations-list.tsx— computehasNoAutomationsonce, pass it to<AutomationViewToggle />, and reuse it for<EmptyState />.__tests__/components/automations/automation-view-toggle.test.tsx— new test: clicking the trigger whiledisableddoes not open the menu and does not fireonChange.__tests__/routes/automations-list.test.tsx— new test: withAutomationService.getAutomationsresolving to an empty list, the toggle is disabled and clicking it does not reveal the list menu item.Issue Number
Resolves #748
How to Test
agent-server-guirepository.http://localhost:3001/automations.Video/Screenshots
app-1914.mov
Type
Notes
(data?.automations.length ?? 0) === 0would disable the toggle during the initial skeleton render, which is jarring. The chosen condition matches the existing<EmptyState />guard.useAutomations; the page owns the wiring.toBeDisabled, menu not rendered,onChangenot called).🐳 Docker images for this PR
• GHCR package: https://github.com/OpenHands/agent-canvas/pkgs/container/agent-canvas
ghcr.io/openhands/agent-canvasghcr.io/openhands/agent-server:1.23.0-pythonopenhands-automation==1.0.0a357151a0b89decd9634b28d69e6d7da2c73eda61aPull (multi-arch manifest)
# Multi-arch manifest — Docker automatically pulls the correct architecture docker pull ghcr.io/openhands/agent-canvas:sha-57151a0Run
All tags pushed for this build
About Multi-Architecture Support
sha-57151a0) is a multi-arch manifest supporting both amd64 and arm64sha-57151a0-amd64) are also available if needed