Skip to content

fix(trash): repair delete, restore, and sync flows - #292

Open
NeerajCodz wants to merge 4 commits into
mainfrom
fix/trash-sync-issues
Open

NeerajCodz wants to merge 4 commits into
mainfrom
fix/trash-sync-issues

Conversation

@NeerajCodz

Copy link
Copy Markdown
Owner

Changes

  • Correct trash/category mutation semantics, recurring items, and offline sync revision handling.

Issues

Fixes #228
Fixes #229
Fixes #230
Fixes #231
Fixes #232
Fixes #233
Fixes #234
Fixes #235
Fixes #236
Fixes #237
Fixes #239
Fixes #281

- Correct trash restore/delete flows and sync revision handling.
- Fixes #228, #229, #230, #231, #232, #233, #234, #235, #236, #237, #239, and #281.
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
finapp Ready Ready Preview Nov 27, 2026 3:19am UTC

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-27T02:42:29.098601Z
We couldn’t complete this review. Comment @codex review to try again.
480a377 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@NeerajCodz

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efcb68e3fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +298 to +299
const category = await ctx.db.get(args.categoryId);
if (!category || category.ownerId !== args.userId || category.archivedAt === undefined) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Tie continuation jobs to the originating archive

When a category with more than 50 transactions is restored and then archived again with “keep transactions” before a delayed continuation runs, this check sees only that the category is currently archived and lets the old job continue deleting the remaining transactions. Compare the current trashedAt with args.now (or use another archive-generation token) so work scheduled by an earlier archive cannot affect the category's new state.

Useful? React with 👍 / 👎.

Comment on lines +1082 to +1084
(error: unknown) => {
console.warn('[local-sync] Could not mark the opened notification read.', error);
setTimeout(() => markQueued(id), 1_000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound retries for failed push-read acknowledgements

If marking a queued notification read fails permanently—for example because the notification ID is stale or the user no longer has access—this schedules another attempt every second forever. The timers are neither capped nor cancelled when the effect is cleaned up, and a later userId change can start an additional retry chain for the same ID, causing persistent network traffic and log spam; use bounded/backed-off retries with cleanup or leave the entry for a later explicit sync attempt.

Useful? React with 👍 / 👎.

Comment thread convex/trash.ts
Comment on lines +362 to +363
if (row.ownerId !== args.userId || row.groupId !== undefined) continue;
await purgeTransaction(ctx, args.userId, row, args.now);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve accounts referenced by active group expenses

When an archived account is purged while an undeleted group expense still uses it, this unconditional group-row skip leaves the live transaction in place and the continuation eventually deletes its required account. groups.updateExpense then rejects even an edit that keeps the existing account because ctx.db.get(args.accountId) returns null, so either block the account purge or explicitly handle active group expenses while retaining only ledger tombstones.

Useful? React with 👍 / 👎.

Comment thread convex/trash.ts Outdated
Comment on lines +138 to +140
let cursor: string | null = null;
while (items.length < limit) {
const page = await ctx.db

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound scans while filtering group tombstones

For a user with many deleted group expenses and few or no personal trashed transactions, this loop paginates through every group tombstone before returning. Because group tombstones are deliberately excluded from expiry, they can accumulate indefinitely until trash.list or trash.empty exceeds Convex query read/byte limits and fails; use an index that excludes group rows or impose a bounded scan rather than looping to isDone.

Useful? React with 👍 / 👎.

Comment thread convex/trash.ts Outdated
Comment on lines +366 to +372
if (!sourcePage.isDone || !transferPage.isDone) {
await ctx.scheduler.runAfter(0, internal.trash.continueAccountPurge, {
...args,
sourceCursor: sourcePage.isDone ? null : sourcePage.continueCursor,
transferCursor: transferPage.isDone ? null : transferPage.continueCursor,
});
return { purged, done: false };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent restores while an account purge is in progress

For an account with more than one transaction page, this mutation permanently deletes the first page, schedules the remainder, and returns while the archived account is still visible and restorable. If the user restores it before the continuation runs—especially when scheduled work is delayed—the continuation aborts because archivedAt was cleared, leaving a restored account with part of its transaction history permanently missing; mark the account as purging or otherwise make the purge atomic from the restore API's perspective.

Useful? React with 👍 / 👎.

- Filter and cap personal trash rows without unbounded collection.
- Process account and transfer transaction indexes in separate scheduled phases.
- Return explicit nulls in the category restore test fixture.
@NeerajCodz

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

- Await the transfer-index phase before asserting all account records were removed.
@NeerajCodz

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

- Supply the fake-timer advancement callback when draining scheduled purge jobs.

This branch was successfully deployed

1 active deployment
Preview — 7f2a0475 Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment