Skip to content

fix: names page Save overwrites cached content with no confirmation and no history #275

Description

@nazarli-shabnam

Problem

On the admin names page, "Save" (which `PATCH`es `/api/admin/names` and overwrites the stored `data` payload outright) has no confirmation, while "Invalidate" on the same page does:

  • Save: no `ConfirmButton` (`app/admin/names/page.tsx:107-125`)
  • Invalidate: wrapped in `ConfirmButton` (`app/admin/names/page.tsx:117-124`)

The API itself does a straight overwrite with no history table:

```ts
// app/api/admin/names/route.ts:60-66
await db.update(names).set({ data }).where(and(eq(names.slug, slug), eq(names.kind, kind)));
```

Impact

Editing cached AI-generated content for a Divine Name permanently overwrites the previous payload in a single, un-confirmed click — there's no way to see or revert to what was there before. A mistake in the JSON textarea (e.g. saving a half-edited draft, or content typed into the wrong field) is unrecoverable other than manually invalidating the entry and waiting for it to regenerate from scratch, which loses any manual admin edits that weren't AI-generated. This is inconsistent with how the Prompts page treats similar content — prompts are explicitly versioned with rollback support.

Location

`app/admin/names/page.tsx:107-125`, `app/api/admin/names/route.ts:60-66`

Suggested fix

At minimum, gate "Save" behind the same `ConfirmButton` pattern already used for "Invalidate" on the same page. Ideally, keep a lightweight history of prior `data` payloads per `(slug, kind)` (even just the previous version) so an accidental overwrite can be undone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions