Skip to content

Commit 1b52391

Browse files
committed
🤖 fix: keep creation prompt on error; only clear on success
- Creation ChatInput no longer wipes the input when workspace creation fails - useCreationWorkspace.handleSend now returns boolean success so UI can decide when to clear _Generated with _
1 parent c72415f commit 1b52391

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/browser/components/ChatInput/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,13 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
459459
if (variant === "creation") {
460460
// Creation variant: simple message send + workspace creation
461461
setIsSending(true);
462-
setInput(""); // Clear input immediately (will be restored by parent if creation fails)
463-
await creationState.handleSend(messageText);
462+
const ok = await creationState.handleSend(messageText);
463+
if (ok) {
464+
setInput("");
465+
if (inputRef.current) {
466+
inputRef.current.style.height = "36px";
467+
}
468+
}
464469
setIsSending(false);
465470
return;
466471
}

src/browser/components/ChatInput/useCreationWorkspace.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interface UseCreationWorkspaceReturn {
4343
toast: Toast | null;
4444
setToast: (toast: Toast | null) => void;
4545
isSending: boolean;
46-
handleSend: (message: string) => Promise<void>;
46+
handleSend: (message: string) => Promise<boolean>;
4747
}
4848

4949
/**
@@ -89,8 +89,8 @@ export function useCreationWorkspace({
8989
}, [projectPath]);
9090

9191
const handleSend = useCallback(
92-
async (message: string) => {
93-
if (!message.trim() || isSending) return;
92+
async (message: string): Promise<boolean> => {
93+
if (!message.trim() || isSending) return false;
9494

9595
setIsSending(true);
9696
setToast(null);
@@ -113,7 +113,7 @@ export function useCreationWorkspace({
113113
if (!result.success) {
114114
setToast(createErrorToast(result.error));
115115
setIsSending(false);
116-
return;
116+
return false;
117117
}
118118

119119
// Check if this is a workspace creation result (has metadata field)
@@ -122,6 +122,8 @@ export function useCreationWorkspace({
122122
// Settings are already persisted via useDraftWorkspaceSettings
123123
// Notify parent to switch workspace (clears input via parent unmount)
124124
onWorkspaceCreated(result.metadata);
125+
setIsSending(false);
126+
return true;
125127
} else {
126128
// This shouldn't happen for null workspaceId, but handle gracefully
127129
setToast({
@@ -130,6 +132,7 @@ export function useCreationWorkspace({
130132
message: "Unexpected response from server",
131133
});
132134
setIsSending(false);
135+
return false;
133136
}
134137
} catch (err) {
135138
const errorMessage = err instanceof Error ? err.message : String(err);
@@ -139,6 +142,7 @@ export function useCreationWorkspace({
139142
message: `Failed to create workspace: ${errorMessage}`,
140143
});
141144
setIsSending(false);
145+
return false;
142146
}
143147
},
144148
[

0 commit comments

Comments
 (0)