Skip to content

fix(gui): keep Tools tabs idle until the page is shown - #201

Merged
donislawdev merged 1 commit into
masterfrom
fix/tools-start-up-work
Sep 24, 2026
Merged

donislawdev merged 1 commit into
masterfrom
fix/tools-start-up-work

Conversation

@donislawdev

@donislawdev donislawdev commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

What

A tool on the Tools tab no longer does its first work at every start of the program. It waits until the Tools page is on screen.

  • Sockets: real Tk queues the <<NotebookTabChanged>> of the Tools page's own select (in its constructor) and runs it once the window is built, with any page in front. ToolboxPage._on_subpage then refreshed the tool on that tab, and the socket table was read about 0.9 s after every start. The test that claimed "not at start-up" was green because the fake Tk fires no event. _on_subpage now refreshes only while app.current_page() is self.
  • Diagnostics: its constructor started the environment check. The first check now runs on the first refresh() or pending() of the panel on screen (the pattern Sockets already used), and a check that failed waits for "Check again" instead of running on every tick.

Measured on real Tk (8.6.15 and 9.0.4)

A probe builds the real window with an isolated ui state, the Tools tab remembered, and counts calls into the socket read and the environment check while the event loop runs.

page in front at start before after
Control or Statistics 1 (Sockets via _on_subpage, Diagnostics via its constructor) 0
Tools 1 1
Control, then the person switches to Tools - 1 (via _on_page_changed)

tools/ci_gui_render.py is OK in en, pl and zh, and Diagnostics is measured with its rows (the render check's pending() starts the check).

Tests

  • tests/test_toolbox.py: opened_on_start_up() fires the sub-notebook's recorded <<NotebookTabChanged>> callbacks and ticks, which is what real Tk does after the constructor. The Sockets start-up test uses it, and so does the new test_diagnostics_checks_when_first_looked_at_and_not_at_start_up.
  • New test_a_first_check_that_fails_says_so_and_is_not_retried_by_itself.
  • test_a_panel_is_built_on_first_view_and_the_open_tab_is_remembered: an off-screen tab change remembers the tab and refreshes nothing.
  • Mutations: 3 new (the on-screen condition removed, the check back in the constructor, a failed first check retried on every tick), 1 moved to the new place of the first check.

No CHANGELOG.md line: the Tools tab is not released yet.

Not checked

  • A start with the window minimized on the Tools page.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Changing tool tabs while the Tools page is off-screen no longer refreshes the selected tool; it refreshes when the page is visible.
    • Diagnostics and socket checks wait until their tools are viewed instead of running automatically at startup.
    • After a diagnostics check records an outcome, another check runs only when you select Check again.

Real Tk queues the <<NotebookTabChanged>> of the Tools page's own select
and runs it once the window is built, with any page in front. Its
handler refreshed the tool on that tab, so the socket table was read at
every start of the program, for a tab nobody had opened. The test said
otherwise because the fake Tk fires no event. The handler now refreshes
only while the Tools page is on screen.

Diagnostics also checked from its constructor. Its first check now waits
for the first refresh or pending() of the panel on screen, and a check
that failed waits for "Check again" instead of running on every tick.

Measured on Tk 8.6.15 and 9.0.4: no work with another page in front, one
read when the window opens on Tools or when the person switches to it.
The tests fire the recorded tab-change callbacks the way real Tk does
after the constructor, with three new mutations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 5f2d57d6-bf1f-456f-b6fa-4e3b4f052c65

📥 Commits

Reviewing files that changed from the base of the PR and between baecc57 and 31deccf.

📒 Files selected for processing (4)
  • beantester/gui/pages/toolbox.py
  • beantester/gui/toolbox/diagnostics.py
  • tests/test_mutation_registry.py
  • tests/test_toolbox.py

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: mutation registry
  • GitHub Check: commit messages and PR description
  • GitHub Check: ruff (F, B, C90 and PLR0913 block, S and ASYNC report)
  • GitHub Check: tests (windows-latest, py3.14)
  • GitHub Check: tests (ubuntu-latest, py3.14)
  • GitHub Check: semgrep (ERROR, HIGH and CRITICAL block)
  • GitHub Check: pip-audit (advisories against the pinned set)
  • GitHub Check: mypy
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (python)
🧰 Additional context used
📓 Path-based instructions (8)
Applies to text shown to the user (labels, buttons, tooltips, placeholders, dialogs, errors, status messages, empty states, translations).

⚙️ CodeRabbit configuration file

Files:

  • beantester/gui/pages/toolbox.py
  • tests/test_toolbox.py
  • beantester/gui/toolbox/diagnostics.py
  • tests/test_mutation_registry.py
Verify tests check real behavior and would fail if the implementation were broken.

⚙️ CodeRabbit configuration file

Files:

  • tests/test_toolbox.py
  • tests/test_mutation_registry.py
Performance is a known weak spot of these projects.

⚙️ CodeRabbit configuration file

Files:

  • beantester/gui/pages/toolbox.py
  • tests/test_toolbox.py
  • beantester/gui/toolbox/diagnostics.py
  • tests/test_mutation_registry.py
Applies only to code that builds or styles a GUI.

⚙️ CodeRabbit configuration file

Files:

  • beantester/gui/pages/toolbox.py
  • tests/test_toolbox.py
  • beantester/gui/toolbox/diagnostics.py
  • tests/test_mutation_registry.py
SECURITY, HIGH PRIORITY.

⚙️ CodeRabbit configuration file

Files:

  • beantester/gui/pages/toolbox.py
  • tests/test_toolbox.py
  • beantester/gui/toolbox/diagnostics.py
  • tests/test_mutation_registry.py
Python code.

⚙️ CodeRabbit configuration file

Files:

  • beantester/gui/pages/toolbox.py
  • tests/test_toolbox.py
  • beantester/gui/toolbox/diagnostics.py
  • tests/test_mutation_registry.py
All code in this repository is written by an AI coding agent (Claude Code).

⚙️ CodeRabbit configuration file

Files:

  • beantester/gui/pages/toolbox.py
  • tests/test_toolbox.py
  • beantester/gui/toolbox/diagnostics.py
  • tests/test_mutation_registry.py
Source excerpt: **Flat hyphen only.**

📄 CodeRabbit inference engine (.github/claude-review-rules.md)

Files:

  • beantester/gui/pages/toolbox.py
  • tests/test_toolbox.py
  • beantester/gui/toolbox/diagnostics.py
  • tests/test_mutation_registry.py

📝 Walkthrough

Walkthrough

The Tools page now refreshes a selected panel only when the page is current. Diagnostics defer their first check until refresh or pending handling, and do not automatically repeat a check after an outcome is recorded.

Changes

Toolbox view behavior

Layer / File(s) Summary
Refresh panels only on the current page
beantester/gui/pages/toolbox.py, tests/test_toolbox.py, tests/test_mutation_registry.py
Off-screen tab changes store the selected tab without refreshing its panel. Tests cover on-screen refreshes and startup behavior for toolbox tools.
Start diagnostics on demand
beantester/gui/toolbox/diagnostics.py, tests/test_toolbox.py, tests/test_mutation_registry.py
Diagnostics start their first check through refresh or pending handling. After a recorded outcome, including failure, automatic checks do not retry; tests cover explicit retry.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested labels: bug, ui, performance

Merge Risk: ⚪ Minimal · up to 31dec

The deferred Tools and Diagnostics behavior is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 13 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Scope, Duplication And Docs ⚠️ Warning The PR changes user-facing Tools behavior: ToolboxPage._on_subpage now suppresses off-screen refreshes, and DiagnosticsPanel delays its first check and stops retrying failed checks automatically. … Update the documentation in the same PR. Add an entry under CHANGELOG.md Unreleased/Changed that explains that Tools work starts when the Tools page or panel is shown and that a failed diagnostics check waits for Check again. Update…
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: Tools-tab work remains idle until the Tools page is shown. It is specific, concise, and suitable for release notes or git history.
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.
Tests For Changed Behavior ✅ Passed The PR changes runtime behavior in ToolboxPage and DiagnosticsPanel, and it adds or updates tests for each change. New tests cover deferred diagnostics checks, failed-check retry behavior, off-scr…
No Secrets Or Debug Leftovers ✅ Passed The PR changes four existing files and adds no private AI-agent files or .env files. Added-line scans found no credentials, tokens, private URLs, IPs, personal email addresses, hardcoded local absol…
No Hardcoded Ui Styling ✅ Passed The PR changes Tkinter lifecycle behavior only. Added GUI lines in toolbox.py and diagnostics.py add page checks and deferred diagnostic checks. They do not add literal colors, fonts, sizes, margi…
No Obvious Performance Problems ✅ Passed No clear performance problem was introduced. ToolboxPage._on_subpage now skips refreshes when Tools is not current, removing off-screen socket work. DiagnosticsPanel now starts its first check onl…
Desktop Robustness ✅ Passed The reviewed changes only gate existing toolbox refreshes and defer the existing diagnostics check. The added diagnostics start path uses ToolJob.busy() to prevent duplicate execution, runs through …
Safe File Parsing ✅ Passed No safe-file-parsing failure is introduced. The production diff only adds app.current_page() gating and _check_if_never() around the existing diagnostics call. Added code does not open, parse, des…
System Changes Are Reversible ✅ Passed PASS. The authoritative diff changes GUI refresh timing and defers the read-only diagnostics check. It does not add or change code that modifies network filters, proxies, firewalls, system time, hooks…
Clear User-Facing Text ✅ Passed The PR changes control flow only. The authoritative diff contains no localization/resource changes and no new or modified user-visible labels, tooltips, confirmations, or error text. The existing Diag…
No Resource Leaks ✅ Passed No resource leak is introduced. The production diff only gates ToolboxPage.refresh() on the current page and defers one diagnostics check through the existing Poller/ToolJob path. `_check_if_nev…
Full details: Scope, Duplication And Docs

Explanation

The PR changes user-facing Tools behavior: ToolboxPage._on_subpage now suppresses off-screen refreshes, and DiagnosticsPanel delays its first check and stops retrying failed checks automatically. The PR changes only source and tests; README.md and the existing CHANGELOG.md are unchanged. The description explicitly confirms that no changelog entry was added. The title and description cover the code scope, and the new diagnostics helper follows the existing Sockets-panel pattern without introducing a new public API.

Resolution

Update the documentation in the same PR. Add an entry under CHANGELOG.md Unreleased/Changed that explains that Tools work starts when the Tools page or panel is shown and that a failed diagnostics check waits for Check again. Update the README Tools section if this timing and retry behavior is part of the supported user experience.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR

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

@coderabbitai coderabbitai Bot added bug Something isn't working performance ui labels Sep 24, 2026
@donislawdev
donislawdev merged commit eda32b9 into master Sep 24, 2026
15 checks passed
@donislawdev
donislawdev deleted the fix/tools-start-up-work branch September 24, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working performance ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant