Skip to content

Pluggable terminal backend (1/2): widen TerminalBackend ABC + construction factory - #277

Open
mrw1986 wants to merge 1 commit into
SeemSeam:mainfrom
mrw1986:feat/pluggable-terminal-backend
Open

Pluggable terminal backend (1/2): widen TerminalBackend ABC + construction factory#277
mrw1986 wants to merge 1 commit into
SeemSeam:mainfrom
mrw1986:feat/pluggable-terminal-backend

Conversation

@mrw1986

@mrw1986 mrw1986 commented Jul 23, 2026

Copy link
Copy Markdown

Prep refactor for a pluggable terminal backend, per #276 (herdr backend + the Windows interest you raised). No behavior change — tmux stays the default and the only implementation.

This is PR 1 of 2. PR 2 adds HerdrBackend on top of this seam.

What changes

  • Widen TerminalBackend (terminal_runtime/backend_types.py) from 5 methods to the full contract TmuxBackend actually exposes — 21 @abstractmethod + 3 safe no-op defaults (set_pane_style, refresh_pane_logs, save_crash_log) — so a second backend shares one typed interface. Signatures were copied verbatim from TmuxBackend; a conformance test asserts TmuxBackend.__abstractmethods__ is empty.
  • Single construction point make_terminal_backend() (terminal_runtime/backend_selection.py); all 11 direct TmuxBackend(...) call sites now route through it (kwargs preserved).
  • herdr selector branch (stub → NotImplementedError) added to the factory, TerminalBackendSelection.get_backend, and TerminalLayoutService.create_auto_layout. tmux paths are unchanged.

Why widen the ABC (the open question from #276)

The ABC declared only 5 methods, but callers rely on ~24 of TmuxBackend's. Widening to the real contract gives HerdrBackend (and a future Windows-native backend) one typed interface to implement, instead of duck-typing against TmuxBackend's de-facto surface. If you'd prefer a narrower ABC or a different split, I'm happy to adjust — this PR is meant to settle that shape before the herdr implementation lands.

Testing

  • Seam suite green: 340 tests across test_terminal_runtime_backend_selection, test_tmux_backend, test_detect_terminal, test_terminal_runtime_layouts, test_v2_tmux_start_layout, test_ccbd_project_clear, the layout CLIs, the *_session_ensure_pane tests, etc. (the live-smoke ones need a real tmux).
  • New tests: factory returns TmuxBackend for tmux/None and raises for herdr; selector + layout herdr stubs raise; TmuxBackend ↔ ABC conformance.

Scope

Touches only terminal_runtime/*, the 11 construction sites, and tests. No changes to the mailbox / lease / recovery / coordination layers — reply capture is session-file based, so those are backend-agnostic and unaffected.

…rough a factory

Prep for a pluggable terminal backend (herdr in PR SeemSeam#2; see issue SeemSeam#276). No behavior change.

- Widen TerminalBackend to the full contract TmuxBackend actually exposes: 21 abstract
  methods + 3 safe no-op defaults (set_pane_style / refresh_pane_logs / save_crash_log),
  so a second backend can share one typed interface.
- Add make_terminal_backend() as the single construction point and route all 11 direct
  TmuxBackend(...) call sites through it. tmux stays the default.
- Add a 'herdr' branch (NotImplementedError stub) to the factory, TerminalBackendSelection,
  and TerminalLayoutService.
- Tests: factory / selector / layout herdr-stub coverage + a TmuxBackend<->ABC conformance test.

340 seam tests green; tmux behavior unchanged. Implemented via codex, reviewed by ccb_self.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXGKFeeEcDR1sYPM1xyoBG
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