Skip to content

[API-373] Add dashboard field flags to create/update#78

Open
callumreid wants to merge 2 commits into
mainfrom
feat/api-373-dashboard-fields
Open

[API-373] Add dashboard field flags to create/update#78
callumreid wants to merge 2 commits into
mainfrom
feat/api-373-dashboard-fields

Conversation

@callumreid
Copy link
Copy Markdown

@callumreid callumreid commented Jun 5, 2026

Summary

coval dashboards create/update only 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)

Flag Type Notes
--description string Free-text description
--favorite true/false Mark as favorite
--default true/false Make this the org default (create: omit to auto-default the first dashboard; setting true unsets any other default)
--position integer Ordering position (>= 0)
--config JSON string or @file Free-form config blob

These compose with --input-json like the existing flags. The dashboard response model and --format json output now include description, is_default, is_favorite, position, and config, and the table view gains a DEFAULT column.

Tests

cargo fmt, cargo clippy --all-targets -D warnings, and cargo test all pass. Added two tests asserting the new flags are serialized into the create POST and update PATCH bodies (via body_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

    • Dashboards now accept description, favorite flag, default flag, position, and custom JSON config when creating or updating.
  • Documentation

    • README example updated to show creating a dashboard and marking it as the organization default.
  • Tests

    • Added integration tests verifying create/update commands serialize and send the new dashboard parameters.

Proof

CI: all 5 platform builds (macOS arm64/x64, Linux arm64/x64, Windows x64) + check green on this PR. Reproduced locally:

fmt + clippycargo fmt --check clean; cargo clippy --all-targets -- -D warnings clean (no warnings).

coval dashboards create --help (new flags wired, booleans constrained to true|false):

Options:
      --name <NAME>
      --description <DESCRIPTION>
      --favorite <FAVORITE>    Mark as a favorite (true/false) [possible values: true, false]
      --default <DEFAULT>      Make this the organization's default dashboard (true/false).
                               Omit to auto-default the first dashboard [possible values: true, false]
      --position <POSITION>    Ordering position (>= 0). Omit to append to the end
      --config <CONFIG>        Free-form JSON config: a JSON string or @path to a file

Testscargo test74 passed; 0 failed. The two new tests assert the flags serialize into the request body (wiremock body_partial_json) and that responses carrying the new fields parse:

test test_dashboard_create_with_full_fields ... ok
test test_dashboard_update_sets_default_and_position ... ok

test_dashboard_create_with_full_fields runs dashboards create --name Ops --description desc --favorite true --default true --position 3 --config '{"date_preferences":{"preset":"last-7-days"}}' and asserts the POST body contains display_name/description/is_favorite/is_default/position/config — a wrong flag→JSON-key mapping (e.g. --default not mapping to is_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.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b451762e-f996-4d36-b60f-46f8beba09b7

📥 Commits

Reviewing files that changed from the base of the PR and between 52d1460 and ba8e984.

📒 Files selected for processing (2)
  • src/commands/dashboards.rs
  • tests/cli_tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/commands/dashboards.rs
  • tests/cli_tests.rs

📝 Walkthrough

Walkthrough

This 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.

Changes

Dashboard Metadata and Default Status

Layer / File(s) Summary
Dashboard data model and request contracts
src/client/models/dashboard.rs
Dashboard, CreateDashboardRequest, and UpdateDashboardRequest extended with optional description, is_default, is_favorite, position, and config fields; serde skips None.
Dashboard table display with default status
src/client/models/dashboard.rs
Tabular implementation adds a DEFAULT column and renders "yes" when is_default is true, preserving existing ID/NAME/CREATED/UPDATED columns.
CLI argument parsing
src/commands/dashboards.rs
CreateArgs and UpdateArgs now accept optional --description, --favorite, --default, --position, and --config flags.
CLI command execution and JSON serialization
src/commands/dashboards.rs
Create/Update handlers validate --position (must be >= 0), parse --config (supports @path), and include description, is_favorite, is_default, position, and config in API request payloads.
Integration tests and usage documentation
tests/cli_tests.rs, README.md
Adds CLI integration tests validating create/update request bodies include new fields; README example shows creating a dashboard with --description and --default true.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Dashboards bloom with fields anew,
Description, config, defaults in view,
Flags that whisper where positions lie,
Tables that show the default—oh my! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title '[API-373] Add dashboard field flags to create/update' accurately describes the main change: extending create and update commands with new optional dashboard field flags.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/api-373-dashboard-fields

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef8f68 and 52d1460.

📒 Files selected for processing (4)
  • README.md
  • src/client/models/dashboard.rs
  • src/commands/dashboards.rs
  • tests/cli_tests.rs

Comment thread src/commands/dashboards.rs
Comment thread src/commands/dashboards.rs
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.

1 participant