Store session state directly

This commit is contained in:
Michael Mikovsky
2026-06-01 11:30:25 -06:00
parent 8ab72d35b0
commit f2bc2d912d
4 changed files with 21 additions and 28 deletions
+8 -5
View File
@@ -41,7 +41,7 @@ unshell_leaf! {
authors: unshell::alloc::vec!["ASTATIN3"],
},
sessions {
pty: PtySession,
pty: PtySessionState,
}
procedures {}
}
@@ -59,10 +59,14 @@ The example above expands to the equivalent of:
pub struct FakePtyLeaf {
state: FakePtyState,
outbox: LeafOutbox,
pty: SessionFamily<<PtySession as Session<FakePtyState>>::State>,
pty: SessionFamily<PtySessionState>,
}
```
Session types are the per-hook state values themselves. There is no separate
zero-sized handler struct; a type like `PtySessionState` implements `Session` and is
stored directly in the generated `SessionFamily`.
The wrapper implements:
- `new(state)`
@@ -149,13 +153,12 @@ Ratatui rendering is a plain feature-gated pass:
leaf.render_ratatui(frame, area, &mut interface);
```
Session rendering is an associated function because session families are type-level
contracts, not stored objects:
Session rendering is an associated function on the stored session state type:
```rust
fn render_ratatui(
leaf: &LeafState,
session: &Self::State,
session: &Self,
view: &mut SessionView,
frame: &mut ratatui::Frame<'_>,
area: ratatui::layout::Rect,