Repository navigation
feat(templates): add project_codebase preset (#164) - #175
Conversation
Horizontal bars now default to bar_gap=0 so rows pack tight (the previous default of 1 left blank rows between bars in narrow horizontal-bar slots). Vertical bars keep bar_gap=1 so labels under each bar stay legible. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… visible Previously the label column was sized to the widest label, leaving dead space on the right when the cell was wider, and clipping the value column when long labels pushed total content past the cell edge. Now the label column always fills the available width, padding short labels so the value sits flush right and truncating overlong labels with `…` so the value column never gets cut off. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #175 +/- ##
==========================================
+ Coverage 78.72% 78.95% +0.23%
==========================================
Files 132 132
Lines 26526 26554 +28
==========================================
+ Hits 20883 20967 +84
+ Misses 5643 5587 -56
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/render/grid_table.rs (1)
40-46:⚠️ Potential issue | 🟡 MinorSchema default is out of sync with the new code default.
The
column_alignschema still advertisesdefault: Some("[\"left\", \"left\"]"), butcolumn_alignments(Line 174) now defaults the value column toRight. This metadata feeds the docs/help generation, so users will read a stale default.📝 Proposed fix
OptionSchema { name: "column_align", type_hint: "array of \"left\" | \"center\" | \"right\"", required: false, - default: Some("[\"left\", \"left\"]"), + default: Some("[\"left\", \"right\"]"), description: "Per-column alignment. First entry aligns the key column, second the value column. Ignored in `inline` layout.", },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/render/grid_table.rs` around lines 40 - 46, Update the OptionSchema entry for "column_align" so its documented default matches the runtime default used by column_alignments (which sets the value column to Right); specifically change the schema default from ["left","left"] to ["left","right"] (or the equivalent string literal currently used for defaults) in the OptionSchema definition so docs/help reflect the actual behavior of column_alignments.
🧹 Nitpick comments (2)
src/render/list_ranking.rs (2)
197-217: Add a unit test forfit_label's truncate/pad branches.
fit_labelis a new helper with three distinct branches (empty width, fits-and-pads, truncates-with-…) and the corresponding behavior changes (truncation with…replaced the previous "keep full + right-pad") aren't directly exercised by the existing tests —value_column_right_aligns_across_rowsonly covers stretching with values that fit. A small direct test would lock the contract in and catch regressions cheaply.🧪 Suggested test
#[test] fn fit_label_pads_and_truncates() { assert_eq!(fit_label("abc", 0), ""); assert_eq!(fit_label("abc", 5), "abc "); assert_eq!(fit_label("abcdef", 4), "abc…"); assert_eq!(fit_label("abcdef", 1), "…"); }It would also be worth adding one buffer-level test that asserts a label longer than the available label column actually ends in
…(usingrender_to_buffer_with_specon a narrow area), to cover the stretching-then-truncation interaction inrender_ranking.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/render/list_ranking.rs` around lines 197 - 217, Add unit tests that exercise fit_label's three branches: width==0, fits-and-pads, and truncates-with-ellipsis. Specifically, add a test calling fit_label("abc", 0) expecting "", fit_label("abc", 5) expecting "abc ", fit_label("abcdef", 4) expecting "abc…", and fit_label("abcdef", 1) expecting "…". Also add one higher-level buffer test that renders a narrow area via render_to_buffer_with_spec / render_ranking and asserts that a label longer than the label column ends with '…' to cover the interaction between stretching and truncation.
95-110: Minor: deduplicate theprefix_partcalculation.The
if widths.prefix > 0 { widths.prefix + 1 } else { 0 }branch here is identical to the one insideWidths::total()(line 155). Extracting a smallprefix_part()method onWidthskeeps the two sites in lockstep if the prefix-spacing rule ever changes.♻️ Proposed refactor
impl Widths { + fn prefix_part(self) -> usize { + if self.prefix > 0 { self.prefix + 1 } else { 0 } + } fn total(self) -> usize { - let prefix_part = if self.prefix > 0 { self.prefix + 1 } else { 0 }; - prefix_part + self.label + COLUMN_GAP.len() + self.value + self.prefix_part() + self.label + COLUMN_GAP.len() + self.value } }let target = align_rect(area, widths.total() as u16, opts.align.as_deref()); - let prefix_part = if widths.prefix > 0 { - widths.prefix + 1 - } else { - 0 - }; - let fixed = prefix_part + COLUMN_GAP.len() + widths.value; + let fixed = widths.prefix_part() + COLUMN_GAP.len() + widths.value; let label_width = (target.width as usize).saturating_sub(fixed);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/render/list_ranking.rs` around lines 95 - 110, The duplicate logic computing prefix spacing (currently inline as if widths.prefix > 0 { widths.prefix + 1 } else { 0 }) should be moved into a dedicated Widths::prefix_part() method and both call sites updated to use widths.prefix_part(); update the Widths impl to return 0 when prefix is 0 and prefix + 1 otherwise, replace the inline `prefix_part` local in list_ranking.rs with a call to widths.prefix_part(), and modify Widths::total() (and any other uses) to call that new method so the rule is centralized.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs-site/src/content/docs/guides/presets.mdx`:
- Around line 200-224: The docs for the project_codebase preset are inaccurate
compared to src/templates/project_codebase.toml: update the intro paragraph and
the implementation table in docs-site/src/content/docs/guides/presets.mdx to
exactly reflect the TOML header comment/widget list (use the actual widget names
and mappings such as name → git_repo_name → text_ascii (style=blocks, quadrant),
loc_by_lang → code_loc → list_ranking, loc_total → code_loc → text_plain,
files_by_dir → code_files → list_ranking, churn → git_churn → list_ranking
(bars), largest_files → code_largest_files → list_ranking (bars), todos →
code_todos → list_plain, plus the three missing widgets age_breakdown,
comment_density, todo_hotspots with their correct widget/type mappings); replace
the erroneous rows (hero, languages, LOC, files, commits, contributors, churn,
largest files, TODOs) and rewrite the prose at the top to describe the actual
TOML layout rather than the GitHub-style layout.
In `@src/templates/mod.rs`:
- Around line 76-81: The Template entry named "project_codebase" has a
misleading description string; update the description field in the Template
struct for name "project_codebase" to match the actual project_codebase.toml
content (as noted in the TOML header) — state it's local-only, uses an ASCII
repo-name hero (text_ascii from git_repo_name) rather than a language logo,
includes repo age, LOC summary and LOC ranking (no LOC grid_table), file map,
largest files / TODOs, and explicitly excludes commit heatmap and
git_contributors widgets so the install-time picker accurately reflects the
implemented widgets.
---
Outside diff comments:
In `@src/render/grid_table.rs`:
- Around line 40-46: Update the OptionSchema entry for "column_align" so its
documented default matches the runtime default used by column_alignments (which
sets the value column to Right); specifically change the schema default from
["left","left"] to ["left","right"] (or the equivalent string literal currently
used for defaults) in the OptionSchema definition so docs/help reflect the
actual behavior of column_alignments.
---
Nitpick comments:
In `@src/render/list_ranking.rs`:
- Around line 197-217: Add unit tests that exercise fit_label's three branches:
width==0, fits-and-pads, and truncates-with-ellipsis. Specifically, add a test
calling fit_label("abc", 0) expecting "", fit_label("abc", 5) expecting "abc ",
fit_label("abcdef", 4) expecting "abc…", and fit_label("abcdef", 1) expecting
"…". Also add one higher-level buffer test that renders a narrow area via
render_to_buffer_with_spec / render_ranking and asserts that a label longer than
the label column ends with '…' to cover the interaction between stretching and
truncation.
- Around line 95-110: The duplicate logic computing prefix spacing (currently
inline as if widths.prefix > 0 { widths.prefix + 1 } else { 0 }) should be moved
into a dedicated Widths::prefix_part() method and both call sites updated to use
widths.prefix_part(); update the Widths impl to return 0 when prefix is 0 and
prefix + 1 otherwise, replace the inline `prefix_part` local in list_ranking.rs
with a call to widths.prefix_part(), and modify Widths::total() (and any other
uses) to call that new method so the rule is centralized.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: df8ffa8d-7fb3-45ce-a723-9cdbaf3b05f4
📒 Files selected for processing (9)
docs-site/src/content/docs/guides/getting-started.mddocs-site/src/content/docs/guides/presets.mdxdocs-site/src/content/docs/showcases.mdsrc/render/chart_bar.rssrc/render/grid_table.rssrc/render/list_ranking.rssrc/templates/mod.rssrc/templates/project_codebase.tomlxtask/src/main.rs
…values Previously the two columns were locked at 40% / 60% of the cell, which truncated long keys (e.g. `first_commit_date`) on narrow tiles and left the value column padded with dead space on its right. Now the key column takes only as many cells as the widest key needs, the value column fills the rest, and values default to right-aligned so they sit flush against the cell edge. `column_align = ["left", "left"]` restores the old default when needed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Code analytics dashboard for the project context — a frame layout with the project title figlet at the centre, surrounded by analytics tiles: LOC by language, project age breakdown, comment density (top); files by dir + largest files flanking the title; most-churned files, TODO comment list, TODO hotspots (bottom). All widgets are local-only / Safety::Safe so the preset works offline with no auth. Tracks #164. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds the new preset to the docs-site Presets gallery (rendered HTML snapshot via cargo xtask), the install-time getting-started flag reference, and the showcases pending-screenshots list. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
f7b8c2a to
201153e
Compare
The Presets page table reflected the original draft (logo hero, commits heatmap, contributors panel) which was scrapped during the PR; update it to match the shipped frame layout (title figlet flanked by files-by-dir / largest-files, surrounded by LOC / age / comment-density tiles on top and churn / TODO / TODO-hotspots on the bottom). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sync the install-time picker description with the shipped frame layout (figlet centre flanked by files-by-dir / largest-files; LOC / age / comment-density tiles above; churn / TODO list / TODO hotspots below) instead of the original draft (logo hero, commits heatmap, contributors). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/render/grid_table.rs (1)
40-46:⚠️ Potential issue | 🟠 Major
column_alignschema default is now stale.The
defaultshown forcolumn_alignstill advertises["left", "left"], butcolumn_alignments(line 171) now defaults the value column toRight. SinceOPTION_SCHEMASpowers--describe/docs output, users will see a default that contradicts actual behavior.📝 Proposed fix
OptionSchema { name: "column_align", type_hint: "array of \"left\" | \"center\" | \"right\"", required: false, - default: Some("[\"left\", \"left\"]"), - description: "Per-column alignment. First entry aligns the key column, second the value column. Ignored in `inline` layout.", + default: Some("[\"left\", \"right\"]"), + description: "Per-column alignment. First entry aligns the key column, second the value column (defaulted right so values sit flush against the cell's right edge). Ignored in `inline` layout.", },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/render/grid_table.rs` around lines 40 - 46, The OptionSchema entry for "column_align" has an outdated default string ("[\"left\", \"left\"]"); update its default to match the actual runtime default used by column_alignments (i.e. set default to "[\"left\", \"right\"]") so OPTION_SCHEMAS/--describe output reflects the true behavior; locate the OptionSchema block with name "column_align" and change the default Some("[\"left\", \"left\"]") to Some("[\"left\", \"right\"]").
🧹 Nitpick comments (2)
src/templates/project_codebase.toml (1)
65-96: Consider explicitlimiton the unboundedlist_rankingwidgets.
files_by_dir,largest_files,churn, andtodo_hotspotsomitoptions = { limit = ... }while their sibling tiles (loc_by_lang,comment_density) cap at 4. The side panels render into 3 content rows (title row, height 4 + top border) and the bottom row gives 7 (height 8 + top border), so the visible cap is set entirely by the renderer default — fine if that default is stable, but an explicitlimithere would make the rendered count obvious from the TOML and immune to default changes. Optional.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/templates/project_codebase.toml` around lines 65 - 96, Add explicit options = { limit = ... } to the unbounded list_ranking widgets so the TOML declares how many items will render: set options = { limit = 4 } for widget ids "files_by_dir", "largest_files", and "todo_hotspots" (matching the side-panel cap used by "loc_by_lang" and "comment_density"), and set options = { limit = 7 } for the bottom-strip widget id "churn" so the visible counts are explicit and not dependent on renderer defaults.src/render/grid_table.rs (1)
104-111: Key column width uses.chars().count(), not display width.For ASCII keys this is fine, but CJK / wide-glyph / emoji keys will under-allocate the column and cause value alignment issues. The codebase deliberately avoids the
unicode-widthcrate; if this is addressed, consider the pattern used inlist_ranking.rs::display_width()which provides context-specific width handling without pulling in a dependency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/render/grid_table.rs` around lines 104 - 111, The key column width calculation in grid_table.rs currently uses e.key.chars().count() which underestimates display width for CJK/emoji; replace that length computation with the project’s display-width helper logic (see list_ranking.rs::display_width()) or copy its context-aware routine to compute display width for each e.key, then take the max and clamp to area.width (preserving the existing unwrap_or/min logic); update the variable referenced as key_width and keep widths = [Constraint::Length(key_width as u16), Constraint::Fill(1)] unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/templates/project_codebase.toml`:
- Around line 137-160: Update the header comment to reflect actual visible entry
count: because [[row]] has height = { length = 4 } and the side children
files_by_dir and largest_files use border = "top", those side panels only render
3 content rows (not 4) while the center name widget renders 4; change the
comment from "show their top 4 entries" to "show their top 3 entries" and/or
otherwise clarify that bordered side panels lose one row due to the top border
(referencing the [[row]] block, height = { length = 4 }, and the child widgets
files_by_dir and largest_files).
---
Outside diff comments:
In `@src/render/grid_table.rs`:
- Around line 40-46: The OptionSchema entry for "column_align" has an outdated
default string ("[\"left\", \"left\"]"); update its default to match the actual
runtime default used by column_alignments (i.e. set default to "[\"left\",
\"right\"]") so OPTION_SCHEMAS/--describe output reflects the true behavior;
locate the OptionSchema block with name "column_align" and change the default
Some("[\"left\", \"left\"]") to Some("[\"left\", \"right\"]").
---
Nitpick comments:
In `@src/render/grid_table.rs`:
- Around line 104-111: The key column width calculation in grid_table.rs
currently uses e.key.chars().count() which underestimates display width for
CJK/emoji; replace that length computation with the project’s display-width
helper logic (see list_ranking.rs::display_width()) or copy its context-aware
routine to compute display width for each e.key, then take the max and clamp to
area.width (preserving the existing unwrap_or/min logic); update the variable
referenced as key_width and keep widths = [Constraint::Length(key_width as u16),
Constraint::Fill(1)] unchanged.
In `@src/templates/project_codebase.toml`:
- Around line 65-96: Add explicit options = { limit = ... } to the unbounded
list_ranking widgets so the TOML declares how many items will render: set
options = { limit = 4 } for widget ids "files_by_dir", "largest_files", and
"todo_hotspots" (matching the side-panel cap used by "loc_by_lang" and
"comment_density"), and set options = { limit = 7 } for the bottom-strip widget
id "churn" so the visible counts are explicit and not dependent on renderer
defaults.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8c5d4cfd-3b7d-4bf7-9104-52b9e61fcd9f
📒 Files selected for processing (7)
docs-site/src/content/docs/guides/getting-started.mddocs-site/src/content/docs/guides/presets.mdxdocs-site/src/content/docs/showcases.mdsrc/render/grid_table.rssrc/templates/mod.rssrc/templates/project_codebase.tomlxtask/src/main.rs
✅ Files skipped from review due to trivial changes (2)
- xtask/src/main.rs
- docs-site/src/content/docs/showcases.md
🚧 Files skipped from review as they are similar to previous changes (1)
- src/templates/mod.rs
Summary
project_codebasepreset — a code-analytics dashboard for the per-project slot, framing the project title figlet with surrounding tiles (LOC by language, project age, comment density on top; files by dir / largest files flanking the title; most-churned, TODO comments list, TODO hotspots on the bottom). All widgets areSafety::Safe(local git2 / file scans, no network, no auth).chart_barexposes a newbar_gapoption and defaults horizontal bars tobar_gap = 0so rows pack tight (the previous default of 1 left blank rows between bars in narrow horizontal-bar slots).list_rankingstretches the label column to the cell width, padding short labels so the value sits flush against the right edge and truncating overlong labels with…so the value column never gets clipped.grid_tablesizes the key column to the widest key, fills the remaining width with the value column, and right-aligns values by default. Long keys (e.g.first_commit_date) no longer get truncated and value cells no longer leave dead space on the right.TEMPLATES(auto-picked up by the install-time picker in feat: "splashboard install" — one-shot setup (rc wiring + starter config from template) #58) and lists it in the docs-site Presets / Showcases / Getting started guides.Tracks #164.
Test plan
cargo test— 1024 lib tests passing, including the fourtemplates::tests(parse / fetcher-known / renderer-known / renders-without-panic).cargo clippy --all-targets -- -D warningsclean.cargo fmt --all -- --checkclean.cargo runsmoke-render in a real repo (splashboard's own tree) — title + figlet + tiles render correctly with values flush right; long file paths in the side panels truncate with…instead of dropping the count.cargo xtaskregeneratesdocs-site/src/assets/rendered/project_codebase.htmlwith the rest of the preset gallery.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements
Documentation