Skip to content

Conversation

kim-hyunjoo
Copy link
Contributor

📝작업 내용

  • 사용자가 이전 메세지를 스크롤해서 보고 있을 때 새로운 메세지가 오면 채팅 하단에 플로팅 버튼을 띄워줍니다.
  • 해당 플로팅 버튼을 누르면 최신 메세지로 이동합니다.
  • 최신메세지를 보고 다시 위로 스크롤하면 또 새로운 메세지가 오기 전까지는 플로팅 버튼을 띄우지 않습니다.
  • 시스템 메세지는 sender을 표기하지 않습니다.

📷스크린샷(필요 시)

KakaoTalk_Video_2025-10-10-18-01-01.mp4

✨PR Point

@kim-hyunjoo kim-hyunjoo requested review from joyswim and ksjdev October 10, 2025 09:15
@kim-hyunjoo kim-hyunjoo self-assigned this Oct 10, 2025
@kim-hyunjoo kim-hyunjoo added ✨기능 새로운 기능 추가 ♻️리팩토링 코드 리팩토링 (성능 및 코드 로직 개선) 💄디자인 css 스타일링 (UI 변경점) labels Oct 10, 2025
Copy link

Summary of Changes

Hello @kim-hyunjoo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 채팅 컴포넌트의 사용자 경험을 개선하는 데 중점을 둡니다. 사용자가 채팅 기록을 탐색하는 동안 새로운 메시지를 놓치지 않도록 시각적인 알림과 편리한 스크롤 기능을 제공하여, 채팅 흐름을 보다 직관적이고 효율적으로 관리할 수 있도록 합니다.

Highlights

  • 새 메시지 알림: 사용자가 이전 메시지를 보고 있을 때 새 메시지가 도착하면 채팅 하단에 플로팅 버튼이 나타납니다.
  • 스크롤 가이드 버튼: 플로팅 버튼을 클릭하면 최신 메시지로 자동 스크롤됩니다.
  • 조건부 표시: 최신 메시지를 보고 있거나, 새 메시지가 도착하지 않으면 플로팅 버튼은 표시되지 않습니다.
  • 시스템 메시지 발신자 숨김: 시스템 메시지에는 발신자 정보가 표시되지 않도록 변경되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

채팅 컴포넌트의 UX를 개선하기 위한 좋은 변경 사항입니다. 새로운 메시지 알림 및 자동 스크롤 기능이 추가되었네요. 전반적으로 잘 구현되었지만, 코드의 안정성과 유지보수성을 높이기 위해 몇 가지 개선점을 제안합니다. 주요 내용은 useEffect 훅의 의존성 관리, 리스트 렌더링 시 key 사용법, 그리고 사소한 코드 스타일 관련입니다. 자세한 내용은 각 파일의 주석을 확인해주세요.

Comment on lines 42 to 85
useEffect(() => {
//@TODO: 추후에 채팅을 실시간으로 보고 있을 때는 자동 스크롤, 위 채팅을 보고 있을 때는 자동 스크롤이 안되도록 기능 수정
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
}, [chatMessages]);
if (chatMessages.length === 0) return;

const lastMessage = chatMessages[chatMessages.length - 1];
const isSentByMe = lastMessage.sender === myName;
const container = messagesContainerRef.current;

if (!isAtBottom) {
setShowNewMessage(true);
}

if (container && (isSentByMe || isAtBottom)) {
container.scrollTop = container.scrollHeight;
}
handleScroll();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [chatMessages, myName, handleScroll]);

Choose a reason for hiding this comment

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

high

안녕하세요! 새 메시지 알림 기능 구현을 위한 좋은 변경입니다. 다만 이 useEffect 훅의 안정성을 높이기 위해 몇 가지 개선점을 제안합니다.

  1. UI 깜빡임 (Flicker): 현재 코드에서는 스크롤을 위로 올린 상태에서 내가 메시지를 보내면 '새 메시지' 알림이 아주 잠깐 보였다가 사라지는 현상이 발생합니다.
  2. eslint-disable 주석: react-hooks/exhaustive-deps 규칙을 비활성화하면, useEffect가 오래된 isAtBottom 값을 참조하여 예기치 않은 동작을 일으킬 수 있습니다(stale closure).

아래와 같이 setShowNewMessage 호출 조건을 수정하면 깜빡임 현상을 해결할 수 있습니다. eslint-disable 문제는 더 근본적인 리팩토링(예: useRef 사용)이 필요할 수 있지만, 우선 급한 UX 버그부터 수정하는 것이 좋습니다.

    if (!isAtBottom && !isSentByMe) {
      setShowNewMessage(true);
    }

    if (container && (isSentByMe || isAtBottom)) {
      container.scrollTop = container.scrollHeight;
    }
    handleScroll();
    // eslint-disable-next-line react-hooks/exhaustive-deps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

완료
isAtBottom이 배열에 들어가면 스크롤이 아래로 계속 고정되므로 반영x

>
{chatMessages.map((item, index) => (
<Item
key={index}

Choose a reason for hiding this comment

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

medium

리스트를 렌더링할 때 key로 배열의 index를 사용하는 것은 권장되지 않습니다. 배열의 순서가 변경되거나 항목이 중간에 추가/삭제될 경우 React가 컴포넌트 상태를 잘못 관리하여 예기치 않은 렌더링 오류나 성능 저하를 일으킬 수 있습니다. 각 메시지에 고유한 ID(예: message.id)를 부여하고 key로 사용하는 것이 가장 좋습니다. 메시지 데이터에 고유 ID가 없다면, 임시적으로 key={${item.sender}-${index}} 와 같이 조금 더 안정적인 키를 생성하는 것을 고려해볼 수 있습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

완료

variant="secondary"
>
<p className="text-body3 overflow-hidden text-ellipsis whitespace-nowrap">
{sender != 'system' && `${sender}: `}

Choose a reason for hiding this comment

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

medium

JavaScript에서는 타입 변환을 방지하기 위해 != 대신 !== 연산자를 사용하는 것이 권장됩니다. 이렇게 하면 예기치 않은 동작을 방지하고 코드의 의도를 더 명확하게 할 수 있습니다.

Suggested change
{sender != 'system' && `${sender}: `}
{sender !== 'system' && `${sender}: `}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

완료

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️리팩토링 코드 리팩토링 (성능 및 코드 로직 개선) ✨기능 새로운 기능 추가 💄디자인 css 스타일링 (UI 변경점)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GRPHI-235] 채팅의 가장 새로운 메세지를 띄워주는 NewMessage 컴포넌트 구현 및 적용

1 participant