Luxe 0.1.3: your sessions on your phone, joinable sessions, and nested AGENTS.md

- luxe remote puts the sessions on your computer in reach of your own phone or tablet over
  Tailscale: write, steer, answer prompts, send photos, browse files, diffs and GitHub, with a
  paired device and your own Tailscale login.
- luxe join lets another program on the same machine join a running session over the RPC protocol.
- An AGENTS.md in a subfolder reaches the model the first time it works there.
- Long sessions stay fast: no stall before each model call, lighter memory, cheaper drawing.
- A session is open in one Luxe at a time, web_search shares results across its phrasings, and a
  grep glob starting with ! excludes.

The CHANGELOG has the full list.
This commit is contained in:
Evan Whittaker
2026-10-20 02:40:13 -05:00
parent 99e30d6d0f
commit d2129a886f
423 changed files with 31666 additions and 1669 deletions

View File

@@ -42,16 +42,18 @@ pub(crate) fn activity_parts(app: &App) -> Option<(&'static str, String)> {
}
}
/// Formats turn elapsed time compactly: `45s` under a minute, `1:23` beyond.
/// Formats a live timer: `45s`, `1m 23s`, then `1h 04m`.
///
/// Whole seconds, for the reason the tool card's duration is: this is redrawn on every frame of a
/// running turn, and a tenths digit there is a number moving ten times a second beside a spinner
/// that is already saying the same thing.
/// The one format for every clock that counts up, tool cards included, so a turn and the call
/// inside it never read in two notations. Whole seconds: this is redrawn every frame, and a tenths
/// digit is a number moving ten times a second beside a bar that already shows motion. Seconds go
/// past an hour, where nobody acts on them.
pub(crate) fn format_elapsed_compact(elapsed: std::time::Duration) -> String {
if elapsed.as_secs() < 60 {
format!("{}s", elapsed.as_secs())
} else {
format!("{}:{:02}", elapsed.as_secs() / 60, elapsed.as_secs() % 60)
let secs = elapsed.as_secs();
match secs {
0..=59 => format!("{secs}s"),
60..=3_599 => format!("{}m {:02}s", secs / 60, secs % 60),
_ => format!("{}h {:02}m", secs / 3_600, (secs % 3_600) / 60),
}
}

View File

@@ -0,0 +1,116 @@
//! Plain — the status line's right-hand facts as words, for a surface that isn't a terminal.
//!
//! The phone app shows what the bar shows, so it takes the bar's own wording from here rather than
//! keeping a copy that could drift: the context reading and its ramp, the cost slot's choice
//! between a plan's allowance and the session's spend, the thinking level's short name. No slabs
//! and no truncation, which are the terminal's problems; glyphs are the Nerd Font marks, which the
//! app's font always has.
use super::segments::{context_text, cost_text};
use super::{context_percent, thinking_label};
use crate::glyphs::{GlyphTier, Icon};
use crate::theme::styles::ContextFill;
use luxe_core::provider::{PlanUsage, ThinkingLevel};
use luxe_core::usage::SessionUsage;
use luxe_core::ModelRef;
/// What a session last reported, each part absent until its event arrives.
#[derive(Debug, Default, Clone, Copy)]
pub struct Facts<'a> {
/// The model answering, from `state_changed`
pub model: Option<&'a ModelRef>,
/// Its thinking level, from `state_changed`
pub thinking: Option<ThinkingLevel>,
/// Tokens in the window and the window's size, from `context_usage`
pub context: Option<(u32, u32)>,
/// A subscription's allowance, from `plan_usage`
pub plan: Option<&'a PlanUsage>,
/// The session's spend, from `session_usage`
pub session: Option<&'a SessionUsage>,
}
/// One fact as the bar words it.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Segment {
/// Which fact this is
pub kind: Kind,
/// The mark in front of it, if the bar draws one
pub glyph: Option<&'static str>,
/// The words
pub label: String,
/// How loudly to color it
pub tone: Tone,
}
/// The facts, in the bar's order.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Kind {
/// How full the context window is
Context,
/// A plan's allowance or the session's spend
Cost,
/// The thinking level
Thinking,
/// The model
Model,
}
/// How loudly a segment is colored.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Tone {
/// Body text
Plain,
/// The theme's warning color
Warning,
/// The theme's error color
Error,
}
/// The facts the session has reported, worded and ordered as the bar's right-hand side.
pub fn segments(facts: &Facts<'_>) -> Vec<Segment> {
[context(facts), cost(facts), thinking(facts), model(facts)].into_iter().flatten().collect()
}
fn context(facts: &Facts<'_>) -> Option<Segment> {
let (used, window) = facts.context.filter(|(_, window)| *window > 0)?;
let percent = context_percent(used, window);
let tone = match ContextFill::at(percent) {
ContextFill::Roomy => Tone::Plain,
ContextFill::Filling => Tone::Warning,
ContextFill::Full => Tone::Error,
};
Some(Segment {
kind: Kind::Context,
glyph: Some(Icon::Context.at(GlyphTier::Nerd)),
label: context_text(percent, window),
tone,
})
}
fn cost(facts: &Facts<'_>) -> Option<Segment> {
let label = cost_text(facts.plan, facts.session.unwrap_or(&SessionUsage::default()))?;
Some(Segment { kind: Kind::Cost, glyph: None, label, tone: Tone::Plain })
}
fn thinking(facts: &Facts<'_>) -> Option<Segment> {
let level = facts.thinking?;
facts.model.filter(|model| !model.model.is_empty())?;
Some(Segment {
kind: Kind::Thinking,
glyph: Some(Icon::Thinking.at(GlyphTier::Nerd)),
label: thinking_label(&level).to_string(),
tone: Tone::Plain,
})
}
// Always there, as on the bar: with no model, saying so explains a refused turn
fn model(facts: &Facts<'_>) -> Option<Segment> {
let (label, tone) = match facts.model.filter(|model| !model.model.is_empty()) {
Some(model) => (model.display().to_string(), Tone::Plain),
None => ("no model".to_string(), Tone::Warning),
};
Some(Segment { kind: Kind::Model, glyph: Some(Icon::Model.at(GlyphTier::Nerd)), label, tone })
}
#[cfg(test)]
mod tests;

