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
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import {
PromptInputTools,
useProviderAttachments,
} from "@superset/ui/ai-elements/prompt-input";
import { Button } from "@superset/ui/button";
import { Input } from "@superset/ui/input";
import { isEnterSubmit } from "@superset/ui/lib/keyboard";
import { cn } from "@superset/ui/utils";
import { useNavigate } from "@tanstack/react-router";
import type { FileUIPart } from "ai";
import { AnimatePresence, motion } from "framer-motion";
import { ArrowUpIcon } from "lucide-react";
Expand All @@ -41,7 +43,10 @@ import { PRLinkCommand } from "./components/PRLinkCommand";
import { ProjectPickerPill } from "./components/ProjectPickerPill";
import { useBranchPickerController } from "./hooks/useBranchPickerController";
import { useLinkedContext } from "./hooks/useLinkedContext";
import { useSubmitWorkspace } from "./hooks/useSubmitWorkspace";
import {
type SubmitAttachment,
useSubmitWorkspace,
} from "./hooks/useSubmitWorkspace";
import {
AGENT_STORAGE_KEY,
PILL_BUTTON_CLASS,
Expand All @@ -65,7 +70,18 @@ export function PromptGroup({
const modKey = PLATFORM === "mac" ? "⌘" : "Ctrl";
const isNewWorkspaceModalOpen = useNewWorkspaceModalOpen();
const { closeModal, draft, updateDraft } = useDashboardNewWorkspaceDraft();
const navigate = useNavigate();
const attachments = useProviderAttachments();
const needsSetup = selectedProject?.needsSetup === true;
const handleGoToSetup = useCallback(() => {
if (!selectedProject?.id) return;
const targetProjectId = selectedProject.id;
closeModal();
void navigate({
to: "/settings/projects/$projectId",
params: { projectId: targetProjectId },
});
}, [closeModal, navigate, selectedProject?.id]);
const {
baseBranch,
hostTarget,
Expand Down Expand Up @@ -126,7 +142,17 @@ export function PromptGroup({
});

// ── Submit (fork) ────────────────────────────────────────────────
const handleCreate = useSubmitWorkspace(projectId);
const createWorkspace = useSubmitWorkspace(projectId);
const handleSubmit = useCallback(
(files: SubmitAttachment[] = []) => {
if (needsSetup) {
handleGoToSetup();
return;
}
void createWorkspace(files);
},
[createWorkspace, handleGoToSetup, needsSetup],
);
const handlePromptSubmit = useCallback(
(message: { text?: string; files?: FileUIPart[] }) => {
// Library converts blob: → data: URLs before calling us; pass them
Expand All @@ -140,9 +166,9 @@ export function PromptGroup({
mediaType: f.mediaType,
filename: f.filename,
}));
void handleCreate(files);
handleSubmit(files);
},
[handleCreate],
[handleSubmit],
);

useEffect(() => {
Expand All @@ -153,11 +179,11 @@ export function PromptGroup({
// Keyboard fallback: submit without attachments. Inside the
// modal's form focus, PromptInput's own Enter handler fires
// instead and routes through handlePromptSubmit with files.
void handleCreate();
handleSubmit();
};
window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler);
}, [isNewWorkspaceModalOpen, handleCreate]);
}, [isNewWorkspaceModalOpen, handleSubmit]);

// ── Linked issues / PR ───────────────────────────────────────────
const {
Expand Down Expand Up @@ -349,9 +375,10 @@ export function PromptGroup({
/>
<PromptInputSubmit
className="size-[22px] rounded-full border border-transparent bg-foreground/10 shadow-none p-[5px] hover:bg-foreground/20"
disabled={needsSetup}
onClick={(e) => {
e.preventDefault();
void handleCreate();
handleSubmit();
}}
>
<ArrowUpIcon className="size-3.5 text-muted-foreground" />
Expand Down Expand Up @@ -400,14 +427,21 @@ export function PromptGroup({
</AnimatePresence>
</div>
<div className="flex items-center gap-1.5">
{selectedProject?.needsSetup === true && (
<span className="text-[11px] text-amber-500">
Project needs to be set up
{needsSetup ? (
<Button
type="button"
variant="outline"
size="sm"
className="h-6 px-2 text-[11px] text-amber-500 hover:text-amber-500"
onClick={handleGoToSetup}
>
Set up project…
</Button>
) : (
<span className="text-[11px] text-muted-foreground/50">
{modKey}↵
</span>
)}
<span className="text-[11px] text-muted-foreground/50">
{modKey}↵
</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export { useSubmitWorkspace } from "./useSubmitWorkspace";
export {
type SubmitAttachment,
useSubmitWorkspace,
} from "./useSubmitWorkspace";
Loading