Skip to content

feat(tui): implement bridge, live scanner, operations menu, and pocs tui CLI#1454

Open
wtgee wants to merge 5 commits into
v1.0.0from
feat/tui-implementation
Open

feat(tui): implement bridge, live scanner, operations menu, and pocs tui CLI#1454
wtgee wants to merge 5 commits into
v1.0.0from
feat/tui-implementation

Conversation

@wtgee

@wtgee wtgee commented May 29, 2026

Copy link
Copy Markdown
Member

Summary

Implements phases 2–4 of the POCS TUI as defined in docs/tui_plan.md.

What's new

  • bridge.py — in-process command channel from TUI to POCS; runs blocking POCS calls in ThreadPoolExecutor; supports initialize, start_run, stop_run, park, abort_exposure, power_down, get_config, set_config
  • Live scannerscanner.py now reads from TelemetryClient (lazy init, graceful fallback when server is down)
  • Data model — added ModalModel, ConfigEditorModel, run_active flag on SystemModel
  • Layoutlayout_compute() implemented; new OPERATIONS and CONFIG view constants
  • Input — simplified to 6 navigation keys only (↑↓←→ Enter Esc/q)
  • Actions — full lifecycle/hardware/config action set wired through bridge
  • Panelsdashboard.py, operations.py, help.py panels
  • __main__.py — tab bar, view routing, modal confirmation overlay
  • pocs tui CLI command--config-file, --no-pocs (monitor-only), --simulator flags

Tests

15 tests pass covering model, bridge, actions, scanner, operations menu, input handling, and layout.

Closes part of #1449

…tui CLI command

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50844% with 185 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.45%. Comparing base (59d36dc) to head (17ed7e5).

Files with missing lines Patch % Lines
src/panoptes/pocs/tui/__main__.py 0.00% 99 Missing ⚠️
src/panoptes/pocs/tui/scanner.py 81.11% 23 Missing and 4 partials ⚠️
src/panoptes/pocs/tui/panels/dashboard.py 85.03% 11 Missing and 11 partials ⚠️
src/panoptes/pocs/utils/cli/tui.py 27.77% 13 Missing ⚠️
tests/tui/test_tui_coverage.py 98.88% 5 Missing and 3 partials ⚠️
src/panoptes/pocs/tui/actions.py 93.58% 3 Missing and 2 partials ⚠️
src/panoptes/pocs/tui/panels/operations.py 87.17% 3 Missing and 2 partials ⚠️
src/panoptes/pocs/tui/bridge.py 96.25% 2 Missing and 1 partial ⚠️
src/panoptes/pocs/tui/panels/help.py 86.36% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           v1.0.0    #1454      +/-   ##
==========================================
+ Coverage   71.36%   73.45%   +2.08%     
==========================================
  Files         124      130       +6     
  Lines       11179    12579    +1400     
  Branches      913     1010      +97     
==========================================
+ Hits         7978     9240    +1262     
- Misses       2991     3110     +119     
- Partials      210      229      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

wtgee and others added 4 commits May 29, 2026 10:25
- 110 tests covering actions, bridge, scanner, theme, cmdlog, layout,
  panels/dashboard, panels/help, panels/operations
- Coverage: 42% → 83% overall; 100% for model/layout/cmdlog/input/theme
- Mock curses screens for rendering tests (no initscr needed)
- Inject mock TelemetryClient for scanner._scan tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Scanner._scan_direct() reads state directly from in-process POCS
  instance (mount booleans from live properties, cameras from
  observatory.cameras, observation from status dict with correct
  'observation' / 'exptime' key names)
- _scan() now prefers _scan_direct() when pocs is available, avoiding
  the need for a running telemetry server
- Pass pocs to Scanner in __main__.main() so direct reads activate
- curses_main() removes all loguru sinks before entering curses and
  restores an error-only stderr sink on exit, preventing log lines
  from corrupting the terminal display
- Added 7 new TestScannerDirect tests covering the direct-read path

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bility

curses.curs_set(0) raises _curses.error on many terminals (macOS iTerm2,
xterm etc.), which propagated out of main() and caused the TUI to exit
immediately with a blank screen. Wrap the call in try/except curses.error.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pocs.status builds the status dict but then inserts it into the DB
(telemetry server on port 6562). When no server is running the insert
raises ConnectionError, pocs.status catches it and returns {}, leaving
the TUI with all-default values.

Fix: _scan_direct() now reads POCS/Observatory state directly from
live Python properties, bypassing pocs.status entirely:
- pocs.state / pocs.next_state / pocs.do_states
- observatory.can_observe, mount.is_initialized, mount.is_parked, etc.
- observatory.cameras iterated directly
- observatory.current_observation.status for observation info
- Camera attributes wrapped per-field in try/except (cam.temperature
  raises on the simulator)

Updated TestScannerDirect fixtures: added can_observe, _MockObservation
with status property, _MockCamera.temperature works via try/except.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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