Skip to content

Decide: retire the legacy readline attach path (keep the one-shot CLI commands)? #123

Description

@saucam

Context

#122 hardened the streaming renderer in the legacy readline client (src/terminal/client.ts, the attach path) by extracting renderStreamMessage and sanitizing untrusted fields. While reviewing it, the real question surfaced: should that interactive path exist at all, or is it dead weight we're now maintaining a bespoke renderer + sanitizer for?

Current state

TerminalClient (src/terminal/client.ts) does two unrelated jobs, wired into src/cli.ts:

  1. Interactive readline attachattachSession() + the streaming render loop (renderStreamMessage). This is the oldest of four ways to watch a session stream, and is redundant with all of them:

    • codeoid-tui (native Rust/Ratatui, recommended cockpit — separate repo)
    • codeoid tui (in-repo Ink cockpit, already documented as the "legacy fallback")
    • Web UI
    • Telegram

    It is also the only part of the file carrying the terminal-escape rendering surface fix: sanitize untrusted output in the legacy readline terminal client (terminal/client.ts) #92 / fix: sanitize untrusted output in the legacy readline terminal client #122 addressed.

  2. One-shot request/response commandsls, new, send, interrupt, approve, destroy. Each connects, sends one message, prints a line, disconnects. Scriptable, pipe-friendly, and with no cockpit equivalent (the cockpits are interactive-only). Worth keeping.

Options

A. Keep as-is (status quo after #122).
Retain codeoid attach and its sanitized renderer.
Cost: maintain a bespoke stream renderer + escape sanitizer indefinitely for a path three richer clients already cover.

B. Remove the interactive attach path; keep the one-shot commands. (Proposed)
Delete attachSession(), renderStreamMessage, the SGR/render helpers, and src/tests/terminal-client-render.test.ts. Drop the codeoid attach command or repoint it to codeoid tui. TerminalClient slims to a thin one-shot WS client for the six scriptable commands.
Benefit: eliminates the terminal-escape surface by removal rather than by maintaining a sanitizer; less code; one fewer renderer to keep in sync with the wire protocol.
Cost / to confirm:

  • Loses the plain, pipe-friendly, over-SSH "stream one session to stdout" niche (codeoid tui uses the alt-screen and isn't pipe-friendly).
  • Docs/recipes reference it — the README device-handoff example (laptop$ codeoid attach oracle) and possibly external demo recipes — those need updating.

C. Remove TerminalClient entirely (including the one-shots).
Not recommended: the six one-shot commands have no equivalent and would need rewriting against some WS client. TuiWsClient is coupled to a React dispatch, so this just rebuilds a minimal one-shot client anyway.

Recommendation

Option B. It's the cleanest outcome: the streaming path that motivated #92/#122 goes away, the genuinely useful scriptable commands stay, and the terminal-injection concern is closed by deletion instead of an ongoing sanitization burden.

Loose end (either way)

listSessions() / #formatStatus print session name/workdir with raw console.log and were never sanitized (out of #122's scope). Low risk — a user's own session names — and it's moot for the streaming concern under B.

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions