fix: implemented missing onClick handler for dynamic active session revocation (#44)#68
Conversation
|
@deekshithgowda85 is attempting to deploy a commit to the Deekshith Gowda HS's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 56 minutes and 34 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR implements session revocation in the account page by introducing local state management for sessions, adding an async handler that confirms and calls the backend DELETE endpoint, and wiring the revoke button to trigger the handler with success/failure alerts and state updates. ChangesSession Revocation Feature
Sequence DiagramsequenceDiagram
participant User
participant AccountPageClient
participant API as /api/user/sessions
User->>AccountPageClient: Click Revoke button
AccountPageClient->>User: Confirm revocation (alert)
User->>AccountPageClient: Confirm
AccountPageClient->>API: DELETE with session id
API->>AccountPageClient: Response (success or error)
alt Success
AccountPageClient->>AccountPageClient: Remove session from state
AccountPageClient->>User: Display success alert
else Failure
AccountPageClient->>User: Display error alert
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
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 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 |
|
Hi @prakshithamalla-art |
|
Since 3 to 30 lines merge takes redundant Ci and vercel build trigger which may trigger rate limits |
6eb20a0 to
473118b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
components/console/account-page-client.tsx (1)
227-233: ⚡ Quick winPrevent repeated revoke clicks while request is in flight.
Rapid clicks can dispatch duplicate DELETEs for the same session and produce noisy alerts. Add a per-session pending state and disable the button while revocation is running.
🤖 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 `@components/console/account-page-client.tsx` around lines 227 - 233, Add a per-session pending flag to prevent duplicate revokes: keep a state like revokedPending (e.g., a Set or Record keyed by session id) and update handleRevokeSession to first check and return early if revokedPending[s.id] is true, then set revokedPending[s.id]=true before sending the DELETE and reset it to false in both success and error paths; update the Revoke button rendering to disable the button (and adjust styles) when revokedPending[s.id] is true and avoid dispatching another request while pending; reference handleRevokeSession and the session id/device (s.id, s.device) to locate where to add the check and state updates.
🤖 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 `@components/console/account-page-client.tsx`:
- Around line 72-77: The DELETE response handling assumes JSON by calling
res.json() unconditionally; update the logic in the revoke/session-delete
handler (where res.json() and setSessions are used) to guard parsing: if
res.status === 204 or the Content-Type header does not include
"application/json", skip res.json() and treat the response as success when
res.ok, otherwise await res.json(); then use the parsed data (if any) to check
data.ok and only call alert for errors; ensure setSessions((prev) =>
prev.filter((s) => s.id !== id)) still runs on successful res.ok even when no
JSON body is returned.
---
Nitpick comments:
In `@components/console/account-page-client.tsx`:
- Around line 227-233: Add a per-session pending flag to prevent duplicate
revokes: keep a state like revokedPending (e.g., a Set or Record keyed by
session id) and update handleRevokeSession to first check and return early if
revokedPending[s.id] is true, then set revokedPending[s.id]=true before sending
the DELETE and reset it to false in both success and error paths; update the
Revoke button rendering to disable the button (and adjust styles) when
revokedPending[s.id] is true and avoid dispatching another request while
pending; reference handleRevokeSession and the session id/device (s.id,
s.device) to locate where to add the check and state updates.
🪄 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
Run ID: 8e03887f-ae44-4d20-8fd4-a24a1177b324
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (1)
components/console/account-page-client.tsx
|
Hi @deekshithgowda85! |
Still repeating small pr ! |
Closes #44
🎯 Overview & Motivation
The active hardware configuration session log cards inside the profile page (
components/console/account-page-client.tsx) rendered a decorative "Revoke" styling block that lacked an attachedonClickaction function.This PR turns the static mock dataset into a responsive local state array, integrates an async
handleRevokeSessionroutine, requires active deletion intent confirmation, and filters out the targeted object node seamlessly upon API resolution.🛠️ Changes Implemented
Summary by CodeRabbit