Repository navigation
fix(desktop): keep deleted-lane tasks retired so they stop resurfacing as live - #11460
Conversation
…g as live Tasks deleted on another device came back as live tasks on a fresh machine, and the Removed list stayed empty: TasksStore: Fetched 100 deleted tasks from API TasksStore: Showing 0 deleted tasks from merged local cache `TaskActionItem.isRetired` re-derives retirement from the response body (`deleted == true`, or a canonical status of cancelled/superseded). Its own doc comment records that list responses may omit legacy `deleted` and project retirement through canonical lifecycle status — and that status vocabulary is open, so any other value reads as live. `ActionItemRecord.from(_:)` persists `deleted: item.isRetired`, so a row arriving from the deleted lane without either marker was written to SQLite as live: it disappeared from the `.deleted` scope query and reappeared as a live task. The lane is the authority on retirement, not a re-derivation from whichever fields a response happened to carry. `fetchDeletedPage` now stamps it after both transports — live API and injected operations — so neither path can skip it, and both callers of that page (first load and auto-refresh) sync a correctly retired row. Scope note: this fixes the retirement state, not the refresh cadence. The deleted refresh still re-fetches and re-syncs a full page per tick whose result `mergeWithoutAdding` may discard; that churn is tracked separately. An earlier draft of this note claimed that churn contributed to the desktop chat outage via kernel-context contention. That was wrong, and it is corrected here so the claim is not carried into the tree. The outage was measured on 2026-08-12 to a missing index: `buildContextSnapshot` joins `conversation_turns` to `conversation_turn_revisions` on `turn_id`, which carried no index, so the snapshot query took ~28s against the kernel's 15s `get_context_snapshot` budget. A Node inspector CPU profile of the live kernel put 20.9% of samples under that one query and journal replay at 0.1%, and the Swift app held 11-23% CPU while the kernel saturated a core - so nothing on this path was starving chat. Adding the index took that query to 0.03s and chat answers again. This deleted-lane churn remains a real defect on its own merits, with no established link to chat latency. TasksStore.swift is on the BasedHardware#9838 oversized-product-file freeze, and stamping retirement after both transports grows it 3688 -> 3697 lines, so the ratchet baseline is raised by exactly that with a one-line justification. Splitting a 3,697-line store is the unreviewable migration a bug fix must not become; the baseline records the debt instead of hiding it. Failure-Class: FC-split-mutation-authority Verification (macOS 27.0, Xcode 26.6 stable, Swift 6.3.3, 2026-08-11) — this replaces the pre-amend "NOT RUN" block, which was accurate when authored in a Linux container with no macOS toolchain: cd desktop/macos/Desktop xcrun swift test --force-resolved-versions --skip-update \ --filter TasksStoreDeletedLaneRetirementTests => Executed 2 tests, with 0 failures The test fails against the unfixed code, so it is coverage rather than decoration. Both production files reverted to this commit's parent and rebuilt: => Executed 2 tests, with 2 failures XCTAssertEqual failed: ("[]") is not equal to ("["deleted-on-phone"]") - the retired row must show up in the deleted list instead of vanishing That is the reported symptom reproduced. The passing run also inverts the log signature from the bug report: "Fetched 1 deleted tasks from API / Showing 1 deleted tasks from merged local cache". Isolation: each case passes alone, and all 85 tests matching `TasksStore` pass together, so nothing leaks through the `TasksStore.shared` singleton. Caveat on the second case: testAlreadyRetiredRowIsPassedThroughUnchanged also fails against the unfixed code, so it is not the already-correct-path invariant its name implies - both cases are sensitive to the stamping. The name oversells what it isolates; the coverage itself is sound. Also checked on macOS: desktop/macos/scripts/swift-format-wrapper.sh lint --strict reports no diagnostics on all three files (verified the linter is live by confirming it flags a deliberately malformed file); desktop/macos/scripts/check-main-actor-xctest-hooks.py passes - note the pre-amend message cited this as scripts/, which is the wrong path; no changed line exceeds 120 columns, and the two >120 lines in TasksStore.swift are pre-existing; Tests/ is the SPM test-target path, confirmed by 16 matching symbols in the built "Omi ComputerPackageTests.xctest" bundle. App-level verification (2026-08-12, after the above was first written): a combined build carrying this fix and the chat context-snapshot index was run as the named bundle `omi-combined-verify` on current upstream. The deleted lane now reports what it was always failing to: TasksStore: Fetched 100 deleted tasks from API TasksStore: Showing 20 deleted tasks from merged local cache `Showing 0` against a non-zero fetch was the whole symptom, so this is the first run in which the Removed list is populated at all. The live list still sheds rows as the lane pages through (581 -> 547 -> 513 -> 483, added=0), but that is now the correct outcome rather than the defect: before, a deleted-lane row left the live list and appeared nowhere, whereas those rows now land in the `.deleted` scope, which is exactly why the count above is non-zero. The bundle had its own fresh kernel database, so nothing here depends on repairing rows an earlier build had already mis-stored as live. Not run: the full desktop suite (only the filtered class and the 87 TasksStore matches). This fix corrects the write path only — rows already persisted as live by an affected build are reconciled by later refreshes, not rewritten. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CYhtePtn1bYg14Yjd2ZJUk Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011qmdS9crg5qFhan7PCbWvZ
There was a problem hiding this comment.
2 issues found across 5 files
Confidence score: 4/5
- In
desktop/macos/Desktop/Sources/TaskActionItem.swift,retired()can leavedeletednil/false for rows marked only withstatus = "cancelled"/"superseded", so fallback or direct consumers may misclassify deleted lanes as active and show incorrect actions/state — normalize the legacydeletedflag for every lane row when deriving retired items. - In
desktop/macos/Desktop/Sources/TaskActionItem.swift, lane stamping currently sets onlydeletedand can leavedeletedBy,deletedAt, anddeletedReasonunset/stale when the server omits fields, which risks inconsistent deletion metadata in UI/logging flows — populate or explicitly clear the related deleted-* fields alongsidedeletedduring normalization.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="desktop/macos/Desktop/Sources/TaskActionItem.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/TaskActionItem.swift:101">
P2: When a deleted-lane row has only `status = "cancelled"` or `"superseded"`, `retired()` leaves `deleted` nil/false. Normalize the legacy `deleted` marker for every lane row so fallback and direct consumers cannot treat the row as live.</violation>
<violation number="2" location="desktop/macos/Desktop/Sources/TaskActionItem.swift:103">
P2: The only field the lane stamps is `deleted`; `deletedBy`, `deletedAt`, and `deletedReason` are left as whatever the server omitted. When a deleted-lane response omits the legacy `deleted` field (the exact case this fix targets), it can omit `deletedBy` too, so rows synced to the cache land with `deleted = true` but no provenance. TasksPage partitions the Removed lane with `removedByMe` (`deletedBy == "user"`) vs `removedByAI` (`deletedBy != "user"`), and `ActionItemStorage.getRecentDeletedTasks(..., deletedBy:)` / `TaskAssistant` (line 1588) query user-deletions by that column, so a user-deleted task whose provenance is dropped shows up as AI-removed and drops out of user-deletion flows.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| /// `deleted = false` and comes back as a live task on any machine whose | ||
| /// cache was built from that lane. | ||
| func retired() -> TaskActionItem { | ||
| guard !isRetired else { return self } |
There was a problem hiding this comment.
P2: When a deleted-lane row has only status = "cancelled" or "superseded", retired() leaves deleted nil/false. Normalize the legacy deleted marker for every lane row so fallback and direct consumers cannot treat the row as live.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/TaskActionItem.swift, line 101:
<comment>When a deleted-lane row has only `status = "cancelled"` or `"superseded"`, `retired()` leaves `deleted` nil/false. Normalize the legacy `deleted` marker for every lane row so fallback and direct consumers cannot treat the row as live.</comment>
<file context>
@@ -86,6 +86,24 @@ struct TaskActionItem: Codable, Identifiable, Equatable {
+ /// `deleted = false` and comes back as a live task on any machine whose
+ /// cache was built from that lane.
+ func retired() -> TaskActionItem {
+ guard !isRetired else { return self }
+ var copy = self
+ copy.deleted = true
</file context>
| func retired() -> TaskActionItem { | ||
| guard !isRetired else { return self } | ||
| var copy = self | ||
| copy.deleted = true |
There was a problem hiding this comment.
P2: The only field the lane stamps is deleted; deletedBy, deletedAt, and deletedReason are left as whatever the server omitted. When a deleted-lane response omits the legacy deleted field (the exact case this fix targets), it can omit deletedBy too, so rows synced to the cache land with deleted = true but no provenance. TasksPage partitions the Removed lane with removedByMe (deletedBy == "user") vs removedByAI (deletedBy != "user"), and ActionItemStorage.getRecentDeletedTasks(..., deletedBy:) / TaskAssistant (line 1588) query user-deletions by that column, so a user-deleted task whose provenance is dropped shows up as AI-removed and drops out of user-deletion flows.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/TaskActionItem.swift, line 103:
<comment>The only field the lane stamps is `deleted`; `deletedBy`, `deletedAt`, and `deletedReason` are left as whatever the server omitted. When a deleted-lane response omits the legacy `deleted` field (the exact case this fix targets), it can omit `deletedBy` too, so rows synced to the cache land with `deleted = true` but no provenance. TasksPage partitions the Removed lane with `removedByMe` (`deletedBy == "user"`) vs `removedByAI` (`deletedBy != "user"`), and `ActionItemStorage.getRecentDeletedTasks(..., deletedBy:)` / `TaskAssistant` (line 1588) query user-deletions by that column, so a user-deleted task whose provenance is dropped shows up as AI-removed and drops out of user-deletion flows.</comment>
<file context>
@@ -86,6 +86,24 @@ struct TaskActionItem: Codable, Identifiable, Equatable {
+ func retired() -> TaskActionItem {
+ guard !isRetired else { return self }
+ var copy = self
+ copy.deleted = true
+ return copy
+ }
</file context>
kodjima33
left a comment
There was a problem hiding this comment.
Deleted-lane rows persisted as live because retirement was re-derived from an open status vocabulary; stamping retirement at the lane is the right authority. Root cause + regression test + revert-proof verification.
|
Both review findings were investigated against current code. Neither requires a change to this PR, and no code was changed. Evidence below, plus two genuine defects found in passing that are filed separately. Finding 1 —
|
Problem
Tasks deleted on another device came back as live tasks on a fresh machine, and the Removed list stayed empty:
Cause
TaskActionItem.isRetiredre-derives retirement from the response body (deleted == true, or a canonical status ofcancelled/superseded). Its own doc comment records that list responses may omit legacydeletedand project retirement through canonical lifecycle status — and that status vocabulary is open, so any other value reads as live.ActionItemRecord.from(_:)persistsdeleted: item.isRetired, so a row arriving from the deleted lane without either marker was written to SQLite as live: absent from the.deletedscope query, present as a live task.Fix
The lane is the authority on retirement, not a re-derivation from whichever fields a response happened to carry.
fetchDeletedPagestamps retirement after both transports — live API and injected operations — so neither path can skip it, and both callers of that page (first load and auto-refresh) sync a correctly retired row.Verification
macOS 27.0, Xcode 26.6 (stable, not the beta):
xcrun swift test --filter TasksStoreDeletedLaneRetirementTests→ 2 passedXCTAssertEqual failed: ("[]") is not equal to ("["deleted-on-phone"]")TasksStorepass together, so nothing leaks through theTasksStore.sharedsingletonswift-format lint --strictclean on all three files (linter confirmed live by checking it flags a deliberately malformed file)desktop/macos/scripts/check-main-actor-xctest-hooks.pypassesApp-level: a combined build carrying this fix was run as the named bundle
omi-combined-verify. The deleted lane now reportsFetched 100 deleted tasks / Showing 20 deleted tasks—Showing 0against a non-zero fetch was the entire symptom, so this is the first run with a populated Removed list. The live list still sheds rows as the lane pages through (581 → 547 → 513 → 483,added=0), which is now the correct outcome: those rows land in the.deletedscope instead of vanishing.Scope
Fixes retirement state, not refresh cadence — the deleted refresh still re-fetches and re-syncs a full page per tick. Tracked separately. Also corrects the write path only: rows already persisted as live by an affected build are reconciled by later refreshes, not rewritten.
Explicitly not a contributor to the desktop chat outage — that was measured to a missing index on
conversation_turn_revisions(conversation_id, turn_id)and is fixed on its own branch.Failure-Class: FC-split-mutation-authority
🤖 Generated with Claude Code
https://claude.ai/code/session_011qmdS9crg5qFhan7PCbWvZ