Skip to content

Phase 0 (9/9): operator TUI — extract keymap (pure-data, 2932→2894) - #43

Closed
Pal Lakatos-Toth (pallakatos) wants to merge 2 commits into
phase0/kubectl-convert-skeletonfrom
phase0/operator-tui-keymap-extract
Closed

Pal Lakatos-Toth (pallakatos) wants to merge 2 commits into
phase0/kubectl-convert-skeletonfrom
phase0/operator-tui-keymap-extract

Conversation

@pallakatos

Copy link
Copy Markdown
Collaborator

Phase 0 · operator TUI — extract keymap to a pure module

First decomposition slice on cli/src/commands/operator.ts. Pure-data extraction, zero behavioural change.

cli/src/commands/operator/keymap.ts (new, 88 lines)

  • BINDINGS — 17-row pure-data table of key → label → action pairs.
  • statusBarForAgents | statusBarForTopology | statusBarForCluster — byte-identical blessed-markup strings to what operator.ts produced inline.
  • Zero runtime deps (no blessed, no commander, no fs, no net). Unit-testable without a TTY.

cli/src/commands/operator.ts

  • 2932 → 2894 lines (Phase 0 cap 2900, 6 lines of slack).
  • Removed: 35-line layout/keyboard doc-comment + 3 inline statusBar.setContent blocks.
  • Added: import + 3 helper calls.

Tests

  • cli/src/commands/operator/keymap.test.ts — 6 unit tests (tables aren't empty, labels are stable, status-bar strings match fixtures).
  • Compat suite operator-tui.spec.ts: 11 passed / 8 todo (unchanged — zero regression).

Security

  • docs/security-audits/2026-04-24-phase0-operator-keymap-extract.md — refactor-only audit; re-audit trigger: any binding whose label changes behaviour.

Known tight-fit

6 lines of slack under the Phase 0 cap. Phase 1 target is 2000; decomposition must continue via TUI render / input / data / overlays splits.

Stack

PR 9/9 — final Phase 0 PR. Bases on phase0/kubectl-convert-skeleton (PR 8).

Copilot AI and others added 2 commits April 24, 2026 22:10
Per docs/implementation-plan.md §4.2 (monotonic-decrease LOC budget)
and §6 item 12 (Phase 0 decomposition slice #2). Pure-data extraction,
no runtime behaviour change.

cli/src/commands/operator.ts: 2932 -> 2894 lines (Phase 0 cap 2900).

cli/src/commands/operator/keymap.ts (new, 88 lines)
- BINDINGS: canonical 17-row key-binding table with (key, action,
  scope) triples. Scope enum: global|agents|egress|cluster|topology|
  overlay.
- statusBarForAgents({focusedPanel, viewMode}) — builds the agents
  status bar with exact blessed markup identical to the previous
  inline copy.
- statusBarForTopology(), statusBarForCluster() — the two simpler
  view modes.
- Zero runtime deps: no blessed, no commander, no I/O. Makes the
  module safe to unit-test without a TTY harness.

cli/src/commands/operator/keymap.test.ts (new, 57 lines)
- 6 tests: BINDINGS invariants (expected keys present, every binding
  has non-empty fields + valid scope) + exact blessed-markup
  substrings for all three view modes.

operator.ts changes
- 35-line layout+keyboard doc-comment trimmed (content relocated to
  keymap.ts jsdoc).
- 3 inline status-bar 'setContent' blocks (~24 lines) replaced by
  calls into the new helpers.
- One new import statement.

Verification
- wc -l operator.ts           : 2894 (< 2900 cap)
- npm run typecheck (cli)     : clean
- npm run build (cli)         : clean
- npx vitest operator/keymap  : 6 passed
- tests/compat npm test       : 11 passed / 8 todo (UNCHANGED from
                                pre-extraction baseline — operator TUI
                                harness unaffected)
- All 5 non-signoff CI gates  : PASS

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Approved by repository maintainer for Phase 0 merge.

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

Copy link
Copy Markdown
Collaborator Author

Closing in favor of an integrated validation on the dev branch. This branch has been merged into dev (see origin/dev) and a single dev → main PR will land once CI is green on dev. No code is lost — every commit remains on its phase0/* branch and is reachable from dev.

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.

2 participants