Skip to content

feat: 에러 상황별 UI 및 토스트 처리 구현#225

Merged
soyeong0115 merged 6 commits into
devfrom
feat/224-error-handling
Jun 17, 2026
Merged

feat: 에러 상황별 UI 및 토스트 처리 구현#225
soyeong0115 merged 6 commits into
devfrom
feat/224-error-handling

Conversation

@soyeong0115

@soyeong0115 soyeong0115 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

작업 요약

  • 404/500 에러 페이지 디자인 적용
  • 세션 만료(401) 및 소셜 로그인 실패 시 토스트 메시지 표시
  • 로그아웃 후 로그인 페이지 리다이렉트 버그 수정

작업 세부 내용

404 페이지 (app/not-found.tsx 신규)

  • Next.js not-found.tsx 생성 — 존재하지 않는 경로 접근 시 자동 렌더링
  • 아이콘 + 안내 문구 + "홈으로 가기" 버튼 구성

500 페이지 (app/error.tsx 교체)

  • 기존 기본 UI → 디자인 적용
  • "다시 시도" (reset()) + "홈으로 가기" 버튼 구성
  • globals.css--color-bg-layer-floating, --color-icon-error CSS 변수 추가

세션 만료 토스트 (401)

  • client.ts — 401 응답 시 refresh 시도, refresh도 실패하면 sessionStorage.setItem('piki_session_expired', '1') 설정 후 /login으로 hard redirect
  • LoginButtons.tsx — 마운트 시 sessionStorage 플래그를 읽어 "로그인 정보가 만료됐어요. 다시 로그인해 주세요." 토스트 표시
  • React Strict Mode 이중 실행 문제로 토스트가 사라지는 현상 → setTimeout + cleanup 패턴으로 수정

소셜 로그인 실패 토스트

  • : usePostSocialLogin.ts onError — sessionStorage에 piki_social_login_error = 1 설정 후 router.replace로 로그인 페이지 이동 → LoginButtons에서 토스트 표시
  • : useNativeLoginResult.tsSOCIAL_LOGIN_ERROR 메시지 수신 시 toast.error() 직접 호출 (client-side navigation이라 toast 유지됨)
  • 두 플랫폼 모두 "요청을 처리하지 못했어요. 다시 시도해 주세요." 동일 메시지, toast.error 통일

로그아웃 버그 수정 (usePostLogout.ts)

  • 기존: 로그아웃 후 ROUTES.ROOT(/) 이동 → 미들웨어 없어서 이후 MEMBER_AND_GUEST 라우트 접근 시 자동 게스트 로그인 발생
  • 수정: ROUTES.LOGIN으로 직접 이동 (PUBLIC 라우트라 미들웨어 자동 게스트 생성 없음)
  • 로그아웃 시 sessionStorage 플래그 초기화 추가 (piki_session_expired, piki_social_login_error) — 로그인 페이지 진입 시 false positive 토스트 방지

기타 버그 수정

  • notification-sse-provider: getRouteType(pathname) !== 'PUBLIC'!!routeType && routeType !== 'PUBLIC' — 404 페이지(null 반환)에서 getMe 불필요하게 호출되던 버그 수정
  • 토스트 배경색: --normal-bg Gray-500 → Gray-700 (피그마 디자인 기준)

작동 확인 방법

항목 확인 방법
404 페이지 브라우저에서 없는 경로 접근 (예: /asdfjkl)
500 페이지 error.tsx UI 직접 확인 (컴포넌트에서 throw 후 확인)
401 토스트 개발자 도구 Cookies에서 access_token + refresh_token 삭제 → 클라이언트 API 호출 트리거 → 로그인 페이지에서 토스트 확인
소셜 로그인 실패 토스트 콘솔에서 sessionStorage.setItem('piki_social_login_error', '1') 입력 → /login 이동
로그아웃 리다이렉트 로그아웃 버튼 클릭 → /login으로 이동하는지 확인

스크린샷

스크린샷 2026-06-17 오전 11 29 16 스크린샷 2026-06-17 오전 11 41 12

연관 이슈

closes #224

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 404 페이지 추가 - 잘못된 링크 접근 시 안내 메시지와 홈으로 가기 링크 제공
    • 세션 만료 및 소셜 로그인 실패 시 토스트 알림 추가
  • 개선 사항

    • 토큰 갱신 실패 시 로그인 페이지로 안내하고 세션 상태 저장
    • 에러 페이지 UI 개선 - 아이콘과 함께 명확한 메시지 및 다시 시도 버튼 제공
  • 스타일

    • 토스트 알림 배경색 조정
    • 디자인 토큰 업데이트 (색상 개선)

@soyeong0115 soyeong0115 self-assigned this Jun 17, 2026
@soyeong0115 soyeong0115 added fix Something isn't working feature New feature or request style labels Jun 17, 2026
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
depromeet Ready Ready Preview, Comment Jun 17, 2026 6:09am

@github-actions
github-actions Bot requested review from iOdiO89 and ychany June 17, 2026 05:53
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@soyeong0115, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 45 minutes and 9 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e0a2b32-e302-4615-ba02-af9c439e972b

