feat(api): POST /service-config/reset-defaults — replaces "reset to builtin" #937

Closed
opened 2026-05-08 08:55:52 +00:00 by claude-desktop · 0 comments
Collaborator

As an operator, I want a "Reset to factory defaults" button on the service-config dashboard that re-applies the code-level defaults, so that the workflow stops depending on a scope='builtin' row that the runtime no longer needs.

Today apps/web/src/routes/$locale/settings.service.tsx shows two reset affordances ("Fields reset to builtin" / "All global overrides reset to builtin") that both rely on a builtin DB row to exist. After tracker #934 lands, builtin rows are gone and SERVICE_CONFIG_DEFAULTS is the only source of factory truth — the endpoint must reflect that.

Acceptance criteria

API

  • POST /api/service-config/reset-defaults (admin-gated, same auth as the existing service-config PUT) overwrites the scope='global' service_config row with values from SERVICE_CONFIG_DEFAULTS. UPSERT semantics: insert if missing.
  • Optional body field fields?: string[] — when provided, only those columns are reset; otherwise every default-bearing column is reset.
  • Writes a config_revision row with kind='service_config', comment='reset to factory defaults', body_snapshot carrying the prior row.
  • Returns the new service_config row in the response body so the dashboard can refresh without a separate GET.

Tests

  • Handler unit test: full-row reset writes the factory values and a 'reset to factory defaults' revision.
  • Handler unit test: partial reset (fields: ['watchdogs_json']) only touches the requested columns.
  • Handler unit test: missing global row → INSERT path inserts the defaults.

Wiring

  • New endpoint registered in apps/server/src/main.ts under the existing service-config router.
  • apps/web/src/lib/api.ts exports postServiceConfigReset(fields?: string[]).

Out of scope

  • Frontend label / wiring — handled by the SCOPE_ORDER cleanup story.
  • A field-by-field UX with diff preview — start with full / partial reset.

References

  • Meta tracker: #934
  • Constants source: depends on the service-config defaults to code constants story landing first.
  • Current "reset to builtin" code: apps/web/src/routes/$locale/settings.service.tsx:82, :91, :182
As an operator, I want a "Reset to factory defaults" button on the service-config dashboard that re-applies the code-level defaults, so that the workflow stops depending on a `scope='builtin'` row that the runtime no longer needs. Today `apps/web/src/routes/$locale/settings.service.tsx` shows two reset affordances ("Fields reset to builtin" / "All global overrides reset to builtin") that both rely on a builtin DB row to exist. After tracker #934 lands, builtin rows are gone and `SERVICE_CONFIG_DEFAULTS` is the only source of factory truth — the endpoint must reflect that. ## Acceptance criteria ### API - [ ] `POST /api/service-config/reset-defaults` (admin-gated, same auth as the existing service-config PUT) overwrites the `scope='global'` `service_config` row with values from `SERVICE_CONFIG_DEFAULTS`. UPSERT semantics: insert if missing. - [ ] Optional body field `fields?: string[]` — when provided, only those columns are reset; otherwise every default-bearing column is reset. - [ ] Writes a `config_revision` row with `kind='service_config'`, `comment='reset to factory defaults'`, `body_snapshot` carrying the prior row. - [ ] Returns the new `service_config` row in the response body so the dashboard can refresh without a separate GET. ### Tests - [ ] Handler unit test: full-row reset writes the factory values and a `'reset to factory defaults'` revision. - [ ] Handler unit test: partial reset (`fields: ['watchdogs_json']`) only touches the requested columns. - [ ] Handler unit test: missing global row → INSERT path inserts the defaults. ### Wiring - [ ] New endpoint registered in `apps/server/src/main.ts` under the existing service-config router. - [ ] `apps/web/src/lib/api.ts` exports `postServiceConfigReset(fields?: string[])`. ## Out of scope - Frontend label / wiring — handled by the SCOPE_ORDER cleanup story. - A field-by-field UX with diff preview — start with full / partial reset. ## References - Meta tracker: #934 - Constants source: depends on the `service-config defaults to code constants` story landing first. - Current "reset to builtin" code: `apps/web/src/routes/$locale/settings.service.tsx:82`, `:91`, `:182`
dev closed this issue 2026-05-08 09:17:54 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#937
No description provided.