Skip to content

fix(desktop): prevent automations empty-state flicker on load#3790

Closed
saddlepaddle wants to merge 1 commit into
mainfrom
automations-loading-flick
Closed

fix(desktop): prevent automations empty-state flicker on load#3790
saddlepaddle wants to merge 1 commit into
mainfrom
automations-loading-flick

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Apr 27, 2026

Summary

  • The automations page rendered AutomationsEmptyState whenever automations.length === 0, including the brief window before the live query had results — causing the empty state to flash before the table populated.
  • Now reads isLoading from useLiveQuery and renders nothing in the body while loading; the header (title + "New automation") still renders immediately.

Test plan

  • Open the Automations tab on an account with existing automations — table should appear without the empty state flashing first.
  • Open it on an account with no automations — empty state still renders once the query settles.

Summary by cubic

Prevents the Automations page empty-state from flashing by hiding the body until useLiveQuery finishes loading. The header renders immediately; the empty state only appears after load when there are no automations.

Written for commit cea0ae1. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the Automations page loading behavior by displaying a loading indicator while fetching data, instead of prematurely showing an empty state. This provides clearer feedback to users during the data retrieval process.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

The automations page component now tracks query loading state, destructuring isLoading from useLiveQuery as automationsLoading. The empty state rendering logic is updated to suppress display while loading, returning null instead of showing the empty state.

Changes

Cohort / File(s) Summary
Automations Page Loading State
apps/desktop/src/renderer/routes/_authenticated/_dashboard/automations/page.tsx
Added isLoading destructuring from useLiveQuery hook and updated conditional logic to prevent rendering the AutomationsEmptyState component while data is loading.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Poem

🐰 Loading states, oh how they dance,
Empty states fade at a glance,
While automations hum and brew,
No premature renders coming through!
A gentle wait, then data's due.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: preventing an empty-state visual flicker on the automations page load.
Description check ✅ Passed The description includes a clear summary explaining the problem and solution, test plan with checkboxes, and additional context from the auto-generated summary.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch automations-loading-flick
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch automations-loading-flick

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 and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR fixes a UX flicker on the Automations page where AutomationsEmptyState would briefly flash before the live query resolved. The fix reads isLoading from useLiveQuery and renders null in the body until loading completes, while keeping the header (title + "New automation" button) visible immediately. The isLoading property is a legitimate, documented return value of @tanstack/react-db's useLiveQuery, so the change is technically sound.

Confidence Score: 5/5

Safe to merge — the fix is minimal, correct, and directly addresses the described flicker.

Only a P2 UX suggestion (no loading skeleton) remains. The core logic is sound: isLoading is a documented return value of @tanstack/react-db's useLiveQuery, and gating the empty state behind it correctly prevents the false-empty flash without affecting the has-data or truly-empty paths.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/routes/_authenticated/_dashboard/automations/page.tsx Extracts isLoading from the automations useLiveQuery call and gates the empty-state render behind it, preventing the false-empty-state flash on initial load. Logic is correct; isLoading is a valid return value from @tanstack/react-db's useLiveQuery.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[AutomationsPage mounts] --> B[useLiveQuery fires]
    B --> C{automationsLoading?}
    C -- true --> D[Render null\nbody is blank]
    C -- false --> E{automations.length === 0?}
    E -- yes --> F[Render AutomationsEmptyState]
    E -- no --> G[Render ToggleGroup + Table]
    G --> H{visible.length === 0?}
    H -- yes --> I[Render scoped empty text]
    H -- no --> J[Render rows]
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/routes/_authenticated/_dashboard/automations/page.tsx
Line: 232

Comment:
**No loading indicator while fetching**

While rendering `null` during load prevents the empty-state flicker, it leaves the content area completely blank until the query settles. A skeleton or spinner would give users a signal that data is on its way, especially on slower machines or large datasets. Consider replacing `null` with a lightweight placeholder:

