Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(prompts): replace the row's Edit icon with a ⋯ actions menu (#1015)

Cihana30173e0027a
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
index 7d06981d0..ef30bf4f8 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
@@ -44,6 +44,13 @@ import {
} from '@/components/ui/select';
import { CompetitionBars } from '@/components/ui/competition-bars';
import { WorkStatusBadge } from '@/components/prompts/work-status';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
import { setPromptWorkStatus, type PromptWorkStatus } from '@/lib/actions/prompt-workflow';
import {
TrendingUp,
@@ -66,6 +73,9 @@ import {
ListChecks,
Sparkles,
ExternalLink,
+ MoreHorizontal,
+ Pause,
+ Play,
} from 'lucide-react';
import { cn } from '@/lib/utils';
import { useBrandStore } from '@/stores/use-brand-store';
@@ -1774,6 +1784,7 @@ export default function PromptsPage() {
locationQuota={locationQuota}
onAddPrompt={canManage ? () => setAddPromptOpen(true) : undefined}
onEditPrompt={canManage ? setEditingPrompt : undefined}
+ onChanged={loadData}
/>
</>
)}
@@ -2159,6 +2170,61 @@ export default function PromptsPage() {
);
}
+/** How long a row deleted from its menu can be restored (PROMPT-006). */
+const DELETE_UNDO_MS = 10_000;
+
+/**
+ * The row's ⋯ menu (PROMPT-006): Edit, pause or resume tracking, open the
+ * Positions panel on Improve, and Delete behind a confirmation. Base UI's menu
+ * opens from mouse and keyboard and closes on Esc and outside clicks.
+ */
+function RowActionsMenu({
+ prompt,
+ onEdit,
+ onToggleActive,
+ onImprove,
+ onDelete,
+}: {
+ prompt: Prompt;
+ onEdit: () => void;
+ onToggleActive: () => void;
+ onImprove: () => void;
+ onDelete: () => void;
+}) {
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ className="inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"
+ aria-label={`Actions for ${prompt.text}`}
+ >
+ <MoreHorizontal className="h-4 w-4" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-48">
+ <DropdownMenuItem className="gap-2" onClick={onEdit}>
+ <Pencil className="h-3.5 w-3.5" />
+ Edit
+ </DropdownMenuItem>
+ <DropdownMenuItem className="gap-2" onClick={onToggleActive}>
+ {prompt.isActive ? <Pause className="h-3.5 w-3.5" /> : <Play className="h-3.5 w-3.5" />}
+ {prompt.isActive ? 'Pause tracking' : 'Resume tracking'}
+ </DropdownMenuItem>
+ <DropdownMenuItem className="gap-2" onClick={onImprove}>
+ <TrendingUp className="h-3.5 w-3.5" />
+ Improve position…
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ className="gap-2 text-red-600 focus:text-red-600 dark:text-red-400"
+ onClick={onDelete}
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
// ─── All Prompts Tab ──────────────────────────────────────────────────────────
const WORK_FILTER_LABELS: Record<string, string> = {
@@ -2171,7 +2237,7 @@ const WORK_FILTER_LABELS: Record<string, string> = {
function AllPromptsTab({
loading,
- prompts,
+ prompts: allRows,
activeBrandId,
volumeByPromptId,
visibility,
@@ -2182,6 +2248,7 @@ function AllPromptsTab({
locationQuota,
onAddPrompt,
onEditPrompt,
+ onChanged,
}: {
loading: boolean;
prompts: Prompt[];
@@ -2199,10 +2266,86 @@ function AllPromptsTab({
locationQuota: LocationQuota | null;
/** Opens the Add Prompt dialog; undefined when the user can't write (member role). */
onAddPrompt?: () => void;
- /** Opens the Edit Prompt dialog for a row; undefined hides the pencil (member role). */
+ /** Opens the Edit Prompt dialog for a row; undefined hides the row menu (member role). */
onEditPrompt?: (prompt: Prompt) => void;
+ /** Reloads the page data after a row is paused, resumed or deleted from its menu. */
+ onChanged: () => void;
}) {
const tCommon = useTranslations('common');
+ // Rows deleted from the row menu, hidden at once and deleted for real after
+ // the Undo window (PROMPT-006). There is no soft delete for prompts — a
+ // delete drops their history — so the delay is the undo: closing the page
+ // inside the window simply leaves the prompt in place.
+ const [pendingDeletes, setPendingDeletes] = useState<Set<string>>(() => new Set());
+ const deleteTimers = useRef(new Map<string, ReturnType<typeof setTimeout>>());
+ const [confirmDelete, setConfirmDelete] = useState<Prompt | null>(null);
+ const [positionsTab, setPositionsTab] = useState<'platforms' | 'improve'>('platforms');
+ const prompts = useMemo(
+ () => allRows.filter((p) => !pendingDeletes.has(p.id)),
+ [allRows, pendingDeletes],
+ );
+
+ const undoDelete = useCallback((id: string) => {
+ const timer = deleteTimers.current.get(id);
+ if (timer) clearTimeout(timer);
+ deleteTimers.current.delete(id);
+ setPendingDeletes((set) => {
+ const next = new Set(set);
+ next.delete(id);
+ return next;
+ });
+ }, []);
+
+ const deleteWithUndo = useCallback(
+ (prompt: Prompt) => {
+ setPendingDeletes((set) => new Set(set).add(prompt.id));
+ const timer = setTimeout(async () => {
+ deleteTimers.current.delete(prompt.id);
+ try {
+ await deletePrompt(prompt.id);
+ onChanged();
+ } catch {
+ toast.error('Failed to delete the prompt.');
+ undoDelete(prompt.id);
+ }
+ }, DELETE_UNDO_MS);
+ deleteTimers.current.set(prompt.id, timer);
+ toast('Prompt deleted', {
+ description: prompt.text,
+ duration: DELETE_UNDO_MS,
+ action: { label: 'Undo', onClick: () => undoDelete(prompt.id) },
+ });
+ },
+ [onChanged, undoDelete],
+ );
+
+ // A pending delete still lands if the table unmounts inside the window
+ // (switching tabs, changing brand); only an Undo or closing the page stops it.
+ useEffect(() => {
+ const timers = deleteTimers.current;
+ return () => {
+ for (const [id, timer] of timers) {
+ clearTimeout(timer);
+ void deletePrompt(id);
+ }
+ timers.clear();
+ };
+ }, []);
+
+ const toggleActive = useCallback(
+ async (prompt: Prompt) => {
+ try {
+ await updatePrompt(prompt.id, { isActive: !prompt.isActive });
+ toast.success(prompt.isActive ? 'Tracking paused' : 'Tracking resumed', {
+ description: prompt.text,
+ });
+ onChanged();
+ } catch {
+ toast.error('Failed to update the prompt.');
+ }
+ },
+ [onChanged],
+ );
const [search, setSearch] = useState('');
const [workFilter, setWorkFilter] = useState<'all' | 'none' | PromptWorkStatus>('all');
// Optimistic per-row status overrides — the prompts prop belongs to the
@@ -2241,7 +2384,8 @@ function AllPromptsTab({
// The panel opens on the table's window; changing it there only moves the panel.
const openPositionsPanel = useCallback(
- (promptId: string) => {
+ (promptId: string, tab: 'platforms' | 'improve' = 'platforms') => {
+ setPositionsTab(tab);
setPositionsRange({
preset: positionsPreset,
from: positionsPreset === 'custom' ? positionsWindow.from.slice(0, 10) : '',
@@ -2519,7 +2663,11 @@ function AllPromptsTab({
>
Last run
</SortableHead>
- {onEditPrompt && <TableHead className="text-right pr-6 w-[60px]">Edit</TableHead>}
+ {onEditPrompt && (
+ <TableHead className="text-right pr-6 w-[60px]">
+ <span className="sr-only">Actions</span>
+ </TableHead>
+ )}
</TableRow>
</TableHeader>
<TableBody>
@@ -2666,15 +2814,13 @@ function AllPromptsTab({
</TableCell>
{onEditPrompt && (
<TableCell className="text-right pr-6">
- <Button
- size="sm"
- variant="ghost"
- className="h-7 w-7 p-0"
- aria-label="Edit prompt"
- onClick={() => onEditPrompt(p)}
- >
- <Pencil className="h-3.5 w-3.5" />
- </Button>
+ <RowActionsMenu
+ prompt={p}
+ onEdit={() => onEditPrompt(p)}
+ onToggleActive={() => void toggleActive(p)}
+ onImprove={() => openPositionsPanel(p.id, 'improve')}
+ onDelete={() => setConfirmDelete(p)}
+ />
</TableCell>
)}
</TableRow>
@@ -2702,8 +2848,36 @@ function AllPromptsTab({
window={panelWindow}
onRangeChange={setPositionsRange}
region={regionFilter}
+ initialTab={positionsTab}
onClose={() => setPositionsId(null)}
/>
+ <Dialog open={confirmDelete !== null} onOpenChange={(v) => !v && setConfirmDelete(null)}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle className="text-base">Delete prompt and its history?</DialogTitle>
+ <DialogDescription className="break-words">
+ &ldquo;{confirmDelete?.text}&rdquo; and its tracking results will be removed. You can
+ undo for 10 seconds.
+ </DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <Button type="button" variant="outline" onClick={() => setConfirmDelete(null)}>
+ Keep it
+ </Button>
+ <Button
+ type="button"
+ variant="destructive"
+ onClick={() => {
+ if (confirmDelete) deleteWithUndo(confirmDelete);
+ setConfirmDelete(null);
+ }}
+ >
+ <Trash2 className="mr-2 h-4 w-4" />
+ Delete
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
</Card>
);
}
diff --git a/web/src/components/prompts/prompt-positions-sheet.tsx b/web/src/components/prompts/prompt-positions-sheet.tsx
index a9b14e46f..38f0be27b 100644
--- a/web/src/components/prompts/prompt-positions-sheet.tsx
+++ b/web/src/components/prompts/prompt-positions-sheet.tsx
@@ -71,6 +71,8 @@ interface Props {
onRangeChange: (range: PositionsRange) => void;
/** The table's location; empty means every location. */
region: string;
+ /** The tab the panel opens on: Improve when opened from the row menu (PROMPT-006). */
+ initialTab?: 'platforms' | 'improve';
onClose: () => void;
}
@@ -113,6 +115,7 @@ export function PromptPositionsSheet({
window,
onRangeChange,
region,
+ initialTab = 'platforms',
onClose,
}: Props) {
const preset = range.preset;
@@ -255,9 +258,9 @@ export function PromptPositionsSheet({
{current?.error && <LoadError message={current.error} onRetry={retry} />}
{data &&
(latestMode ? (
- <LatestView data={data} improve={improve} />
+ <LatestView data={data} improve={improve} initialTab={initialTab} />
) : (
- <PeriodView data={data} improve={improve} />
+ <PeriodView data={data} improve={improve} initialTab={initialTab} />
))}
</div>
@@ -463,7 +466,15 @@ function ImproveTrigger({ improve }: { improve: ImproveController }) {
);
}
-function LatestView({ data, improve }: { data: PromptPositionsData; improve: ImproveController }) {
+function LatestView({
+ data,
+ improve,
+ initialTab,
+}: {
+ data: PromptPositionsData;
+ improve: ImproveController;
+ initialTab: 'platforms' | 'improve';
+}) {
const included = data.platforms.filter((p) => p.access.state === 'included');
const answered = included.filter((p) => p.latest);
const mentioned = answered.filter((p) => p.latest!.mentioned).length;
@@ -489,7 +500,7 @@ function LatestView({ data, improve }: { data: PromptPositionsData; improve: Imp
<Stat label="Avg. position" value={avg} sub="when mentioned" />
</div>
- <Tabs defaultValue="platforms">
+ <Tabs defaultValue={initialTab}>
<TabsList>
<TabsTrigger value="platforms">Platform results</TabsTrigger>
<ImproveTrigger improve={improve} />
@@ -560,7 +571,15 @@ function LatestRow({ platform: p }: { platform: PlatformPositions }) {
// ─── 7d / 30d / 90d / custom: days ────────────────────────────────────────────
-function PeriodView({ data, improve }: { data: PromptPositionsData; improve: ImproveController }) {
+function PeriodView({
+ data,
+ improve,
+ initialTab,
+}: {
+ data: PromptPositionsData;
+ improve: ImproveController;
+ initialTab: 'platforms' | 'improve';
+}) {
const s = data.summary;
return (
<div className="space-y-4">
@@ -597,7 +616,7 @@ function PeriodView({ data, improve }: { data: PromptPositionsData; improve: Imp
</p>
)}
- <Tabs defaultValue="platforms">
+ <Tabs defaultValue={initialTab}>
<TabsList>
<TabsTrigger value="platforms">Platform results</TabsTrigger>
<TabsTrigger value="history">Daily history ({s.trackedDays})</TabsTrigger>