Skip to content

fix(web): 채팅 재진입 시 메시지 히스토리 유실 방지#495

Merged
manNomi merged 1 commit intomainfrom
codex/investigate-chat-history-loss
Mar 27, 2026
Merged

fix(web): 채팅 재진입 시 메시지 히스토리 유실 방지#495
manNomi merged 1 commit intomainfrom
codex/investigate-chat-history-loss

Conversation

@manNomi
Copy link
Copy Markdown
Contributor

@manNomi manNomi commented Mar 27, 2026

배경

채팅방에서 메시지는 보이지만, 뒤로 나갔다가 재진입하면 일부(특히 본인) 메시지 히스토리가 사라지는 현상이 있었습니다.

원인

  • 서버 응답에서 message.id가 누락되는 경우가 있어 정규화 단계에서 id=0으로 변환됨
  • 히스토리 병합 시 id만으로 중복 제거를 수행하여 id=0 메시지들이 한 건만 남고 제거됨
  • 렌더 key도 message.id를 사용해 id=0 충돌 가능성이 있었음

변경 사항

  1. normalizeChatMessage에서 id 누락 시 메시지 내용 기반의 안정적인 음수 fallback id를 생성하도록 변경
  2. 히스토리 dedupe 기준을 id 단일값에서 복합 키(id/내용/생성시각/첨부)로 강화
  3. 채팅 목록 렌더 key를 안전한 키 생성 방식으로 변경하고 중복 key 제거

검증

  • pnpm --filter @solid-connect/web exec biome check (수정 파일 대상)
  • pnpm --filter @solid-connect/web typecheck
  • pre-push 훅 CI parity check 및 build 통과

@manNomi manNomi requested review from enunsnv and wibaek as code owners March 27, 2026 10:19
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

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

Project Deployment Actions Updated (UTC)
solid-connection-web Ready Ready Preview, Comment Mar 27, 2026 10:26am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
solid-connect-web-admin Skipped Skipped Mar 27, 2026 10:26am

@github-actions github-actions bot added the web label Mar 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3eb0ad4e-e4ac-4c88-94e6-fe0ba776070f

📥 Commits

Reviewing files that changed from the base of the PR and between 7c6c220 and 3aee313.

📒 Files selected for processing (3)
  • apps/web/src/apis/chat/normalize.ts
  • apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_hooks/useChatListHandler.ts
  • apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/index.tsx

둘러보기

이 변경사항은 채팅 메시지 ID 정규화 및 중복 제거 로직을 개선하는 작업입니다. 다음과 같은 변경사항들이 포함되어 있습니다.

  1. 메시지 ID 정규화 강화

    • 해시 함수와 폴백 메시지 ID 생성 로직을 추가하여, 서버에서 제공하지 않거나 유효하지 않은 ID에 대해 결정적인 임시 음수 ID를 생성합니다.
  2. 중복 제거 로직 개선

    • 메시지 ID 기반 추적에서 안정적인 문자열 키 기반 추적으로 변경하여, 콘텐츠 및 첨부파일 속성을 기반으로 일관된 중복 제거를 보장합니다.
  3. 렌더링 키 재계산

    • React 리스트 조정을 위해 메시지 래퍼 요소의 key 속성을 동적으로 계산된 문자열 키로 변경합니다.

예상 코드 리뷰 난이도

🎯 3 (보통) | ⏱️ ~25분

제안 검토자

  • wibaek
  • enunsnv
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 주요 변경사항을 명확하게 요약하고 있으며, 채팅 재진입 시 메시지 히스토리 유실 방지라는 핵심 목표를 정확히 전달합니다.
Description check ✅ Passed PR 설명은 템플릿의 주요 섹션(배경, 원인, 변경사항, 검증)을 모두 포함하며 충분한 기술적 세부사항과 맥락을 제공합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ 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 codex/investigate-chat-history-loss

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3aee3133ba

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

const messageKey =
message.id > 0
? `message-${message.id}`
: `message-${message.senderId}-${message.createdAt}-${message.content}-${index}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use a stable key for fallback chat messages

Using index in the fallback React key makes keys shift whenever older items are prepended by infinite scroll, so messages with missing server IDs (the exact target of this fix) are remounted on each page load instead of preserved. In practice this can cause visible flicker/reset of message bubbles and attachment rendering in long threads; the key should be derived from stable message identity only (e.g., fallback id/dedupe key) and not list position.

Useful? React with 👍 / 👎.

@manNomi manNomi merged commit 9fae5a9 into main Mar 27, 2026
10 checks passed
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.

1 participant