Skip to content

Unify server refresh interval handling across auto-refresh views#1160

Merged
GT-610 merged 4 commits into
mainfrom
unified-refresh-time-interval
May 4, 2026
Merged

Unify server refresh interval handling across auto-refresh views#1160
GT-610 merged 4 commits into
mainfrom
unified-refresh-time-interval

Conversation

@GT-610
Copy link
Copy Markdown
Collaborator

@GT-610 GT-610 commented May 4, 2026

Summary

  • Added a shared refresh-interval helper to normalize serverStatusUpdateInterval in one place.
  • Applied the helper to server auto-refresh, process, PVE, and container pages so 0 now consistently means manual refresh and no timer is started.
  • Added a small unit test suite for the interval normalization rules.

Testing

  • flutter test test/refresh_interval_test.dart
  • dart analyze on the changed files
  • flutter analyze lib test
  • Local validation covered the new helper behavior and confirmed the repo remains clean under analysis.

Summary by CodeRabbit

  • Bug Fixes

    • Auto-refresh timers now safely start/stop, cancel on dispose, and only run when a validated interval is provided or enabled.
    • Refresh interval inputs are normalized with sensible fallbacks and disabled when set to zero.
    • Error messages are trimmed and show a friendly localized failure text instead of blank/null.
  • New Features

    • Robust version parsing and comparison for release compatibility checks.
  • Tests

    • Added tests for refresh-interval normalization and version parsing.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 81f551b2-19f4-4051-8bbe-660a305745f2

📥 Commits

Reviewing files that changed from the base of the PR and between ca9297a and fe9102d.

📒 Files selected for processing (1)
  • lib/view/page/container/actions.dart

📝 Walkthrough

Walkthrough

Adds utilities to normalize and retrieve the server-status refresh interval: normalizeServerStatusRefreshSeconds(int) (returns null for 0, Defaults.updateInterval for out-of-range values, otherwise the input) and serverStatusRefreshInterval() (reads the stored setting and returns a Duration?). Replaces direct store reads across Container, Process, and PVE pages with the new utility, makes periodic timers nullable and only starts them when the utility returns a non-null duration, cancels timers safely on dispose, and adds unit tests for the new functions. Also includes formatting and UI refactors across multiple files.

Possibly related PRs

