fix(library): say only 'Nothing was deleted.' on the archived shelf (#492)

Review LOWs: the archived shelf archives nothing, so its empty outcome no
longer says 'Nothing was deleted or archived.'; a mixed write (deleted,
drifted, protected, gone and restored ids) counts each once.
This commit is contained in:
Vito Sansevero
2026-10-29 13:53:43 -07:00
parent ba30b8f94c
commit 18685e0c83
3 changed files with 31 additions and 1 deletions
@@ -286,4 +286,8 @@ test('the outcome names prompts restored since the review', async () => {
const {deleteOutcome} = await source;
const outcome = deleteOutcome({success: true, deleted: 1, archived: 0, not_archived: 2, changed: 0}, null, {protected: []});
assert.equal(outcome.toast, 'Deleted 1 prompt. 2 were restored since the review and kept.');
const none = deleteOutcome({success: true, deleted: 0, archived: 0, not_archived: 1, changed: 1}, null,
{protected: [], shelf: 'archived'});
assert.equal(none.toast, 'Nothing was deleted. 1 was restored since the review and kept. 1 changed since the review and ' +
'was not deleted. The Library was reloaded.');
});
+25
View File
@@ -851,6 +851,31 @@ class TestArchivedShelfDelete(LibraryDeleteCase):
self.assertEqual((result["deleted"], result["pairs_removed"]), (1, 1))
self.assertEqual(archived_ids(self.db), [shared])
def test_mixed_outcomes_are_each_counted_once(self):
owl, _neg, _pair = self.paired("Owl", "dark")
hen, _neg2, hen_pair = self.paired("Hen", "fog")
loose = save(self.db, "Loose")
self.image(loose, "loose.png")
guarded = save(self.db, "Guarded", tags=["__protected__"])
self.image(guarded, "guarded.png")
gone = save(self.db, "Gone")
self.image(gone, "gone.png")
self.archive(owl, hen, loose, guarded, gone)
review = self.shelf_classify([owl, hen, loose, guarded, gone])
self.db.update_prompt_pair_metadata(hen_pair, notes="drifted")
self.restore([loose])
with self.db.model.get_connection() as conn:
conn.execute("DELETE FROM generated_images WHERE prompt_id=?", (gone,))
conn.execute("DELETE FROM prompts WHERE id=?", (gone,))
conn.commit()
result = self.shelf_write(review, deletes=[loose, gone])
self.assertEqual(
{k: result[k] for k in ("deleted", "changed", "not_found", "not_archived")},
{"deleted": 1, "changed": 1, "not_found": 1, "not_archived": 1},
)
self.assertNotIn(owl, prompt_ids(self.db))
self.assertEqual(archived_ids(self.db), sorted([hen, guarded]))
def test_shelf_must_be_active_or_archived(self):
owl, _neg, _pair = self.paired("Owl")
with self.assertRaises(ValueError):
+2 -1
View File
@@ -322,7 +322,8 @@ export function deleteOutcome(result, failure, review) {
if (deleted) parts.push(`Deleted ${countOf(deleted, 'prompt')}.`);
if (pairs) parts.push(`Removed ${countOf(pairs, 'saved pair')}.`);
if (archived) parts.push(`Archived ${countOf(archived, 'prompt')}.`);
if (!parts.length) parts.push(NOTHING);
// #492: the archived shelf archives nothing, so it says only that nothing was deleted.
if (!parts.length) parts.push(review?.shelf === 'archived' ? 'Nothing was deleted.' : NOTHING);
const already = count(result.already_archived), missing = count(result.not_found), changed = count(result.changed);
if (already) parts.push(`${were(already, 'was', 'were')} already archived.`);
const restored = count(result.not_archived);