Skip to content

feat: reintroduce OPDB model selection for machines#1055

Open
timothyfroehlich wants to merge 6 commits intomainfrom
feature/opdb-model-integration
Open

feat: reintroduce OPDB model selection for machines#1055
timothyfroehlich wants to merge 6 commits intomainfrom
feature/opdb-model-integration

Conversation

@timothyfroehlich
Copy link
Owner

Summary

  • reintroduce OPDB integration for machines with a new typed client + mappers + validation layer (src/lib/opdb/*)
  • add persisted OPDB metadata fields to machines and migration (opdb_id, title, manufacturer, year, image URL, type, last synced)
  • add authenticated OPDB search API route and reusable OpdbModelSelect UI used in both create and edit flows
  • lock machine name to selected OPDB model and enforce read-only behavior for unchanged OPDB-linked machines in server actions
  • support legacy machines with null OPDB data until a model is selected
  • extend unit and smoke coverage, including explicit edit-flow interaction for changing OPDB model

Testing

  • pnpm run check
  • pnpm test -- src/test/unit/machine-actions.test.ts
  • pnpm exec playwright test e2e/smoke/machine-with-invite.spec.ts --config=playwright.config.smoke.ts --project=chromium --project='Mobile Chrome'
  • pnpm exec playwright test e2e/smoke/machine-presence-status.spec.ts --config=playwright.config.smoke.ts --project='Mobile Chrome'
  • pnpm exec playwright test e2e/smoke/issues-crud.spec.ts e2e/smoke/machines-crud.spec.ts --config=playwright.config.smoke.ts --project='Mobile Chrome' ✅ (isolated rerun)
  • pnpm run preflight ❌ due existing smoke instability:
    • e2e/smoke/status-overhaul.spec.ts times out on page.waitForLoadState("networkidle") (chromium + mobile)
    • e2e/smoke/issues-crud.spec.ts mobile failures in full-suite run
    • e2e/smoke/machines-crud.spec.ts mobile failure in full-suite run

Notes

  • OPDB search route intentionally requires authentication, but is not limited to admin/technician so machine owners who can edit can also search/select models in the edit dialog.

Copilot AI review requested due to automatic review settings February 22, 2026 22:40
@vercel
Copy link

vercel bot commented Feb 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pin-point Ready Ready Preview, Comment Feb 28, 2026 1:17pm

@supabase
Copy link

supabase bot commented Feb 22, 2026

Updates to Preview Branch (feature/opdb-model-integration) ↗︎

Deployments Status Updated
Database Sat, 28 Feb 2026 13:16:40 UTC
Services Sat, 28 Feb 2026 13:16:40 UTC
APIs Sat, 28 Feb 2026 13:16:40 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Sat, 28 Feb 2026 13:16:41 UTC
Migrations Sat, 28 Feb 2026 13:16:41 UTC
Seeding Sat, 28 Feb 2026 13:16:41 UTC
Edge Functions Sat, 28 Feb 2026 13:16:41 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reintroduces OPDB (Open Pinball Database) integration to enable searching and importing machine model metadata during machine creation and editing. The implementation adds a typed client layer with validation, mappers, and in-memory caching, persists OPDB metadata fields in the database, and locks machine names to selected OPDB models for data consistency.

Changes:

  • Added OPDB client infrastructure with types, mappers, and API client (src/lib/opdb/*)
  • Extended machines schema with 7 new OPDB metadata columns (id, title, manufacturer, year, image URL, machine type, last synced timestamp) plus index
  • Created authenticated /api/opdb/search route and reusable OpdbModelSelect UI component
  • Updated machine create/edit server actions to fetch OPDB details, lock names to OPDB titles, and support legacy machines with null OPDB data
  • Added comprehensive unit tests and E2E coverage including edit-flow model changes

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib/opdb/types.ts Zod schemas and TypeScript types for OPDB API validation and type safety
src/lib/opdb/mappers.ts Data transformation functions to normalize OPDB API responses into app domain models
src/lib/opdb/client.ts HTTP client with in-memory caching, timeout handling, and graceful credential fallback
src/components/machines/OpdbModelSelect.tsx Client component with debounced search, result selection, and clear functionality
src/app/api/opdb/search/route.ts Authenticated API route proxying OPDB search requests
src/app/(app)/m/schemas.ts Added optional opdbId field to create/update machine schemas
src/app/(app)/m/actions.ts Server actions fetch OPDB details, map to DB fields, lock names, support legacy machines
src/app/(app)/m/new/create-machine-form.tsx Integrated OpdbModelSelect with name auto-population and read-only behavior when model selected
src/app/(app)/m/[initials]/update-machine-form.tsx Added OpdbModelSelect to edit dialog with allowClear=false to prevent accidental unlinking
src/server/db/schema.ts Added 7 OPDB metadata columns to machines table with index on opdb_id
drizzle/0021_petite_maverick.sql Migration adding OPDB columns and index
drizzle/meta/_journal.json Migration journal entry for 0021
drizzle/meta/0021_snapshot.json Full schema snapshot after migration 0021
src/test/unit/machine-actions.test.ts Unit tests for OPDB metadata storage and name locking behavior
e2e/smoke/machine-with-invite.spec.ts E2E test with OPDB mocking for create and edit flows
.env.example Added OPDB_API_URL and OPDB_API_KEY configuration with legacy alias support

…vite dialog

The initials field is re-filled after the InviteUserDialog closes because
focus-trapping portals can drop uncontrolled input values when focus returns
to the parent form in some browser/driver combinations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@timothyfroehlich timothyfroehlich added ready-for-review PR passed CI and has no unresolved review comments claude-review Triggers Claude Code Review GitHub Action and removed claude-review Triggers Claude Code Review GitHub Action labels Feb 23, 2026
timothyfroehlich and others added 2 commits February 26, 2026 09:06
Give the Notes & Details section proper card treatment (bg-surface-container,
border, shadow) matching the Machine Details card on the left. Add subtle
bg-surface-variant/15 backgrounds to individual note fields and make
min-h-[80px] conditional on canEdit to avoid dead space for read-only viewers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review PR passed CI and has no unresolved review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants