Skip to content

Cascade client view default to existing clients with confirmation#1319

Merged
priosshrsth merged 2 commits into
anit/out-3851-cu-view-settings-foundationfrom
anit/out-3851-cascade-client-view-settings
Jun 15, 2026
Merged

Cascade client view default to existing clients with confirmation#1319
priosshrsth merged 2 commits into
anit/out-3851-cu-view-settings-foundationfrom
anit/out-3851-cascade-client-view-settings

Conversation

@priosshrsth

@priosshrsth priosshrsth commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

What

Applies a workspace client-view default change to every existing client's view setting, with an IU confirmation step before the destructive override.

Stacked on top of anit/out-3851-cu-view-settings-foundation.

Changes

workspaceSettings.service.ts

  • Wrap the workspace-setting update and the per-client cascade updateMany in a single $transaction (using the repo's setTransaction/unsetTransaction pattern) so they commit atomically.
  • Only cascade values that actually changed (diff against the previous row).
  • clientHideSubtasks maps to the inverse of the per-user showSubtasks flag.

ClientViewSettingsSection.tsx

  • Confirmation modal before applying a default change ("Update view for all clients?").
  • Optimistic update with rollback preserved through the confirm flow.
  • Guard no-op dropdown changes so the modal doesn't pop when the value is unchanged.

Notes

  • The aria ids on StyledModal follow the existing repo-wide ConfirmUI convention.

Screenshots

New confirmation UI

Screenshot 2026-06-15 at 16 14 59
2026-06-15.16-11-16.mov

🤖 Generated with Claude Code

Apply a workspace client-view default change to every existing client's
view setting atomically, and confirm the destructive override in the IU
before persisting.

- Wrap the workspace-setting update and per-client cascade in a single
  transaction so they commit together
- Only cascade values that actually changed
- Show a confirmation modal before applying; guard no-op dropdown changes

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 15, 2026

Copy link
Copy Markdown

OUT-3851

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
tasks-app Ready Ready Preview, Comment Jun 15, 2026 9:57am

Request Review

@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a confirmation step before cascading a workspace-level client-view default to all existing clients, and wraps the workspace-setting update plus the per-client updateMany in a single atomic Prisma transaction so both either commit or roll back together.

  • Service (workspaceSettings.service.ts): introduces $transaction with setTransaction/unsetTransaction (guarded by try/finally), fetches the previous row inside the transaction to diff only truly changed fields, and maps clientHideSubtasks to the inverse showSubtasks on ViewSetting.
  • UI (ClientViewSettingsSection.tsx): adds a pendingSettings state so controls remain at the committed value until the user confirms; the optimistic update and rollback path flow correctly through handleConfirmpersist; the no-op guard on the dropdown prevents spurious modal appearances for same-value selections.

Confidence Score: 5/5

Safe to merge; the transaction logic, diff-only cascade, and UI rollback path all hold up under inspection.

The transaction wraps both writes atomically, the try/finally guard correctly restores this.db even when the cascade throws, and the optimistic-update rollback in the UI captures the right prior state. The only finding is a dangling aria-labelledby/aria-describedby pair on the confirmation modal that has no functional impact on the cascade logic itself.

The ARIA attributes on the StyledModal in ClientViewSettingsSection.tsx reference IDs that ConfirmUI does not render — worth fixing before this ships to ensure the modal is accessible to screen-reader users.

Important Files Changed

Filename Overview
src/app/api/workspace-settings/workspaceSettings.service.ts Wraps workspace-setting update and per-client view cascade in a single Prisma transaction using setTransaction/unsetTransaction; correctly guards cascade behind a diff check; the tx-as-PrismaClient cast (pre-existing thread) remains.
src/app/configure-tasks-app/ui/ClientViewSettingsSection.tsx Adds confirmation modal before cascading view-setting changes; optimistic update with rollback is correctly preserved; aria-labelledby/aria-describedby on StyledModal reference IDs that ConfirmUI never renders.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as ClientViewSettingsSection
    participant API as updateWorkspaceSettings (action)
    participant Svc as WorkspaceSettingsService
    participant DB as Prisma / DB

    User->>UI: Changes dropdown or switch
    UI->>UI: setPendingSettings(next)
    UI->>User: Show confirmation modal
    User->>UI: Clicks "Apply to all clients"
    UI->>UI: setPendingSettings(null) — closes modal
    UI->>UI: setSettings(next) — optimistic update
    UI->>API: updateWorkspaceSettings(token, next)
    API->>Svc: updateWorkspaceSettings(data)
    Svc->>DB: $transaction start
    DB-->>Svc: tx client
    Svc->>Svc: setTransaction(tx)
    Svc->>DB: workspaceSetting.findUnique (previous)
    DB-->>Svc: previous row
    Svc->>DB: workspaceSetting.update(data)
    DB-->>Svc: updated row
    Svc->>Svc: diff(previous, data) → cascade fields
    Svc->>DB: viewSetting.updateMany (all clients in workspace)
    DB-->>Svc: n rows updated
    Svc->>Svc: unsetTransaction()
    DB-->>API: commit
    API-->>UI: success
    UI->>User: Settings applied

    alt API error
        DB-->>Svc: error (rollback)
        Svc->>Svc: unsetTransaction() [finally]
        API-->>UI: error
        UI->>UI: setSettings(previous) — rollback
        UI->>User: Settings reverted
    end
Loading

Reviews (2): Last reviewed commit: "Restore db handle in finally so cascade ..." | Re-trigger Greptile

Comment thread src/app/api/workspace-settings/workspaceSettings.service.ts
Comment thread src/app/api/workspace-settings/workspaceSettings.service.ts
Addresses Greptile P1: unsetTransaction() only ran on the happy path, so a
DB error inside the cascade left this.db pointing at the expired transaction
client.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Deployment failed with the following error:

Deploying Serverless Functions to multiple regions is restricted to the Pro and Enterprise plans.

Learn More: https://vercel.link/multiple-function-regions

@SandipBajracharya SandipBajracharya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@priosshrsth priosshrsth merged commit 4de371a into anit/out-3851-cu-view-settings-foundation Jun 15, 2026
4 checks passed
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.

2 participants