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

@@ -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"