eye-declare #
A library for building inline terminal UIs in Rust: interfaces that live in your terminal's normal flow, where finished output scrolls into native scrollback and only a small live region updates in place.
eye-declare is built for CLI tools, AI agents, and interactive prompts: the programs where output accumulates and history should stay visible, exactly as if the program had printed it.
Rust Docs #
For the rustdoc documentation, visit https://docs.rs/eye_declare.
Example #
The whole design in one small fragment: a streaming agent turn. Content lives in
the live tail while it's changing; the moment it's finished, ctx.push
commits it to scrollback, like println!:
struct Agent {
response: String,
streaming: Option<Task>,
}
enum Msg {
Delta(String),
Done,
}
impl App for Agent {
type Msg = Msg;
type Output = ();
fn update(&mut self, msg: Msg, ctx: &mut Ctx<'_, Self>) {
match msg {
// Still changing: lives in the tail.
Msg::Delta(word) => self.response.push_str(&word),
// Finished: commit to scrollback.
Msg::Done => {
let reply = std::mem::take(&mut self.response);
ctx.push(markdown(reply));
self.streaming = None;
}
}
}
// The live region: a pure view of the model, rebuilt every frame.
fn tail(&self) -> impl Element + '_ {
col()
.when(self.streaming.is_some(), |c| {
c.child(spinner("Thinking…"))
})
.child(text(self.response.as_str()))
}
}
Messages arrive from terminal input through a keymap and from async work
through ctx.spawn — both shown in the quick start,
which builds a complete runnable app in about sixty lines.
Examples #
The repository ships runnable examples that double as learning material:
echo— the smallest useful app: type, Enter commits, Ctrl+C exits.stream— a mini agent: a streaming turn with a spinner, Esc cancels.openrouter— a real streaming AI chat TUI in one commented file.
Where to go next #
Start with the introduction for the idea behind the design, or jump to the quick start to build a working app. The guide covers the concepts in depth; the reference documents the widgets, runtime, and migration path.