Suggested reviewers

  • lollipopkit
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective of unifying server refresh interval handling across multiple auto-refresh views, which is the primary focus of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch unified-refresh-time-interval

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot requested a review from lollipopkit May 4, 2026 04:54
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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/view/page/container/actions.dart`:
- Around line 179-182: Replace the literal fallback 'null' shown in user dialogs
with a localized fallback using libL10n (prefer libL10n.fail or libL10n.unknown)
rather than a raw string; specifically update calls to context.showRoundDialog
where you build the child Text(e ?? 'null') so it becomes Text(e ??
libL10n.fail) (or Text(e ?? l10n.unknown if libL10n is unavailable), keeping
libL10n.error as the title). Apply the same change to the other dialog sites
referenced (the similar Text(e ?? 'null') occurrences around the later blocks)
so all user-facing error texts use localization instead of the literal "null".
- Around line 309-314: The _initAutoRefresh() method must cancel any existing
timer before any early returns to avoid leaving a running periodic timer; update
_initAutoRefresh() so that at the top (or immediately before each return) you
call _autoRefreshTimer?.cancel() and set _autoRefreshTimer = null when
Stores.setting.containerAutoRefresh.fetch() is false or when
serverStatusRefreshInterval() returns null, then only create a new
Timer.periodic(duration, ...) when you actually proceed.

In `@lib/view/page/pve.dart`:
- Around line 557-558: The current check uses pveState.release!.compareTo('8.0')
which does lexicographic comparison and fails for multi-digit majors (e.g.,
"10.0" < "8.0"); change this to a proper semantic numeric comparison by parsing
pveState.release into version parts (or use a Version/semver parser) and compare
major, minor (and patch if present) numerically; update the conditional around
pveState.release (the block where pveState.release != null and compareTo is
used) to parse safely (handle non-numeric or malformed strings) and then test
whether the parsed version is less than 8.0 using numeric comparisons or
Version.compareTo from a semver library.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 85bff823-cdfe-4c2f-8fd8-d81d46050db0

📥 Commits

Reviewing files that changed from the base of the PR and between 624bd47 and afb4170.

📒 Files selected for processing (7)
  • lib/core/utils/refresh_interval.dart
  • lib/data/provider/server/all.dart
  • lib/view/page/container/actions.dart
  • lib/view/page/container/container.dart
  • lib/view/page/process.dart
  • lib/view/page/pve.dart
  • test/refresh_interval_test.dart

Comment thread lib/view/page/container/actions.dart
Comment thread lib/view/page/pve.dart Outdated
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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
lib/view/page/container/actions.dart (1)

72-75: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use localized fallback instead of e.toString() in error dialogs.

At Line 74 and Line 102, Text(e.toString()) can still show literal "null" to users. Use a localized fallback (e ?? libL10n.fail) to keep UI strings consistent.

💡 Suggested patch
           if (err != null || result != null) {
             final e = result?.message ?? err?.toString();
             context.showRoundDialog(
               title: libL10n.error,
-              child: Text(e.toString()),
+              child: Text(e ?? libL10n.fail),
             );
           }
             if (err != null || result != null) {
               final e = result?.message ?? err?.toString();
               context.showRoundDialog(
                 title: libL10n.error,
-                child: Text(e.toString()),
+                child: Text(e ?? libL10n.fail),
               );
             }

As per coding guidelines lib/**/*.dart: Use libL10n and l10n for localization strings, prioritizing libL10n from fl_lib package to avoid duplication.

Also applies to: 100-103

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/view/page/container/actions.dart` around lines 72 - 75, Replace the raw
e.toString() used in the error dialogs with a localized fallback using libL10n:
where you call context.showRoundDialog (the title uses libL10n.error) replace
Text(e.toString()) with Text(e?.toString() ?? libL10n.fail) (or equivalent) so
null/empty errors show the localized libL10n.fail; apply the same change to both
occurrences around the context.showRoundDialog calls in this file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/core/utils/version.dart`:
- Around line 1-8: The parseVersionParts function currently uses int.parse on
match.group(1) which can throw for oversized integers; change it to use
int.tryParse for the major version (the same pattern used for minor/patch) and
if that returns null make parseVersionParts return null to preserve the
function's nullable contract (update the logic around match.group(1) in
parseVersionParts accordingly).

---

Duplicate comments:
In `@lib/view/page/container/actions.dart`:
- Around line 72-75: Replace the raw e.toString() used in the error dialogs with
a localized fallback using libL10n: where you call context.showRoundDialog (the
title uses libL10n.error) replace Text(e.toString()) with Text(e?.toString() ??
libL10n.fail) (or equivalent) so null/empty errors show the localized
libL10n.fail; apply the same change to both occurrences around the
context.showRoundDialog calls in this file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5848d17d-364c-4eed-90cb-15bcf1d186e7

📥 Commits

Reviewing files that changed from the base of the PR and between afb4170 and 7a3562d.

📒 Files selected for processing (4)
  • lib/core/utils/version.dart
  • lib/view/page/container/actions.dart
  • lib/view/page/pve.dart
  • test/version_test.dart
✅ Files skipped from review due to trivial changes (1)
  • test/version_test.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/view/page/pve.dart

Comment thread lib/core/utils/version.dart
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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
lib/view/page/container/actions.dart (1)

146-146: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid rendering literal "null" in user-facing snackbar text.

At Line 146, fallback text still shows raw "null" when no message is returned.

💡 Suggested fix
-            context.showSnackBar(result.message ?? 'null');
+            final msg = result.message;
+            context.showSnackBar(msg?.isNotEmpty == true ? msg! : libL10n.fail);

As per coding guidelines lib/**/*.dart: Use libL10n and l10n for localization strings, prioritizing libL10n from fl_lib package to avoid duplication.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/view/page/container/actions.dart` at line 146, Replace the literal "null"
fallback in the context.showSnackBar call so user-facing text never renders
"null": when calling context.showSnackBar with result.message (in actions.dart,
the context.showSnackBar and result.message usage), use a localized fallback
from fl_lib's libL10n (e.g., libL10n.of(context).<appropriateKey>) and if
libL10n is not available fall back to the app l10n
(l10n.of(context).<appropriateKey>); ensure the necessary import for libL10n is
present, handle the nullable result.message safely, and pick a suitable
localization key like "unknownMessage" or "emptyMessage" to display instead of
the literal "null".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/view/page/container/actions.dart`:
- Around line 179-182: The dialog content currently uses a null-coalescing
fallback (e ?? libL10n.fail) which still shows blank when e is an empty string;
update all calls to context.showRoundDialog (including the instances around the
contexts currently using e at lines 179–182, 239–242, 254–257, 266–269, 278–281)
to guard for empty strings instead of only null by using a non-empty check on e
(e.g., use e if non-empty, otherwise libL10n.fail) so the dialog always displays
the localized failure message when e is null or empty.

---

Duplicate comments:
In `@lib/view/page/container/actions.dart`:
- Line 146: Replace the literal "null" fallback in the context.showSnackBar call
so user-facing text never renders "null": when calling context.showSnackBar with
result.message (in actions.dart, the context.showSnackBar and result.message
usage), use a localized fallback from fl_lib's libL10n (e.g.,
libL10n.of(context).<appropriateKey>) and if libL10n is not available fall back
to the app l10n (l10n.of(context).<appropriateKey>); ensure the necessary import
for libL10n is present, handle the nullable result.message safely, and pick a
suitable localization key like "unknownMessage" or "emptyMessage" to display
instead of the literal "null".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ed08c4bd-ab0c-4511-a056-39729f160feb

📥 Commits

Reviewing files that changed from the base of the PR and between 7a3562d and ca9297a.

📒 Files selected for processing (3)
  • lib/core/utils/version.dart
  • lib/view/page/container/actions.dart
  • test/version_test.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/core/utils/version.dart

Comment thread lib/view/page/container/actions.dart
@GT-610 GT-610 merged commit c50bee8 into main May 4, 2026
3 checks passed
@GT-610 GT-610 deleted the unified-refresh-time-interval branch May 4, 2026 06:07
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