Conversation
Walkthrough
Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant A as App
participant H as useSigninMutation
participant API as Auth API
participant S as User Store
U->>A: Submit signin
A->>H: mutate(credentials)
H->>API: POST /signin
API-->>H: SigninResponse
H->>H: onSuccess(data)
H->>S: setUser(data.user)
Note right of S: Global user state updated
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Preview Deployment Ready!🔗 Preview URL: https://roam-ready-kwdv8oqfc-yongmins-projects-bf5f7733.vercel.app This preview will be automatically updated on new commits. |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/domain/Auth/hooks/useSigninMutation.ts (1)
42-49: 로그인 성공 후 헤더와 유저 상태를 즉시 갱신하도록 onSuccess 핸들러를 리팩토링하세요.
onSuccess를async로 변경하고,
queryClient.setQueryData(['user', 'me'], data.user)로 프리시드await queryClient.invalidateQueries({ queryKey: ['user', 'me'], refetchType: 'active' })router.refresh()로 서버 컴포넌트 강제 갱신router.replace(ROUTES.ACTIVITIES.ROOT)로 라우팅- 쿼리 키
['user','me']는useUser훅의queryKey와 일치합니다.- onSuccess: (data: SigninResponse) => { + onSuccess: async (data: SigninResponse) => { sessionStorage.removeItem('signup-form'); - setUser(data.user); - queryClient.invalidateQueries({ queryKey: ['user', 'me'] }); + setUser(data.user); + // 헤더/유저 UI 즉시 반영 + queryClient.setQueryData(['user', 'me'], data.user); + await queryClient.invalidateQueries({ + queryKey: ['user', 'me'], + refetchType: 'active', + }); + // 서버 컴포넌트 강제 갱신 + router.refresh(); - router.push(ROUTES.ACTIVITIES.ROOT); + router.replace(ROUTES.ACTIVITIES.ROOT); },
🧹 Nitpick comments (1)
src/domain/Auth/hooks/useSigninMutation.ts (1)
5-5: 타입 전용 임포트로 전환하세요.런타임 사이드이펙트 방지 및 번들 최적화를 위해 타입 전용 임포트를 사용하세요.
-import { SigninResponse } from '@/domain/Auth/schemas/response'; +import type { SigninResponse } from '@/domain/Auth/schemas/response';
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/domain/Auth/hooks/useSigninMutation.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/domain/Auth/hooks/useSigninMutation.ts (4)
src/shared/store/index.ts (1)
useRoamReadyStore(32-47)src/shared/hooks/useToast.ts (1)
useToast(29-50)src/domain/Auth/services/index.ts (1)
signin(57-61)src/domain/Auth/schemas/response.ts (1)
SigninResponse(91-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: vercel-preview
🔇 Additional comments (1)
src/domain/Auth/hooks/useSigninMutation.ts (1)
36-36:setUser타입/호출 검증 요청.
SigninResponse['user']의 스키마가 ZustandsetUser가 기대하는 타입과 1:1로 일치하는지 확인해 주세요. 백엔드 응답에user가 누락될 가능성이 있다면 가드 추가를 고려하세요.- const setUser = useRoamReadyStore((state) => state.setUser); + const setUser = useRoamReadyStore((state) => state.setUser);참고(옵션):
if (!data?.user) { console.warn('signin 응답에 user가 없습니다.'); return; }
| import { ROUTES } from '@/shared/constants/routes'; | ||
| import { useToast } from '@/shared/hooks/useToast'; | ||
| // import { useRoamReadyStore } from '@/shared/store'; | ||
| import { useRoamReadyStore } from '@/shared/store'; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Client 전용 훅이므로 'use client' 지시어 추가 권장.
useRouter, sessionStorage, Zustand 훅을 사용하므로 서버 컴포넌트에서 오용되는 것을 미연에 방지합니다. 기존 사용처가 모두 Client여도 안전망으로 추가하는 것을 권장합니다.
+ 'use client';
import { useMutation, useQueryClient } from '@tanstack/react-query';🤖 Prompt for AI Agents
In src/domain/Auth/hooks/useSigninMutation.ts around line 9, this is a
client-only hook (uses useRouter, sessionStorage, and a Zustand hook) so add the
"use client" directive as the very first line of the file; ensure the directive
appears before any imports and then keep the existing imports and code unchanged
so the hook cannot be used in a server component.
👻 관련 이슈 번호
👻 요약
👻 주요 변경 사항
👻 체크리스트
📷 UI 변경 사항
👻 문제 사항
👻 논의 사항
👻 기타 참고 사항
Summary by CodeRabbit