fix: 채팅 전송 스크롤 상태 초기화#532
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Walkthrough이 변경사항은 채팅 메시지 자동 스크롤 제어 로직을 정교하게 개선합니다.
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_hooks/useChatListHandler.ts (1)
251-266: ⚡ Quick win1.
.some()사용 시 첫 번째 매칭 후 반복이 중단되는 문제
.some()메서드는 첫 번째true반환 시 즉시 반복을 중단합니다. 만약 여러 outbound 메시지가 동시에 도착하면, 첫 번째 매칭된 pending 항목만 제거되고 나머지는 타임아웃까지 남아있게 됩니다.
forEach또는reduce를 사용하여 모든 새 메시지를 순회하고, 매칭된 모든 pending 항목을 수집하는 것이 더 정확합니다.♻️ 모든 매칭을 처리하도록 수정
const newMessages = submittedMessages.slice(prevMessageCount); const matchedPendingOutboundTextIds = new Set<string>(); - const hasConfirmedOutboundText = newMessages.some((message) => { + + newMessages.forEach((message) => { const pendingOutboundText = pendingOutboundTextScrollsRef.current.find( (item) => item.senderId === message.senderId && item.content === normalizePendingText(message.content), ); - if (!pendingOutboundText) return false; + if (!pendingOutboundText) return; matchedPendingOutboundTextIds.add(pendingOutboundText.id); - return true; }); + + const hasConfirmedOutboundText = matchedPendingOutboundTextIds.size > 0; if (matchedPendingOutboundTextIds.size > 0) { removePendingOutboundTextScrolls(matchedPendingOutboundTextIds); }🤖 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/mentor/chat/`[chatId]/_ui/ChatContent/_hooks/useChatListHandler.ts around lines 251 - 266, The current use of submittedMessages.some(...) stops after the first match so only one pendingOutboundText gets removed; instead iterate all newMessages (derived from submittedMessages.slice(prevMessageCount)) with a forEach or for...of, for each message find pendingOutboundText via pendingOutboundTextScrollsRef.current.find(...) (using normalizePendingText for comparison), add every matched pendingOutboundText.id to matchedPendingOutboundTextIds, and after the loop call removePendingOutboundTextScrolls(matchedPendingOutboundTextIds); remove or replace the hasConfirmedOutboundText boolean logic that relied on .some() if not needed.
🤖 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.
Nitpick comments:
In
`@apps/web/src/app/mentor/chat/`[chatId]/_ui/ChatContent/_hooks/useChatListHandler.ts:
- Around line 251-266: The current use of submittedMessages.some(...) stops
after the first match so only one pendingOutboundText gets removed; instead
iterate all newMessages (derived from submittedMessages.slice(prevMessageCount))
with a forEach or for...of, for each message find pendingOutboundText via
pendingOutboundTextScrollsRef.current.find(...) (using normalizePendingText for
comparison), add every matched pendingOutboundText.id to
matchedPendingOutboundTextIds, and after the loop call
removePendingOutboundTextScrolls(matchedPendingOutboundTextIds); remove or
replace the hasConfirmedOutboundText boolean logic that relied on .some() if not
needed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ad1ebc14-cff1-49ea-a60a-177a669f5b92
📒 Files selected for processing (1)
apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_hooks/useChatListHandler.ts
관련 이슈
작업 내용
senderId와 같은 내용의 내 메시지가 확인될 때만 하단 강제 이동을 수행하도록 수정했습니다.검증
pnpm --filter @solid-connect/web lint:checkpnpm --filter @solid-connect/web typecheck@solid-connect/web ci:check및@solid-connect/web build통과참고
v23.10.0이라engines.node: 22.x경고가 출력되지만 검증은 모두 통과했습니다.