The terminal interface — explanation
What is this about?
rzb tui is a full-screen program for the person at the Mac: chat with the server's models, see what the server holds, manage the model cache, change the configuration. This page explains why it is a separate process, how it reaches what it shows, and what it deliberately keeps local.
A second process, not a mode of the server
The server is meant to run for a long time, in the background, possibly started at login. A terminal window is meant to come and go. Putting the interface inside rzb serve would tie the two lifetimes together: closing the window would stop the server, and a crash in the drawing code would take the models down with it. As a second rzb process on the same machine, the interface can be opened, closed and opened again while the server keeps serving every other client.
Three ways to reach things
The interface uses the channel that already exists for each kind of thing:
- The OpenAI API for chatting. The Chat screen is a client like any other; it sends the whole conversation with each message, as OpenAI clients do, and the server's prompt cache avoids reading it again. A side effect is useful: the interface exercises the same API as every other client.
- The
/rzb/routes for what only the server process knows: the models in memory, the queues, the engine's memory, the last requests, unloading a model, reloading the configuration. - The disk for what is on the disk: the Hugging Face cache, read and cleaned like
rzb modelsdoes, and the configuration file, opened like any file. Adding routes for them would make the server a file manager.
Downloading needs the engine, which lives in the MLX part of rzb. The interface itself links no MLX, so that it builds and is tested on Linux like the server; the command line hands it the engine's download function.
What stays local
The /rzb/ routes answer the machine itself only. They act on the server for everyone and show what other clients do, so the person allowed to use them is the one at the Mac. rzb tui follows the same line: it is meant for a server on the same machine, and a server on another one answers 403. Port forwarding over ssh is the way to use it from elsewhere, because the server then sees a local connection.
Polling rather than events
The Dashboard asks for the status every second. A refresh costs a few hundred bytes, keeps no connection open, and works the same with curl. A stream of events would be a second way to learn the same state, to keep consistent with the first, for a display that changes at human speed.
The server's file in an editor, the preferences in a form
The server's configuration is a file people write by hand, with comments that explain their choices. Rewriting it from a form would lose those comments, because the YAML library does not keep them. So rzb tui opens it in the user's editor, checks it on return with the same validation as rzb config validate, and only then asks the server to reload it; a file with mistakes never reaches the server. The interface's own preferences are a small file it writes itself, so a form is the simpler way to change them.
Rejected alternatives
- The interface inside
rzb serve(rzb serve --tui): one process, but the server's life would depend on a terminal. - Server-sent events for the Dashboard: instant updates, at the price of a second protocol for the same information.
- Forms for the server's file: comfortable, but comments would be lost on every save.
- Routes for the model cache (
/rzb/modelsto list, download, delete): the interface would not need disk access, but the server would gain file-management duties thatrzb modelsalready covers.
How it relates to the rest
- The routes it calls: HTTP API reference; why they exist: OpenAI compatibility.
- Where its module sits: architecture.
- Using it: tutorial, reference.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|