📥 Commits

Reviewing files that changed from the base of the PR and between a78d023 and 292e2bf.

📒 Files selected for processing (3)
  • apps/web/src/apis/client.ts
  • apps/web/src/app/error.tsx
  • apps/web/src/app/login/_components/LoginButtons.tsx

Walkthrough

세션 만료 및 소셜 로그인 실패 시 sessionStorage 플래그를 기록한 뒤 로그인 페이지로 이동하고, LoginButtons 마운트 시 해당 플래그를 읽어 toast 알림을 표시하는 패턴이 도입됩니다. error.tsx UI가 단순화되고 not-found.tsx가 신규 추가되며, 관련 디자인 토큰과 SSE 조건도 조정됩니다.

Changes

에러 상황별 UI 및 토스트 처리

Layer / File(s) Summary
sessionStorage 플래그 기록 및 로그인 리다이렉트
apps/web/src/apis/client.ts, apps/web/src/app/auth/callback/[provider]/_hooks/usePostSocialLogin.ts
401 토큰 갱신 실패 시 piki_session_expired, 소셜 로그인 실패 시 piki_social_login_error를 sessionStorage에 기록하고 getLoginPath로 이동합니다.
로그인 페이지 마운트 시 플래그 읽기 및 토스트 표시
apps/web/src/app/login/_components/LoginButtons.tsx, apps/web/src/hooks/useNativeLoginResult.ts
LoginButtons 마운트 시 sessionStorage 플래그를 읽어 sonner toast.error를 표시하고 키를 제거합니다. useNativeLoginResultSOCIAL_LOGIN_ERROR 분기에도 toast.error가 추가됩니다.
로그아웃 시 sessionStorage 플래그 제거 및 리다이렉트 경로 변경
apps/web/src/app/mypage/_hooks/usePostLogout.ts
onSettled에서 두 sessionStorage 플래그를 제거하고, 로그아웃 후 이동 경로를 ROUTES.ROOT에서 ROUTES.LOGIN으로 변경합니다.
error 페이지 UI 교체 및 not-found 페이지 신규 추가
apps/web/src/app/error.tsx, apps/web/src/app/not-found.tsx
error.tsxstatusCode 기반 조건부 렌더링에서 고정 에러 화면(아이콘·reset 버튼·홈 링크)으로 교체되고, not-found.tsx가 신규 추가됩니다.
SSE 활성화 조건 수정 및 디자인 토큰·토스트 스타일 조정
apps/web/src/components/notification-sse-provider/index.tsx, apps/web/src/components/toast/index.tsx, apps/web/src/styles/globals.css
SSE enabled 조건에 routeType truthy 체크가 추가되고, --color-bg-layer-floating 토큰 추가, --color-icon-errorred-300으로, 토스트 배경이 gray-700으로 변경됩니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • depromeet/PIKI-Client#220: apps/web/src/apis/client.ts의 401 토큰 갱신 실패 처리 흐름을 동일하게 수정하며, 이번 PR에서 sessionStorage 플래그 기록이 추가된 같은 코드 경로를 다룹니다.
  • depromeet/PIKI-Client#131: usePostSocialLogin의 소셜 로그인 실패 경로(토스트+리다이렉트)를 직접 수정했으며, 이번 PR에서 동일 훅의 같은 onError 경로를 sessionStorage 패턴으로 교체합니다.
  • depromeet/PIKI-Client#153: useNativeLoginResultSOCIAL_LOGIN_ERROR 분기를 수정했으며, 이번 PR에서 해당 분기에 toast.error 호출이 추가됩니다.

Suggested labels

WEB

Suggested reviewers

  • ychany

🐰 세션이 만료됐다 깜짝 놀라지 마세요,
토스트 한 조각 띄워 알려드릴게요 🍞
404엔 귀여운 안내 페이지,
500엔 따뜻한 재시도 버튼!
플래그 세우고 지우는 토끼처럼,
에러도 깔끔하게 처리 완료 🐾

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 요약하고 있으며, 에러 UI 및 토스트 처리라는 주요 변경사항을 잘 반영하고 있습니다.
Linked Issues check ✅ Passed 404 페이지 구현, 500 에러 페이지 재설계, 401 세션 만료 토스트 처리, 소셜 로그인 실패 토스트 처리 등 모든 링크 이슈의 요구사항이 구현되었습니다.
Out of Scope Changes check ✅ Passed 모든 코드 변경사항이 에러 처리 및 UI 개선이라는 PR의 주요 목표와 관련되어 있으며, 범위 외 변경사항이 없습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/224-error-handling

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

No description provided.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/web/src/app/not-found.tsx (1)

8-8: ⚡ Quick win

404 페이지도 <main> 컨테이너 + 모바일 폭 패턴으로 맞춰 주세요.

현재 최상위가 <div>이고 w-full + px-5 패턴이 없어 공통 UI 가이드와 불일치합니다.

