Skip to content

[codex] Fix dashboard box API contract drift#729

Merged
DorianZheng merged 1 commit into
mainfrom
codex/dashboard-build-contract-fixes
Jun 11, 2026
Merged

[codex] Fix dashboard box API contract drift#729
DorianZheng merged 1 commit into
mainfrom
codex/dashboard-build-contract-fixes

Conversation

@law-chain-hot

@law-chain-hot law-chain-hot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Split

This PR is the frontend contract-fix layer. The Docker packaging work is stacked separately in #730.

main
  |
  v
#729 dashboard/API contract fixes
  |
  v
#730 monorepo Docker packaging

Problem

The dashboard was still using several assumptions from the older API/SDK shape. Once the API/dashboard were built through the production path, those mismatches became hard build blockers.

Generated API / SDK surface
  |
  |-- CreateBox request expects resources.{cpu,memory,disk}
  |-- Box API exposes start/delete/recover/stop as distinct methods
  |-- BoxState no longer has BUILD_FAILED / BUILDING_ARTIFACT / PENDING_BUILD
  |-- Runner DTO no longer exposes currentArtifactCount
  v
Dashboard stale call sites
  |
  |-- cpu/memory/disk sent at top level
  |-- copied mutation hooks exported the wrong hook names/actions
  |-- UI referenced removed BoxState enum values
  |-- Runner details rendered a removed field
  v
Dashboard typecheck / production build failure

What Changed

CreateBoxSheet
  cpu, memory, disk
      -> resources.cpu, resources.memory, resources.disk

Box mutation hooks
  useStartBoxMutation   -> boxApi.startBox
  useDeleteBoxMutation  -> boxApi.deleteBox
  useRecoverBoxMutation -> boxApi.recoverBox
  useStopBoxMutation    -> boxApi.stopBox + detailRef invalidation

Box state UI
  removed stale generated enum references
  added UNKNOWN_DEFAULT_OPEN_API handling

Runner details
  removed currentArtifactCount display

Why This Is Separate

This PR only makes the dashboard match the current generated API/SDK contract. It does not change Docker, Nx, SST, package layout, or runtime image packaging. That keeps the frontend compile fixes reviewable before #730 changes the build pipeline.

Validation

yarn tsc --project dashboard/tsconfig.app.json --noEmit
NX_DAEMON=false NX_SKIP_NX_CACHE=true \
  VITE_BASE_API_URL=%BOXLITE_BASE_API_URL% \
  yarn nx build dashboard --configuration=production --nxBail=true --output-style=stream

Result: dashboard typecheck and production build pass. Existing Vite/OpenTelemetry/chunk-size warnings still appear, but the build exits successfully.

Summary by CodeRabbit

  • New Features

    • Added Start Box and Recover Box actions to box management
    • Enhanced resource field handling in box creation for conditional inclusion
  • Bug Fixes

    • Refined box state transitions and visual representations
    • Updated Runner health metrics to display Active Boxes count instead of Images
    • Improved state display accuracy for various box conditions

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 07f2b0ab-bd30-442c-aa0c-2bd1f6e71892

📥 Commits

Reviewing files that changed from the base of the PR and between 21df05a and 666d9f2.

📒 Files selected for processing (12)
  • apps/dashboard/src/components/Box/CreateBoxSheet.tsx
  • apps/dashboard/src/components/BoxTable/BoxState.tsx
  • apps/dashboard/src/components/BoxTable/constants.ts
  • apps/dashboard/src/components/BoxTable/state-icons.tsx
  • apps/dashboard/src/components/RunnerDetailsSheet.tsx
  • apps/dashboard/src/hooks/mutations/useDeleteBoxMutation.ts
  • apps/dashboard/src/hooks/mutations/useRecoverBoxMutation.ts
  • apps/dashboard/src/hooks/mutations/useStartBoxMutation.ts
  • apps/dashboard/src/hooks/mutations/useStopBoxMutation.ts
  • apps/dashboard/src/hooks/useBoxWsSync.ts
  • apps/dashboard/src/lib/utils/box.ts
  • apps/dashboard/src/pages/Boxes.tsx

📝 Walkthrough

Walkthrough

This PR simplifies box state lifecycle by removing build-related states from UI and handlers, reorganizes box action mutations into focused hooks, adds dual-cache invalidation support to mutations, conditionalizes resource creation payloads, and updates runner metrics display. The changes span state constants, WebSocket handlers, mutation hooks, and component UI updates.

Changes

Box lifecycle and UI consolidation

Layer / File(s) Summary
State UI and icon mappings
apps/dashboard/src/components/BoxTable/BoxState.tsx, apps/dashboard/src/components/BoxTable/constants.ts, apps/dashboard/src/components/BoxTable/state-icons.tsx
Removes BUILD_FAILED, BUILDING_ARTIFACT, and PENDING_BUILD from state label and icon mappings. Adds UNKNOWN_DEFAULT_OPEN_API label. Updates error state rendering to treat only ERROR (not BUILD_FAILED) as an error condition.
Transitioning state utilities
apps/dashboard/src/lib/utils/box.ts
isTransitioning now recognizes RESTORING state alongside existing transitioning states.
WebSocket and cache handling for failure states
apps/dashboard/src/hooks/useBoxWsSync.ts, apps/dashboard/src/pages/Boxes.tsx
WebSocket handlers for box.state.updated and box.desired-state.updated now map DESTROYED desired state only when box is in ERROR state, removing previous BUILD_FAILED allowance. Cache removal logic tightened to sync with narrowed failure state conditions.

Box mutations and resource creation

Layer / File(s) Summary
Conditional resource payload in box creation
apps/dashboard/src/components/Box/CreateBoxSheet.tsx
onSubmit builds a resources object from optional cpu, memory, and disk fields; mutation payload conditionally includes resources only when overrides are present.
Box action mutation hooks
apps/dashboard/src/hooks/mutations/useDeleteBoxMutation.ts, apps/dashboard/src/hooks/mutations/useRecoverBoxMutation.ts, apps/dashboard/src/hooks/mutations/useStartBoxMutation.ts
New useStartBoxMutation hook starts boxes. Reorganized useDeleteBoxMutation for deleting boxes and useRecoverBoxMutation for recovering boxes. All mutations use typed variables, organization scope, and cache invalidation on success.
Stop mutation cache invalidation enhancement
apps/dashboard/src/hooks/mutations/useStopBoxMutation.ts
StopBoxVariables adds optional detailRef. useStopBoxMutation onSuccess now conditionally invalidates an additional detail query when detailRef is provided and differs from boxId.
Runner health metrics display
apps/dashboard/src/components/RunnerDetailsSheet.tsx
"Images" metric replaced with "Active Boxes" metric; value switches from currentArtifactCount to currentStartedBoxes.

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • DorianZheng

🐰 States once blooming bright with builds,
Now dance with ERROR's cleaner truth,
Start, recover, delete—mutations split,
Each cache invalidation swift,
Box lifecycle grows lean, precise as winter's gift!

✨ 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 codex/dashboard-build-contract-fixes

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

@DorianZheng DorianZheng marked this pull request as ready for review June 11, 2026 07:23
@DorianZheng DorianZheng requested a review from a team as a code owner June 11, 2026 07:23
@DorianZheng DorianZheng added this pull request to the merge queue Jun 11, 2026
Merged via the queue into main with commit baebe20 Jun 11, 2026
30 of 31 checks passed
@DorianZheng DorianZheng deleted the codex/dashboard-build-contract-fixes branch June 11, 2026 07:25
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.

2 participants