You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/quotesdb/.beans/quotesdb-iar0--home-page-sh...

1.6 KiB

title status type priority created_at updated_at
Home page: show friendly empty state when no quotes in database completed bug high 2026-03-10T23:32:09Z 2026-03-10T23:32:09Z

Bug

When the database is empty, GET /api/quotes/random returns a 404 response. The home page (src/bin/ui/pages/home.rs) currently treats all errors (including 404) the same way — it sets the error state and displays it via <ErrorDisplay>, which results in something like a raw JSON error message being shown to the user.

Expected behaviour

When the API returns a 404 on /api/quotes/random, the home page should display a friendly empty-state message instead of a generic error:

"Nothing here yet. Submit a quote!"

The message should include a link to /submit.

How to fix

In src/bin/ui/pages/home.rs, in the use_effect_with block, inspect the Err value. The API client returns ApiError::Server { status, .. } for HTTP error codes. When status == 404, set a dedicated "empty" state (or detect it from the error) and render the friendly message instead of <ErrorDisplay>.

Relevant code: src/bin/ui/pages/home.rs — the use_effect_with error branch and the HTML render block.

File

  • src/bin/ui/pages/home.rs

Validation

# From quotesdb/ root
cargo fmt && cargo check && cargo clippy && cargo test

Also manually test with an empty database:

rm -f quotesdb.sqlite
cargo run &
# navigate to http://localhost:3000 — should show the friendly message, not a raw error

Commit scope

fix(quotesdb): home page empty state