Skip to content

Add confirmation dialog for delete all workspace data#6

Merged
x0ba merged 10 commits into
stagingfrom
feat/settings-delete-confirmation
Jun 9, 2026
Merged

Add confirmation dialog for delete all workspace data#6
x0ba merged 10 commits into
stagingfrom
feat/settings-delete-confirmation

Conversation

@x0ba

@x0ba x0ba commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add shadcn alert-dialog and show a confirmation modal when clicking "Delete all data" in settings.
  • Wire confirm to a new deleteAllWorkspaceData Convex mutation that soft-deletes all sessions, reports, and trace files for the signed-in user.

Test plan

  • Open Settings and click "Delete all data" — confirmation dialog appears with cancel and delete actions.
  • Click Cancel — dialog closes with no data changes.
  • Click "Delete all data" in the dialog — sessions disappear from dashboard/sessions list and user is redirected to dashboard.
  • Verify vp check passes.

Made with Cursor

Gate the settings danger-zone action behind an alert dialog and wire it to a new deleteAllWorkspaceData mutation.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
peek Ready Ready Preview, Comment Jun 9, 2026 9:04pm

@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown

Greptile Summary

Adds a confirmation AlertDialog before "Delete all workspace data" and wires it to a new deleteAllWorkspaceData Convex mutation that soft-deletes all sessions, their analysis reports, and hard-deletes their jobs and storage files via a client-driven cursor loop. Also replaces several any annotations in sessions.ts with typed Doc/Id generics.

  • Cursor pagination uses importedAt + _creationTime as a two-level key to handle same-timestamp ties correctly; the "after" cursor branch includes a deletedAt filter so it stays bounded to undeleted documents, but the initial and "before" branches do not, meaning workspaces with many previously-deleted sessions may require proportionally more mutation round-trips.
  • softDeleteSessionReports now correctly filters deletedAt = undefined inside its while-loop, preventing infinite loops on already-patched reports.
  • Error state (deleteError) is surfaced in the dialog with catch/finally guarding deleting, so the user is informed of failures without being left in a broken UI state.

Confidence Score: 5/5

Safe to merge — the pagination logic is correct across all cursor branches, error handling is in place, and the helpers correctly handle loops and soft-deletes.

The core delete-all flow works correctly: same-timestamp ties are broken by _creationTime, the "after" cursor transitions cleanly to older timestamps when the tie group is exhausted, softDeleteSessionReports filters out already-patched records so its while-loop terminates, and mutation errors are surfaced to the user. The only findings are efficiency improvements (missing deletedAt filters) that do not affect correctness.

src/convex/sessions.ts — the initial and "before" cursor branches in fetchDeleteAllBatch omit the deletedAt filter, wasting batch slots on already-deleted sessions.

Important Files Changed

Filename Overview
src/convex/sessions.ts Adds deleteAllWorkspaceData mutation with cursor-based pagination using _creationTime as a tie-breaker for same-importedAt groups; refactors softDeleteSession, deleteSessionJobs, and softDeleteSessionReports into reusable helpers; replaces any annotations with typed Convex Doc/Id types. The "before" and initial cursor branches in fetchDeleteAllBatch include already-deleted sessions in the batch, which can cause extra mutation round-trips for workspaces with many previously individually-deleted sessions.
src/routes/settings/+page.svelte Wires confirmation dialog to the new mutation; adds deleteError/deleting state, error display, and redirect-to-dashboard on success. Client loop correctly propagates cursor between mutation calls and surfaces errors to the user.
src/lib/components/ui/alert-dialog/index.ts Standard shadcn-style re-export barrel for bits-ui AlertDialog primitives; no issues.

Sequence Diagram

sequenceDiagram
    participant U as User (Browser)
    participant S as Settings Page
    participant C as Convex Client
    participant M as deleteAllWorkspaceData

    U->>S: Click "Delete all data"
    S->>S: openDeleteDialog() — reset error, open dialog
    U->>S: Click "Delete all data" in dialog
    S->>S: "deleting = true"

    loop while hasMore
        S->>C: "mutation(deleteAllWorkspaceData, { cursor })"
        C->>M: fetchDeleteAllBatch(userId, cursor)
        M-->>C: batch of ≤5 sessions
        M->>M: softDeleteSession × N
        M-->>C: "{ deletedCount, hasMore, cursor? }"
        C-->>S: result
        alt hasMore
            S->>S: "cursor = result.cursor"
        else done
            S->>S: break
        end
    end

    alt Success
        S->>S: "deleteDialogOpen = false"
        S->>U: goto("/dashboard")
    else Error
        S->>S: "deleteError = message"
        S->>U: show error in dialog
    end
    S->>S: "deleting = false"
Loading

Fix All in Cursor Fix All in Codex

Reviews (16): Last reviewed commit: "address greptile review feedback (greplo..." | Re-trigger Greptile

Comment thread src/routes/settings/+page.svelte
Comment thread src/convex/sessions.ts Outdated
Paginate deleteAllWorkspaceData with batched cursor reads and surface mutation errors in the settings dialog.

Co-authored-by: Cursor <cursoragent@cursor.com>
@x0ba

x0ba commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread src/convex/sessions.ts
Comment thread src/convex/sessions.ts Outdated
Comment thread src/convex/sessions.ts
Use composite session cursors for batched deletes and remove analysis jobs when soft-deleting sessions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@x0ba

x0ba commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread src/convex/sessions.ts Outdated
Delete jobs and reports in batches until exhausted and ignore already-deleted sessions when advancing cursors.

Co-authored-by: Cursor <cursoragent@cursor.com>
@x0ba

x0ba commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread src/convex/sessions.ts Outdated
Filter undeleted analysis reports when batching soft-delete cleanup for a session.

Co-authored-by: Cursor <cursoragent@cursor.com>
@x0ba

x0ba commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread src/convex/sessions.ts Outdated
Comment thread src/convex/sessions.ts Outdated
Continue delete-all pagination to older timestamps after an "after" cursor exhausts its tie group.

Co-authored-by: Cursor <cursoragent@cursor.com>
@x0ba

x0ba commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread src/convex/sessions.ts Outdated
@x0ba

x0ba commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

@greptile review

Co-authored-by: Cursor <cursoragent@cursor.com>
@x0ba

x0ba commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

@greptile review

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@x0ba
x0ba merged commit 385c20f into staging Jun 9, 2026
6 checks passed
@x0ba
x0ba deleted the feat/settings-delete-confirmation branch June 9, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant