Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Add `delete` option for project actions (#223)
Mubin Ansari1c43bad705bd
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex b284523c5..a96b17bdb 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -1621,6 +1621,36 @@ export default function ChatView({ threadId }: ChatViewProps) {},[activeProject, persistProjectScripts],);+ const deleteProjectScript = useCallback(+ async (scriptId: string) => {+ if (!activeProject) return;+ const nextScripts = activeProject.scripts.filter((script) => script.id !== scriptId);++ const deletedName = activeProject.scripts.find((s) => s.id === scriptId)?.name;++ try {+ await persistProjectScripts({+ projectId: activeProject.id,+ projectCwd: activeProject.cwd,+ previousScripts: activeProject.scripts,+ nextScripts,+ keybinding: null,+ keybindingCommand: commandForProjectScript(scriptId),+ });+ toastManager.add({+ type: "success",+ title: `Deleted action "${deletedName ?? "Unknown"}"`,+ });+ } catch (error) {+ toastManager.add({+ type: "error",+ title: "Could not delete action",+ description: error instanceof Error ? error.message : "An unexpected error occurred.",+ });+ }+ },+ [activeProject, persistProjectScripts],+ );const handleRuntimeModeChange = useCallback((mode: RuntimeMode) => {@@ -3428,6 +3458,7 @@ export default function ChatView({ threadId }: ChatViewProps) {}}onAddProjectScript={saveProjectScript}onUpdateProjectScript={updateProjectScript}+ onDeleteProjectScript={deleteProjectScript}onToggleDiff={onToggleDiff}/></header>@@ -4008,6 +4039,7 @@ interface ChatHeaderProps {onRunProjectScript: (script: ProjectScript) => void;onAddProjectScript: (input: NewProjectScriptInput) => Promise<void>;onUpdateProjectScript: (scriptId: string, input: NewProjectScriptInput) => Promise<void>;+ onDeleteProjectScript: (scriptId: string) => Promise<void>;onToggleDiff: () => void;}@@ -4027,6 +4059,7 @@ const ChatHeader = memo(function ChatHeader({onRunProjectScript,onAddProjectScript,onUpdateProjectScript,+ onDeleteProjectScript,onToggleDiff,}: ChatHeaderProps) {return (@@ -4059,6 +4092,7 @@ const ChatHeader = memo(function ChatHeader({onRunScript={onRunProjectScript}onAddScript={onAddProjectScript}onUpdateScript={onUpdateProjectScript}+ onDeleteScript={onDeleteProjectScript}/>)}{activeProjectName && (diff --git a/apps/web/src/components/ProjectScriptsControl.tsx b/apps/web/src/components/ProjectScriptsControl.tsxindex 092f2d598..437b3e78e 100644--- a/apps/web/src/components/ProjectScriptsControl.tsx+++ b/apps/web/src/components/ProjectScriptsControl.tsx@@ -14,7 +14,7 @@ import {SettingsIcon,WrenchIcon,} from "lucide-react";-import React, { type FormEvent, type KeyboardEvent, useMemo, useState } from "react";+import React, { type FormEvent, type KeyboardEvent, useCallback, useMemo, useState } from "react";import {keybindingValueForCommand,@@ -27,6 +27,15 @@ import {} from "~/projectScripts";import { shortcutLabelForCommand } from "~/keybindings";import { isMacPlatform } from "~/lib/utils";+import {+ AlertDialog,+ AlertDialogClose,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogPopup,+ AlertDialogTitle,+} from "./ui/alert-dialog";import { Button } from "./ui/button";import {Dialog,@@ -84,6 +93,7 @@ interface ProjectScriptsControlProps {onRunScript: (script: ProjectScript) => void;onAddScript: (input: NewProjectScriptInput) => Promise<void> | void;onUpdateScript: (scriptId: string, input: NewProjectScriptInput) => Promise<void> | void;+ onDeleteScript: (scriptId: string) => Promise<void> | void;}function normalizeShortcutKeyToken(key: string): string | null {@@ -144,6 +154,7 @@ export default function ProjectScriptsControl({onRunScript,onAddScript,onUpdateScript,+ onDeleteScript,}: ProjectScriptsControlProps) {const addScriptFormId = React.useId();const [editingScriptId, setEditingScriptId] = useState<string | null>(null);@@ -155,6 +166,7 @@ export default function ProjectScriptsControl({const [runOnWorktreeCreate, setRunOnWorktreeCreate] = useState(false);const [keybinding, setKeybinding] = useState("");const [validationError, setValidationError] = useState<string | null>(null);+ const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false);const primaryScript = useMemo(() => {if (preferredScriptId) {@@ -247,6 +259,13 @@ export default function ProjectScriptsControl({setDialogOpen(true);};+ const confirmDeleteScript = useCallback(() => {+ if (!editingScriptId) return;+ setDeleteConfirmOpen(false);+ setDialogOpen(false);+ void onDeleteScript(editingScriptId);+ }, [editingScriptId, onDeleteScript]);+return (<>{primaryScript ? (@@ -440,6 +459,16 @@ export default function ProjectScriptsControl({</form></DialogPanel><DialogFooter>+ {isEditing && (+ <Button+ type="button"+ variant="destructive-outline"+ className="mr-auto"+ onClick={() => setDeleteConfirmOpen(true)}+ >+ Delete+ </Button>+ )}<Buttontype="button"variant="outline"@@ -455,6 +484,21 @@ export default function ProjectScriptsControl({</DialogFooter></DialogPopup></Dialog>++ <AlertDialog open={deleteConfirmOpen} onOpenChange={setDeleteConfirmOpen}>+ <AlertDialogPopup>+ <AlertDialogHeader>+ <AlertDialogTitle>Delete action "{name}"?</AlertDialogTitle>+ <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>+ <Button variant="destructive" onClick={confirmDeleteScript}>+ Delete action+ </Button>+ </AlertDialogFooter>+ </AlertDialogPopup>+ </AlertDialog></>);}