feat: add regenerate button to re‑send last prompt#700
Conversation
Add a 'Regenerate' button below the last agent response so users can re-run their last prompt without retyping. Changes: - MessageList: add onRegenerate prop + RegenerateBar component with RefreshCw icon, shown when agent has finished and a user message exists - Chat: add handleRegenerate that finds the last user message and re-sends it via handleSendRef - main.css: .chat-regenerate-bar + .chat-regenerate-btn styles - i18n: add copyMessage and regenerate strings to all 10 locales
| const handleRegenerate = useCallback(() => { | ||
| const lastUser = [...messages] | ||
| .reverse() | ||
| .find((m) => m.role === "user") as | ||
| | import("./types").ChatBubbleMessage | ||
| | undefined; | ||
| if (!lastUser?.content) return; | ||
| void handleSendRef.current(lastUser.content, lastUser.attachments || []); | ||
| }, [messages]); |
There was a problem hiding this comment.
Regenerate duplicates the last user message
handleRegenerate calls handleSendRef.current(...), which internally calls pushUser(text, "user", attachments) — that appends a brand-new user bubble to the messages array. As a result, every regenerate produces an extra copy of the original user message in the transcript: the conversation grows as […, user: "hello", agent: "resp1", user: "hello" (duplicate), agent: "resp2"].
The standard "regenerate" pattern strips the last agent turn (and optionally the duplicate user turn) before re-sending. At a minimum, handleSend should not push another user bubble when regenerating — consider passing sendToAgent directly, or adding a noUserBubble flag to handleSend/handleSendRef.
| copyMessage: "Copy message", | ||
| regenerate: "Regenerate", |
There was a problem hiding this comment.
The
copyMessage key is added here and to all 10 locale files, but there is no reference to t("chat.copyMessage") anywhere in the PR. Shipping unused i18n keys adds translation overhead without benefit; consider removing it if the copy-message feature is not yet implemented.
| copyMessage: "Copy message", | |
| regenerate: "Regenerate", | |
| regenerate: "Regenerate", |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| ); | ||
| }); | ||
| }); No newline at end of file |
There was a problem hiding this comment.
Feature
Add a 'Regenerate' button below the last agent response. Clicking it re-sends the last user message to get a new response from the agent, matching the common 'regenerate' pattern in AI chat apps.
Changes
MessageList.tsx
onRegeneratepropRegenerateBarcomponent withRefreshCwicon and localized 'Regenerate' labelChat.tsx
handleRegeneratecallback: finds the last user message and callshandleSendRef.current()with its content and attachmentsmain.css
.chat-regenerate-bar— thin bar below messages, aligned to the message column (margin-left: 42px to clear the avatar).chat-regenerate-btn— inline-flex button with border, hover effecti18n
copyMessageandregeneratekeys to all 10 supported localesBehavior