PY-76: Möglichkeit default Workspace zu setzen#91
Conversation
📝 WalkthroughWalkthroughAdds last-active organization preferences, server persistence, session restoration, centralized workspace resolution, and activation updates for organization switching, route hints, and invitation acceptance. ChangesLast active organization
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/invitation-accept.ts (1)
170-184: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winIsolate organization activation to prevent partial failure errors.
If
activateInvitedOrganizationthrows an error, it is currently caught by the outertry...catchblock. This means if a user successfully accepts an invitation but the subsequent activation fails, they will see an error page instead of being redirected to the dashboard. Retrying the acceptance will then fail because they are already a member, resulting in a broken user flow.Wrap the activation step in its own
try...catchblock (similar to thealready_memberbranch) so that non-critical activation errors do not break the main invitation acceptance flow.🐛 Proposed fix
- try { - await acceptResolvedInvitation(resolved.invitationId); - await activateInvitedOrganization( - session.user.id, - resolved.organizationId - ); - return { status: "success", redirectTo: "/dashboard" }; - } catch (error) { - console.error("Failed to accept invitation", error); - return { - status: "error", - email: session.user.email, - message: mapAcceptApiError(error), - }; - } + try { + await acceptResolvedInvitation(resolved.invitationId); + } catch (error) { + console.error("Failed to accept invitation", error); + return { + status: "error", + email: session.user.email, + message: mapAcceptApiError(error), + }; + } + + try { + await activateInvitedOrganization( + session.user.id, + resolved.organizationId + ); + } catch (error) { + console.error("Failed to activate invited organization", error); + } + + return { status: "success", redirectTo: "/dashboard" };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/invitation-accept.ts` around lines 170 - 184, Isolate activateInvitedOrganization from the outer invitation-acceptance error path by wrapping it in its own try/catch, following the handling used in the already_member branch. Preserve the successful accept flow by returning the dashboard redirect even when activation fails, while keeping acceptResolvedInvitation failures handled by the existing outer catch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/lib/invitation-accept.ts`:
- Around line 170-184: Isolate activateInvitedOrganization from the outer
invitation-acceptance error path by wrapping it in its own try/catch, following
the handling used in the already_member branch. Preserve the successful accept
flow by returning the dashboard redirect even when activation fails, while
keeping acceptResolvedInvitation failures handled by the existing outer catch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 729cadf1-5ad7-4f5e-861b-2039e544e70a
📒 Files selected for processing (9)
src/db/mutations/last-active-organization.tssrc/db/schema.tssrc/hooks/use-organization-switch.tssrc/lib/auth.tssrc/lib/ensure-active-organization.server.tssrc/lib/invitation-accept.tssrc/lib/last-active-organization.server.tssrc/lib/last-active-organization.test.tssrc/lib/last-active-organization.ts
Task
PY-76: Möglichkeit default Workspace zu setzen
Summary
Summary by CodeRabbit
New Features
Bug Fixes
Tests