Skip to content

feat: 주최자 알림 토스트를 담기 화면에서만 노출 - #499

Merged
kanghaeun merged 1 commit into
devfrom
feat/478-sse-notification-toast-scope
Aug 13, 2026
Merged

feat: 주최자 알림 토스트를 담기 화면에서만 노출#499
kanghaeun merged 1 commit into
devfrom
feat/478-sse-notification-toast-scope

Conversation

@kanghaeun

@kanghaeun kanghaeun commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

작업 요약

  • 주최자 알림 토스트를 담기 화면에서만 노출
  • 토스트 바로가기 딥링크 제거

작업 세부 내용

SSE 알림 토스트가 타입과 무관하게 어느 페이지에서든 노출되던 것을, 알림 성격에 맞게 범위를 조정했습니다.

1. 주최자가 받는 참여자 활동 알림을 담기 화면 한정으로

알림 받는 사람 노출 범위
TOURNAMENT_JOINED (참여자 입장) 주최자 해당 토너먼트 담기 화면에서만
TOURNAMENT_ITEM_ADDED (참여자가 후보 담음) 주최자 해당 토너먼트 담기 화면에서만
TOURNAMENT_ITEM_DELETED (참여자가 후보 뺌) 주최자 해당 토너먼트 담기 화면에서만
TOURNAMENT_STARTED (주최자가 시작) 참여자 어디서든 (기존 유지)
파싱 완료·실패, 그 외 전체 - 기존 유지

주최자가 받는 참여자 활동 알림은 담기 화면을 보고 있을 때만 의미가 있습니다. 다른 화면에서는 지금 하는 일과 무관해 방해가 됩니다.

  • 캐시 무효화(invalidateQueries)는 토스트 노출 여부와 무관하게 항상 실행됩니다. 다른 화면에 있다가 담기 화면으로 돌아와도 목록은 최신입니다.
  • 경로 비교에 payload.refId를 사용해 해당 토너먼트의 담기 화면인지까지 확인합니다. A 토너먼트를 보는 중에 B 토너먼트 알림이 뜨는 것을 막습니다.
  • TOURNAMENT_STARTED는 놓치면 참여 기회를 잃는 알림이라 별도 case로 분리해 전역 노출을 유지했습니다.

2. 토스트의 바로가기 버튼 전면 제거

담기 화면 한정 알림은 이미 그 페이지에 있는 사용자에게 같은 페이지로 가는 버튼을 주는 셈이라 무의미해졌습니다. 이에 맞춰 전체 토스트에서 제거했습니다.

  • resolveDeepLink 함수 삭제
  • 미사용이 된 useRouter, QUERY_ACTION import 정리
  • effect deps 에서 router 제거 → SSE 재연결 유발 요인이 하나 줄었습니다
  • SCROLL_TO_LAST_QUERY 는 이 파일에서 딥링크 URL 조립에만 쓰이던 지역 상수라 함께 삭제했습니다. 원본 QUERY_ACTION.VALUE.SCROLL_TO_LAST 는 위시 담기 플로우에서 계속 사용하므로 유지됩니다.

pathname 을 deps 대신 ref 로 참조한 이유

const pathnameRef = useRef(pathname);
useEffect(() => {
  pathnameRef.current = pathname;
}, [pathname]);

pathname 을 SSE effect 의 deps 에 넣으면 값은 최신이 되지만, 페이지 이동마다 연결이 끊겼다 재연결됩니다.

  • 이동할 때마다 서버에 새 스트림 연결
  • onopen 의 재연결 복구 로직이 매번 실행되어 invalidateQueries 3개(notifications·tournament·wishlists)가 불필요하게 반복
  • 재연결 사이 공백에 도착한 이벤트 유실 가능

onmessage 는 연결 시점에 한 번만 생성되는 클로저라, pathname 을 직접 참조하면 연결 당시 값에 고정됩니다(stale closure). 연결은 유지한 채 최신 값만 읽어야 해서 ref 를 경유합니다.

스크린샷

변경 전

2026-08-12.6.30.48.mov

변경 후

2026-08-12.6.30.04.mov

연관 이슈

closes #478

