readest/apps/readest-app
Huang Xin 052bbc8e77
feat(library): remove selected books from the device only (#7324)
* feat(library): remove selected books from the device only (#7318)

Bulk delete in selection mode always deleted from cloud and device; the
device-only removal was only in Book Details, one book at a time. The
bulk delete confirmation now has a "Remove from Device Only" toggle. It
runs the existing local delete for the selected books that have a cloud
copy (or an Audiobookshelf offline download) and skips the rest, so a
bulk action never leaves a book with no copy anywhere. With it on, the
purge toggle and the delete message are hidden and the button reads
"Remove".

Verified:
- Tests written first. Before the change, library-utils.test.ts failed
  with "canRemoveFromDeviceOnly is not a function" and
  DeleteConfirmAlert.test.tsx with "Unable to find ... checkbox
  'Remove from Device Only'"; the hidden-message check failed with
  "expected <div class="text-start text-sm"></div> to be null". All
  pass now (176 tests across library-utils, DeleteConfirmAlert,
  Bookshelf and BookDetailModal), plus alert-width-stability browser
  test (3 tests).
- pnpm lint and pnpm format:check clean.
- dev-web with Playwright on a fresh profile: imported 3 EPUBs, gave 2
  a stand-in cloud copy (uploadedAt), selected all 9 books, turned the
  toggle on and confirmed. The 2 lost their local file and
  downloadedAt and stayed in the library; the local-only book and the
  demo books were untouched. Dialog checked in light, dark, e-ink
  (data-eink), RTL and at 390 px.
- Not run: a real cloud account (the cloud copy was faked), native
  desktop/Android/iOS builds, and confirming the toggle-off Delete path
  in the app (covered by the unit test).

Reported by poife on GitHub.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(library): keep Enter on a delete toggle and a cancelled delete from misfiring

Two CodeRabbit findings on #7324:
- Alert confirms on any Enter, so Enter on the focused "Remove from Device
  Only" toggle ran a cloud-and-device delete. Enter on a toggle now flips
  it instead (capture phase, ahead of Alert's listener).
- Cancel set the abort flag even with no deletion running, so the next
  confirmed bulk delete stopped before its first batch and deleted
  nothing. runDeletion now clears the flag when it starts.

Verified:
- DeleteConfirmAlert.test.tsx "toggles instead of confirming when Enter
  is pressed on a toggle" failed before the fix with 'expected "vi.fn()"
  to not be called at all, but actually been called 1 times'.
- library.test.tsx "deletes the books after an earlier delete
  confirmation was cancelled" failed before the fix with 'expected
  "vi.fn()" to be called 2 times, but got 0 times'.
- Both pass now, with 178 tests across the four related suites and the
  alert-width browser test; pnpm lint and pnpm format:check clean.
- dev-web with Playwright: Cancel, reopen, focus the toggle, press Enter:
  the toggle turned on and the dialog stayed open; Remove then dropped
  the local files of the 2 books with a cloud copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(library): keep each bulk deletion's cancel to its own run

CodeRabbit on #7324: clearing a shared abort flag at the start of a run
let a cancelled run continue with its remaining batches when a new
deletion started before its current batch finished, and the old run
could then close the newer alert. Each run now takes a token; Cancel and
any newer run make it stale, so it stops before its next batch and leaves
the alert alone. Also fixes the Romanian plural forms of the new string
("al 1 carte" was ungrammatical).

Verified:
- library.test.tsx "stops a cancelled deletion even when another one
  starts before its batch ends" failed before the fix with 'expected
  "vi.fn()" to be called 21 times, but got 41 times' and passes now; 179
  tests across the four related suites pass; pnpm lint and
  pnpm format:check clean.
- dev-web with Playwright: Cancel, reopen, Enter on the toggle, Remove
  still drops the local files of the 2 books with a cloud copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:29:12 +01:00
..
.agents
.claude chore(agent): update memories (#7295) 2026-11-03 17:25:39 +01:00
bench
data/wordlens feat(wordlens): Traditional Chinese hints and an English→Arabic pack (#6303) 2026-09-19 16:49:10 +02:00
docs feat(tts): read aloud with Speech Dispatcher voices on Linux (#7314) 2026-11-04 10:38:54 +01:00
e2e feat(reader): vim-style find to start and extend a selection from the keyboard (#7282) 2026-11-03 18:45:25 +01:00
extensions fix(security): remediate Dependabot dependency alerts (#7248) 2026-11-02 11:50:57 +01:00
public feat(library): remove selected books from the device only (#7324) 2026-11-04 15:29:12 +01:00
scripts build(android): ship per-ABI APKs (arm64, armv7, legacy) instead of universal (#6772) 2026-10-13 19:33:05 +02:00
src feat(library): remove selected books from the device only (#7324) 2026-11-04 15:29:12 +01:00
src-tauri feat(tts): preview voices and pick a default voice per language (#7322) 2026-11-04 13:37:48 +01:00
workers
.env chore(auth): point clients at the Supabase project URL (#6729) 2026-10-12 13:12:32 +02:00
.env.local.example
.env.tauri
.env.tauri.example fix(api): validate DeepL and AI gateway request limits (#6818) 2026-10-18 17:28:59 +02:00
.env.web
.env.web.example fix(api): validate DeepL and AI gateway request limits (#6818) 2026-10-18 17:28:59 +02:00
.gitignore chore(agent): update memories (#7295) 2026-11-03 17:25:39 +01:00
AGENTS.md fix(library): add colored fallback covers (owner: use the classic) (#7222) 2026-11-01 17:24:06 +01:00
CLAUDE.md
components.json feat(ui): migrate to daisyUI 5 and Tailwind CSS 4 (#5884) 2026-08-26 16:09:41 +02:00
DESIGN.md fix(library): add colored fallback covers (owner: use the classic) (#7222) 2026-11-01 17:24:06 +01:00
i18n-langs.json feat(i18n): add Georgian translations (#5763) 2026-08-17 12:21:10 +02:00
i18next-scanner.config.cjs
LESSONS.md chore(agent): lessons from 2026-10-14 to 10-15 (#6842) 2026-10-18 17:42:12 +02:00
next.config.mjs fix(build): turn off the Turbopack build cache that Next 16.4 enables (#7082) 2026-10-25 11:22:23 +01:00
open-next.config.ts
package.json fix(build): make pnpm preview serve pages and rewrites again (#7141) 2026-10-28 13:38:59 +01:00
pdfjs.d.ts fix(build): repair the Docker and Nix builds after #6368 (#6379) 2026-09-23 15:13:35 +02:00
playwright.config.ts
postcss.config.mjs feat(ui): migrate to daisyUI 5 and Tailwind CSS 4 (#5884) 2026-08-26 16:09:41 +02:00
PRODUCT.md feat(reader): Notebook as a linked writing workspace (#5928) 2026-08-28 21:18:17 +02:00
raw-loader.d.ts
release-notes.json release: version 0.12.16 (#6779) 2026-10-14 00:33:31 +02:00
skills-lock.json
TODOS.md feat(reader): Notebook as a linked writing workspace (#5928) 2026-08-28 21:18:17 +02:00
tsconfig.json fix(build): repair the Docker and Nix builds after #6368 (#6379) 2026-09-23 15:13:35 +02:00
vite.config.ts fix(build): repair the Docker and Nix builds after #6368 (#6379) 2026-09-23 15:13:35 +02:00
vitest.android.config.mts
vitest.browser.config.mts fix(build): repair the Docker and Nix builds after #6368 (#6379) 2026-09-23 15:13:35 +02:00
vitest.config.mts test: use four workers for unit tests (#7242) 2026-11-02 08:27:07 +01:00
vitest.env.mts
vitest.setup.ts feat(tts): custom OpenAI-compatible TTS services (#6746) 2026-10-13 14:33:28 +02:00
vitest.tauri.config.mts fix(build): repair the Docker and Nix builds after #6368 (#6379) 2026-09-23 15:13:35 +02:00
vitest.tauri.setup.ts
wdio.conf.ts
worker.ts feat(tts): move Readest Voice into its own service (#6732) 2026-10-12 15:10:19 +02:00
wrangler.toml perf(web): run the web Worker near Supabase with Smart Placement (#7273) 2026-11-02 20:30:48 +01:00