[API-373] Add dashboard field flags to create/update#78
Conversation
Expose description, is_favorite, is_default, position, and config on `coval dashboards create` and `coval dashboards update`, plus the same fields on the dashboard response (with a DEFAULT table column). Mirrors the v1 API gaining full dashboard field parity.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR adds optional dashboard metadata fields (description, is_default, is_favorite, position, config) to the data model and request types, exposes CLI flags to set them, validates and serializes them into create/update API payloads (including config file support), updates table output with a DEFAULT column, and adds integration tests plus a README example. ChangesDashboard Metadata and Default Status
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/commands/dashboards.rs`:
- Around line 65-78: Add input validation to enforce position >= 0: implement a
helper fn validate_position(position: Option<i64>) -> Result<()> that returns an
error (e.g., bail!("--position must be >= 0")) when a Some value is negative,
and call validate_position(...) from the Create and Update command handlers
before constructing the request (similar to validate_widget_grid used at lines
~192-204) so negative --position values are rejected client-side with a clear
CLI error.
- Around line 88-101: The position field allows negative values despite the doc
comment; update the dashboard update argument validation to enforce position >=
0 by adding a validator for the position field (the same approach used in
CreateArgs) — either add a clap value parser/range (e.g. value_parser with range
0..) or a small validate() check in the UpdateArgs handling path that returns an
error when position < 0; target the position field in the dashboards.rs
UpdateArgs/struct and mirror the CreateArgs validation logic so negatives are
rejected.
🪄 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: 58efad1a-2da8-4700-ad81-1103d18cfb44
📒 Files selected for processing (4)
README.mdsrc/client/models/dashboard.rssrc/commands/dashboards.rstests/cli_tests.rs
Summary
coval dashboards create/updateonly accepted--name. This adds the rest of the dashboard fields the v1 API exposes (paired backend PR coval-ai/backend#4498) so the CLI can fully manage dashboards — including marking one as the organization's default/dashboard.Linear: API-373
New flags (create + update)
--description--favoritetrue/false--defaulttrue/false--position>= 0)--config@fileThese compose with
--input-jsonlike the existing flags. The dashboard response model and--format jsonoutput now includedescription,is_default,is_favorite,position, andconfig, and the table view gains aDEFAULTcolumn.Tests
cargo fmt,cargo clippy --all-targets -D warnings, andcargo testall pass. Added two tests asserting the new flags are serialized into the create POST and update PATCH bodies (viabody_partial_json) and that responses carrying the new fields parse.No version bump here — per this repo's convention version bumps land in a separate
chore:PR after merge.Summary by CodeRabbit
New Features
Documentation
Tests
Proof
CI: all 5 platform builds (macOS arm64/x64, Linux arm64/x64, Windows x64) +
checkgreen on this PR. Reproduced locally:fmt + clippy —
cargo fmt --checkclean;cargo clippy --all-targets -- -D warningsclean (no warnings).coval dashboards create --help(new flags wired, booleans constrained totrue|false):Tests —
cargo test→74 passed; 0 failed. The two new tests assert the flags serialize into the request body (wiremockbody_partial_json) and that responses carrying the new fields parse:test_dashboard_create_with_full_fieldsrunsdashboards create --name Ops --description desc --favorite true --default true --position 3 --config '{"date_preferences":{"preset":"last-7-days"}}'and asserts the POST body containsdisplay_name/description/is_favorite/is_default/position/config— a wrong flag→JSON-key mapping (e.g.--defaultnot mapping tois_default) would 404 the mock and fail the test.Note: a live run against current prod isn't shown because the new fields are server-side-gated on coval-ai/backend#4498 — current prod silently ignores unknown request fields, so a prod run wouldn't actually exercise them until that PR is deployed. End-to-end proof against the real API lands via that PR's post-merge integration suite.