Add supported box image picker#792
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughRefactors the API ChangesImage Picker, Resource Defaults, and Cosmetic Fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 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 unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/api-client-go/model_supported_box_image.go`:
- Around line 176-221: The UnmarshalJSON method in SupportedBoxImage currently
validates that required fields exist as keys in the JSON object but does not
check if their values are null, allowing malformed responses like {"id": null,
...} to pass validation. Update the custom template at
apps/hack/go-client/openapi-templates/model.mustache to add null-value checks
for required fields in the validation logic alongside the existing key existence
checks, ensuring that any null values for id, name, ref, and isDefault are
rejected with an appropriate error message. After updating the template,
regenerate the Go client using nx run api-client-go:generate:api-client to apply
the fix to SupportedBoxImage and all other generated models.
🪄 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 Plus
Run ID: 8a698aac-6cf9-480d-9805-1783cdd41a35
📒 Files selected for processing (21)
apps/api-client-go/.openapi-generator/FILESapps/api-client-go/api/openapi.yamlapps/api-client-go/api_box.goapps/api-client-go/model_supported_box_image.goapps/api/src/box/constants/curated-images.constant.spec.tsapps/api/src/box/constants/curated-images.constant.tsapps/api/src/box/controllers/box.controller.tsapps/api/src/box/dto/supported-box-image.dto.tsapps/api/src/box/services/box.service.tsapps/dashboard/src/components/Box/CreateBoxSheet.tsxapps/dashboard/src/components/admin/AdminTelemetryDrawer.tsxapps/dashboard/src/components/ui/sheet.tsxapps/dashboard/src/hooks/queries/queryKeys.tsapps/dashboard/src/hooks/queries/useSupportedBoxImagesQuery.tsapps/infra-local/README.mdapps/libs/api-client/src/.openapi-generator/FILESapps/libs/api-client/src/api/box-api.tsapps/libs/api-client/src/docs/BoxApi.mdapps/libs/api-client/src/docs/SupportedBoxImage.mdapps/libs/api-client/src/models/index.tsapps/libs/api-client/src/models/supported-box-image.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/api/src/migrations/1741087887225-migration.ts`:
- Line 73: The historical migration Migration1741087887225 is being mutated with
default value changes, but existing databases that already applied this
migration will retain the old defaults, causing schema drift. Instead of
modifying the existing migration, revert the changes to the CREATE TABLE
statement in Migration1741087887225 back to its original state, then create a
new separate migration file that applies the default value changes via ALTER
TABLE statements. This ensures existing databases can receive the schema updates
through the new forward migration without conflicts.
🪄 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 Plus
Run ID: 7e7a2352-c74d-40cf-b6c5-8efe86f01de7
⛔ Files ignored due to path filters (2)
apps/dashboard/src/assets/boxlite-black.pngis excluded by!**/*.pngapps/dashboard/src/assets/boxlite-light.pngis excluded by!**/*.png
📒 Files selected for processing (10)
apps/api/src/box/constants/box-create-defaults.constant.tsapps/api/src/box/entities/box.entity.tsapps/api/src/box/services/box.service.tsapps/api/src/config/dto/configuration.dto.tsapps/api/src/migrations/1741087887225-migration.tsapps/dashboard/src/assets/Logo.tsxapps/dashboard/src/components/Box/CreateBoxSheet.tsxapps/dashboard/src/components/OnboardingGuideDialog.tsxapps/dashboard/src/providers/ConfigProvider.tsxapps/dashboard/src/types/DashboardConfig.ts
✅ Files skipped from review due to trivial changes (1)
- apps/dashboard/src/providers/ConfigProvider.tsx
| ) | ||
| await queryRunner.query( | ||
| `CREATE TABLE "box" ("id" character varying NOT NULL DEFAULT uuid_generate_v4(), "boxId" character varying(12) NOT NULL, "organizationId" uuid NOT NULL, "name" character varying NOT NULL, "region" character varying NOT NULL, "image" character varying, "runnerId" uuid, "prevRunnerId" uuid, "class" "public"."box_class_enum" NOT NULL DEFAULT 'small', "state" "public"."box_state_enum" NOT NULL DEFAULT 'unknown', "desiredState" "public"."box_desiredstate_enum" NOT NULL DEFAULT 'started', "osUser" character varying NOT NULL, "errorReason" character varying, "recoverable" boolean NOT NULL DEFAULT false, "env" jsonb NOT NULL DEFAULT '{}', "public" boolean NOT NULL DEFAULT false, "networkBlockAll" boolean NOT NULL DEFAULT false, "networkAllowList" character varying, "labels" jsonb, "cpu" integer NOT NULL DEFAULT '2', "gpu" integer NOT NULL DEFAULT '0', "mem" integer NOT NULL DEFAULT '4', "disk" integer NOT NULL DEFAULT '10', "volumes" jsonb NOT NULL DEFAULT '[]', "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "autoStopInterval" integer NOT NULL DEFAULT '15', "autoDeleteInterval" integer NOT NULL DEFAULT '-1', "pending" boolean NOT NULL DEFAULT false, "authToken" character varying NOT NULL, "daemonVersion" character varying, CONSTRAINT "box_organizationId_name_unique" UNIQUE ("organizationId", "name"), CONSTRAINT "box_id_pk" PRIMARY KEY ("id"))`, | ||
| `CREATE TABLE "box" ("id" character varying NOT NULL DEFAULT uuid_generate_v4(), "boxId" character varying(12) NOT NULL, "organizationId" uuid NOT NULL, "name" character varying NOT NULL, "region" character varying NOT NULL, "image" character varying, "runnerId" uuid, "prevRunnerId" uuid, "class" "public"."box_class_enum" NOT NULL DEFAULT 'small', "state" "public"."box_state_enum" NOT NULL DEFAULT 'unknown', "desiredState" "public"."box_desiredstate_enum" NOT NULL DEFAULT 'started', "osUser" character varying NOT NULL, "errorReason" character varying, "recoverable" boolean NOT NULL DEFAULT false, "env" jsonb NOT NULL DEFAULT '{}', "public" boolean NOT NULL DEFAULT false, "networkBlockAll" boolean NOT NULL DEFAULT false, "networkAllowList" character varying, "labels" jsonb, "cpu" integer NOT NULL DEFAULT '1', "gpu" integer NOT NULL DEFAULT '0', "mem" integer NOT NULL DEFAULT '1', "disk" integer NOT NULL DEFAULT '10', "volumes" jsonb NOT NULL DEFAULT '[]', "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "autoStopInterval" integer NOT NULL DEFAULT '15', "autoDeleteInterval" integer NOT NULL DEFAULT '-1', "pending" boolean NOT NULL DEFAULT false, "authToken" character varying NOT NULL, "daemonVersion" character varying, CONSTRAINT "box_organizationId_name_unique" UNIQUE ("organizationId", "name"), CONSTRAINT "box_id_pk" PRIMARY KEY ("id"))`, |
There was a problem hiding this comment.
Create a forward migration instead of mutating a historical one.
At Line 73, defaults are changed inside Migration1741087887225. Environments that already applied this migration will keep old DB defaults, causing schema drift against current entity defaults.
Suggested approach
+// add a new migration file (new timestamp), e.g. Migration<newTimestamp>
+await queryRunner.query(`ALTER TABLE "box" ALTER COLUMN "cpu" SET DEFAULT '1'`)
+await queryRunner.query(`ALTER TABLE "box" ALTER COLUMN "mem" SET DEFAULT '1'`)
+
+// down()
+await queryRunner.query(`ALTER TABLE "box" ALTER COLUMN "cpu" SET DEFAULT '2'`)
+await queryRunner.query(`ALTER TABLE "box" ALTER COLUMN "mem" SET DEFAULT '4'`)🤖 Prompt for 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.
In `@apps/api/src/migrations/1741087887225-migration.ts` at line 73, The
historical migration Migration1741087887225 is being mutated with default value
changes, but existing databases that already applied this migration will retain
the old defaults, causing schema drift. Instead of modifying the existing
migration, revert the changes to the CREATE TABLE statement in
Migration1741087887225 back to its original state, then create a new separate
migration file that applies the default value changes via ALTER TABLE
statements. This ensures existing databases can receive the schema updates
through the new forward migration without conflicts.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/api-client-go/api/openapi.yaml`:
- Line 5216: The boxCreateDefaults field at line 5216 in the OpenAPI YAML is set
to an empty string, but the schema defines it as a BoxCreateDefaults object
type, creating a type mismatch in the example. Replace the empty string value
with a valid BoxCreateDefaults object structure that conforms to the schema
definition for that type. This will ensure generated documentation and SDK
examples correctly represent the expected object format rather than a string.
🪄 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 Plus
Run ID: 5e6f6020-c988-4788-ab00-43cebf517b50
📒 Files selected for processing (10)
apps/api-client-go/.openapi-generator/FILESapps/api-client-go/api/openapi.yamlapps/api-client-go/model_box_create_defaults.goapps/api-client-go/model_boxlite_configuration.goapps/libs/api-client/src/.openapi-generator/FILESapps/libs/api-client/src/docs/BoxCreateDefaults.mdapps/libs/api-client/src/docs/BoxliteConfiguration.mdapps/libs/api-client/src/models/box-create-defaults.tsapps/libs/api-client/src/models/boxlite-configuration.tsapps/libs/api-client/src/models/index.ts
✅ Files skipped from review due to trivial changes (4)
- apps/libs/api-client/src/docs/BoxCreateDefaults.md
- apps/api-client-go/.openapi-generator/FILES
- apps/libs/api-client/src/models/box-create-defaults.ts
- apps/api-client-go/model_box_create_defaults.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/dashboard/src/components/Box/CreateBoxSheet.tsx`:
- Around line 138-139: The form visually displays defaultImage but the
submission can send undefined when the user doesn't interact with the image
picker, causing a UI/payload mismatch. Initialize the image field in the form's
defaultValues object (or form initialization logic) to use the defaultImage
variable that is calculated on line 138-139. This ensures that when the form is
submitted without user interaction, it reflects what the UI shows by default.
Check the form submission logic in the CreateBoxSheet component and ensure the
image field's default value is properly set to align with the visual default at
all locations where the form is used or submitted (particularly around lines
169-172 and 257-267 where the image handling occurs).
🪄 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 Plus
Run ID: ab1695f5-4e9f-4b65-9ad7-e685b70c01e4
📒 Files selected for processing (4)
apps/api/src/box/constants/curated-images.constant.tsapps/api/src/box/services/box.service.tsapps/dashboard/src/components/Box/CreateBoxSheet.tsxapps/dashboard/src/hooks/queries/queryKeys.ts
💤 Files with no reviewable changes (1)
- apps/dashboard/src/hooks/queries/queryKeys.ts
✅ Files skipped from review due to trivial changes (1)
- apps/api/src/box/constants/curated-images.constant.ts
## Summary - switch curated Box image refs from digest pins to public `20260605-p0-r3` tags - keep API env overrides intact while updating fallback refs - sync Dashboard Create Box presets and SST API env fallbacks ## Testing - `git diff --check` - `cd apps && yarn jest --config api/jest.config.ts api/src/box/constants/curated-images.constant.spec.ts` Note: created from a clean branch off latest `origin/main` because the earlier `codex/fix-supported-images-dashboard` branch was already merged via PR #792.
Summary
GET /box/supported-imagesbacked by the curated/pinned image allowlistValidation
cd apps && npx vitest run dashboard/src/lib/cloudBox.test.tscd apps && npx jest --config api/jest.config.ts api/src/box/constants/curated-images.constant.spec.ts --runInBandcd apps && NX_DAEMON=false npx nx build dashboard --configuration=development --skipNxCache --outputStyle=streamcd apps && NX_DAEMON=false npx nx build api --configuration=production --skipNxCache --outputStyle=streamNotes
Summary by CodeRabbit
New Features
Changes
Style
Documentation