Skip to content

fix(models): clicking Archive on a disabled model had no effect#1535

Merged
looplj merged 2 commits into
looplj:unstablefrom
djdembeck:fix/models-archive-dialog
Apr 29, 2026
Merged

fix(models): clicking Archive on a disabled model had no effect#1535
looplj merged 2 commits into
looplj:unstablefrom
djdembeck:fix/models-archive-dialog

Conversation

@djdembeck

Copy link
Copy Markdown
Contributor

Summary

The dropdown menu called setOpen('archive') but ModelsDialogs never rendered a dialog for open === 'archive', so clicking Archive did nothing.

Spirit/Intent

Fix the broken archive action on the models page so users can archive/restore models.

Key Changes

  • Added ModelsArchiveDialog component with archive/restore confirmation
  • Wired ModelsArchiveDialog into ModelsDialogs for open === 'archive'
  • Added useUpdateModelStatus mutation hook calling updateModelStatus GraphQL API
  • Added Restore menu item for archived models (previously unreachable)
  • Added i18n keys for archive/restore dialogs and success toasts (en, zh-CN)

Risks

None identified - changes are isolated to models UI components and locales.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the functionality to archive and restore models, including UI updates for row actions, a new confirmation dialog, a GraphQL mutation hook for status updates, and localized strings. Feedback was provided to improve the implementation of the status change handler by using the mutate method instead of mutateAsync with an empty catch block. Additionally, it is recommended to make the success and error messages in the useUpdateModelStatus hook more dynamic to accurately reflect different status transitions.

Comment thread frontend/src/features/models/components/models-archive-dialog.tsx Outdated
Comment thread frontend/src/features/models/data/models.ts
@greptile-apps

greptile-apps Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a broken Archive action on the models page — setOpen('archive') was called but no dialog was rendered for that state. The fix adds a ModelsArchiveDialog component wired into ModelsDialogs, a useUpdateModelStatus mutation hook, and a Restore menu item for already-archived models, along with matching i18n keys in English and Simplified Chinese.

The previous error-context issue (hardcoded "Archive Model" string on restore errors) is correctly addressed: onError now branches on variables.status to pick either archiveTitle or restoreTitle.

Confidence Score: 5/5

Safe to merge — the fix is minimal, well-scoped, and follows existing patterns throughout the codebase.

All changes are isolated to the models UI and locale files. The prior error-context concern from the previous review thread has been resolved. No new logic paths touch auth, data integrity, or shared state outside the models feature. No P0/P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
frontend/src/features/models/components/models-archive-dialog.tsx New component implementing archive/restore confirmation dialog; correctly reads currentRow.status to determine action direction, guards against null row, and delegates to useUpdateModelStatus.
frontend/src/features/models/data/models.ts Adds useUpdateModelStatus mutation with correct per-operation toast keys and error context keys (archive vs restore branched on variables.status); invalidates ['models'] query on success.
frontend/src/features/models/components/data-table-row-actions.tsx Converts the archive conditional from a simple guard to a ternary, exposing a Restore item (with IconArchiveOff) for archived models; both branches share the same 'archive' open key.
frontend/src/features/models/components/models-dialogs.tsx Wires ModelsArchiveDialog into the dialog switcher for open === 'archive'; no issues.
frontend/src/locales/en/models.json Adds six new i18n keys for archive/restore dialog titles, descriptions, and success toasts; copy is clear and consistent with existing entries.
frontend/src/locales/zh-CN/models.json Adds the same six keys in Simplified Chinese; translations are accurate and parallel the English entries.

Sequence Diagram

sequenceDiagram
    actor User
    participant RowActions as DataTableRowActions
    participant Context as ModelsContext
    participant Dialogs as ModelsDialogs
    participant Dialog as ModelsArchiveDialog
    participant Hook as useUpdateModelStatus
    participant API as GraphQL API

    User->>RowActions: Click Archive / Restore
    RowActions->>Context: setCurrentRow(model)
    RowActions->>Context: setOpen('archive')
    Context-->>Dialogs: open === 'archive'
    Dialogs->>Dialog: render ModelsArchiveDialog
    Dialog->>Context: read currentRow.status
    Note over Dialog: isArchived = status === 'archived'
    Dialog-->>User: Show confirm dialog (Archive or Restore)

    User->>Dialog: Confirm
    Dialog->>Hook: mutate({ id, status: isArchived ? 'enabled' : 'archived' })
    Hook->>API: updateModelStatus(id, status)
    API-->>Hook: { updateModelStatus: true }
    Hook->>Hook: invalidateQueries(['models'])
    Hook->>Hook: toast.success(archiveSuccess | restoreSuccess)
    Hook->>Dialog: onSuccess callback
    Dialog->>Context: setOpen(null)
Loading

Reviews (3): Last reviewed commit: "fix(models): narrow useUpdateModelStatus..." | Re-trigger Greptile

Comment thread frontend/src/features/models/data/models.ts Outdated
The dropdown menu called setOpen('archive') but ModelsDialogs never
rendered a dialog for open === 'archive', so clicking Archive did nothing.

- Add useUpdateModelStatus mutation hook calling updateModelStatus GraphQL
- Add ModelsArchiveDialog with archive/restore confirmation
- Wire ModelsArchiveDialog into ModelsDialogs for open === 'archive'
- Add Restore menu item for archived models (previously unreachable)
- Add i18n keys for archive/restore dialogs and success toasts (en, zh-CN)
@djdembeck djdembeck force-pushed the fix/models-archive-dialog branch from e0b6f20 to 7a800c0 Compare April 29, 2026 08:19
The hook only handles archive/restore, not disable. Narrowing the
status union prevents callers from accidentally passing 'disabled'.
@looplj looplj merged commit 34e9009 into looplj:unstable Apr 29, 2026
4 checks passed
@djdembeck djdembeck deleted the fix/models-archive-dialog branch April 29, 2026 08:56
looplj pushed a commit that referenced this pull request May 8, 2026
* fix(models): wire archive dialog so clicking Archive on a model works

The dropdown menu called setOpen('archive') but ModelsDialogs never
rendered a dialog for open === 'archive', so clicking Archive did nothing.

- Add useUpdateModelStatus mutation hook calling updateModelStatus GraphQL
- Add ModelsArchiveDialog with archive/restore confirmation
- Wire ModelsArchiveDialog into ModelsDialogs for open === 'archive'
- Add Restore menu item for archived models (previously unreachable)
- Add i18n keys for archive/restore dialogs and success toasts (en, zh-CN)

* fix(models): narrow useUpdateModelStatus type to enabled|archived

The hook only handles archive/restore, not disable. Narrowing the
status union prevents callers from accidentally passing 'disabled'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants