Health cache keyed by server name: renames leave stale entries and can pin wrong health to a reused name #36

Closed
opened 2026-07-12 12:44:48 -04:00 by the_og · 0 comments
Owner

Found in audit of main @ 06326e5.

MainWindow._health maps server name → (status, summary). Two problems:

  1. _editor_changed() (bcc.py ~L2043) pops entry.name after assigning the new name from the editor — so on a rename it pops the new name (usually a no-op) and the old name's cached health stays in _health forever. If any server is later given that old name, it inherits a stale health dot from a different server.
  2. _update_health_cell() resolves by next(i for … if s.name == name); with duplicate names mid-edit (validation blocks save but not the in-memory state), results attach to the wrong row.

Proposed fix: capture the old name before reassigning (old = entry.name) and pop that; or key the cache by object identity (id(entry))/master index and rebuild on load. Keep the existing behavior that an edit invalidates the entry's health.

Acceptance: rename a tested server → its old name no longer appears in _health; renaming another server to the freed name shows UNTESTED, not the previous server's result. Unit-testable if the cache logic is extracted; otherwise cover via a small GUI-free helper.

**Found in audit of `main` @ 06326e5.** `MainWindow._health` maps **server name → (status, summary)**. Two problems: 1. `_editor_changed()` (`bcc.py` ~L2043) pops `entry.name` **after** assigning the new name from the editor — so on a rename it pops the *new* name (usually a no-op) and the *old* name's cached health stays in `_health` forever. If any server is later given that old name, it inherits a stale health dot from a different server. 2. `_update_health_cell()` resolves by `next(i for … if s.name == name)`; with duplicate names mid-edit (validation blocks save but not the in-memory state), results attach to the wrong row. **Proposed fix**: capture the old name before reassigning (`old = entry.name`) and pop that; or key the cache by object identity (`id(entry)`)/master index and rebuild on load. Keep the existing behavior that an edit invalidates the entry's health. **Acceptance**: rename a tested server → its old name no longer appears in `_health`; renaming another server to the freed name shows UNTESTED, not the previous server's result. Unit-testable if the cache logic is extracted; otherwise cover via a small GUI-free helper.
the_og added the P2 label 2026-07-12 12:44:48 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: the_og/better-claude-config#36