Add shared invite acceptance flow - #24
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds invite acceptance with serviceEndpoint support, persists an active shared session in settings/Jotai, introduces acceptShareInvite API, updates relay to persist/sanitize endpoints, and adapts MainLayout/relay polling to operate in an active shared-session mode. ChangesShared Invite Acceptance & Active Session Mode
Sequence DiagramsequenceDiagram
participant User
participant AcceptScreen as AcceptShareInviteScreen
participant SignIn as SignInScreen
participant API as api.acceptShareInvite
participant Relay as Relay Service
participant State as Jotai Settings
participant MainLayout
participant ChatScreen
User->>AcceptScreen: Visit /shares/invite/[ownerUserId]/[token]/accept
AcceptScreen->>SignIn: Not signed in → redirect
User->>SignIn: Sign in with redirect param
SignIn->>API: POST /auth/sign-in
SignIn->>User: Redirect back to /shares/invite/...
AcceptScreen->>AcceptScreen: Auth loaded & signed in
AcceptScreen->>API: acceptShareInvite(ownerUserId, token, {token})
API->>Relay: POST /shares/invite/{ownerUserId}/{token}/accept
Relay->>API: Return serviceEndpoint, sessionId, shareId
AcceptScreen->>State: Write activeSharedSessionAtom
AcceptScreen->>State: Write selectedSessionIdAtom
AcceptScreen->>MainLayout: Navigate to /agent/[sessionId]/chat
MainLayout->>MainLayout: Detect activeShare set
MainLayout->>Relay: Create RelayTransport with owner/share scope
MainLayout->>MainLayout: Poll with shared-only project
ChatScreen->>ChatScreen: Load in active shared session mode
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@app/app/sign-in.tsx`:
- Around line 32-34: The sign-in flow currently only navigates when a `redirect`
exists, so after `setActive({ session: result.createdSessionId })` successful
sign-in with no `redirect` leaves the user on the sign-in page; update the logic
in the block handling `result.status === "complete"` to call
`router.replace(redirect)` when `redirect` is provided and otherwise perform a
fallback navigation (e.g., `router.replace("/")` or the app's default post-login
route) so the user is immediately routed; modify the code around `if
(result.status === "complete") { ... }` where `setActive` is called to add this
fallback behavior and ensure it integrates with the existing `AuthGate` flow.
- Around line 63-65: When handling the verification flow where result.status ===
"complete" (same block that calls setActive({ session: result.createdSessionId
})), ensure you apply the same redirect fallback as the sign-in flow: replace
the router.replace(redirect) call with a fallback-aware call (e.g.,
router.replace(redirect ?? '/')) so a default path is used when redirect is
undefined; update the verification flow's block that checks result.status ===
"complete" to use this fallback behavior.
In `@relay/src/sharing.ts`:
- Around line 165-172: normalizeShare currently returns persisted share records
without sanitizing the stored serviceEndpoint, so legacy data can bypass the
host/port normalization done for new input; update normalizeShare (used by
normalizeSharingState and findShareForSession) to run sanitizeServiceEndpoint on
share.serviceEndpoint (and replace the field only if sanitizeServiceEndpoint
returns a value) so downstream consumers always receive a normalized host/port
shape consistent with the input-side call to sanitizeServiceEndpoint.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8b7052a7-9b22-472c-a4df-66295965cad0
📒 Files selected for processing (12)
app/app/(main)/(tabs)/(dashboard)/agent/[sessionId]/chat.tsxapp/app/(main)/_layout.tsxapp/app/_layout.tsxapp/app/shares/invite/[ownerUserId]/[token]/accept.tsxapp/app/sign-in.tsxapp/lib/api.test.tsapp/lib/api.tsapp/stores/settings.test.tsapp/stores/settings.tsrelay/src/relay-object.tsrelay/src/sharing.test.tsrelay/src/sharing.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@relay/src/sharing.test.ts`:
- Around line 220-237: The persisted-share fixture passed into createShareInvite
is missing the top-level SharingState version and has an invalid participants
shape: add version: 1 at the top of the persisted state and change the
participants entry for "share_existing" so each participant value conforms to
ShareParticipantRecord (include required fields such as status and joinedAt
alongside the existing owner fields) so that the participants map contains
objects with status and joinedAt rather than the raw owner object.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8fae821c-d7f5-4c30-adb2-89035597b3bb
📒 Files selected for processing (3)
app/app/sign-in.tsxrelay/src/sharing.test.tsrelay/src/sharing.ts
Summary
Verification
Summary by CodeRabbit
New Features
Bug Fixes
Tests