제안 diff
-    <div className="flex h-full flex-col items-center bg-bg-layer-basement pt-40 gap-6">
+    <main className="flex h-full w-full flex-col items-center gap-6 bg-bg-layer-basement px-5 pt-40">
@@
-    </div>
+    </main>

As per coding guidelines, apps/web/src/**/*.tsx: Use semantic HTML tags: <main> for containersAvoid fixed width; use w-full + px-5 pattern for mobile, and max-w-* for upper limits.

🤖 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 `@apps/web/src/app/not-found.tsx` at line 8, The 404 page component uses a
`<div>` as the top-level container instead of the semantic `<main>` tag, and it
lacks the standard mobile width pattern used throughout the codebase. Replace
the outermost `<div>` with a `<main>` element and add the responsive width
classes pattern: include w-full for full width and px-5 for mobile padding, plus
an appropriate max-w-* class for desktop width constraints. This will align the
not-found page with the common UI guidelines and the pattern used in other pages
in the apps/web/src directory.

Source: Coding guidelines

apps/web/src/app/error.tsx (1)

15-16: ⚡ Quick win

최상위 컨테이너를 <main>으로 바꾸고 모바일 폭 패턴을 적용해 주세요.

현재 랜드마크 태그와 w-full + px-5 (+ max-w-*) 패턴이 빠져 있어 접근성/반응형 가이드와 어긋납니다.

제안 diff
-    <div className="flex h-full flex-col items-center gap-6 bg-bg-layer-basement pt-40">
+    <main className="flex h-full w-full flex-col items-center gap-6 bg-bg-layer-basement px-5 pt-40">
       <div className="flex flex-col items-center gap-4">
         <WarningIconFill className="size-20 text-icon-error" />
         <div className="flex flex-col items-center gap-2">
           <h1 className="heading-1 text-text-neutral-secondary">오류가 발생했어요.</h1>
@@
-    </div>
+    </main>

As per coding guidelines, apps/web/src/**/*.tsx: Use semantic HTML tags: <main> for containersAvoid fixed width; use w-full + px-5 pattern for mobile, and max-w-* for upper limits.

🤖 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 `@apps/web/src/app/error.tsx` around lines 15 - 16, Replace the outermost div
container element with a semantic main tag to improve accessibility. Update the
className of this main container to include the mobile-first responsive width
pattern by adding w-full and px-5 classes for mobile padding and full-width
behavior, along with an appropriate max-width constraint class (such as max-w-*)
to limit the width on larger screens. This ensures compliance with the coding
guidelines for semantic HTML tags and responsive design patterns used throughout
the codebase.

Source: Coding guidelines

🤖 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 `@apps/web/src/app/error.tsx`:
- Line 21: The error message text in the error.tsx file contains a Korean
grammar error. Locate the error message string that reads "일시적인 오류에요. 잠시 후 다시
시도해 주세요." and change the word "오류에요" to "오류예요" to correct the Korean grammar and
match the target user-facing text standard.

---

Nitpick comments:
In `@apps/web/src/app/error.tsx`:
- Around line 15-16: Replace the outermost div container element with a semantic
main tag to improve accessibility. Update the className of this main container
to include the mobile-first responsive width pattern by adding w-full and px-5
classes for mobile padding and full-width behavior, along with an appropriate
max-width constraint class (such as max-w-*) to limit the width on larger
screens. This ensures compliance with the coding guidelines for semantic HTML
tags and responsive design patterns used throughout the codebase.

In `@apps/web/src/app/not-found.tsx`:
- Line 8: The 404 page component uses a `<div>` as the top-level container
instead of the semantic `<main>` tag, and it lacks the standard mobile width
pattern used throughout the codebase. Replace the outermost `<div>` with a
`<main>` element and add the responsive width classes pattern: include w-full
for full width and px-5 for mobile padding, plus an appropriate max-w-* class
for desktop width constraints. This will align the not-found page with the
common UI guidelines and the pattern used in other pages in the apps/web/src
directory.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 77e855e9-809f-420a-9e8c-c3c14a61f96f

📥 Commits

Reviewing files that changed from the base of the PR and between 5785ef5 and a78d023.

📒 Files selected for processing (10)
  • apps/web/src/apis/client.ts
  • apps/web/src/app/auth/callback/[provider]/_hooks/usePostSocialLogin.ts
  • apps/web/src/app/error.tsx
  • apps/web/src/app/login/_components/LoginButtons.tsx
  • apps/web/src/app/mypage/_hooks/usePostLogout.ts
  • apps/web/src/app/not-found.tsx
  • apps/web/src/components/notification-sse-provider/index.tsx
  • apps/web/src/components/toast/index.tsx
  • apps/web/src/hooks/useNativeLoginResult.ts
  • apps/web/src/styles/globals.css

Comment thread apps/web/src/app/error.tsx Outdated
@soyeong0115
soyeong0115 merged commit 753f0ba into dev Jun 17, 2026
5 checks passed
@soyeong0115
soyeong0115 deleted the feat/224-error-handling branch June 17, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request fix Something isn't working style

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 에러 상황별 UI 및 토스트 처리 구현

1 participant