feat: Allow deleting an orphaned summary from HypaV3 (#831)

# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [x] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [x] Have you added type definitions?

# Description

Currently, you can:

- Manually rewrite summaries
- Delete orphaned summaries (all or none, in the settings)
- Delete all summaries after one

But you can't:

- Manually add summaries
- Delete a summary

This PR aims to add a feature for the second one - you can pick and
delete a specific summary.

As I'm not yet familiar with the implementation of HypaV3, this PR only
allows deleting orphaned summaries to minimize any unforeseen
side-effects.

cn, de, es, vi, zh-Hant strings were made with Gemini. Reviews welcome.
This commit is contained in:
kwaroran
2025-05-10 20:17:29 +09:00
committed by GitHub
8 changed files with 32 additions and 5 deletions

View File

@@ -800,6 +800,7 @@ export const languageChinese = {
"noSummariesLabel": "尚无总结",
"searchPlaceholder": "输入 #N、ID 或搜索关键词",
"summaryNumberLabel": "总结 #{0}",
"deleteThisConfirmMessage": "删除此摘要?",
"deleteAfterConfirmMessage": "删除此后的所有总结?",
"deleteAfterConfirmSecondMessage": "此操作无法撤销。您确定吗?",
"translationLabel": "翻译",

View File

@@ -464,6 +464,7 @@ export const languageGerman = {
"noSummariesLabel": "Noch keine Zusammenfassungen",
"searchPlaceholder": "Geben Sie #N, ID oder Suchanfrage ein",
"summaryNumberLabel": "Zusammenfassung #{0}",
"deleteThisConfirmMessage": "Diese Zusammenfassung löschen?",
"deleteAfterConfirmMessage": "Alle Zusammenfassungen nach dieser löschen?",
"deleteAfterConfirmSecondMessage": "Diese Aktion kann nicht rückgängig gemacht werden. Sind Sie wirklich sicher?",
"translationLabel": "Übersetzung",

View File

@@ -1036,6 +1036,7 @@ export const languageEnglish = {
noSummariesLabel: "No summaries yet",
searchPlaceholder: "Enter #N, ID, or query",
summaryNumberLabel: "Summary #{0}",
deleteThisConfirmMessage: "Delete this summary?",
deleteAfterConfirmMessage: "Delete all summaries after this one?",
deleteAfterConfirmSecondMessage: "This action cannot be undone. Are you really sure?",
translationLabel: "Translation",

View File

@@ -709,6 +709,7 @@ export const languageSpanish = {
"noSummariesLabel": "Aún no hay resúmenes",
"searchPlaceholder": "Ingrese #N, ID o búsqueda",
"summaryNumberLabel": "Resumen #{0}",
"deleteThisConfirmMessage": "¿Eliminar este resumen?",
"deleteAfterConfirmMessage": "¿Eliminar todos los resúmenes después de este?",
"deleteAfterConfirmSecondMessage": "Esta acción no se puede deshacer. ¿Está realmente seguro?",
"translationLabel": "Traducción",

View File

@@ -955,6 +955,7 @@ export const languageKorean = {
"noSummariesLabel": "아직 요약이 없습니다",
"searchPlaceholder": "#N, ID 또는 검색어 입력",
"summaryNumberLabel": "요약 #{0}",
"deleteThisConfirmMessage": "이 요약을 삭제하시겠습니까?",
"deleteAfterConfirmMessage": "이 요약 이후의 모든 요약을 삭제하시겠습니까?",
"deleteAfterConfirmSecondMessage": "이 작업은 되돌릴 수 없습니다. 정말 삭제하시겠습니까?",
"translationLabel": "번역",

View File

@@ -438,6 +438,7 @@ export const LanguageVietnamese = {
"noSummariesLabel": "Chưa có tóm tắt nào",
"searchPlaceholder": "Nhập #N, ID hoặc từ khóa",
"summaryNumberLabel": "Tóm tắt #{0}",
"deleteThisConfirmMessage": "Xóa bản tóm tắt này?",
"deleteAfterConfirmMessage": "Xóa tất cả các tóm tắt sau tóm tắt này?",
"deleteAfterConfirmSecondMessage": "Hành động này không thể hoàn tác. Bạn có chắc chắn không?",
"translationLabel": "Bản dịch",

View File

@@ -833,6 +833,7 @@ export const languageChineseTraditional = {
"noSummariesLabel": "尚無摘要",
"searchPlaceholder": "輸入 #N、ID 或搜尋關鍵字",
"summaryNumberLabel": "摘要 #{0}",
"deleteThisConfirmMessage": "刪除此摘要?",
"deleteAfterConfirmMessage": "刪除此摘要之後的所有摘要?",
"deleteAfterConfirmSecondMessage": "此操作無法撤銷。您確定要這樣做嗎?",
"translationLabel": "翻譯",

View File

@@ -413,23 +413,23 @@
summaryUIState.isTranslating = false;
}
function isRerollable(summaryIndex: number): boolean {
function isOrphan(summaryIndex: number): boolean {
const summary = hypaV3DataState.summaries[summaryIndex];
for (const chatMemo of summary.chatMemos) {
if (!getMessageFromChatMemo(chatMemo)) {
return false;
return true;
}
}
return true;
return false;
}
async function toggleReroll(summaryIndex: number): Promise<void> {
const summaryUIState = summaryUIStates[summaryIndex];
if (summaryUIState.isRerolling) return;
if (!isRerollable(summaryIndex)) return;
if (isOrphan(summaryIndex)) return;
summaryUIState.isRerolling = true;
summaryUIState.rerolledText = "Loading...";
@@ -1083,12 +1083,32 @@
<button
class="p-2 text-zinc-400 hover:text-zinc-200 transition-colors"
tabindex="-1"
disabled={!isRerollable(i)}
disabled={isOrphan(i)}
onclick={async () => await toggleReroll(i)}
>
<RefreshCw class="w-4 h-4" />
</button>
<!-- Delete This Button -->
<button
class="p-2 text-zinc-400 hover:text-rose-300 transition-colors"
tabindex="-1"
disabled={!isOrphan(i)}
onclick={async () => {
if (
await alertConfirm(language.hypaV3Modal.deleteThisConfirmMessage)
) {
hypaV3DataState.summaries = hypaV3DataState.summaries.filter(
(_, index) => index !== i
);
}
showHypaV3Alert();
}}
>
<Trash2Icon class="w-4 h-4" />
</button>
<!-- Delete After Button -->
<button
class="p-2 text-zinc-400 hover:text-rose-300 transition-colors"