Skip to content

fix: refresh browser controls after clearing messages - #158

Merged
bluegrassiot merged 2 commits into
release/v1.0.10from
fix/135-clear-controls
Oct 17, 2026
Merged

bluegrassiot merged 2 commits into
release/v1.0.10from
fix/135-clear-controls

Conversation

@bluegrassiot

Copy link
Copy Markdown
Owner

Root cause

BrowserPanel gates its timer-driven StateHasChanged on _lastCount tracking MessageStoreManager.RootTopicCount. Clearing messages awaited ClearAllMessages() and the button disabled on the resulting rerender, but _lastCount was left at the pre-clear value. If traffic restored the same root count before the next tick, OnTimerTick saw count == _lastCount, skipped the guarded render, and the Clear button (and the header Topics chip) stayed stale and disabled.

Fix

After the awaited clear, resync the tracked count so the next tick renders:

await MessageStoreManager.ClearAllMessages();
_lastCount = MessageStoreManager.RootTopicCount;

One line, no layout or style changes.

Regression test

ClearMessages_AfterClear_WhenTrafficRestoresCount_ReenablesButtonOnNextTick (proven failing before the fix, passing after): count 1 → button enabled and Topics chip present → click Clear (count 0) → button disabled and chip absent → restore count 1 before any tick → OnTimerTick() → button re-enabled and Topics chip present. Also restored the [Test] attribute on BrowserHint_WhenNoStoresAndNotDismissed_IsVisible; BrowserPanelTests discovery is 13 (12 baseline + 1 new), no reduction.

Fixes #135.

Validation

  • Core: 1884 passed, 1 skipped (platform/assembly-inspection)
  • UI: 1810 passed, 1 skipped (Windows-only)
  • Full MqttProbe.slnx build: succeeded, 0 warnings, 0 errors
  • python scripts/ci/format-check.py full tree: clean
  • Checks: comments, blocking-awaits, file-length clean; review clean

Note: validation ran in the working worktree, which also carried unrelated dirty changes; the committed tree contains only this change plus the baseline.

@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous test-timing concern is fixed.

Summary

The PR refreshes browser controls after messages are cleared.

  • Browser controls refresh when traffic returns after clearing.

The previous test-timing concern is fixed. No new actionable issues were found.

Reviews (2) · Last reviewed commit: "test: make clear controls regression det..." · Reviewed by Greptile

Comment thread tests/MqttProbe.UI.Tests/Components/Browser/BrowserPanelTests.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The localized fix addresses the stale-count condition, and the regression test covers the reported failure sequence.

No open issues 🎉

What changed in this PR

Fixes #135 by refreshing Browser controls when new messages arrive after clearing stored messages.

Changes:

  • Resynchronizes the tracked root-topic count after clearing.
  • Adds a deterministic regression test using an overridable timer factory.
File Description
tests/​MqttProbe.UI.Tests/​Components/​Browser/​BrowserPanelTests.cs Verifies Clear and Topics recover when traffic restores the previous count.
src/​MqttProbe.UI/​Components/​Browser/​BrowserPanel.razor Updates count tracking after clearing and allows tests to disable the timer.

Review effort: Balanced

@bluegrassiot
bluegrassiot merged commit ad4a74e into release/v1.0.10 Oct 17, 2026
9 checks passed
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