Skip to content

Phase 15: refactoring pass (log_viewer split, settings, message router) - #22

Merged
tommy-gun merged 1 commit into
mainfrom
refactor/phase-15
Jul 16, 2026
Merged

tommy-gun merged 1 commit into
mainfrom
refactor/phase-15

Conversation

@tommy-gun

Copy link
Copy Markdown
Contributor

Implements Phase 15 — Refactoring Pass (5 of 6 items; packaging deferred).

Pays down structural debt before phases 7 / 11 / 12 grow the codebase.

Changes

  • Split app/ui/log_viewer.py (~1450 lines) into a package app/ui/log_viewer/, mirroring the app/ui/profiler/ split:
    • common.py (constants, pure helpers, LogRowItem), factories.py (column cell factories), tag_bar.py (_TagBarLayout + TagBarMixin chip fitting), capture_panel.py (CapturePanelMixin), view.py (LogViewerView composing them).
    • Per-concern mixins keep runtime behavior identical; __init__.py re-exports LogViewerView so from app.ui.log_viewer import LogViewerView is unchanged. Dropped dead code (_INVALID_POS).
  • Unify settings persistence → new app/core/settings.py Settings class (merge semantics, per-namespace files), replacing the two diverging _load_settings/_save_settings trios in profiler_view.py and log_viewer.py. This is the seam for the Phase 9 GSettings backend.
  • Extract SocketServer._reset_connection() — the connection-teardown block was copy-pasted 3× (error path, EOF path, stop()).
  • Typed message router → new app/core/message_router.py (MessageRouter.on("profile_event", cb)), replacing the per-view message-received if/elif filtering in profiler_view.py, inspector_view.py and main.py.
  • Delete tests/test_placeholder.py (Phase 0 leftover).

Deferred

  • Item 3 — Python packaging ([project] table + console_scripts, dropping the sys.path.insert hack): deferred. All three launch paths (setup-and-run.sh, build-deb.sh, Flatpak) run app/main.py directly, so dropping the hack requires launcher/manifest changes that must be build-tested on a real Linux box.

Tests

  • New unit tests: tests/test_settings.py, tests/test_message_router.py.
  • New headless log-viewer construct/ingest/filter test in the WSL harness; updated the Stop-hook syntax-check file list for the new package layout.
  • Full Stop hook green: ruff, eslint, mypy (39 files), syntax check, WSL headless (8 tests), pytest.

Note: headless covers code paths only — the log viewer's visual layout, hover/click and popover behavior still warrant a live check via scripts/setup-and-run.sh on a real GNOME box.

🤖 Generated with Claude Code

Pay down structural debt before phases 7/11/12 grow the codebase.

- Split app/ui/log_viewer.py (~1450 lines) into app/ui/log_viewer/
  package (common, factories, tag_bar, capture_panel, view), mirroring
  the app/ui/profiler split. Per-concern mixins keep behavior identical;
  __init__ re-exports LogViewerView so the public import is unchanged.
- Add app/core/settings.py (Settings class, merge semantics, per-namespace
  files) replacing the duplicated _load_settings/_save_settings in
  profiler_view and log_viewer; the seam for the Phase 9 GSettings backend.
- Extract SocketServer._reset_connection() (teardown was copy-pasted 3x).
- Add app/core/message_router.py (typed MessageRouter.on(type, cb)) and
  replace the per-view message-received if/elif filtering in profiler_view,
  inspector_view and main.py.
- Delete tests/test_placeholder.py (Phase 0 leftover).

Add unit tests (test_settings.py, test_message_router.py), a headless
log-viewer test in the WSL harness, and update the hook syntax-check list.

Item 3 (Python packaging / dropping the sys.path hack) is deferred: all
launch paths run app/main.py directly, so it needs launcher/manifest
changes that must be build-tested on a real Linux box.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@tommy-gun
tommy-gun merged commit f236760 into main Jul 16, 2026
8 checks passed
@tommy-gun
tommy-gun deleted the refactor/phase-15 branch July 19, 2026 13:01
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