Skip to content

feat(render): implement 8 render types (#19) - #23

Merged
unhappychoice merged 5 commits into
mainfrom
feat/19-render-types
Apr 21, 2026
Merged

unhappychoice merged 5 commits into
mainfrom
feat/19-render-types

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Apr 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

Middle axis of the 3-axis model. render_payload dispatches each Payload variant to its Ratatui widget inside a bordered Block.

variant widget
text Paragraph
list Table (key/value, status-colored rows)
gauge Gauge (clamped to 0.0–1.0)
sparkline Sparkline
line_chart Chart (auto-bounds)
bar_chart BarChart
bignum tui-big-text BigText
image ratatui-image with sixel / kitty / iTerm2 auto-detection, half-blocks fallback

main.rs now renders through render_payload with a demo Text payload.

Design notes

  • Renderers are closed-set built-ins. Plugins produce Payload data, not their own renderers.
  • Block + title is applied at the dispatch layer (render/mod.rs::build_block), so individual renderers render into inner only.
  • Status color on list rows (Ok=green / Warn=yellow / Error=red) — full theming (feat: Theme / color scheme system #17) will override later.
  • Image uses Picker::from_query_stdio on TTY for sixel / kitty / iTerm2 detection, falls back to half-blocks (Picker::from_fontsize) on detection failure. Non-TTY contexts (CI, tests) skip the stdio query via IsTerminal gate to avoid hangs. Picker cached in a OnceLock so the detection query runs at most once per process. Missing file / decode errors render as [image: ...] text fallback.

Test plan

  • cargo build
  • cargo test (24 passed: 12 payload + 12 render)
  • cargo clippy --all-targets -- -D warnings
  • cargo fmt --check
  • CI (ubuntu / macos / windows × format / clippy / test)

Closes #19.

🤖 Generated with Claude Code

Adds the render layer — the middle of the 3-axis model. Fetchers produce
Payload, layout engine positions it, this module maps each Payload
variant to its concrete Ratatui widget inside a bordered Block with
optional title.

- text      → Paragraph
- list      → Table (key / value, status-colored rows)
- gauge     → Gauge (clamped ratio 0.0-1.0)
- sparkline → Sparkline
- line_chart → Chart (auto-bounds from series points)
- bar_chart → BarChart
- bignum    → tui-big-text BigText
- image     → placeholder ("[image: renderer pending]"); deferred

main.rs now dispatches through render_payload with a demo Text payload
instead of rendering Paragraph directly.

Refs #19

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@unhappychoice has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 29 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 29 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 12fdf98c-07da-428a-a675-24d1534938a2

📥 Commits

Reviewing files that changed from the base of the PR and between 08be159 and 181c57a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • Cargo.toml
  • src/main.rs
  • src/render/bar_chart.rs
  • src/render/bignum.rs
  • src/render/gauge.rs
  • src/render/image.rs
  • src/render/line_chart.rs
  • src/render/list.rs
  • src/render/mod.rs
  • src/render/sparkline.rs
  • src/render/test_utils.rs
  • src/render/text.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/19-render-types

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Completes the 8 render types. Uses ratatui-image 4.x with the
half-blocks protocol (`Picker::from_fontsize`) as the v1 default so
rendering works in every terminal. Sixel / kitty / iTerm2 opt-in is a
later concern (likely driven by config in #2 or env detection).

Missing file or decode errors surface as a `[image: ...]` text
fallback — one bad path should never take the splash screen down.

Minimizes image crate default features (png + jpeg only) to cut binary
size, though ratatui-image still pulls in broader format support as a
transitive.

Closes #19

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@unhappychoice unhappychoice changed the title feat(render): implement 7 of 8 render types (#19) feat(render): implement 8 render types (#19) Apr 21, 2026
unhappychoice and others added 3 commits April 21, 2026 09:32
v1 should cover the graphical end-to-end, not punt it to "later". Uses
Picker::from_query_stdio on TTY for sixel / kitty / iTerm2 detection,
falls back to half-blocks (Picker::from_fontsize) on detection failure.

Non-TTY contexts (CI, tests) skip the stdio query entirely via
io::IsTerminal gate — avoids hangs waiting for a cursor-position
response that won't come.

Picker is cached in a OnceLock so the detection query runs at most once
per process.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replaces the single-text demo with a 2-column × 3-row layout showing:
- Greeting (text) + Clock (bignum)
- CPU (gauge) + Memory (sparkline)
- System (list) + PRs (bar_chart)

Also makes bignum pick the largest PixelSize that fits the allocated
area height (Full ≥ 8 rows, Quadrant ≥ 4, Sextant otherwise) so small
cells don't get a cropped render.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The previous demo showed live CPU% and a memory-history sparkline —
both nonsensical for a shell-startup one-shot render. Swapped for data
that makes sense at launch time:

- Disk / gauge (static snapshot of root partition usage)
- Commits (14d) sparkline (retrospective per-day count from git log)
- Open PRs retitled with per-repo labels

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@unhappychoice
unhappychoice merged commit a7159d7 into main Apr 21, 2026
5 checks passed
@unhappychoice
unhappychoice deleted the feat/19-render-types branch April 21, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: Render types implementation (text / list / gauge / sparkline / chart / bignum / image)

1 participant