mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
fix(desktop): deleting the active profile reliably falls back to default
Centralize the fallback in DeleteProfileDialog (the single delete choke point) so both the rail and the Profiles view inherit it. Reset *after* the host's onDeleted refresh so a refreshActiveProfile racing the dying backend can't clobber the pill back to the deleted profile, and set $activeProfile too (selectProfile only moved the gateway, leaving the statusbar pill stranded on the dead profile).
This commit is contained in:
parent
9dbd3c57d7
commit
f764b0400a
2 changed files with 16 additions and 11 deletions
|
|
@ -264,16 +264,7 @@ export function ProfileRail() {
|
||||||
|
|
||||||
<DeleteProfileDialog
|
<DeleteProfileDialog
|
||||||
onClose={() => setPendingDelete(null)}
|
onClose={() => setPendingDelete(null)}
|
||||||
onDeleted={async () => {
|
onDeleted={refreshActiveProfile}
|
||||||
// Deleting the profile you're currently in would strand the gateway on
|
|
||||||
// a dead profile — fall back to default.
|
|
||||||
const wasActive = pendingDelete != null && normalizeProfileKey(pendingDelete.name) === activeKey
|
|
||||||
await refreshActiveProfile()
|
|
||||||
|
|
||||||
if (wasActive) {
|
|
||||||
selectProfile('default')
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
open={pendingDelete !== null}
|
open={pendingDelete !== null}
|
||||||
profile={pendingDelete}
|
profile={pendingDelete}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import { ConfirmDialog } from '@/components/ui/confirm-dialog'
|
import { ConfirmDialog } from '@/components/ui/confirm-dialog'
|
||||||
import { deleteProfile } from '@/hermes'
|
import { deleteProfile } from '@/hermes'
|
||||||
|
import { $activeGatewayProfile, normalizeProfileKey, selectProfile, setActiveProfile } from '@/store/profile'
|
||||||
|
|
||||||
// Thin wrapper over ConfirmDialog: owns the deleteProfile call, inherits
|
// Thin wrapper over ConfirmDialog: owns the deleteProfile call, inherits
|
||||||
// Enter-to-confirm + busy/done/error from the shared dialog.
|
// Enter-to-confirm + busy/done/error from the shared dialog. The single choke
|
||||||
|
// point for every delete entry point (rail + Profiles view).
|
||||||
export function DeleteProfileDialog({
|
export function DeleteProfileDialog({
|
||||||
profile,
|
profile,
|
||||||
onClose,
|
onClose,
|
||||||
|
|
@ -34,8 +36,20 @@ export function DeleteProfileDialog({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deleting the profile the live gateway is on strands it on a dead
|
||||||
|
// backend. Capture that before the delete; reset *after* the host's
|
||||||
|
// onDeleted refresh so our reset is the last write — a refreshActiveProfile
|
||||||
|
// racing the (still-dying) backend can't clobber the pill back to it.
|
||||||
|
const wasActive = normalizeProfileKey(profile.name) === normalizeProfileKey($activeGatewayProfile.get())
|
||||||
await deleteProfile(profile.name)
|
await deleteProfile(profile.name)
|
||||||
await onDeleted?.()
|
await onDeleted?.()
|
||||||
|
|
||||||
|
if (wasActive) {
|
||||||
|
// Swap gateway/sidebar to default and set the pill now — the primary
|
||||||
|
// backend is always default, so this is correct, not just optimistic.
|
||||||
|
selectProfile('default')
|
||||||
|
setActiveProfile('default')
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
open={open}
|
open={open}
|
||||||
title="Delete profile?"
|
title="Delete profile?"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue