Cha 3 answer feedback#21
Conversation
📝 WalkthroughWalkthrough위젯 메시지와 피드백 응답 타입을 추가하고, 공통 스트리밍 헬퍼를 기반으로 답변 재생성·피드백 제출·최신 assistant 메시지 조회 API를 구현했습니다. ChatWidget에는 피드백 버튼과 BAD 답변 1회 재생성 흐름이 연결되었습니다. Changes위젯 피드백 흐름
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ChatWidget
participant widgetApiClient
participant streamWidgetChatResponse
ChatWidget->>widgetApiClient: 피드백 제출
widgetApiClient-->>ChatWidget: 피드백 응답
ChatWidget->>streamWidgetChatResponse: BAD 답변 재생성 요청
streamWidgetChatResponse->>widgetApiClient: 재생성 SSE 요청
widgetApiClient-->>streamWidgetChatResponse: 답변 청크와 resources 이벤트
streamWidgetChatResponse-->>ChatWidget: 재생성 답변과 sources 반영
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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)
src/widget/types.ts (1)
13-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
FeedbackRating중복 정의 — 단일 출처로 통합 권장.동일한
FeedbackRating이src/api/types.ts:112에도 정의되어 있습니다. 두 정의가 같은 계약을 표현하므로, 한쪽만 값이 바뀌면(예: 등급 추가) 조용히 불일치가 생길 수 있습니다.src/api/types.ts의 정의를 재-export 하는 방식으로 통합하는 것을 고려해 주세요.♻️ 통합 예시
-export type FeedbackRating = "GOOD" | "BAD"; +export type { FeedbackRating } from "../api/types";🤖 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 `@src/widget/types.ts` at line 13, `FeedbackRating` is defined in both `src/widget/types.ts` and `src/api/types.ts`, creating duplicated contract source. Update the widget types to reuse the API type instead of redefining the union, and keep the symbol `FeedbackRating` available via re-export/import from the shared API types module so there is a single source of truth for future rating changes.
🤖 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 `@src/widget/types.ts`:
- Line 13: `FeedbackRating` is defined in both `src/widget/types.ts` and
`src/api/types.ts`, creating duplicated contract source. Update the widget types
to reuse the API type instead of redefining the union, and keep the symbol
`FeedbackRating` available via re-export/import from the shared API types module
so there is a single source of truth for future rating changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0ee92a8f-7426-4ea5-820c-f6e8a54c44c4
📒 Files selected for processing (5)
src/api/types.tssrc/api/widgetChat.tssrc/components/Icons.tsxsrc/widget/ChatWidget.tsxsrc/widget/types.ts
Deploying chatbot-fe with
|
| Latest commit: |
c315aba
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b415dc70.chatbot-fe-bmx.pages.dev |
| Branch Preview URL: | https://cha-3-answer-feedback.chatbot-fe-bmx.pages.dev |
|
지금은 아예 반응 버튼이 비활성화되는데, 재생성만 막는 방식으로 재구현 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/widget/ChatWidget.tsx (2)
471-479: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win재생성 실패 복원 시 로컬 피드백이 서버 상태와 어긋납니다.
handleFeedback에서submitMessageFeedback(BAD)가 이미 성공한 뒤regenerateAnswer(msg)가 호출되는데,originalMsg는 렌더 시점 스냅샷이라feedback이 갱신 이전 값(예:undefined)입니다. 여기서{ ...originalMsg }로 복원하면 서버에는BAD가 저장돼 있는데 로컬은 피드백이 초기화되어 "답변이 도움이 되었나요?" 문구가 다시 노출됩니다. 복원 시BAD선택 상태를 유지해도 재시도 흐름(👎 재클릭 → 재생성)은 그대로 동작합니다.🔧 제안 수정
return prev.map((msg) => - msg.id === regenMsgId ? { ...originalMsg } : msg, + msg.id === regenMsgId ? { ...originalMsg, feedback: "BAD" } : msg, );🤖 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 `@src/widget/ChatWidget.tsx` around lines 471 - 479, 재생성 실패 복원 시 최신 BAD 피드백 상태를 유지하도록 수정하세요. handleFeedback에서 submitMessageFeedback(BAD) 성공 후 regenerateAnswer가 호출되는 흐름과 setMessages 내부의 originalMsg 복원 로직을 확인하고, { ...originalMsg } 대신 해당 메시지의 기존 최신 feedback을 보존하거나 BAD로 명시해 복원하세요.
379-397: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
attachServerId가 최신 assistant 메시지를 현재 답변으로 가정합니다.
fetchLatestAssistantMessage()의limit=1결과를 그대로 쓰기 때문에, 같은 세션에서 연속 전송되거나 다른 탭에서 메시지가 먼저 저장되면 다른 답변의serverId가 붙을 수 있습니다. 서버 응답의 메시지 ID를onComplete에서 직접 돌려주거나, 생성 시점의 로컬 ID와 1:1로 매핑할 수 있게 바꾸는 쪽이 안전합니다.🤖 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 `@src/widget/ChatWidget.tsx` around lines 379 - 397, attachServerId currently assigns the latest assistant message indiscriminately, which can attach another response’s serverId during concurrent or cross-tab sends. Update the completion flow around attachServerId and onComplete to use the server message ID returned by the server directly, or establish an explicit one-to-one mapping from the localId to the created server message; remove reliance on fetchLatestAssistantMessage’s limit=1 result.
🤖 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.
Outside diff comments:
In `@src/widget/ChatWidget.tsx`:
- Around line 471-479: 재생성 실패 복원 시 최신 BAD 피드백 상태를 유지하도록 수정하세요. handleFeedback에서
submitMessageFeedback(BAD) 성공 후 regenerateAnswer가 호출되는 흐름과 setMessages 내부의
originalMsg 복원 로직을 확인하고, { ...originalMsg } 대신 해당 메시지의 기존 최신 feedback을 보존하거나
BAD로 명시해 복원하세요.
- Around line 379-397: attachServerId currently assigns the latest assistant
message indiscriminately, which can attach another response’s serverId during
concurrent or cross-tab sends. Update the completion flow around attachServerId
and onComplete to use the server message ID returned by the server directly, or
establish an explicit one-to-one mapping from the localId to the created server
message; remove reliance on fetchLatestAssistantMessage’s limit=1 result.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2abf0fee-cab9-4d93-a5ac-853798807a5f
📒 Files selected for processing (1)
src/widget/ChatWidget.tsx
|

개요
답변 생성 완료 후 피드백(👍/👎) 버튼을 표시하고, 부정 피드백 시 답변을 1회 재생성하는 기능을 추가합니다.
주요 변경사항
PUT /v1/widget/messages/:id/feedback로 GOOD 저장POST /v1/widget/messages/:id/regenerate/stream로 답변 1회 재생성. 원본 답변은 제거되고 같은 자리에서 재생성 답변이 스트리밍되며, 완료 후 "다시 생성된 답변" 라벨 표시GET /v1/widget/messages?limit=1로 서버 메시지 ID를 조회해 연결Summary by CodeRabbit