Skip to content

Persistent analysis loading#354

Merged
brucetony merged 2 commits intodevelopfrom
353-persistent-analysis-loading
Apr 7, 2026
Merged

Persistent analysis loading#354
brucetony merged 2 commits intodevelopfrom
353-persistent-analysis-loading

Conversation

@brucetony
Copy link
Copy Markdown
Collaborator

@brucetony brucetony commented Apr 7, 2026

After clicking on the start analysis button, the loading indicator now persists between page refresh

Summary by CodeRabbit

  • Bug Fixes

    • Improved analysis loading state handling to ensure consistent UI feedback. Loading indicators now persist correctly across page refreshes and clear appropriately when execution completes.
  • Chores

    • Updated development dependencies.

@brucetony brucetony linked an issue Apr 7, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

This PR adds persistent loading state recovery to the analysis control component using localStorage, enabling the "in-flight" loading indicator to be restored across page refreshes. Additionally, the happy-dom development dependency is bumped from version 20.0.8 to 20.8.9.

Changes

Cohort / File(s) Summary
Persistent Loading State
app/components/analysis/AnalysisControlButtons.vue
Introduced localStorage-based persistence of the "loading-in-flight" state keyed by analysis-start-loading-${analysisId}. On component mount, restores the loading flag if stored as "true" and execution status is active. Added watcher on analysisExecutionStatus to clear stored flag and reset loading when status moves out of active states. Updated onStartAnalysis() to persist/clear the flag around API initialization requests.
Dependency Update
package.json
Updated happy-dom devDependency from ^20.0.8 to ^20.8.9.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • Persistent analysis loading #353: Directly addresses the persistent analysis loading bug by implementing the exact localStorage-based restoration mechanism described in this PR.

Possibly related PRs

Poem

🐰 A storage box beneath the page,
Remembers loads through every stage,
When refreshed, the flag returns,
As busy state again learns,
Loading persists, no more in vain! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Persistent analysis loading' directly and clearly summarizes the main change: adding persistence to the analysis loading indicator across page refreshes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 353-persistent-analysis-loading

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.

Copy link
Copy Markdown

@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)
app/components/analysis/AnalysisControlButtons.vue (1)

63-65: Consider cleanup mechanism for stale localStorage entries.

If a user abandons the page mid-request and never returns to that analysis, the localStorage entry persists indefinitely. Over time, this could accumulate orphaned entries for analyses that no longer exist or have long since completed.

Consider adding either:

  • A timestamp alongside the flag, with expiration logic in onMounted
  • Or cleanup of old entries when listing analyses

This is a minor concern and could be addressed in a follow-up if it becomes a practical issue.

💡 Optional: Add timestamp-based expiration
 onMounted(() => {
+  const storedValue = localStorage.getItem(loadingStorageKey.value);
+  if (storedValue) {
+    const parsed = JSON.parse(storedValue);
+    const isExpired = Date.now() - parsed.timestamp > 5 * 60 * 1000; // 5 min expiration
+    if (
+      !isExpired &&
+      playButtonActiveStates.includes(props.analysisExecutionStatus)
+    ) {
+      loading.value = true;
+      loadingRestoredFromStorage.value = true;
+      return;
+    }
+  }
+  localStorage.removeItem(loadingStorageKey.value);
-  if (
-    localStorage.getItem(loadingStorageKey.value) === "true" &&
-    playButtonActiveStates.includes(props.analysisExecutionStatus)
-  ) {
-    loading.value = true;
-    loadingRestoredFromStorage.value = true;
-  } else {
-    localStorage.removeItem(loadingStorageKey.value);
-  }
 });

And update the setItem call:

-  localStorage.setItem(loadingStorageKey.value, "true");
+  localStorage.setItem(loadingStorageKey.value, JSON.stringify({ timestamp: Date.now() }));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/components/analysis/AnalysisControlButtons.vue` around lines 63 - 65, The
computed key loadingStorageKey currently stores a persistent start-loading flag
in localStorage with no cleanup; modify the logic so the flag is stored with a
timestamp and add expiration handling in onMounted (or a cleanup routine invoked
when listing analyses) to remove stale entries: update where you call
localStorage.setItem for the loading flag to store an object {value: true, ts:
Date.now()}, implement a helper (e.g., isLoadingStale or
cleanupStaleLoadingKeys) that checks the timestamp against a configurable TTL
and removes expired entries, and invoke that helper in onMounted (or during
analysis list load) and before reading loadingStorageKey to ensure abandoned
flags are cleared.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/components/analysis/AnalysisControlButtons.vue`:
- Around line 63-65: The computed key loadingStorageKey currently stores a
persistent start-loading flag in localStorage with no cleanup; modify the logic
so the flag is stored with a timestamp and add expiration handling in onMounted
(or a cleanup routine invoked when listing analyses) to remove stale entries:
update where you call localStorage.setItem for the loading flag to store an
object {value: true, ts: Date.now()}, implement a helper (e.g., isLoadingStale
or cleanupStaleLoadingKeys) that checks the timestamp against a configurable TTL
and removes expired entries, and invoke that helper in onMounted (or during
analysis list load) and before reading loadingStorageKey to ensure abandoned
flags are cleared.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d49c2988-f775-495f-8187-4a937ac31d33

📥 Commits

Reviewing files that changed from the base of the PR and between 668edce and cb1bfdf.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • app/components/analysis/AnalysisControlButtons.vue
  • package.json

@brucetony brucetony merged commit 175f964 into develop Apr 7, 2026
5 checks passed
@brucetony brucetony deleted the 353-persistent-analysis-loading branch April 7, 2026 14:42
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.

Persistent analysis loading

1 participant