View File

@@ -0,0 +1,89 @@
use super::*;
use luxe_core::usage::UsageTotals;
/// `state_changed`, `plan_usage` and `session_usage` as a Copilot session sent them over the
/// bridge, so the shapes the phone forwards are the ones these words are made from.
const MODEL: &str = r#"{"provider":"github-copilot","model":"claude-haiku-4.5","display_name":"Claude Haiku 4.5 (latest)"}"#;
const PLAN: &str = r#"{"plan":"individual","primary":{"used_percent":22.3,"window_minutes":43200,"resets_in_secs":1106993}}"#;
const SESSION: &str = r#"{"total":{"calls":14,"prompt_tokens":122790,"completion_tokens":2212,"cache_read_tokens":103435,"cache_write_tokens":19237,"reasoning_tokens":888,"cost_usd":0.0,"unpriced_calls":0,"plan_usd":0.04556775,"plan_calls":14},"by_source":[]}"#;
fn parse<T: serde::de::DeserializeOwned>(json: &str) -> T {
serde_json::from_str(json).expect("a literal copied from a real frame parses")
}
fn words(facts: &Facts<'_>) -> Vec<(Kind, String)> {
segments(facts).into_iter().map(|segment| (segment.kind, segment.label)).collect()
}
fn spent(cost_usd: f64) -> SessionUsage {
SessionUsage::single(
luxe_core::usage::UsageSource::Agent,
UsageTotals { calls: 1, cost_usd, ..UsageTotals::default() },
)
}
/// The break this catches: the phone's wording or order drifting from the bar's, which says
/// `4.8%/200k`, the plan's share, `high` and the model, in that order.
#[test]
fn every_fact_reads_as_the_bar_words_it() {
let (model, plan, session) = (parse(MODEL), parse(PLAN), parse(SESSION));
let facts = Facts {
model: Some(&model),
thinking: Some(ThinkingLevel::High),
context: Some((9613, 200_000)),
plan: Some(&plan),
session: Some(&session),
};
let expected = [
(Kind::Context, "4.8%/200k"),
(Kind::Cost, "22% monthly"),
(Kind::Thinking, "high"),
(Kind::Model, "Claude Haiku 4.5 (latest)"),
];
let expected: Vec<_> = expected.into_iter().map(|(kind, label)| (kind, label.into())).collect();
assert_eq!(words(&facts), expected);
}
/// The break this catches: the phone coloring a window at a different mark than the bar's ramp.
#[test]
fn the_context_reading_colors_on_the_bars_ramp() {
let tone = |used| {
let facts = Facts { context: Some((used, 1000)), ..Facts::default() };
segments(&facts)[0].tone
};
assert_eq!([tone(749), tone(750), tone(900)], [Tone::Plain, Tone::Warning, Tone::Error]);
}
/// The break this catches: a dollar figure shown in the slot a plan's allowance owns, spend
/// dropped when there's no plan, plan-billed calls with no allowance reading shown as nothing
/// rather than what they were worth, or `$0.00` claimed before anything was priced.
#[test]
fn the_cost_slot_prefers_the_plan_then_the_spend_then_nothing() {
let (plan, session, covered) = (parse::<PlanUsage>(PLAN), spent(0.44), parse(SESSION));
let cost = |plan, session| {
let facts = Facts { plan, session, ..Facts::default() };
segments(&facts).into_iter().find(|segment| segment.kind == Kind::Cost).map(|s| s.label)
};
assert_eq!(cost(Some(&plan), Some(&session)).as_deref(), Some("22% monthly"));
assert_eq!(cost(None, Some(&session)).as_deref(), Some("$0.44"));
assert_eq!(cost(None, Some(&covered)).as_deref(), Some("≈$0.05"));
assert_eq!(cost(None, None), None);
}
/// The break this catches: a session with no model left without a word, when saying so is what
/// explains a refused turn; or a thinking level shown for a model that isn't there.
#[test]
fn no_model_says_so_and_drops_the_thinking_level() {
let facts = Facts { thinking: Some(ThinkingLevel::High), ..Facts::default() };
let all = segments(&facts);
assert_eq!(all.len(), 1, "{all:?}");
assert_eq!((all[0].label.as_str(), all[0].tone), ("no model", Tone::Warning));
}
/// The break this catches: an empty window (a provider that doesn't say its size) read as a
/// division by zero, which prints `NaN%` or `inf%`.
#[test]
fn a_window_of_unknown_size_shows_no_reading() {
let facts = Facts { context: Some((10, 0)), ..Facts::default() };
assert!(segments(&facts).iter().all(|segment| segment.kind != Kind::Context));
}