```suggestion
				{automationsLoading ? (
					<div className="flex h-32 items-center justify-center text-sm text-muted-foreground">
						Loading automations…
					</div>
				) : automations.length === 0 ? (
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(desktop): hide automations body unti..." | Re-trigger Greptile


<div className="flex-1 overflow-y-auto px-8 py-6">
{automations.length === 0 ? (
{automationsLoading ? null : automations.length === 0 ? (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 No loading indicator while fetching

While rendering null during load prevents the empty-state flicker, it leaves the content area completely blank until the query settles. A skeleton or spinner would give users a signal that data is on its way, especially on slower machines or large datasets. Consider replacing null with a lightweight placeholder:

Suggested change
{automationsLoading ? null : automations.length === 0 ? (
{automationsLoading ? (
<div className="flex h-32 items-center justify-center text-sm text-muted-foreground">
Loading automations…
</div>
) : automations.length === 0 ? (
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/routes/_authenticated/_dashboard/automations/page.tsx
Line: 232

Comment:
**No loading indicator while fetching**

While rendering `null` during load prevents the empty-state flicker, it leaves the content area completely blank until the query settles. A skeleton or spinner would give users a signal that data is on its way, especially on slower machines or large datasets. Consider replacing `null` with a lightweight placeholder:

```suggestion
				{automationsLoading ? (
					<div className="flex h-32 items-center justify-center text-sm text-muted-foreground">
						Loading automations…
					</div>
				) : automations.length === 0 ? (
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/_dashboard/automations/page.tsx (1)

232-232: Consider adding a lightweight loading placeholder instead of null to preserve layout stability.

Returning null while automationsLoading is true eliminates the empty-state flash, but it also leaves the body blank on slow initial loads, which can look like a broken page on first paint. A subtle skeleton (or even a min-height container) would maintain layout stability without reintroducing flicker.

The concern about the table disappearing during refetches is not applicable here. The useLiveQuery hook's isLoading is true exclusively during the initial collection sync and transitions to false once ready. During live updates and refetches, isLoading remains false, so the UI updates reactively without the loading state triggering again.

♻️ Example: add a skeleton placeholder for initial load
-				{automationsLoading ? null : automations.length === 0 ? (
+				{automationsLoading ? (
+					<div className="rounded-md border border-dashed px-8 py-12 text-center text-sm text-muted-foreground">
+						Loading automations…
+					</div>
+				) : automations.length === 0 ? (
 					<AutomationsEmptyState onSelectTemplate={handleSelectTemplate} />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/automations/page.tsx`
at line 232, The current render branch returns null while automationsLoading is
true which causes a blank body on initial load; instead, update the conditional
rendering in page.tsx (the expression that checks automationsLoading and
automations.length) to render a lightweight placeholder (e.g., a skeleton row
set or a container with a min-height and subtle shimmer) when automationsLoading
is true so layout is preserved, while keeping the existing empty-state UI when
automationsLoading is false and automations.length === 0; target the
automationsLoading flag and the JSX branch where automations are rendered to
swap null for the placeholder component/markup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/automations/page.tsx`:
- Line 232: The current render branch returns null while automationsLoading is
true which causes a blank body on initial load; instead, update the conditional
rendering in page.tsx (the expression that checks automationsLoading and
automations.length) to render a lightweight placeholder (e.g., a skeleton row
set or a container with a min-height and subtle shimmer) when automationsLoading
is true so layout is preserved, while keeping the existing empty-state UI when
automationsLoading is false and automations.length === 0; target the
automationsLoading flag and the JSX branch where automations are rendered to
swap null for the placeholder component/markup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 60c766c9-b0ff-45a0-b8e0-0d9e0e463395

📥 Commits

Reviewing files that changed from the base of the PR and between b9c0d7c and cea0ae1.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/automations/page.tsx

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@Kitenite Kitenite deleted the automations-loading-flick branch May 6, 2026 04:52
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