Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions frontend/src/components/editor/ai/add-cell-with-ai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,21 @@ export const AddCellWithAI: React.FC<{

const handleDeclineCompletion = () => {
deleteAllStagedCells();
// Focus the input so the user can refine the prompt.
inputRef.current?.view?.focus();
};

const handleClose = () => {
deleteAllStagedCells();
onClose();
};

const inputComponent = (
<div className="flex items-center px-3">
<SparklesIcon className="size-4 text-(--blue-11) mr-2" />
<PromptInput
inputRef={inputRef}
onClose={() => {
deleteAllStagedCells();
onClose();
}}
onClose={handleClose}
value={input}
onChange={(newValue) => {
setInput(newValue);
Expand All @@ -254,7 +258,12 @@ export const AddCellWithAI: React.FC<{
hasCompletion,
})}
/>
<Button variant="text" size="sm" className="mb-0 px-1" onClick={onClose}>
<Button
variant="text"
size="sm"
className="mb-0 px-1"
onClick={handleClose}
>
<XIcon className="size-4" />
</Button>
</div>
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/editor/ai/ai-completion-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,12 @@ export const AiCompletionEditor: React.FC<Props> = ({
setCompletion("");
};

// Reject discards the suggestion but keeps the prompt open for refinement.
const handleDeclineCompletion = () => {
declineChange();
stop();
setCompletion("");
setShowInputPrompt(true);
inputRef.current?.view?.focus();
};

const showCompletionBanner =
Expand Down
Loading