🐛 fix: Memories Key Updates (#8302)

* Updated the PATCH /memories/:key endpoint to allow key changes while ensuring no duplicate keys exist.
* Improved error handling in MemoryCreateDialog and MemoryEditDialog for key validation and duplication scenarios.
* Added a new translation for memory key validation error in translation.json.
This commit is contained in:
Dustin Healy 2025-07-07 13:38:55 -07:00 committed by GitHub
parent f4d97e1672
commit 12b08183ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 68 additions and 15 deletions

View file

@ -52,6 +52,10 @@ export default function MemoryCreateDialog({
if (axiosError.response?.status === 409 || errorMessage.includes('already exists')) {
errorMessage = localize('com_ui_memory_key_exists');
}
// Check for key validation error (lowercase and underscores only)
else if (errorMessage.includes('lowercase letters and underscores')) {
errorMessage = localize('com_ui_memory_key_validation');
}
}
} else if (error.message) {
errorMessage = error.message;

View file

@ -44,9 +44,29 @@ export default function MemoryEditDialog({
status: 'success',
});
},
onError: () => {
onError: (error: Error) => {
let errorMessage = localize('com_ui_error');
if (error && typeof error === 'object' && 'response' in error) {
const axiosError = error as any;
if (axiosError.response?.data?.error) {
errorMessage = axiosError.response.data.error;
// Check for duplicate key error
if (axiosError.response?.status === 409 || errorMessage.includes('already exists')) {
errorMessage = localize('com_ui_memory_key_exists');
}
// Check for key validation error (lowercase and underscores only)
else if (errorMessage.includes('lowercase letters and underscores')) {
errorMessage = localize('com_ui_memory_key_validation');
}
}
} else if (error.message) {
errorMessage = error.message;
}
showToast({
message: localize('com_ui_error'),
message: errorMessage,
status: 'error',
});
},

View file

@ -856,6 +856,7 @@
"com_ui_memory_deleted": "Memory deleted",
"com_ui_memory_deleted_items": "Deleted Memories",
"com_ui_memory_key_exists": "A memory with this key already exists. Please use a different key.",
"com_ui_memory_key_validation": "Memory key must only contain lowercase letters and underscores.",
"com_ui_memory_updated": "Updated saved memory",
"com_ui_memory_updated_items": "Updated Memories",
"com_ui_mention": "Mention an endpoint, assistant, or preset to quickly switch to it",