Skip to content

TUI: deep split of tui.ts and tui-command-handlers.ts - #78

Merged
ApiliumDevTeam merged 2 commits into
devfrom
chore/tui-split-deep-v2
Jul 14, 2026
Merged

ApiliumDevTeam merged 2 commits into
devfrom
chore/tui-split-deep-v2

Conversation

@ApiliumDevTeam

Copy link
Copy Markdown
Collaborator

Summary

Closes the file-size reduction follow-up from #74. Both monolithic TUI files are split below the ~500 LOC guideline without changing any observable behavior.

tui.ts (883 → 591 LOC) — three modules extracted from runTui():

  • tui-status-renderer.ts (301 LOC): status/footer rendering, busy/idle timers, waiting-status animation. Owns activityStatus, connectionStatus, isConnected, statusTimeout — the state object delegates via late-bound getters/setters.
  • tui-keybindings.ts (119 LOC): editor callbacks (onEscape, onCtrlC/D/O/L/G/P/T, onShiftTab). Mutable state accessed via TuiStateAccess.
  • tui-connection.ts (121 LOC): gateway client lifecycle (onEvent, onConnected, onDisconnected, onGap). Pairing/gateway-down hint flags are internal.

The remaining 591 LOC is primarily the state object definition (~170 LOC of getters/setters) plus essential wiring — extraer eso a una factory añade indirección sin claridad.

tui-command-handlers.ts (1402 → 351 LOC) — 7 command group modules + dispatcher:

  • tui-cmd-session.ts: agent, session, model, new, reset, search
  • tui-cmd-config.ts: think, verbose, reasoning, elevated, activation, usage, context
  • tui-cmd-display.ts: style, theme, diff, permission, fast, tools
  • tui-cmd-clipboard.ts: copy, export
  • tui-cmd-ecosystem.ts: plan, kg, trace, team, tasks, workflow, rules, mailbox, sync, mouse
  • tui-cmd-teleport.ts: teleport (export/import)
  • tui-cmd-misc.ts: help, status, undo, abort, settings, bug, init, exit, quit, onboard, batch, vim, compact, default
  • tui-cmd-types.ts: shared CommandHandlerContext (extended with closures) + CommandGroupHandler type

The dispatcher iterates over the groups until one returns true (handled). The public API (createCommandHandlers → { handleCommand, sendMessage, ... }) is unchanged.

Test plan

  • pnpm tsgo — 0 errors
  • pnpm lint — 0 errors, 359 warnings
  • pnpm exec vitest run src/tui/ — 512 passed, 1 skipped, 0 failed
  • All 34 tui-command-handlers.test.ts tests pass without modification (public API preserved)
  • Rebased on latest origin/dev (includes FTS5 session search and skill curator lifecycle #77 FTS5 search) — no conflicts, searchSessions interface unchanged

@ApiliumDevTeam
ApiliumDevTeam merged commit 48af542 into dev Jul 14, 2026
13 of 14 checks passed
@ApiliumDevTeam
ApiliumDevTeam deleted the chore/tui-split-deep-v2 branch July 14, 2026 18:30
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