Summary
Comprehensive source code analysis of 3 production terminal UI projects to inform oclite's architecture. Repos cloned to /tmp and analyzed file-by-file.
Projects Analyzed
🦀 AIChat (Rust) — github.com/sigoden/aichat (9.2k ⭐)
- Input:
reedline library (Nushell's line editor) — handles all input, cursor, completion, keybindings - Output: Append-only stdout with cursor position tracking via
crossterm::cursor::position() - Scroll: Does NOT use DECSTBM. Uses explicit
ScrollUp/ScrollDown commands - Streaming: Direct stdout writes, tracks cursor to know when to scroll
- Tools/MCP: Renders with dimmed text, spinner during execution
- Multi-line:
::: delimiters (not raw multi-line) - Key files:
src/repl/mod.rs (949 lines), src/repl/prompt.rs, src/repl/highlighter.rs
🐍 Aider (Python) — github.com/paul-gauthier/aider (40.1k ⭐)
- Input:
prompt_toolkit.PromptSession — full line editor with completion, history, key bindings - Output: Append-only stdout,
rich.Live for streaming rerender - Scroll: Does NOT use DECSTBM. Terminal scrolls naturally
- Streaming markdown: Full re-render at 8fps using Rich
Markdown + Live context manager - Multi-line: Alt+Enter toggle (Enter submits in normal mode, adds newline in multi-line mode)
- Separators:
rich.rule() horizontal lines between messages - Key files:
aider/io.py (1192 lines — InputOutput class)
📦 blessed (Node.js) — github.com/chjj/blessed
- DECSTBM: Full implementation in
lib/program.js:2760-2770 - CSR Recipe: Set → Position → Insert/Delete → ALWAYS reset to full screen
- Screen buffer: Two-buffer system (
lines current, olines previous), per-line dirty flags - Attr format: 27-bit packed integer per cell
- Resize: 300ms debounce, realloc buffers, reset CSR
- Key files:
lib/program.js (4,295 lines), lib/widgets/screen.js (1,400+ lines) - Key insight: Requires 16k+ LOC to make DECSTBM reliable — not appropriate for "lite"
Key Finding
Neither production AI chat CLI uses ANSI scroll regions. Both use append-only stdout + dedicated line editor library. This is the proven pattern for terminal chat UIs.
Recommendation Applied
Status: Complete ✅
This is a reference issue — no further action needed.
Summary
Comprehensive source code analysis of 3 production terminal UI projects to inform oclite's architecture. Repos cloned to /tmp and analyzed file-by-file.
Projects Analyzed
🦀 AIChat (Rust) — github.com/sigoden/aichat (9.2k ⭐)
reedlinelibrary (Nushell's line editor) — handles all input, cursor, completion, keybindingscrossterm::cursor::position()ScrollUp/ScrollDowncommands:::delimiters (not raw multi-line)src/repl/mod.rs(949 lines),src/repl/prompt.rs,src/repl/highlighter.rs🐍 Aider (Python) — github.com/paul-gauthier/aider (40.1k ⭐)
prompt_toolkit.PromptSession— full line editor with completion, history, key bindingsrich.Livefor streaming rerenderMarkdown+Livecontext managerrich.rule()horizontal lines between messagesaider/io.py(1192 lines — InputOutput class)📦 blessed (Node.js) — github.com/chjj/blessed
lib/program.js:2760-2770linescurrent,olinesprevious), per-line dirty flagslib/program.js(4,295 lines),lib/widgets/screen.js(1,400+ lines)Key Finding
Neither production AI chat CLI uses ANSI scroll regions. Both use append-only stdout + dedicated line editor library. This is the proven pattern for terminal chat UIs.
Recommendation Applied
Status: Complete ✅
This is a reference issue — no further action needed.