THU-505: Move model API keys to local-only table
Summary
- Moves
api_keyout of the syncedmodelstable into a new local-onlymodels_secretstable that PowerSync never syncs — API keys never leave the device - All model DAL queries LEFT JOIN with
models_secretsso consumers still getapiKeytransparently - Adds warning indicator (amber triangle + tooltip) in model picker and settings list for models missing an API key
- Adds edit/delete button group to model cards with an edit modal for updating model config and API keys
- Removes
api_keyfrom E2EE encrypted columns and backend schema (with migration)
Test plan
- [ ] Create a model with API key → key stored in
models_secrets, not inmodels - [ ] Edit model API key via edit modal →
models_secretsupdated, warning disappears - [ ] Delete model →
models_secretsrow deleted - [ ] Default/system models load correctly with
apiKey: null, no warning shown - [ ] Model picker shows warning icon + tooltip on models without API key, disables selection
- [ ] AI chat works with API-key-based providers (OpenAI, Anthropic, etc.)
- [ ] TypeScript compiles, lint passes, all tests pass
🤖 Generated with Claude Code
[!NOTE] Medium Risk Schema and DAL changes move
apiKeystorage and retrieval, which can break model configuration and provider authentication if joins/migrations are wrong, but scope is limited to models/settings UI and persistence.Overview Moves model API keys out of sync scope. Drops
api_keyfrom the backendpowersync.modelstable (new migration + updated Drizzle schema) and removes it from the E2EE encrypted-columns list.Introduces a local-only
models_secretstable in the client SQLite schema and PowerSync app schema (markedlocalOnly) to storeapiKeyon-device only, with new relations.Updates the models DAL to transparently include
apiKey. All model reads nowLEFT JOINmodels_secrets, andcreateModel/updateModel/resetModelToDefault/deleteModelmanage secrets in transactions (including manual upsert behavior).UI/UX updates for missing keys and editing. The model selector and models settings list now flag and disable models that need an API key but don’t have one (amber warning + tooltip), and the settings page replaces the removed detail/new routes with an inline edit modal plus a consolidated delete confirmation.
Tests adjusted/added to cover
models_secretspersistence, join behavior, update semantics, and cascade delete.Reviewed by Cursor Bugbot for commit 57503494f3b2fdd21b5a395e6875e1a2758eb26c. Bugbot is set up for automated code reviews on this repo. Configure here.
Semgrep Security Scan
No security issues found.
Preview environment deployed 🚀
| Service | URL |
|---|---|
| Marketing / blog / docs | https://thunderbolt-pr-858.preview.thunderbolt.io |
| App | https://app-pr-858.preview.thunderbolt.io |
| API | https://api-pr-858.preview.thunderbolt.io |
| Keycloak | https://auth-pr-858.preview.thunderbolt.io |
| PowerSync | https://powersync-pr-858.preview.thunderbolt.io |
Stack: preview-pr-858 · Commit: 57503494f3b2fdd21b5a395e6875e1a2758eb26c
Auto-destroys on PR close/merge. Login via the bundled Keycloak realm — [email protected] / demo by default.
PR Metrics
| Metric | Value |
|---|---|
| Lines changed (prod code) | +391 / -648 |
| JS bundle size (gzipped) | :green_circle: 1.02 MB → 1.02 MB (-3.6 KB, -0.3%) |
| Test coverage | :yellow_circle: 71.47% → 71.14% (-0.3%) |
| Performance (preview) | Preview not ready — Render deploy may have timed out |
| Accessibility | — |
| Best Practices | — |
| SEO | — |
Updated Fri, 15 May 2026 10:36:49 GMT · run #1504