Skip to content

Conversation

@sgoldenbird
Copy link
Contributor

@sgoldenbird sgoldenbird commented Aug 29, 2025

👻 관련 이슈 번호

  • none

👻 요약

  • 로그인했을때 헤더가 로그인 헤더로 즉각 업데이트 되도록 수정

👻 주요 변경 사항

👻 체크리스트

  • Assignees에 본인을 등록했나요?
  • 라벨을 사이드 탭에서 등록했나요?
  • PR은 사이드 탭 Projects를 등록 하지마세요.
  • PR은 Milestone을 등록 하지마세요.
  • PR을 보내는 브랜치가 올바른지 확인했나요?
  • 팀원들이 리뷰하기 쉽도록 설명을 자세하게 작성했나요?
  • 변경사항을 충분히 테스트 했나요?
  • 컨벤션에 맞게 구현했나요?

📷 UI 변경 사항

👻 문제 사항

👻 논의 사항

👻 기타 참고 사항

Summary by CodeRabbit

  • 버그 수정
    • 로그인 성공 후 사용자 정보가 즉시 반영되지 않던 문제를 수정했습니다.
    • 로그인 후 캐시 갱신과 페이지 이동이 간헐적으로 실패하던 현상을 개선했습니다.
  • 리팩터링
    • 로그인 성공 응답을 기반으로 전역 사용자 상태를 일관되게 갱신하도록 흐름을 정비하여, 로그인 이후 경험의 안정성과 예측 가능성을 높였습니다.

@sgoldenbird sgoldenbird linked an issue Aug 29, 2025 that may be closed by this pull request
7 tasks
@sgoldenbird sgoldenbird self-assigned this Aug 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 29, 2025

Walkthrough

useSigninMutation’s onSuccess handler now accepts SigninResponse and uses data.user to update global user state via setUser. The hook’s success payload is typed and consumed directly.

Changes

Cohort / File(s) Summary
Auth Signin Mutation Hook
src/domain/Auth/hooks/useSigninMutation.ts
Change onSuccess signature from () => {} to (data: SigninResponse) => {} and invoke setUser(data.user) to persist the signed-in user.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

Suggested labels

fix

Poem

귀가 쫑긋 로그인 바람, 삐약-삐약 키보드 춤
응답 한 봉지 물고 와, user 담아 쏙-꽉-꽉
캐시에 톡, 화면에 퐁—
오늘부터 나는 로그인 토끼!
(=^.^=) 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/560/header-update

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sgoldenbird sgoldenbird changed the title (#560) fix: 로그인 시 헤더 즉각 업데이트 Fix: 로그인 시 헤더 즉각 업데이트 Aug 29, 2025
@github-actions
Copy link

✅ Preview Deployment Ready!

🔗 Preview URL: https://roam-ready-kwdv8oqfc-yongmins-projects-bf5f7733.vercel.app
📝 Branch: feat/560/header-update
💾 Commit: (#560) fix: 로그인 시 헤더 즉각 업데이트
🕐 Deployed at:


This preview will be automatically updated on new commits.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 핸들러를 리팩토링하세요.

  • onSuccessasync로 변경하고,
    1. queryClient.setQueryData(['user', 'me'], data.user)로 프리시드
    2. await queryClient.invalidateQueries({ queryKey: ['user', 'me'], refetchType: 'active' })
    3. router.refresh()로 서버 컴포넌트 강제 갱신
    4. 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 5978e96 and d27bc7e.

📒 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']의 스키마가 Zustand setUser가 기대하는 타입과 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';
Copy link

Choose a reason for hiding this comment

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

🛠️ 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.

@sgoldenbird sgoldenbird merged commit 580d60a into main Aug 29, 2025
2 checks passed
@sgoldenbird sgoldenbird deleted the feat/560/header-update branch August 29, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: 로그인 후 헤더 즉시 업데이트

2 participants