Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

refactor(sidepanel): make the guide view read only

Luis Ortiz184f77c280b1
diff --git a/src/locales/de.yml b/src/locales/de.yml
index 9c86ab5..856334c 100644
--- a/src/locales/de.yml
+++ b/src/locales/de.yml
@@ -178,6 +178,8 @@ confirmDelete:
editor:
backToLibrary: Zurück zur Bibliothek
+ openInDashboard: Öffnen
+ openInDashboardHint: Im Dashboard öffnen, um zu bearbeiten oder zu exportieren
guideMe: Anleiten
guideMeUnavailable: Keine abspielbaren Schritte in dieser Anleitung
deleteThisStep: "Diesen Schritt löschen?"
diff --git a/src/locales/en.yml b/src/locales/en.yml
index 30247cf..cab4e6d 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -178,6 +178,8 @@ confirmDelete:
editor:
backToLibrary: Back to library
+ openInDashboard: Open
+ openInDashboardHint: Open in the dashboard to edit or export
guideMe: Guide Me
guideMeUnavailable: No replayable steps in this guide
deleteThisStep: "Delete this step?"
diff --git a/src/locales/es.yml b/src/locales/es.yml
index 4e23c0f..9613e4a 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -178,6 +178,8 @@ confirmDelete:
editor:
backToLibrary: Volver a la biblioteca
+ openInDashboard: Abrir
+ openInDashboardHint: Ábrelo en el panel para editar o exportar
guideMe: "¡Guíame!"
guideMeUnavailable: Esta guía no tiene pasos que se puedan repetir
deleteThisStep: "¿Eliminar este paso?"
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index 0c2c5ef..4c097e1 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -178,6 +178,8 @@ confirmDelete:
editor:
backToLibrary: "Retour à la bibliothèque"
+ openInDashboard: Ouvrir
+ openInDashboardHint: Ouvrir dans le tableau de bord pour modifier ou exporter
guideMe: "Guidez-moi !"
guideMeUnavailable: "Aucune étape rejouable dans ce guide"
deleteThisStep: "Supprimer cette étape ?"
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index da5a678..a25faf6 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -178,6 +178,8 @@ confirmDelete:
editor:
backToLibrary: Voltar pra biblioteca
+ openInDashboard: Abrir
+ openInDashboardHint: Abre no painel pra editar ou exportar
guideMe: "Me guia!"
guideMeUnavailable: Esse guia não tem passos pra repetir
deleteThisStep: "Excluir esse passo?"
diff --git a/src/ui/shared/BlockCard.tsx b/src/ui/shared/BlockCard.tsx
index bce91f7..131439a 100644
--- a/src/ui/shared/BlockCard.tsx
+++ b/src/ui/shared/BlockCard.tsx
@@ -10,8 +10,8 @@ import { DragGrip, type DragHandleProps, useCardDrag } from '@/ui/shared/card-dr
interface BlockCardProps {
step: Step;
- onDescriptionChange: (stepId: string, description: string) => void;
- onDelete: (stepId: string) => void;
+ onDescriptionChange?: (stepId: string, description: string) => void;
+ onDelete?: (stepId: string) => void;
onChanged?: () => void;
dragHandleProps?: DragHandleProps;
readOnly?: boolean;
@@ -84,7 +84,7 @@ export default function BlockCard({
e.target.style.height = `${e.target.scrollHeight}px`;
}}
onBlur={() => {
- if (description !== step.description) onDescriptionChange(step.id, description);
+ if (description !== step.description) onDescriptionChange?.(step.id, description);
}}
placeholder={isHeading ? i18n.t('blocks.headingPlaceholder') : i18n.t('blocks.calloutPlaceholder')}
/>
@@ -151,7 +151,7 @@ export default function BlockCard({
destructive
onConfirm={() => {
setConfirmDelete(false);
- onDelete(step.id);
+ onDelete?.(step.id);
}}
onCancel={() => setConfirmDelete(false)}
/>
diff --git a/src/ui/sidepanel/App.tsx b/src/ui/sidepanel/App.tsx
index ec8e38c..635551a 100644
--- a/src/ui/sidepanel/App.tsx
+++ b/src/ui/sidepanel/App.tsx
@@ -3,7 +3,6 @@ import { useCallback, useEffect, useState } from 'react';
import { browser, i18n } from '#imports';
import { CaptureState } from '@/core/capture/machine';
import { isRecordableUrl } from '@/core/capture/recordable-tabs';
-import { startInsertRecording } from '@/core/capture/start-insert-recording';
import type { GuideMeSession } from '@/core/guideme/session';
import { SESSION_KEY } from '@/core/guideme/session';
import {
@@ -186,14 +185,6 @@ export default function App() {
}
}, []);
- const handleInsertRecording = useCallback(async (guideId: string, insertAtIndex: number, tabId: number) => {
- const started = await startInsertRecording(guideId, insertAtIndex, tabId);
- if (started) {
- setIsRecording(true);
- setView({ name: 'recording', guideId: started });
- }
- }, []);
-
const handleStopRecording = useCallback(async () => {
try {
const res = await sendMessage('stopRecording', undefined);
@@ -253,7 +244,6 @@ export default function App() {
guideId={view.guideId}
onBack={() => setView({ name: 'library' })}
onGuideMe={(id) => setView({ name: 'guideme', guideId: id })}
- onInsertRecording={handleInsertRecording}
/>
);
}
diff --git a/src/ui/sidepanel/GuideEditor.tsx b/src/ui/sidepanel/GuideEditor.tsx
index cdf7fe3..85561ef 100644
--- a/src/ui/sidepanel/GuideEditor.tsx
+++ b/src/ui/sidepanel/GuideEditor.tsx
@@ -1,42 +1,23 @@
-import { ArrowLeft, Check, Layers, Loader2, Maximize2, Pencil, Play, Sparkles } from 'lucide-react';
-import { useCallback, useEffect, useRef, useState } from 'react';
+import { ArrowLeft, Maximize2, Play } from 'lucide-react';
+import { useCallback, useEffect, useState } from 'react';
import { i18n } from '#imports';
import { actionSteps, isBlock, stepNumbers } from '@/core/guides/blocks';
-import {
- createSnapshot,
- deleteStep,
- getGuide,
- insertBlock,
- onGuidesChanged,
- reorderSteps,
- updateGuideDescription,
- updateGuideTitle,
- updateStepDescription,
-} from '@/core/guides/service';
-import type { BlockType, Guide, Screenshot, Step } from '@/core/guides/types';
-import { createTab, focusWindow, getExtensionURL, localStorage, queryTabs, updateTab } from '@/lib/browser-api';
-import { logger } from '@/lib/logger';
+import { getGuide, onGuidesChanged } from '@/core/guides/service';
+import type { Guide, Screenshot, Step } from '@/core/guides/types';
+import { createTab, focusWindow, getExtensionURL, queryTabs, updateTab } from '@/lib/browser-api';
import { sendMessage } from '@/lib/messaging';
import { getMostCommonDomain } from '@/lib/utils';
-import { Input } from '@/ui/components/ui/input';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/ui/components/ui/tooltip';
-import { useAskAi } from '@/ui/shared/AskAi';
import BlockCard from '@/ui/shared/BlockCard';
-import CaptureTabDialog from '@/ui/shared/CaptureTabDialog';
import EmptyGuideState from '@/ui/shared/EmptyGuideState';
import FaviconImg from '@/ui/shared/FaviconImg';
-import { guideDescriptionErrorMessage } from '@/ui/shared/guide-description-error';
import { dominantRatio } from '@/ui/shared/ImagePlaceholder';
-import InsertBlockMenu from '@/ui/shared/InsertBlockMenu';
-import Toast from '@/ui/shared/Toast';
-import ExportMenu from './ExportMenu';
import StepCard from './StepCard';
interface GuideEditorProps {
guideId: string;
onBack: () => void;
onGuideMe?: (guideId: string) => void;
- onInsertRecording?: (guideId: string, insertAtIndex: number, tabId: number) => void;
}
interface OpenInFullViewOptions {
@@ -50,30 +31,13 @@ interface GuideData {
screenshots: Map<string, Screenshot>;
}
-function flushFocusedField() {
- const el = document.activeElement;
- if (el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement) el.blur();
-}
-
-export default function GuideEditor({ guideId, onBack, onGuideMe, onInsertRecording }: GuideEditorProps) {
- const [recordAtIndex, setRecordAtIndex] = useState<number | null>(null);
+export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorProps) {
const [data, setData] = useState<GuideData | null>(null);
const [loading, setLoading] = useState(true);
const [notFound, setNotFound] = useState(false);
- const [title, setTitle] = useState('');
- const [editing, setEditing] = useState(false);
- const [description, setDescription] = useState('');
- const [generating, setGenerating] = useState(false);
- const [hasApiKey, setHasApiKey] = useState(false);
- const [descriptionError, setDescriptionError] = useState<string | null>(null);
- const [dragIndex, setDragIndex] = useState<number | null>(null);
- const [dragOverIndex, setDragOverIndex] = useState<number | null>(null);
- const editingDescriptionRef = useRef(false);
const applyGuide = useCallback((result: GuideData) => {
setData(result);
- setTitle(result.guide.title);
- if (!editingDescriptionRef.current) setDescription(result.guide.description ?? '');
}, []);
const loadGuide = useCallback(async () => {
@@ -92,90 +56,8 @@ export default function GuideEditor({ guideId, onBack, onGuideMe, onInsertRecord
}, [loadGuide]);
useEffect(() => {
- return onGuidesChanged(() => {
- if (!editing) loadGuide();
- });
- }, [editing, loadGuide]);
-
- useEffect(() => {
- localStorage.get(['aiApiKey']).then((s) => setHasApiKey(Boolean(s.aiApiKey)));
- }, []);
-
- const handleTitleBlur = useCallback(async () => {
- if (!data || title === data.guide.title) return;
- await updateGuideTitle(guideId, title);
- setData((prev) => (prev ? { ...prev, guide: { ...prev.guide, title } } : prev));
- }, [data, guideId, title]);
-
- const handleGuideDescriptionBlur = useCallback(async () => {
- if (data && description !== (data.guide.description ?? '')) {
- await updateGuideDescription(guideId, description);
- setData((prev) => (prev ? { ...prev, guide: { ...prev.guide, description } } : prev));
- }
- editingDescriptionRef.current = false;
- }, [data, guideId, description]);
-
- const commitGuideDescription = useCallback(
- (next: string) => {
- setDescription(next);
- void updateGuideDescription(guideId, next);
- setData((prev) => (prev ? { ...prev, guide: { ...prev.guide, description: next } } : prev));
- },
- [guideId],
- );
-
- const askAi = useAskAi(description, commitGuideDescription, hasApiKey);
-
- const handleGenerateDescription = useCallback(async () => {
- setGenerating(true);
- setDescriptionError(null);
- try {
- const result = await sendMessage('generateGuideDescription', { guideId });
- if (result.error) {
- setDescriptionError(guideDescriptionErrorMessage(result.error));
- return;
- }
- const generated = result.description;
- if (!generated) return;
- setDescription(generated);
- setData((prev) => (prev ? { ...prev, guide: { ...prev.guide, description: generated } } : prev));
- } catch {
- setDescriptionError(guideDescriptionErrorMessage('generation-failed'));
- } finally {
- setGenerating(false);
- }
- }, [guideId]);
-
- const handleDescriptionChange = useCallback(async (stepId: string, description: string) => {
- await updateStepDescription(stepId, description);
- setData((prev) => {
- if (!prev) return prev;
- return { ...prev, steps: prev.steps.map((s) => (s.id === stepId ? { ...s, description } : s)) };
- });
- }, []);
-
- const handleDeleteStep = useCallback(
- async (stepId: string) => {
- await deleteStep(guideId, stepId);
- const result = await getGuide(guideId);
- if (result) {
- applyGuide(result);
- } else {
- setData(null);
- setLoading(true);
- await loadGuide();
- }
- },
- [guideId, loadGuide, applyGuide],
- );
-
- const handleInsertBlock = useCallback(
- async (atIndex: number, blockType: BlockType) => {
- await insertBlock(guideId, atIndex, blockType, '');
- await loadGuide();
- },
- [guideId, loadGuide],
- );
+ return onGuidesChanged(loadGuide);
+ }, [loadGuide]);
const openInFullView = useCallback((targetGuideId: string, options?: OpenInFullViewOptions) => {
const params = new URLSearchParams({ guideId: targetGuideId });
@@ -192,16 +74,6 @@ export default function GuideEditor({ guideId, onBack, onGuideMe, onInsertRecord
});
}, []);
- const toggleEditing = useCallback(() => {
- if (editing) {
- flushFocusedField();
- setEditing(false);
- return;
- }
- setEditing(true);
- createSnapshot(guideId).catch((err) => logger.error(' Snapshot before editing failed', err));
- }, [editing, guideId]);
-
if (loading) return <p className="text-sm text-purple p-4">{i18n.t('common.loading')}</p>;
if (notFound || !data) {
@@ -216,40 +88,9 @@ export default function GuideEditor({ guideId, onBack, onGuideMe, onInsertRecord
);
}
- const metaGenerating = title === i18n.t('fullview.untitledGuide') && data.steps.length > 0 && !description;
const actionCount = actionSteps(data.steps).length;
const numbers = stepNumbers(data.steps);
-
- const dragHandlers = (idx: number) =>
- editing
- ? {
- onDragStart: (e: React.DragEvent) => {
- setDragIndex(idx);
- e.dataTransfer.effectAllowed = 'move';
- },
- onDragOver: (e: React.DragEvent) => {
- e.preventDefault();
- setDragOverIndex(idx);
- },
- onDragEnd: () => {
- if (dragIndex !== null && dragOverIndex !== null && dragIndex !== dragOverIndex) {
- setData((prev) => {
- if (!prev) return prev;
- const newSteps = [...prev.steps];
- const [moved] = newSteps.splice(dragIndex, 1);
- newSteps.splice(dragOverIndex, 0, moved);
- reorderSteps(
- guideId,
- newSteps.map((s) => s.id),
- );
- return { ...prev, steps: newSteps };
- });
- }
- setDragIndex(null);
- setDragOverIndex(null);
- },
- }
- : undefined;
+ const domain = getMostCommonDomain(data.steps);
return (
<div className="min-h-screen bg-card flex flex-col">
@@ -263,34 +104,31 @@ export default function GuideEditor({ guideId, onBack, onGuideMe, onInsertRecord
</TooltipTrigger>
<TooltipContent align="start">{i18n.t('editor.backToLibrary')}</TooltipContent>
</Tooltip>
- {editing ? (
- <Input
- value={title}
- onChange={(e) => setTitle(e.target.value)}
- onBlur={handleTitleBlur}
- className="text-lg font-bold bg-transparent border-0 border-b border-transparent hover:border-border focus-visible:ring-0 focus-visible:border-accent shadow-none p-0 h-auto text-foreground"
- />
- ) : (
+
+ <div className="flex-1 min-w-0">
<Tooltip>
<TooltipTrigger asChild>
- <h2 className="flex-1 min-w-0 text-lg font-bold truncate text-foreground">{title}</h2>
+ <h2 className="text-[13px] font-bold truncate text-foreground leading-tight">{data.guide.title}</h2>
</TooltipTrigger>
- <TooltipContent align="start">{title}</TooltipContent>
+ <TooltipContent align="start">{data.guide.title}</TooltipContent>
</Tooltip>
- )}
- <Tooltip>
- <TooltipTrigger asChild>
- <button
- onClick={() => openInFullView(guideId)}
- className="shrink-0 p-1.5 rounded-md transition-colors text-purple hover:text-accent hover:bg-secondary"
- >
- <Maximize2 size={15} />
- </button>
- </TooltipTrigger>
- <TooltipContent>{i18n.t('library.openInFullView')}</TooltipContent>
- </Tooltip>
- {!editing &&
- data.steps.length > 0 &&
+ <div className="flex items-center gap-1.5 text-[10px] text-muted-foreground leading-tight">
+ <span>
+ {actionCount !== 1
+ ? i18n.t('fullview.stepCountPlural', [String(actionCount)])
+ : i18n.t('fullview.stepCount', [String(actionCount)])}
+ </span>
+ {domain && (
+ <>
+ <span className="text-border">·</span>
+ <FaviconImg domain={domain} size={10} className="rounded-full" />
+ <span className="truncate">{domain}</span>
+ </>
+ )}
+ </div>
+ </div>
+
+ {data.steps.length > 0 &&
(() => {
const replayable = data.steps.some((s) => s.elementMeta);
const label = i18n.t(replayable ? 'editor.guideMe' : 'editor.guideMeUnavailable');
@@ -314,157 +152,43 @@ export default function GuideEditor({ guideId, onBack, onGuideMe, onInsertRecord
</Tooltip>
);
})()}
- <div className="ml-auto shrink-0 flex items-center gap-1">
- <Tooltip>
- <TooltipTrigger asChild>
- <button
- onClick={toggleEditing}
- aria-label={editing ? i18n.t('editor.done') : i18n.t('editor.edit')}
- className="shrink-0 p-1.5 rounded-md transition-colors text-purple hover:text-accent hover:bg-secondary"
- >
- {editing ? <Check size={15} /> : <Pencil size={15} />}
- </button>
- </TooltipTrigger>
- <TooltipContent align="end">{editing ? i18n.t('editor.done') : i18n.t('editor.edit')}</TooltipContent>
- </Tooltip>
- {!editing && (
- <ExportMenu guideId={guideId} guide={data.guide} steps={data.steps} screenshots={data.screenshots} />
- )}
- </div>
- </div>
- <div className="mt-1 mb-1.5" style={{ marginLeft: '34px' }}>
- <textarea
- ref={(el) => {
- if (el) {
- el.style.height = '0';
- el.style.height = `${el.scrollHeight}px`;
- }
- }}
- value={description}
- rows={2}
- onChange={(e) => {
- setDescription(e.target.value);
- const el = e.target;
- el.style.height = '0';
- el.style.height = `${el.scrollHeight}px`;
- }}
- onFocus={() => {
- editingDescriptionRef.current = true;
- }}
- onSelect={askAi.onSelect}
- onBlur={handleGuideDescriptionBlur}
- placeholder={i18n.t('editor.descriptionPlaceholder')}
- className="w-full resize-none overflow-hidden bg-transparent p-0 text-xs leading-snug text-muted-foreground placeholder:text-muted-foreground/60 border-b border-transparent hover:border-border focus:outline-none focus:border-accent"
- />
- {hasApiKey && (
- <div className="mt-1 flex items-center gap-1.5">
- {askAi.trigger}
+
+ <Tooltip>
+ <TooltipTrigger asChild>
<button
- type="button"
- onClick={handleGenerateDescription}
- disabled={generating || metaGenerating}
- className="flex items-center gap-1 text-[11px] font-medium text-accent hover:text-deep disabled:opacity-50 disabled:cursor-not-allowed"
+ onClick={() => openInFullView(guideId)}
+ className="shrink-0 flex items-center gap-1 rounded-lg border border-border px-2 py-1 text-[11px] font-semibold text-purple transition-colors hover:border-accent hover:text-accent"
>
- {generating || metaGenerating ? <Loader2 size={11} className="animate-spin" /> : <Sparkles size={11} />}
- {generating || metaGenerating
- ? i18n.t('editor.generatingDescription')
- : description
- ? i18n.t('editor.regenerateDescription')
- : i18n.t('editor.generateDescription')}
+ <Maximize2 size={12} />
+ {i18n.t('editor.openInDashboard')}
</button>
- </div>
- )}
- <Toast message={descriptionError} onDismiss={() => setDescriptionError(null)} />
- </div>
- <div className="text-[11px] flex items-center gap-2 text-muted-foreground" style={{ marginLeft: '34px' }}>
- <span className="flex items-center gap-1">
- <Layers size={11} />
- {actionCount !== 1
- ? i18n.t('fullview.stepCountPlural', [String(actionCount)])
- : i18n.t('fullview.stepCount', [String(actionCount)])}
- </span>
- {(() => {
- const d = getMostCommonDomain(data.steps);
- if (!d) return null;
- return (
- <span className="flex items-center gap-1">
- <span className="text-border">·</span>
- <FaviconImg domain={d} size={12} className="rounded-full" />
- {d}
- </span>
- );
- })()}
+ </TooltipTrigger>
+ <TooltipContent align="end">{i18n.t('editor.openInDashboardHint')}</TooltipContent>
+ </Tooltip>
</div>
</div>
+
<div className="px-4 pt-1 pb-4 flex-1 flex flex-col">
{data.steps.length === 0 ? (
- <>
- <EmptyGuideState />
- {editing && (
- <InsertBlockMenu
- onInsert={(blockType) => handleInsertBlock(0, blockType)}
- onRecord={onInsertRecording && (() => setRecordAtIndex(0))}
- />
- )}
- </>
+ <EmptyGuideState />
) : (
- <>
- {editing && (
- <InsertBlockMenu
- onInsert={(blockType) => handleInsertBlock(0, blockType)}
- onRecord={onInsertRecording && (() => setRecordAtIndex(0))}
+ data.steps.map((step) =>
+ isBlock(step) ? (
+ <BlockCard key={step.id} step={step} readOnly />
+ ) : (
+ <StepCard
+ key={step.id}
+ step={step}
+ number={numbers.get(step.id) ?? 0}
+ screenshot={data.screenshots.get(step.id)}
+ placeholderRatio={dominantRatio(data.screenshots)}
+ frameRatio={dominantRatio(data.screenshots)}
+ readOnly
/>
- )}
- {data.steps.map((step, idx) => (
- <div key={step.id}>
- {dragOverIndex === idx && dragIndex !== null && dragIndex !== idx && (
- <div className="h-1 bg-accent rounded-full mx-4 mb-1" />
- )}
- {isBlock(step) ? (
- <BlockCard
- step={step}
- onDescriptionChange={handleDescriptionChange}
- onDelete={handleDeleteStep}
- onChanged={loadGuide}
- readOnly={!editing}
- dragHandleProps={dragHandlers(idx)}
- />
- ) : (
- <StepCard
- step={step}
- number={numbers.get(step.id) ?? 0}
- screenshot={data.screenshots.get(step.id)}
- placeholderRatio={dominantRatio(data.screenshots)}
- frameRatio={dominantRatio(data.screenshots)}
- onDescriptionChange={handleDescriptionChange}
- onDelete={handleDeleteStep}
- onOpenEditor={(stepId, tool) => openInFullView(guideId, { stepId, tool })}
- readOnly={!editing}
- hasApiKey={hasApiKey}
- onChanged={loadGuide}
- dragHandleProps={dragHandlers(idx)}
- />
- )}
- {editing && (
- <InsertBlockMenu
- onInsert={(blockType) => handleInsertBlock(idx + 1, blockType)}
- onRecord={onInsertRecording && (() => setRecordAtIndex(idx + 1))}
- />
- )}
- </div>
- ))}
- </>
+ ),
+ )
)}
</div>
- <CaptureTabDialog
- open={recordAtIndex !== null}
- onCancel={() => setRecordAtIndex(null)}
- onStart={(tabId) => {
- const atIndex = recordAtIndex;
- setRecordAtIndex(null);
- if (atIndex !== null) onInsertRecording?.(guideId, atIndex, tabId);
- }}
- />
</div>
);
}
diff --git a/src/ui/sidepanel/StepCard.tsx b/src/ui/sidepanel/StepCard.tsx
index 00bc650..6b0e8b1 100644
--- a/src/ui/sidepanel/StepCard.tsx
+++ b/src/ui/sidepanel/StepCard.tsx
@@ -16,8 +16,8 @@ interface StepCardProps {
step: Step;
number: number;
screenshot: Screenshot | undefined;
- onDescriptionChange: (stepId: string, description: string) => void;
- onDelete: (stepId: string) => void;
+ onDescriptionChange?: (stepId: string, description: string) => void;
+ onDelete?: (stepId: string) => void;
dragHandleProps?: DragHandleProps;
onOpenEditor?: (stepId: string, tool: 'annotate' | 'redact' | 'crop' | 'target') => void;
onCopy?: (stepId: string) => void;
@@ -53,21 +53,21 @@ export default function StepCard({
}, [step.description]);
const handleDescriptionBlur = () => {
- if (description !== step.description) onDescriptionChange(step.id, description);
+ if (description !== step.description) onDescriptionChange?.(step.id, description);
};
const askAi = useAskAi(
description,
(next) => {
setDescription(next);
- onDescriptionChange(step.id, next);
+ onDescriptionChange?.(step.id, next);
},
!readOnly && !step.aiPending && Boolean(hasApiKey),
);
const handleDelete = () => {
setConfirmDelete(false);
- onDelete(step.id);
+ onDelete?.(step.id);
};
const handleCopy = async () => {