Compare commits
2 Commits
main
...
feat/usage
| Author | SHA1 | Date | |
|---|---|---|---|
|
7f15a1a19f
|
|||
|
408d48783a
|
@@ -9,6 +9,14 @@ The version on `main` is always the next release. The first change to what ships
|
|||||||
`Cargo.toml`, `Cargo.lock`) after a release bumps it one step and opens its section here, and later
|
`Cargo.toml`, `Cargo.lock`) after a release bumps it one step and opens its section here, and later
|
||||||
changes add to that section until it ships; `scripts/version-check.py` holds them to it.
|
changes add to that section until it ships; `scripts/version-check.py` holds them to it.
|
||||||
|
|
||||||
|
## [0.1.7]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- The dock has a **USAGE** section between MODEL and SESSION while a ChatGPT or Copilot plan reports
|
||||||
|
what is left of it. Each window the plan has gets a row with a bar, the share used and, when the
|
||||||
|
provider says, the time until it resets, such as `weekly ▓▓▓░░░░░░░ 30% · 3d 4h`.
|
||||||
|
|
||||||
## [0.1.6]
|
## [0.1.6]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -1690,7 +1690,7 @@ checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-cli"
|
name = "luxe-cli"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -1723,7 +1723,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-core"
|
name = "luxe-core"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base16ct",
|
"base16ct",
|
||||||
@@ -1754,7 +1754,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-dap"
|
name = "luxe-dap"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"luxe-core",
|
"luxe-core",
|
||||||
@@ -1768,7 +1768,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-lsp"
|
name = "luxe-lsp"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base16ct",
|
"base16ct",
|
||||||
@@ -1792,7 +1792,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-mcp"
|
name = "luxe-mcp"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@@ -1812,7 +1812,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-providers"
|
name = "luxe-providers"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64",
|
"base64",
|
||||||
@@ -1831,7 +1831,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-remote"
|
name = "luxe-remote"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"base16ct",
|
"base16ct",
|
||||||
@@ -1854,7 +1854,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-tools"
|
name = "luxe-tools"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -1880,7 +1880,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luxe-tui"
|
name = "luxe-tui"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arboard",
|
"arboard",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ members = ["crates/*"]
|
|||||||
# Every crate here releases together from one workspace, so the versions move in lockstep and each
|
# Every crate here releases together from one workspace, so the versions move in lockstep and each
|
||||||
# crate inherits this one. The internal `path` dependencies carry the same number explicitly — cargo
|
# crate inherits this one. The internal `path` dependencies carry the same number explicitly — cargo
|
||||||
# uses the path locally and the version on crates.io, and refuses to publish a path dep without one.
|
# uses the path locally and the version on crates.io, and refuses to publish a path dep without one.
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/evanwhittaker/luxe"
|
repository = "https://github.com/evanwhittaker/luxe"
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ name = "luxe"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
luxe-core = { path = "../luxe-core", version = "0.1.6" }
|
luxe-core = { path = "../luxe-core", version = "0.1.7" }
|
||||||
luxe-providers = { path = "../luxe-providers", version = "0.1.6" }
|
luxe-providers = { path = "../luxe-providers", version = "0.1.7" }
|
||||||
luxe-tools = { path = "../luxe-tools", version = "0.1.6" }
|
luxe-tools = { path = "../luxe-tools", version = "0.1.7" }
|
||||||
luxe-lsp = { path = "../luxe-lsp", version = "0.1.6" }
|
luxe-lsp = { path = "../luxe-lsp", version = "0.1.7" }
|
||||||
luxe-dap = { path = "../luxe-dap", version = "0.1.6" }
|
luxe-dap = { path = "../luxe-dap", version = "0.1.7" }
|
||||||
luxe-mcp = { path = "../luxe-mcp", version = "0.1.6" }
|
luxe-mcp = { path = "../luxe-mcp", version = "0.1.7" }
|
||||||
luxe-tui = { path = "../luxe-tui", version = "0.1.6" }
|
luxe-tui = { path = "../luxe-tui", version = "0.1.7" }
|
||||||
luxe-remote = { path = "../luxe-remote", version = "0.1.6", optional = true }
|
luxe-remote = { path = "../luxe-remote", version = "0.1.7", optional = true }
|
||||||
# The pairing QR in the terminal. Without its defaults it is the encoder and text renderer alone,
|
# The pairing QR in the terminal. Without its defaults it is the encoder and text renderer alone,
|
||||||
# with no dependencies.
|
# with no dependencies.
|
||||||
qrcode = { version = "0.14", default-features = false, optional = true }
|
qrcode = { version = "0.14", default-features = false, optional = true }
|
||||||
|
|||||||
@@ -2493,6 +2493,7 @@ conversation, or in its place below 80 columns.
|
|||||||
| **FILES** | The project as a tree, with what changed marked in it. Click a file to [preview](#preview) it. |
|
| **FILES** | The project as a tree, with what changed marked in it. Click a file to [preview](#preview) it. |
|
||||||
| **ELSEWHERE** | Files the session changed outside the project, when there are any |
|
| **ELSEWHERE** | Files the session changed outside the project, when there are any |
|
||||||
| **MODEL** | The provider, model, thinking level and [mode](agent.md#plan-then-build). Click the provider or the model to change it, or the mode to switch it. |
|
| **MODEL** | The provider, model, thinking level and [mode](agent.md#plan-then-build). Click the provider or the model to change it, or the mode to switch it. |
|
||||||
|
| **USAGE** | What is left of a ChatGPT or Copilot plan, one row for each window the plan has: a bar, the share used and, when the provider says, the time until it resets. It shows only once the plan has reported, after your first reply, and never on an API key. |
|
||||||
| **SESSION** | Context used, tokens and cost, with what a review and compaction cost on rows of their own. A review's row shows its full cost once its guide or drafted summary is done. While a phone or another client has [joined](remote.md), a **joined** row names it. |
|
| **SESSION** | Context used, tokens and cost, with what a review and compaction cost on rows of their own. A review's row shows its full cost once its guide or drafted summary is done. While a phone or another client has [joined](remote.md), a **joined** row names it. |
|
||||||
|
|
||||||
`alt+d` shows or hides the dock, and `/dock left` or `/dock right` moves it. To set it for good:
|
`alt+d` shows or hides the dock, and `/dock left` or `/dock right` moves it. To set it for good:
|
||||||
@@ -3337,7 +3338,8 @@ Usage on a ChatGPT or Copilot subscription is counted in full but never added to
|
|||||||
`plan ≈$0.42 of usage over 12 calls, covered by your subscription`. On a
|
`plan ≈$0.42 of usage over 12 calls, covered by your subscription`. On a
|
||||||
ChatGPT plan, the statusline shows how much of the plan is used, such as `12% weekly`, and `/cost`
|
ChatGPT plan, the statusline shows how much of the plan is used, such as `12% weekly`, and `/cost`
|
||||||
shows when it resets. On a Copilot plan it shows the month's allowance the same way, such as `19%
|
shows when it resets. On a Copilot plan it shows the month's allowance the same way, such as `19%
|
||||||
monthly`.
|
monthly`. The dock's [USAGE section](interface.md#the-dock) shows the same windows as a bar, with the
|
||||||
|
time until each resets when the provider says.
|
||||||
|
|
||||||
luxe prices Copilot usage at Copilot's per-token rates, so the figure matches what Copilot reports
|
luxe prices Copilot usage at Copilot's per-token rates, so the figure matches what Copilot reports
|
||||||
for each request. A Copilot plan billed by the token spends its monthly allowance at those rates.
|
for each request. A Copilot plan billed by the token spends its monthly allowance at those rates.
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ impl PlanWindow {
|
|||||||
};
|
};
|
||||||
Some(label)
|
Some(label)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A fixed-width meter such as `▓▓▓░░░░░░░`, filled in proportion to the share used.
|
||||||
|
///
|
||||||
|
/// Rounds to the nearest cell so a nearly-full window never reads as empty, and clamps so a
|
||||||
|
/// provider reporting over 100% can't draw past the edge.
|
||||||
|
pub fn bar(&self, cells: usize) -> String {
|
||||||
|
let share = (self.used_percent / 100.0).clamp(0.0, 1.0);
|
||||||
|
let filled = ((share * cells as f32).round() as usize).min(cells);
|
||||||
|
format!("{}{}", "▓".repeat(filled), "░".repeat(cells - filled))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A subscription's remaining headroom, as reported alongside a response.
|
/// A subscription's remaining headroom, as reported alongside a response.
|
||||||
@@ -146,6 +156,18 @@ mod plan_tests {
|
|||||||
assert!(window(0.0, 60, None).reset_label().is_none());
|
assert!(window(0.0, 60, None).reset_label().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_bar_fills_in_proportion_and_never_overflows() {
|
||||||
|
assert_eq!(window(0.0, 60, None).bar(10), "░░░░░░░░░░");
|
||||||
|
assert_eq!(window(50.0, 60, None).bar(10), "▓▓▓▓▓░░░░░");
|
||||||
|
assert_eq!(window(100.0, 60, None).bar(10), "▓▓▓▓▓▓▓▓▓▓");
|
||||||
|
// over-reported and negative values clamp instead of panicking on the subtraction
|
||||||
|
assert_eq!(window(250.0, 60, None).bar(4), "▓▓▓▓");
|
||||||
|
assert_eq!(window(-5.0, 60, None).bar(4), "░░░░");
|
||||||
|
// a window that is nearly spent must not round down to an empty-looking bar
|
||||||
|
assert_eq!(window(96.0, 60, None).bar(10), "▓▓▓▓▓▓▓▓▓▓");
|
||||||
|
}
|
||||||
|
|
||||||
/// The status line has room for one window, and it should be whichever is about to bite.
|
/// The status line has room for one window, and it should be whichever is about to bite.
|
||||||
#[test]
|
#[test]
|
||||||
fn the_tightest_window_wins_the_status_line() {
|
fn the_tightest_window_wins_the_status_line() {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ homepage.workspace = true
|
|||||||
# Provides a native Debug Adapter Protocol client + the `debug` tool.
|
# Provides a native Debug Adapter Protocol client + the `debug` tool.
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
luxe-core = { path = "../luxe-core", version = "0.1.6" }
|
luxe-core = { path = "../luxe-core", version = "0.1.7" }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ homepage.workspace = true
|
|||||||
# Provides a generic LSP client (rust-analyzer first).
|
# Provides a generic LSP client (rust-analyzer first).
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
luxe-core = { path = "../luxe-core", version = "0.1.6" }
|
luxe-core = { path = "../luxe-core", version = "0.1.7" }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ homepage.workspace = true
|
|||||||
# no-HTTP rule forbids in core itself. The low-level stdio transport stays in luxe-core.
|
# no-HTTP rule forbids in core itself. The low-level stdio transport stays in luxe-core.
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
luxe-core = { path = "../luxe-core", version = "0.1.6" }
|
luxe-core = { path = "../luxe-core", version = "0.1.7" }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ homepage.workspace = true
|
|||||||
# Provides LLM provider adapters (OpenAI-compat, Anthropic, Gemini).
|
# Provides LLM provider adapters (OpenAI-compat, Anthropic, Gemini).
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
luxe-core = { path = "../luxe-core", version = "0.1.6" }
|
luxe-core = { path = "../luxe-core", version = "0.1.7" }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ exclude = ["app-tests/"]
|
|||||||
# reqwest and the workspace's rustls.
|
# reqwest and the workspace's rustls.
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
luxe-core = { path = "../luxe-core", version = "0.1.6" }
|
luxe-core = { path = "../luxe-core", version = "0.1.7" }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ homepage.workspace = true
|
|||||||
# Provides tool implementations (read, write, edit, bash, grep, glob, etc.).
|
# Provides tool implementations (read, write, edit, bash, grep, glob, etc.).
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
luxe-core = { path = "../luxe-core", version = "0.1.6" }
|
luxe-core = { path = "../luxe-core", version = "0.1.7" }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ repository.workspace = true
|
|||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
luxe-core = { path = "../luxe-core", version = "0.1.6" }
|
luxe-core = { path = "../luxe-core", version = "0.1.7" }
|
||||||
# `unstable-rendered-line-info` enables Paragraph::line_count, used for precise wrapping-aware
|
# `unstable-rendered-line-info` enables Paragraph::line_count, used for precise wrapping-aware
|
||||||
# mouse hit-testing over word-wrapped surfaces (guide/dock/conversation clicks). It adds no crate;
|
# mouse hit-testing over word-wrapped surfaces (guide/dock/conversation clicks). It adds no crate;
|
||||||
# the API is marked unstable upstream but is stable within our pinned minor (re-check on upgrade).
|
# the API is marked unstable upstream but is stable within our pinned minor (re-check on upgrade).
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ mod files;
|
|||||||
mod plan;
|
mod plan;
|
||||||
mod telemetry;
|
mod telemetry;
|
||||||
mod tree;
|
mod tree;
|
||||||
|
mod usage;
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::workspace_dock::{DockPresentation, DockSectionModel};
|
use crate::workspace_dock::{DockPresentation, DockSectionModel};
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ pub(super) enum Section {
|
|||||||
Files,
|
Files,
|
||||||
Elsewhere,
|
Elsewhere,
|
||||||
Model,
|
Model,
|
||||||
|
Usage,
|
||||||
Session,
|
Session,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ impl Section {
|
|||||||
Self::Files => "FILES",
|
Self::Files => "FILES",
|
||||||
Self::Elsewhere => "ELSEWHERE",
|
Self::Elsewhere => "ELSEWHERE",
|
||||||
Self::Model => "MODEL",
|
Self::Model => "MODEL",
|
||||||
|
Self::Usage => "USAGE",
|
||||||
Self::Session => "SESSION",
|
Self::Session => "SESSION",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +96,7 @@ impl Section {
|
|||||||
match self {
|
match self {
|
||||||
Self::Project | Self::Model => Depth::Hero,
|
Self::Project | Self::Model => Depth::Hero,
|
||||||
Self::Plan | Self::Files => Depth::Raised,
|
Self::Plan | Self::Files => Depth::Raised,
|
||||||
Self::Elsewhere | Self::Session => Depth::Recessed,
|
Self::Elsewhere | Self::Usage | Self::Session => Depth::Recessed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ pub(super) fn telemetry_lines(app: &App) -> Vec<Line<'static>> {
|
|||||||
let row = row_width(app);
|
let row = row_width(app);
|
||||||
let column = telemetry_label_width(row, WIDEST_TELEMETRY_LABEL);
|
let column = telemetry_label_width(row, WIDEST_TELEMETRY_LABEL);
|
||||||
let mut lines = model_telemetry(app, row, column);
|
let mut lines = model_telemetry(app, row, column);
|
||||||
|
lines.extend(super::usage::usage_telemetry(app, column));
|
||||||
lines.extend(session_telemetry(app, row, column));
|
lines.extend(session_telemetry(app, row, column));
|
||||||
lines
|
lines
|
||||||
}
|
}
|
||||||
@@ -386,7 +387,7 @@ fn review_spending(app: &App) -> bool {
|
|||||||
///
|
///
|
||||||
/// `ink` is body text for a measurement, dim for a share of one above it, and the severity hue for
|
/// `ink` is body text for a measurement, dim for a share of one above it, and the severity hue for
|
||||||
/// the window, which is the one value that is also a warning.
|
/// the window, which is the one value that is also a warning.
|
||||||
fn telemetry_row(
|
pub(super) fn telemetry_row(
|
||||||
label: &str,
|
label: &str,
|
||||||
value: String,
|
value: String,
|
||||||
ink: ratatui::style::Style,
|
ink: ratatui::style::Style,
|
||||||
|
|||||||
@@ -38,6 +38,42 @@ fn the_rail_reports_a_session_that_is_approving_its_own_asks() {
|
|||||||
assert!(row.contains("auto-approve"), "{row}");
|
assert!(row.contains("auto-approve"), "{row}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An API-key provider reports no allowance, and a USAGE heading over nothing would be noise.
|
||||||
|
#[test]
|
||||||
|
fn the_rail_has_no_usage_block_without_a_plan() {
|
||||||
|
let mut app = app();
|
||||||
|
app.status.model = "claude-sonnet-5".into();
|
||||||
|
let rendered: Vec<String> = telemetry_lines(&app).iter().map(text).collect();
|
||||||
|
assert!(!rendered.iter().any(|row| row.contains("USAGE")), "{rendered:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The point of the block: the share spent and the time left, one row per window the plan has.
|
||||||
|
#[test]
|
||||||
|
fn the_rail_shows_each_plan_window_with_its_meter_and_reset() {
|
||||||
|
use luxe_core::provider::{PlanUsage, PlanWindow};
|
||||||
|
let mut app = app();
|
||||||
|
app.status.model = "gpt-5".into();
|
||||||
|
app.status.plan_usage = Some(PlanUsage {
|
||||||
|
primary: Some(PlanWindow {
|
||||||
|
used_percent: 30.0,
|
||||||
|
window_minutes: 10_080,
|
||||||
|
resets_in_secs: Some(274_000),
|
||||||
|
}),
|
||||||
|
secondary: Some(PlanWindow {
|
||||||
|
used_percent: 80.0,
|
||||||
|
window_minutes: 300,
|
||||||
|
resets_in_secs: Some(1_800),
|
||||||
|
}),
|
||||||
|
..PlanUsage::default()
|
||||||
|
});
|
||||||
|
let rendered: Vec<String> = telemetry_lines(&app).iter().map(text).collect();
|
||||||
|
assert!(rendered.iter().any(|row| row.contains("USAGE")), "{rendered:?}");
|
||||||
|
let weekly = rendered.iter().find(|row| row.starts_with("weekly")).expect("weekly row");
|
||||||
|
assert!(weekly.contains("▓▓▓░░░░░░░ 30% · 3d 4h"), "{weekly}");
|
||||||
|
let short = rendered.iter().find(|row| row.starts_with("5h")).expect("5h row");
|
||||||
|
assert!(short.contains("▓▓▓▓▓▓▓▓░░ 80% · 30m"), "{short}");
|
||||||
|
}
|
||||||
|
|
||||||
/// The surface behind the span carrying `needle` — the slab the badge is cut from.
|
/// The surface behind the span carrying `needle` — the slab the badge is cut from.
|
||||||
pub(super) fn surface_behind(line: &Line<'_>, needle: &str) -> Color {
|
pub(super) fn surface_behind(line: &Line<'_>, needle: &str) -> Color {
|
||||||
line.spans
|
line.spans
|
||||||
@@ -65,7 +101,7 @@ fn the_rail_is_anchored_at_both_ends_and_recedes_between_them() {
|
|||||||
for live in [Section::Plan, Section::Files] {
|
for live in [Section::Plan, Section::Files] {
|
||||||
assert_eq!(surface(live), shades.at(Depth::Raised), "{live:?} is one step back");
|
assert_eq!(surface(live), shades.at(Depth::Raised), "{live:?} is one step back");
|
||||||
}
|
}
|
||||||
for ambient in [Section::Elsewhere, Section::Session] {
|
for ambient in [Section::Elsewhere, Section::Usage, Section::Session] {
|
||||||
assert_eq!(surface(ambient), shades.at(Depth::Recessed), "{ambient:?} is two");
|
assert_eq!(surface(ambient), shades.at(Depth::Recessed), "{ambient:?} is two");
|
||||||
}
|
}
|
||||||
// Or every assertion above passes on a theme with no ramp at all.
|
// Or every assertion above passes on a theme with no ramp at all.
|
||||||
|
|||||||
63
crates/luxe-tui/src/view/dock/usage.rs
Normal file
63
crates/luxe-tui/src/view/dock/usage.rs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
//! Dock usage — the USAGE block: how much of a subscription plan is spent, and when it resets.
|
||||||
|
|
||||||
|
use super::chrome::{section_heading_line, Section};
|
||||||
|
use super::telemetry::telemetry_row;
|
||||||
|
use crate::app::App;
|
||||||
|
use luxe_core::provider::PlanWindow;
|
||||||
|
use ratatui::text::Line;
|
||||||
|
|
||||||
|
/// Cells in the meter: ten reads in tenths, and leaves the percentage and countdown room beside it
|
||||||
|
/// on the default rail.
|
||||||
|
const BAR_CELLS: usize = 10;
|
||||||
|
|
||||||
|
/// The USAGE block, drawn only while the provider reports a plan window.
|
||||||
|
///
|
||||||
|
/// An API-key provider reports no allowance, so it gets no block at all rather than an empty one.
|
||||||
|
/// Each window gets its own row: a plan with a 5h and a weekly window is limited by whichever
|
||||||
|
/// fills first, and the reader can't steer by one they can't see.
|
||||||
|
pub(super) fn usage_telemetry(app: &App, column: usize) -> Vec<Line<'static>> {
|
||||||
|
let Some(plan) = app.status.plan_usage.as_ref() else {
|
||||||
|
return Vec::new();
|
||||||
|
};
|
||||||
|
let windows: Vec<&PlanWindow> =
|
||||||
|
[&plan.primary, &plan.secondary].into_iter().flatten().collect();
|
||||||
|
if windows.is_empty() {
|
||||||
|
return Vec::new();
|
||||||
|
}
|
||||||
|
let styles = &app.theme_styles;
|
||||||
|
let mut lines = vec![Line::default(), section_heading_line(Section::Usage, app)];
|
||||||
|
for window in windows {
|
||||||
|
let ink = styles.context_fill(window.used_percent.clamp(0.0, 100.0));
|
||||||
|
lines.push(telemetry_row(&window.window_label(), window_value(window), ink, column, app));
|
||||||
|
}
|
||||||
|
lines
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `▓▓▓░░░░░░░ 32% · 3d 4h`: the meter, the share, and the time left when the provider says.
|
||||||
|
fn window_value(window: &PlanWindow) -> String {
|
||||||
|
let mut value = format!("{} {:.0}%", window.bar(BAR_CELLS), window.used_percent);
|
||||||
|
if let Some(reset) = window.reset_label() {
|
||||||
|
value.push_str(&format!(" · {reset}"));
|
||||||
|
}
|
||||||
|
value
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn window(used: f32, resets: Option<u64>) -> PlanWindow {
|
||||||
|
PlanWindow { used_percent: used, window_minutes: 10_080, resets_in_secs: resets }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_row_shows_meter_share_and_countdown() {
|
||||||
|
assert_eq!(window_value(&window(30.0, Some(274_000))), "▓▓▓░░░░░░░ 30% · 3d 4h");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Copilot reports no reset countdown, and the row must not invent one.
|
||||||
|
#[test]
|
||||||
|
fn a_window_without_a_reset_time_omits_the_countdown() {
|
||||||
|
assert_eq!(window_value(&window(30.0, None)), "▓▓▓░░░░░░░ 30%");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -145,6 +145,7 @@ conversation, or in its place below 80 columns.
|
|||||||
| **FILES** | The project as a tree, with what changed marked in it. Click a file to [preview](#preview) it. |
|
| **FILES** | The project as a tree, with what changed marked in it. Click a file to [preview](#preview) it. |
|
||||||
| **ELSEWHERE** | Files the session changed outside the project, when there are any |
|
| **ELSEWHERE** | Files the session changed outside the project, when there are any |
|
||||||
| **MODEL** | The provider, model, thinking level and [mode](agent.md#plan-then-build). Click the provider or the model to change it, or the mode to switch it. |
|
| **MODEL** | The provider, model, thinking level and [mode](agent.md#plan-then-build). Click the provider or the model to change it, or the mode to switch it. |
|
||||||
|
| **USAGE** | What is left of a ChatGPT or Copilot plan, one row for each window the plan has: a bar, the share used and, when the provider says, the time until it resets. It shows only once the plan has reported, after your first reply, and never on an API key. |
|
||||||
| **SESSION** | Context used, tokens and cost, with what a review and compaction cost on rows of their own. A review's row shows its full cost once its guide or drafted summary is done. While a phone or another client has [joined](remote.md), a **joined** row names it. |
|
| **SESSION** | Context used, tokens and cost, with what a review and compaction cost on rows of their own. A review's row shows its full cost once its guide or drafted summary is done. While a phone or another client has [joined](remote.md), a **joined** row names it. |
|
||||||
|
|
||||||
`alt+d` shows or hides the dock, and `/dock left` or `/dock right` moves it. To set it for good:
|
`alt+d` shows or hides the dock, and `/dock left` or `/dock right` moves it. To set it for good:
|
||||||
|
|||||||
@@ -146,7 +146,8 @@ Usage on a ChatGPT or Copilot subscription is counted in full but never added to
|
|||||||
`plan ≈$0.42 of usage over 12 calls, covered by your subscription`. On a
|
`plan ≈$0.42 of usage over 12 calls, covered by your subscription`. On a
|
||||||
ChatGPT plan, the statusline shows how much of the plan is used, such as `12% weekly`, and `/cost`
|
ChatGPT plan, the statusline shows how much of the plan is used, such as `12% weekly`, and `/cost`
|
||||||
shows when it resets. On a Copilot plan it shows the month's allowance the same way, such as `19%
|
shows when it resets. On a Copilot plan it shows the month's allowance the same way, such as `19%
|
||||||
monthly`.
|
monthly`. The dock's [USAGE section](interface.md#the-dock) shows the same windows as a bar, with the
|
||||||
|
time until each resets when the provider says.
|
||||||
|
|
||||||
luxe prices Copilot usage at Copilot's per-token rates, so the figure matches what Copilot reports
|
luxe prices Copilot usage at Copilot's per-token rates, so the figure matches what Copilot reports
|
||||||
for each request. A Copilot plan billed by the token spends its monthly allowance at those rates.
|
for each request. A Copilot plan billed by the token spends its monthly allowance at those rates.
|
||||||
|
|||||||
Reference in New Issue
Block a user