Skip to content

Commit 1c8593d

Browse files
committed
fix: hide reviews from ChatInput during send to avoid duplicate display
1 parent e1beb02 commit 1c8593d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/browser/components/ChatInput/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
142142

143143
const [input, setInput] = usePersistedState(storageKeys.inputKey, "", { listener: true });
144144
const [isSending, setIsSending] = useState(false);
145+
const [hideReviewsDuringSend, setHideReviewsDuringSend] = useState(false);
145146
const [showCommandSuggestions, setShowCommandSuggestions] = useState(false);
146147
const [commandSuggestions, setCommandSuggestions] = useState<SlashSuggestion[]>([]);
147148
const [providerNames, setProviderNames] = useState<string[]>([]);
@@ -1099,10 +1100,12 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
10991100
// Capture review IDs before clearing (for marking as checked on success)
11001101
const sentReviewIds = attachedReviews.map((r) => r.id);
11011102

1102-
// Clear input and images immediately for responsive UI
1103-
// These will be restored if the send operation fails
1103+
// Clear input, images, and hide reviews immediately for responsive UI
1104+
// Text/images are restored if send fails; reviews remain "attached" in state
1105+
// so they'll reappear naturally on failure (we only call onCheckReviews on success)
11041106
setInput("");
11051107
setImageAttachments([]);
1108+
setHideReviewsDuringSend(true);
11061109
// Clear inline height style - VimTextArea's useLayoutEffect will handle sizing
11071110
if (inputRef.current) {
11081111
inputRef.current.style.height = "";
@@ -1162,6 +1165,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
11621165
setDraft(preSendDraft);
11631166
} finally {
11641167
setIsSending(false);
1168+
setHideReviewsDuringSend(false);
11651169
}
11661170
} finally {
11671171
// Always restore focus at the end
@@ -1340,7 +1344,8 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
13401344
)}
13411345

13421346
{/* Attached reviews preview - show styled blocks with remove/edit buttons */}
1343-
{variant === "workspace" && attachedReviews.length > 0 && (
1347+
{/* Hide during send to avoid duplicate display with the sent message */}
1348+
{variant === "workspace" && attachedReviews.length > 0 && !hideReviewsDuringSend && (
13441349
<div className="border-border max-h-[50vh] space-y-2 overflow-y-auto border-b px-1.5 py-1.5">
13451350
{attachedReviews.map((review) => (
13461351
<ReviewBlockFromData

0 commit comments

Comments
 (0)