Skip to content

fix(mind-map) clear stale error state on successful background reload - #8285

Merged
krushnarout merged 5 commits into
mainfrom
fix/mind-map-error-persists
Jun 26, 2026
Merged

krushnarout merged 5 commits into
mainfrom
fix/mind-map-error-persists

Conversation

@krushnarout

@krushnarout krushnarout commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Bug fix: When the Mind Map failed to load on initial open (e.g. momentary network issue), the error state persisted permanently — even after the app resumed and a background reload succeeded. Root cause: the silent: true reload path never called setState, so _error was never cleared after a successful load.
  • Lint cleanups: Three follow-up refactors in the same file — remove unnecessary ! null assertion, add final to a never-reassigned field, and use const for compile-time constants in the share-graph path.

Commits

  1. fix(mind-map): clear _error when silent reload succeeds
  2. refactor(mind-map): remove unnecessary ! on hitNodeId
  3. refactor(mind-map): make _highlightedNodeIds final
  4. refactor(mind-map): prefer const for textSpan and yPos

Test plan

  • Open the app with no network → Mind Map shows error
  • Restore network, background + foreground the app → Mind Map should now show the graph (no more stuck error)

🤖 Generated with Claude Code

Review in cubic

krushnarout and others added 4 commits June 24, 2026 22:01
When the app resumes from background, _loadGraph(silent: true) was
skipping all setState calls even on success, leaving _error set
permanently after an initial network failure.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
hitNodeId is already guarded by a null check above, so the ! operator
has no effect and triggers a lint warning.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The field is never reassigned, only mutated via clear/add, so it can
be declared final.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Both are compile-time constants; using const avoids unnecessary
runtime allocation.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 1 file

Confidence score: 3/5

  • In app/lib/pages/memories/widgets/memory_graph_page.dart, the _isSameGraph early return can skip the new error-clearing setState, so a successful silent reload may still show a stale _error banner and mislead users into thinking the graph is still failing — clear _error before the early return (or in a path that always runs) and add a regression test for same-data successful reloads before merging.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic


_populateGraph(data);
_runLayoutSync();
if (_error != null && mounted) {

@cubic-dev-ai cubic-dev-ai Bot Jun 24, 2026 •

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: Successful silent reloads still leave stale _error when graph data is unchanged because _isSameGraph returns before the new error-clearing setState block.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/pages/memories/widgets/memory_graph_page.dart, line 341:

<comment>Successful silent reloads still leave stale `_error` when graph data is unchanged because `_isSameGraph` returns before the new error-clearing `setState` block.</comment>

<file context>
@@ -338,6 +338,11 @@ class _MemoryGraphPageState extends State<MemoryGraphPage> with SingleTickerProv
 
       _populateGraph(data);
       _runLayoutSync();
+      if (_error != null && mounted) {
+        setState(() {
+          _error = null;
</file context>
Fix with cubic

✅ Addressed in 7aa6e27

The error-clearing setState was placed after _isSameGraph, so a
silent reload that succeeded but found unchanged data (common for
empty graphs) would still leave _error set and show the stale error
banner indefinitely.

Move the clear to before the early return so every successful API
response clears the error, regardless of whether the graph changed.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@krushnarout
krushnarout requested a review from mdmohsin7 June 24, 2026 16:39

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

Copy link
Copy Markdown

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

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Tip: cubic could auto-approve low-risk PRs like this, if it thinks it's safe to merge. Learn more

Re-trigger cubic

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @krushnarout — this looks good to me.

The change cleanly fixes the stale Mind Map error state by clearing _error after a successful background reload, including the same-graph early-return path. The additional Dart cleanup is small and safe, and CI is green.

@krushnarout
krushnarout merged commit 1b611a8 into main Jun 26, 2026
2 checks passed
@krushnarout
krushnarout deleted the fix/mind-map-error-persists branch June 26, 2026 02:13
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.

2 participants