Repository navigation
Conversation
Reviewer's GuideAPIExtend template rendering with a resolver for inline fields that can produce styled pieces, while preserving the existing renderer as a no-extra-fields wrapper.
ImplementationAdd elapsed-bar resolution to widget rendering and factor shared bar drawing into a helper so the inline bar uses the configured glyphs and tier.
Register elapsed_bar as a supported field for quota windows and the spend window without changing built-in templates.
DocumentationDocument the elapsed-bar placeholder, its configurable cell count, and how it behaves when reset time is unavailable.
TestsVerify elapsed-bar rendering, missing and invalid fields, glyph variants, quota-field registration, and unchanged default templates.
Test that template rendering resolves extra styled fields and omits groups when a field is unavailable.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/metrics/usage.rs" line_range="452" />
<code_context>
+ let all = metrics();
+ let m5h = all.iter().find(|m| m.meta.id == "quota.5h").unwrap();
+ let m7d = all.iter().find(|m| m.meta.id == "quota.7d").unwrap();
+ assert_eq!(m5h.meta.templates, WINDOW_TEMPLATES);
+ assert!(m5h.meta.fields.contains(&"left_bar"));
+
</code_context>
<issue_to_address>
**Default template changes go unnoticed**
When `WINDOW_TEMPLATES` is changed along with the quota metadata, when `WINDOW_TEMPLATES` changes along with the quota metadata, `quota_windows_render_left_bar_and_keep_default_templates` compares `m5h.meta.templates` to that same production constant and passes, so changed built-in quota output goes undetected.
Compare the metric templates against a literal expected array of the unchanged defaults.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: src/metrics/usage.rs:452
|
Hi @Haleclipse |
What
Adds a
{elapsed_bar}placeholder to the text templates ofquota.5handquota.7d(and the spend window). It draws the share of the window that has already passed as a small bar, so the reset countdown is readable at a glance:{elapsed_bar}draws 5 cells;{elapsed_bar:N}draws N cells (1 to 64).barglyphs and the glyph tier ([==---]in ASCII), so there is no second bar system.[ … ]group drops it. An invalid count (0,65,abc) also renders as empty.Example:
How
template::render_withtakes a resolver for inline fields that render as styled pieces instead of plain text.widgets::renderresolveselapsed_bar/elapsed_bar:NfromReading::elapsed, through abar_cellshelper split out ofbar().Checks
cargo fmt -- --check,cargo clippy --all-targets -- -D warnings: clean.cargo test: 205 unit + 2 snapshot tests pass. New tests cover 0%, 60% and 100% elapsed, a missing reset time, custom and invalid cell counts, ASCII and eighths glyphs, and that the default quota templates still equal the literal built-in strings.Summary by Sourcery
Add opt-in elapsed-time bars to quota window templates without changing existing default output.
New Features:
{elapsed_bar}and{elapsed_bar:N}placeholders to quota and spend-window templates to visualize elapsed window time.Enhancements:
Documentation:
Tests: