Hunter Bown 66360ded8b feat(tui): per-session control socket (#5533) (#5831)
* feat(tui): per-session control socket with message/interrupt/relaunch/status verbs

Config-gated [control_socket] table (off by default) binds
<sessions-dir>/<session-id>/control.sock (0600) per running session,
speaking a newline-framed JSON-RPC. Verbs: message (structured
user message through the composer dispatch path; queued under load),
interrupt (the extracted Esc cancel body, shared with the Esc key path),
relaunch (seam: dispatches the /relaunch slash-command path — no
mechanics duplicated here), status (turn/goal snapshot answered by the
socket thread). Wiring: run_event_loop constructs SessionControl and
reconciles/updates/drains once per iteration; the socket runs on
background threads with bounded reads (1 MiB) and 5 s dispatch
timeouts. Unix-only; non-unix parses the key but refuses to bind.

Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>

* fix(tui): back off control-socket bind retries after a refused takeover

A second live process holding a session's socket made the per-frame
reconcile retry the connect-probe and warn-log every iteration. Retries
now back off (5 s in prod, 200 ms under test) keyed on the session id,
so switching sessions is never delayed by another session's refusal.

Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>

* fix(tui): make accepted control-socket connections blocking on BSD platforms

The listener is nonblocking, and on macOS/FreeBSD an accepted socket
inherits O_NONBLOCK from the listener (Linux accepted sockets are
blocking). The connection handler assumes blocking reads, so on macOS a
large request hit EAGAIN mid-frame, the handler dropped the connection,
and the client's in-flight write failed with BrokenPipe — the
oversized-request test failed exactly this way on macOS CI. Setting the
accepted stream back to blocking (a no-op on Linux) makes the handler's
bounded-read model hold on every platform.

Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>

* fix(tui): cfg-gate unix-only control-socket items for Windows builds

The Windows CI gate (cargo test --no-run) denies unused imports and dead
code under -D warnings. On non-unix targets the socket transport does not
exist, so its imports, timing constants, and request/response types are
unreachable there. Split the io/atomic imports and gate the five socket
timing constants with cfg(unix), and mark the six protocol types
(Request, Method, MessageParams, EmptyParams, ControlCommand,
ResponseResult) with a scoped allow: they stay reachable in the portable
protocol/parsing tests and on unix builds, and are only unreachable in
the plain Windows lib build. The dead-code budget file is untouched.

Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>

* docs(tui): reference the filed issue #5533 in the control-socket module doc

The module doc still carried the pre-filing placeholder numbering; the
issue is filed as #5533 and the changelog/PR text already use it.

Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>

* fix(config): remove syntax errors in tests for control socket

---------

Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>
Co-authored-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>
Co-authored-by: CodeWhale Bot <bot@codewhale.net>
2026-09-02 17:19:46 +00:00

Codewhale

Codewhale is an open source coding agent for your terminal, built in Rust and improved in public with the people who use it.

Codewhale

简体中文 · 日本語 · Tiếng Việt · Bahasa Indonesia · 한국어 · Español · Português · Русский · Українська · Français · Deutsch · 繁體中文 · हिन्दी · Türkçe · Italiano · Polski · العربية · Català

CI crates.io npm Discord

A Codewhale terminal session

Install

npm install -g codewhale
codewhale

The first run helps you connect a provider or stay offline. Codewhale also supports Cargo, Docker, Nix, Scoop, prebuilt archives, Android/Termux, and a CNB mirror. See the installation guide.

Tab completion is one command per shell — codewhale completion bash|zsh|fish|powershell|elvish. See shell completions.

Use

Talk to Codewhale the same way you would talk to a teammate:

Fix the failing tests and explain what changed.

Or run a task without opening the TUI:

codewhale exec "fix the failing tests and explain what changed"

Codewhale can read your repository, edit files, run commands, inspect results, and keep working toward a goal. You decide how much access it has.

Why Codewhale

  • Use the model you want. Connect hosted providers or local models through Ollama, vLLM, or SGLang. Switch provider and model with /model.
  • Stay in control. Plan is read-only. Ask, Auto-Review, and Full Access make approval behavior visible. /undo reverts the last turn and /restore returns the workspace to an earlier snapshot.
  • Keep long work organized. Save sessions, set a durable /goal, review workflows before they run, and coordinate agents without turning their internal instructions into your transcript.
  • Extend the agent you already have. Connect MCP servers and skills, configure hooks, and keep agent roles as readable files in your project or personal settings.

Run /help in the TUI for commands and keyboard shortcuts.

Safety

Codewhale runs on your machine with the access you grant it. Approval modes and repository rules limit what the agent may do; optional OS sandboxing adds a stronger execution boundary where supported. Unknown model prices stay unknown instead of being reported as free.

Read authorization order for the exact policy stack and configuration for local settings.

Documentation

Join the community

Codewhale gets better when people use it, report what feels wrong, and help fix it. If a provider is missing, a workflow is awkward, or the terminal UI gets in your way, open an issue. If you know how to improve it, open a pull request. First contributions are welcome, and contributors keep credit for the work that lands.

Join the Discord, or add Hunter on WeChat (hunterbown) and ask to join the Whale Brothers group.

Project history

Codewhale began as deepseek-tui and still preserves that configuration and session compatibility. It is now provider-neutral and independently maintained; it is not affiliated with any model provider.

Thanks to every contributor and to the open source communities that helped the project grow. See the contributor record.

License

MIT. Portions adapted from other open-source projects are recorded in third-party notices.

Description
面向 DeepSeek V4 的终端原生编程智能体:100 万 token 上下文、思考模式流式推理、前缀缓存感知。自包含 Rust 二进制发布——开箱即带 MCP 客户端、沙箱和持久化任务队列
Readme MIT 378 MiB
Languages
Rust 92.9%
TypeScript 3.2%
JavaScript 1.7%
Python 1%
Shell 0.7%
Other 0.3%