Repository navigation
feat(ios): add vault deletion to Manage Vaults - #224
Conversation
Settings > Manage Vaults (LibrarySettingsView) previously had no delete affordance at all - the mock row it once showed was already replaced by real vault data in a prior UI-parity pass (see e159bc3), but the only way to remove a vault was an undiscoverable swipe gesture with zero confirmation. - SettingsView.swift: replace swipe-to-delete with a per-row trash icon + confirmation alert, copy matching Android's VaultRow/AlertDialog pattern (SettingsScreen.kt) word for word. - DomainBridge.swift: add removeVault(bookIds:), the Swift-native counterpart to core:domain's RemoveVaultFolderUseCase. Android's use case deletes a vault's library items via libraryRepository, which cascades (Room FK ON DELETE CASCADE) to drop their highlights/ bookmarks/progress rows for free. No KMP framework is actually linked into this app (see this file's own header comment - every other DomainBridge method, e.g. bookmarks/highlights/progress, is already a native Swift reimplementation, not a real KMP call-through), and there is no on-device database here to cascade automatically, so this walks the three dictionaries explicitly instead. Without it, a removed vault's reading data would silently linger forever in UserDefaults. - AppState.swift: removeVault(_:) now resolves the removed vault's book ids before dropping it, routes them through bridge.removeVault(bookIds:) first, then removes the vault entry from VaultPersistence as before. Closes #223 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
📱 iOS Build Status: FAILED❌ iOS Simulator Build & Unit Tests - failure iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
CI (Build & Test iOS Simulator) caught two real bugs in the first pass:
- AppState.removeVault(_:) fired its bridge cleanup inside an internal,
un-awaited Task, and the test asserting on it assumed (wrongly, as
actual XCTest scheduling proved) that a subsequent await on the same
MainActor was enough to let that Task finish first. Made removeVault
itself async and awaited directly by its one caller (SettingsView's
confirm-alert action, now wrapped in Task { await ... }) instead of
racing a detached Task with no real synchronization point.
- Two DomainBridgeTests cases reused the bookId "kept-1" against the
shared LibravaultDomainBridge.shared singleton and asserted an absolute
bookmark count, which broke depending on run order (an earlier test's
bookmark under the same id was still there). Switched to unique ids and
before/after deltas, matching the delta pattern the pre-existing
addBookmark/deleteBookmark tests in the same file already use for
exactly this reason.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
QA verification — PR #224 vs issue #223Verdict: PASS Acceptance criteria
Tests actually test something real
Test suites run
Regressions / other observations
QA verdict: PASS |
📱 iOS Build Status: PASSED✅ iOS Simulator Build & Unit Tests - success iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
|
Update: pushed a follow-up commit (91790ef) fixing 2 real bugs the first CI run caught in Separately: the |
Principal review — PR #224 (feat(ios): add vault deletion to Manage Vaults)Risk classification: Both disclosed deviations verified true, not just trusted
CI/test claims verified against ground truth, not taken at face value
CONFIRMED finding — cascade-delete ordering is inverted vs. its own stated contract
func removeVault(_ vault: Vault) async {
let orphanedBookIds = books.filter { $0.vaultId == vault.id }.map(\.id)
vaults.removeAll { $0.id == vault.id }
vaultPersistence.save(vaults) // vault entry gone + persisted HERE
try? await bridge.removeVault(bookIds: orphanedBookIds) // cascade cleanup HERE, after
await loadLibrary()
}Both the method's own doc comment (" Practical impact is narrow ( Fix is a one-line reorder: run Confirmation UXTrash icon (was bare Minor / non-blocking
Verdict: REQUEST CHANGESEverything else in this PR is solid — both disclosed deviations from the issue are genuinely justified and verified, the two CI-driven bug fixes are real and sound, test coverage is substantive (would fail against a partial fix, not just compile-gate), and there's no sensitive-path/networking exposure. But there is one CONFIRMED, if narrow-window, correctness bug in exactly the area this PR's own docs claim to have gotten right (cascade-delete ordering / partial-failure behavior) — per the pipeline's outcome rules, a CONFIRMED finding routes this to human-merge regardless of the (correctly-assigned) |
Principal review on PR #224 caught the cascade-delete order inverted from its own documented contract: AppState.removeVault dropped the vault from persistence, then attempted bridge.removeVault(bookIds:) cleanup with try? — silently swallowing any failure. A thrown DomainError.notInitialized there left the vault gone while its books' bookmarks/highlights/progress survived forever, orphaned with no owner — the exact failure mode this PR exists to prevent, reached via the opposite order. Reorder so the cascade cleanup runs first and is genuinely awaited: on failure, log it, surface AppError.vaultRemovalFailed to the user (this already renders as an alert app-wide), and leave the vault + its data untouched rather than half-deleting. Only remove the vault entry after cleanup actually succeeds, matching Android's RemoveVaultFolderUseCase order (deleteByVault before removeVault). Review thread: #224 (comment)
|
Fixed in b2e129f: reordered |
📱 iOS Build Status: FAILED❌ iOS Simulator Build & Unit Tests - failure iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
… has no .name, only .displayName)
📱 iOS Build Status: PASSED✅ iOS Simulator Build & Unit Tests - success iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
Strict branch protection requires the branch be up to date. #224 touches only iOS sources/tests with no overlap with this PR's files.
Unlike dev-agent.yml and qa-agent.yml, principal-review.yml had no crash-handling backstop. Live on PR #224: the "Run principal review agent" step hit --max-turns 40 and crashed (error_max_turns). Without continue-on-error, that failed the whole job and skipped every step after it, including "Advance PR based on review verdict" - the PR was left stuck on status:needs-review with zero visible signal anything had gone wrong (no comment, no label change). A human happened to notice the failed workflow run and reviewed the PR by hand; the pipeline did not recover on its own and would have left it stuck indefinitely otherwise (principal-review.yml only triggers on a labeled event). Mirrors qa-agent.yml's existing pattern: - Add continue-on-error: true to the agent step, so the job continues past a crash instead of skipping everything downstream. - In "Advance PR based on review verdict", check steps.agent.outcome == 'failure' first and route to status:needs-info (remove status:needs-review) with an explanatory comment linking the run, before falling through to the normal verdict-file logic. Closes #227 Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
…nce (#230) Live on PR #225: qa-agent.yml tried to verify it against issue #223's acceptance criteria, completely unrelated (#225 is a CI pipeline-infra fix; #223 is a separate feature closed by the separate PR #224). Root cause: PR #225's own body mentioned, in passing prose, "PR #224 (which fixes #223)" - background context, not PR #225's own closing keyword - and the shared regex matched it anyway. qa-agent caught the mismatch itself and evaluated the PR on its own merits, but flagged it as a process signal. Confirmed via the GitHub GraphQL API (closingIssuesReferences) that this isn't just our script being loose - GitHub's own real closing-keyword parser is exactly this naive too: it had linked PR #225 as a genuine closing reference for issue #223, meaning merging it would have auto-closed the wrong issue a second time. That's a footgun in GitHub's parser this script can't fix, but resolve_linked_issue.sh's actual job (telling dev-agent/qa-agent/principal-review which issue's acceptance criteria a PR should be judged against) is a stricter question than "what would GitHub technically auto-close" - matching GitHub's looser behavior here isn't worth keeping. Anchors the keyword to the start of its (trimmed) line, stripping optional markdown list/heading/blockquote markers first - matches how every real PR in this pipeline already writes it ("Closes #N" alone on its own line) and rejects mid-sentence mentions. Verified against real PR bodies: #224 still resolves to 223, #229 still resolves to 227, #221 (pre-existing pipeline PR) still resolves to 4, #225 now correctly resolves to nothing. Also cleaned up PR #225's own body to stop tripping this (both the original phrasing and, ironically, an early draft of this explanation itself re-triggered the same match). Closes #228 Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
…ne (#225) dev-agent.yml's risk-classification + status:needs-qa handoff only runs as the tail of its own triage-and-implement job, i.e. only for PRs it opens itself via the pipeline App token in that same job run. A PR opened any other way (a human, or a Claude Code session working an issue directly rather than through status:ready-for-dev) never enters that job, so it carries no risk:*/status:* label and nothing downstream ever picks it up. Confirmed live: issue #223's actual fix, PR #224, was opened this way by a session outside the pipeline and sat unlabeled until a human noticed and hand-applied risk:low/status:needs-qa manually. Adds pr-intake.yml: triggers on pull_request opened/reopened, skips PRs authored by libravault-pipeline-bot[bot] (already handled synchronously by dev-agent.yml) and PRs already carrying a pipeline status label (idempotent against reopened re-firing), then runs the same deterministic classify-and-label step dev-agent.yml's tail runs for its own PRs. Runs no agent - pure backstop, not a fourth triage path. Documents the gap and fix in docs/agent-team-pipeline.md. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Summary
Closes #223.
Settings → Manage Vaults previously had no way to delete a vault, per a real TestFlight field report. Two things worth flagging up front, since they change the shape of the fix from what the issue describes:
LibrarySettingsViewno longer exists. The issue's file references (SettingsView.swift:62-93, the hardcoded/Documentsmock) are stale — that mock was already removed in commite159bc3(Jul 25, three weeks before this issue was filed) as part of the iOS/Android UI-parity pass.vaultsSectioninSettingsView.swiftalready renders real vault data. The actual remaining gap is narrower than the issue title suggests: the only delete affordance was an undiscoverable.onDeleteswipe gesture with zero confirmation — one accidental swipe permanently deleted a vault.DomainBridge.swift's own header comment says so explicitly, and confirmed by grep — there is noscanLibrarymethod or any other real KMP call-through anywhere inios/. Every existingDomainBridgemethod (bookmarks, highlights, progress, TTS) is a native Swift reimplementation, not a call intocore:domain. So "add a bridge method that invokes the existing sharedRemoveVaultFolderUseCasevia whatever KMP interop mechanismDomainBridge.swiftalready uses forscanLibrary" isn't achievable as literally written — that mechanism doesn't exist for anything on iOS today. Actually wiringcore:domaininto iOS is a separate, much larger tracked effort (see theiOS KMP integration statushistory — blocked on ajava.time.Instantswap rippling 6 modules).Approach
Given (2), this ports
RemoveVaultFolderUseCase's behavior natively in Swift, consistent with how every otherDomainBridgemethod already works in this codebase, rather than either reimplementing without documenting the gap or attempting an unrelated multi-week KMP-linkage project:SettingsView.swift: replaced the swipe-to-delete gesture with a per-row trash icon + confirmation.alert, copy matching Android'sVaultRow/AlertDialog(SettingsScreen.kt) word for word ("Remove vault?" /This will remove "<name>" and all its items from the library./ Remove (destructive) / Cancel).DomainBridge.swift: addedremoveVault(bookIds:) async throws. Android'sRemoveVaultFolderUseCaseis two steps:libraryRepository.deleteByVault(vaultId)(which cascades via RoomON DELETE CASCADEFKs to drop that vault's books' highlights/bookmarks/progress rows for free) thenvaultRepository.removeVault(vaultId). iOS has no on-device database to cascade automatically, so this method does the first step explicitly — clearingbookmarks/highlights/progressfor the given book ids and persisting via the existingReadingDataPersistence. Without this, a removed vault's reading data would have silently lingered forever inUserDefaults, keyed by book ids nothing could ever resolve back to a real book again — a real (if minor) bug independent of the confirmation-dialog gap.AppState.swift:removeVault(_:)now resolves the removed vault's book ids first, awaitsbridge.removeVault(bookIds:), then removes the vault entry fromVaultPersistenceas before (mirrorsRemoveVaultFolderUseCase's step ordering).Risk
No
agent-policy.ymlsensitive_pathstouched (not CI/CD, crypto, billing, dependency-catalog, or agent-pipeline config). No networking dependency or call added. Small, self-contained diff across 3 source files + 2 test files.Test plan
Added unit test coverage for the new bridge method and the
AppStatewiring, per this repo's test convention:DomainBridgeTests.swift:removeVault(bookIds:)clears bookmarks/highlights/progress for the given ids, leaves unrelated books' data untouched, no-ops on an empty id list, and throwsDomainError.notInitializedwhen called beforeinitialize().DomainBridgePersistenceTests.swift(same file): the cleanup actually persists across a fresh bridge instance (not just an in-memory mutation).AppStateVaultTests.swift: removing a vault clears the bridge's bookmark data for that vault's books (regression guard for the actual bug, not just "the list shrinks").Could not build or run
xcodebuild/XCTestlocally — no Xcode toolchain on this machine (Linux sandbox;ios-app-build.ymlrequiresmacos-26). Every change was written and reviewed by hand against existing patterns in the same files (DomainBridgeTests/AppStateVaultTests' existing tests,.alert(_:isPresented:presenting:actions:message:)usage elsewhere in the repo), but the actual first compile/test signal is CI on this PR — flagging explicitly rather than claiming a local green run that didn't happen.🤖 Generated with Claude Code