Skip to content

fix(web): keep sealed bid data out of dashboard empty/error states (#… - #470

Open
Mubking-dev wants to merge 2 commits into
Sub-Rosa-Issue:mainfrom
Mubking-dev:fix/425-dashboard-sealed-states
Open

Mubking-dev wants to merge 2 commits into
Sub-Rosa-Issue:mainfrom
Mubking-dev:fix/425-dashboard-sealed-states

Conversation

@Mubking-dev

Copy link
Copy Markdown

Closes #425

Summary

The dashboard empty and error states can no longer carry or render round
data. The error state now shows an SDK error code.

Changes

  • SDK (errors.ts): adds SDK_ERROR_CODES, SdkErrorCode and
    sdkErrorCode(error). It classifies by error class only and never reads
    properties off the thrown value. Existing classes are unchanged; the API
    snapshot is updated for the 3 new exports.
  • useDashboardData: returns a discriminated union
    (loading | empty | error + code | ready + data).
    • Each outcome is built from scratch, so a failure drops previously
      loaded round data.
    • Only the latest load may publish, so out-of-order responses can't
      overwrite newer state.
    • Accepts optional { endpoint, fetchImpl } for testing.
  • DashboardEmptyState: shown only for null / round: null.
  • DashboardErrorState: props are now { code, onRetry }. The code is
    re-validated at runtime and falls back to UNKNOWN.
  • DashboardContent.tsx (new): the state switch, extracted so tests
    cover the real wiring.
  • Docs: "SDK error codes" section in INTEGRATION.md.

Behaviour changes to note

  • A payload without a round key is treated as malformed, so it shows the
    error state rather than the empty state.
  • The error state shows fixed copy plus the code instead of a message.
  • Removed the "data source temporarily unavailable" bullet from the empty
    state, since that case is now an error.

Acceptance criteria → tests (DashboardStates.test.tsx)

  • Empty fixture shows the empty state with no amount.
  • Failed fixture shows the SDK error code and no bid amount.
  • Sealed fixture failing mid-load does not show the fixture amount.
    Assertions run against the full serialized render tree, including props
    and attributes.
  • All tests render without a wallet (injected fetch, fake timers).

Also covered: retry from error, success replacing error, and both
out-of-order races. Removing the sequencing guard makes the race tests fail.

Verification

  • Web first test group: 101/101; SDK: 214/214 (3 new)
  • Web and SDK typecheck pass; web:build passes

Pre-existing failures (also on clean main, not touched here)

  • 4 tests in useLiveRound.test.tsx, so pnpm web:test exits non-zero
  • time:guard flags useDashboardData.test.ts

Open questions

  • An unreachable endpoint (rejected fetch) maps to UNKNOWN, since the SDK
    has no network error class. Would you like a dedicated NETWORK_ERROR
    code in a follow-up?
  • Out of scope but related: in the ready state, BidderProgressCard
    renders bidUsdc for an Open round whenever the endpoint sends it.
    Happy to open a separate issue.

mubking and others added 2 commits October 2, 2026 00:24
…ub-Rosa-Issue#425)

useDashboardData returned one flat object where a round payload could sit
next to an error, so a failed load kept (and on retry re-rendered) a bid the
contract still treats as sealed. The hook now returns a discriminated union
in which only the ready state carries round data, builds every outcome from
scratch, and lets only the most recently started load publish.

- sdk: add SDK_ERROR_CODES, SdkErrorCode and sdkErrorCode(), classifying by
  error class only; existing error classes are unchanged
- web: DashboardErrorState takes only an SDK error code; the empty state is
  shown only when the endpoint reports no round
- web: move the state switch into DashboardContent and cover the empty,
  error, mid-load failure and out-of-order cases without a wallet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Keep sealed bid amounts out of the dashboard empty and error states

2 participants