Summary by CodeRabbit

  • 개선 사항
    • 알림 수신 시 현재 화면에 맞춰 토스트 표시 여부가 조정됩니다.
    • 토너먼트 관련 알림이 도착하면 최신 정보가 자동으로 갱신됩니다.
    • 토너먼트 상세 화면에서 참가, 아이템 추가·삭제 알림을 확인할 수 있습니다.
    • 파싱 성공·실패 알림의 화면 이동 동작이 제거되었습니다.
    • 알림 연결 성공 후 데이터 재조회와 자동 재연결 기능은 계속 지원됩니다.

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
piki Ready Ready Preview Aug 13, 2026 7:06am

@github-actions github-actions Bot added feature New feature or request WEB labels Aug 12, 2026
@github-actions
github-actions Bot requested a review from iOdiO89 August 12, 2026 09:35
@github-actions

Copy link
Copy Markdown

Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c519281-d84c-4b0a-a4de-b3814472d97e

📥 Commits

Reviewing files that changed from the base of the PR and between d4c9153 and 3cba93e.

📒 Files selected for processing (1)
  • apps/web/src/hooks/useNotificationSSE.ts

📝 Walkthrough

Walkthrough

SSE 알림 훅이 usePathname으로 현재 경로를 추적합니다. 토너먼트 알림은 관련 쿼리를 무효화합니다. 토너먼트 활동 알림은 해당 토너먼트 화면에서만 토스트를 표시합니다. 토스트의 deep-link action을 제거했습니다.

Changes

SSE 알림 토스트 범위

Layer / File(s) Summary
현재 경로 추적 및 SSE 연결 유지
apps/web/src/hooks/useNotificationSSE.ts
useRouter 의존성을 제거하고 pathname ref를 추가했습니다. pathname 변경 시 ref를 갱신하며 SSE effect의 router 의존성을 제거했습니다.
토너먼트 알림 처리
apps/web/src/hooks/useNotificationSSE.ts
토스트 action을 제거했습니다. 토너먼트 시작 알림은 항상 토스트를 표시합니다. 참가·아이템 추가·삭제 알림은 쿼리를 무효화하고 해당 토너먼트 화면에서만 토스트를 표시합니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to 3cba9

알림 토스트 범위 변경은 국소적이며, 현재 병합을 막을 수 있는 실행상 위험은 남아 있지 않습니다.

Possibly related PRs

  • TeamPiKi/client#363: useNotificationSSE.ts의 재연결 후 쿼리 재조회 동작과 관련됩니다.
  • TeamPiKi/client#456: useNotificationSSE.ts의 알림 토스트 동작과 관련됩니다.

Suggested labels: refactor

Suggested reviewers: iodio89

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 주최자 알림 토스트를 해당 담기 화면으로 제한하는 주요 변경을 명확하게 설명합니다.
Linked Issues check ✅ Passed 참여자 활동 알림의 화면 제한, 전역 시작 알림, 캐시 무효화, 딥링크 제거 요구를 모두 반영합니다 [#478].
Out of Scope Changes check ✅ Passed 변경 사항은 연결된 이슈의 알림 노출 범위, 캐시 무효화, 경로 판단, 딥링크 제거 범위에 포함됩니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/478-sse-notification-toast-scope

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.

@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

🤖 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/hooks/useNotificationSSE.ts`:
- Around line 176-185: Validate the parsed SSE payload at runtime before
processing it, replacing the unchecked NotificationSsePayloadT assertion with a
Zod schema or type guard that enforces each notification type’s required fields,
including a numeric refId for tournament events. Use only the validated payload
for query invalidation, pathname comparisons, and subsequent event handling, and
ignore or safely reject invalid messages.
🪄 Autofix

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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c2a97862-49d9-48fc-b826-45caa7f566a7

📥 Commits

Reviewing files that changed from the base of the PR and between f53b255 and d4c9153.

📒 Files selected for processing (1)
  • apps/web/src/hooks/useNotificationSSE.ts

Comment thread apps/web/src/hooks/useNotificationSSE.ts
@kanghaeun
kanghaeun force-pushed the feat/478-sse-notification-toast-scope branch from d4c9153 to 3cba93e Compare August 13, 2026 07:04
@kanghaeun
kanghaeun merged commit a580d7f into dev Aug 13, 2026
9 checks passed
@kanghaeun
kanghaeun deleted the feat/478-sse-notification-toast-scope branch August 13, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request WEB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: SSE 알림 토스트 노출 범위 조정

1 participant