View File

@@ -9,6 +9,8 @@ use crate::app::App;
use crate::glyphs::Icon;
use crate::widgets::truncate_end as truncate_to_width;
use luxe_core::config::StatuslineModule;
use luxe_core::provider::PlanUsage;
use luxe_core::usage::SessionUsage;
/// Builds the left cluster from the configured (or default) module list.
///
@@ -282,12 +284,7 @@ pub(super) fn right_segments(app: &App, palette: Palette) -> Vec<Segment> {
fn right_segment(module: StatuslineModule, app: &App, palette: Palette) -> Option<Segment> {
match module {
StatuslineModule::Cost => {
// On a subscription the binding constraint is the plan's allowance, not a dollar figure
// nobody is being charged — so that takes the slot when the provider reports it.
let label = match app.status.plan_compact() {
Some(plan) => plan,
None => app.status.session_cost_label()?,
};
let label = cost_text(app.status.plan_usage.as_ref(), &app.status.session)?;
Some(segment(SegmentKind::Cost, None, label, Ink::Neutral))
}
StatuslineModule::Tokens
@@ -325,11 +322,7 @@ fn right_segment(module: StatuslineModule, app: &App, palette: Palette) -> Optio
Some(segment(
SegmentKind::Context,
Some((Icon::Context.glyph(), ink)),
format!(
"{:.1}%/{}",
app.status.context_pct,
compact_number(u64::from(app.status.context_window))
),
context_text(app.status.context_pct, app.status.context_window),
ink,
))
}
@@ -363,3 +356,16 @@ fn right_segment(module: StatuslineModule, app: &App, palette: Palette) -> Optio
_ => None,
}
}
/// The cost slot's words. On a subscription the binding constraint is the plan's allowance, not a
/// dollar figure nobody is being charged, so that takes the slot when the provider reports it.
pub(super) fn cost_text(plan: Option<&PlanUsage>, session: &SessionUsage) -> Option<String> {
plan.and_then(PlanUsage::compact)
.or_else(|| session.total.cost_label())
.or_else(|| session.total.plan_label())
}
/// The context reading: `4.8%/200k`.
pub(super) fn context_text(percent: f32, window: u32) -> String {
format!("{percent:.1}%/{}", compact_number(u64::from(window)))
}