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 πŸ“–

feat(editor): record more steps from the insert menu

Luis Ortiz1b14e13e53eb
diff --git a/src/ui/fullview/GuideContent.tsx b/src/ui/fullview/GuideContent.tsx
index c01989c..5ff9618 100644
--- a/src/ui/fullview/GuideContent.tsx
+++ b/src/ui/fullview/GuideContent.tsx
@@ -2,6 +2,7 @@ import { History, Loader2, Play, Sparkles } from 'lucide-react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { TypeAnimation } from 'react-type-animation';
import { i18n } from '#imports';
+import { startInsertRecording } from '@/core/capture/start-insert-recording';
import { actionSteps } from '@/core/guides/blocks';
import {
deleteStep,
@@ -469,6 +470,10 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
readOnly={!editing || preview !== null}
hasApiKey={hasApiKey}
onChanged={loadGuide}
+ onInsertRecording={(targetGuideId, insertAtIndex, tabId) => {
+ openSidebar();
+ void startInsertRecording(targetGuideId, insertAtIndex, tabId);
+ }}
/>
</div>
diff --git a/src/ui/fullview/components/GuideStepList.tsx b/src/ui/fullview/components/GuideStepList.tsx
index bd3a234..aa78bb2 100644
--- a/src/ui/fullview/components/GuideStepList.tsx
+++ b/src/ui/fullview/components/GuideStepList.tsx
@@ -4,6 +4,7 @@ import { insertBlock, reorderSteps } from '@/core/guides/service';
import type { BlockType, Screenshot, Step } from '@/core/guides/types';
import { useFullview } from '@/stores/fullview';
import BlockCard from '@/ui/shared/BlockCard';
+import CaptureTabDialog from '@/ui/shared/CaptureTabDialog';
import EmptyGuideState from '@/ui/shared/EmptyGuideState';
import { dominantRatio } from '@/ui/shared/ImagePlaceholder';
import InsertBlockMenu from '@/ui/shared/InsertBlockMenu';
@@ -20,6 +21,7 @@ interface GuideStepListProps {
readOnly?: boolean;
onChanged?: () => void;
hasApiKey?: boolean;
+ onInsertRecording?: (guideId: string, insertAtIndex: number, tabId: number) => void;
}
export default function GuideStepList({
@@ -33,12 +35,14 @@ export default function GuideStepList({
readOnly,
onChanged,
hasApiKey,
+ onInsertRecording,
}: GuideStepListProps) {
const { scrollToStepId, setActiveStepId } = useFullview((s) => ({
scrollToStepId: s.scrollToStepId,
setActiveStepId: s.setActiveStepId,
}));
+ const [recordAtIndex, setRecordAtIndex] = useState<number | null>(null);
const [dragIndex, setDragIndex] = useState<number | null>(null);
const [dragOverIndex, setDragOverIndex] = useState<number | null>(null);
const stepRefs = useRef<Map<string, HTMLDivElement>>(new Map());
@@ -102,18 +106,41 @@ export default function GuideStepList({
onDragEnd: handleDragEnd,
};
+ const captureDialog = (
+ <CaptureTabDialog
+ open={recordAtIndex !== null}
+ onCancel={() => setRecordAtIndex(null)}
+ onStart={(tabId) => {
+ const atIndex = recordAtIndex;
+ setRecordAtIndex(null);
+ if (atIndex !== null) onInsertRecording?.(guideId, atIndex, tabId);
+ }}
+ />
+ );
+
if (steps.length === 0) {
return (
<div className="flex flex-col">
<EmptyGuideState />
- {!readOnly && <InsertBlockMenu onInsert={(blockType) => handleInsertBlock(0, blockType)} />}
+ {!readOnly && (
+ <InsertBlockMenu
+ onInsert={(blockType) => handleInsertBlock(0, blockType)}
+ onRecord={onInsertRecording && (() => setRecordAtIndex(0))}
+ />
+ )}
+ {captureDialog}
</div>
);
}
return (
<div className="space-y-6">
- {!readOnly && <InsertBlockMenu onInsert={(blockType) => handleInsertBlock(0, blockType)} />}
+ {!readOnly && (
+ <InsertBlockMenu
+ onInsert={(blockType) => handleInsertBlock(0, blockType)}
+ onRecord={onInsertRecording && (() => setRecordAtIndex(0))}
+ />
+ )}
{steps.map((step, idx) => (
<div
key={step.id}
@@ -151,9 +178,15 @@ export default function GuideStepList({
dragHandleProps={dragHandlers(idx)}
/>
)}
- {!readOnly && <InsertBlockMenu onInsert={(blockType) => handleInsertBlock(idx + 1, blockType)} />}
+ {!readOnly && (
+ <InsertBlockMenu
+ onInsert={(blockType) => handleInsertBlock(idx + 1, blockType)}
+ onRecord={onInsertRecording && (() => setRecordAtIndex(idx + 1))}
+ />
+ )}
</div>
))}
+ {captureDialog}
</div>
);
}
diff --git a/src/ui/shared/InsertBlockMenu.tsx b/src/ui/shared/InsertBlockMenu.tsx
index fb75697..a5aed49 100644
--- a/src/ui/shared/InsertBlockMenu.tsx
+++ b/src/ui/shared/InsertBlockMenu.tsx
@@ -1,13 +1,14 @@
-import { Heading, Plus, StickyNote } from 'lucide-react';
+import { Circle, Heading, Plus, StickyNote } from 'lucide-react';
import { useEffect, useRef, useState } from 'react';
import { i18n } from '#imports';
import type { BlockType } from '@/core/guides/types';
interface InsertBlockMenuProps {
onInsert: (blockType: BlockType) => void;
+ onRecord?: () => void;
}
-export default function InsertBlockMenu({ onInsert }: InsertBlockMenuProps) {
+export default function InsertBlockMenu({ onInsert, onRecord }: InsertBlockMenuProps) {
const [open, setOpen] = useState(false);
const rowRef = useRef<HTMLDivElement>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
@@ -63,6 +64,19 @@ export default function InsertBlockMenu({ onInsert }: InsertBlockMenuProps) {
{choice.label}
</button>
))}
+ {open && onRecord && (
+ <button
+ type="button"
+ onClick={() => {
+ setOpen(false);
+ onRecord();
+ }}
+ className="relative flex items-center gap-1 rounded-full border border-border bg-card px-2 py-0.5 text-[11px] font-medium text-purple hover:text-accent hover:bg-secondary"
+ >
+ <Circle size={13} />
+ {i18n.t('capture.recordSteps')}
+ </button>
+ )}
</div>
);
}
diff --git a/src/ui/sidepanel/App.tsx b/src/ui/sidepanel/App.tsx
index c574f0f..62ed9a8 100644
--- a/src/ui/sidepanel/App.tsx
+++ b/src/ui/sidepanel/App.tsx
@@ -2,6 +2,7 @@ import { Search, Settings, Video } from 'lucide-react';
import { useCallback, useEffect, useState } from 'react';
import { browser, i18n } from '#imports';
import { CaptureState } from '@/core/capture/machine';
+import { startInsertRecording } from '@/core/capture/start-insert-recording';
import type { GuideMeSession } from '@/core/guideme/session';
import { SESSION_KEY } from '@/core/guideme/session';
import {
@@ -95,6 +96,10 @@ export default function App() {
onStateUpdate: (update) => {
if (update.state === CaptureState.RECORDING) {
setIsRecording(true);
+ const guideId = update.currentGuideId;
+ if (guideId) {
+ setView((prev) => (prev.name === 'recording' ? prev : { name: 'recording', guideId }));
+ }
} else {
setIsRecording(false);
}
@@ -145,12 +150,20 @@ 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);
if (res.success) {
setIsRecording(false);
- setView({ name: 'library' });
+ setView(res.inserted && res.guideId ? { name: 'editor', guideId: res.guideId } : { name: 'library' });
if (res.guideId) {
const url = getExtensionURL(`/fullview.html?guideId=${res.guideId}`);
const tabs = await queryTabs({ url: getExtensionURL('/fullview.html') });
@@ -203,6 +216,7 @@ 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 13650ce..1d3aaf6 100644
--- a/src/ui/sidepanel/GuideEditor.tsx
+++ b/src/ui/sidepanel/GuideEditor.tsx
@@ -21,6 +21,7 @@ import { getMostCommonDomain } from '@/lib/utils';
import { Input } from '@/ui/components/ui/input';
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';
@@ -34,6 +35,7 @@ interface GuideEditorProps {
guideId: string;
onBack: () => void;
onGuideMe?: (guideId: string) => void;
+ onInsertRecording?: (guideId: string, insertAtIndex: number, tabId: number) => void;
}
interface OpenInFullViewOptions {
@@ -52,7 +54,8 @@ function flushFocusedField() {
if (el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement) el.blur();
}
-export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorProps) {
+export default function GuideEditor({ guideId, onBack, onGuideMe, onInsertRecording }: GuideEditorProps) {
+ const [recordAtIndex, setRecordAtIndex] = useState<number | null>(null);
const [data, setData] = useState<GuideData | null>(null);
const [loading, setLoading] = useState(true);
const [notFound, setNotFound] = useState(false);
@@ -373,11 +376,21 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP
{data.steps.length === 0 ? (
<>
<EmptyGuideState />
- {editing && <InsertBlockMenu onInsert={(blockType) => handleInsertBlock(0, blockType)} />}
+ {editing && (
+ <InsertBlockMenu
+ onInsert={(blockType) => handleInsertBlock(0, blockType)}
+ onRecord={onInsertRecording && (() => setRecordAtIndex(0))}
+ />
+ )}
</>
) : (
<>
- {editing && <InsertBlockMenu onInsert={(blockType) => handleInsertBlock(0, blockType)} />}
+ {editing && (
+ <InsertBlockMenu
+ onInsert={(blockType) => handleInsertBlock(0, blockType)}
+ onRecord={onInsertRecording && (() => setRecordAtIndex(0))}
+ />
+ )}
{data.steps.map((step, idx) => (
<div key={step.id}>
{dragOverIndex === idx && dragIndex !== null && dragIndex !== idx && (
@@ -408,12 +421,26 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP
dragHandleProps={dragHandlers(idx)}
/>
)}
- {editing && <InsertBlockMenu onInsert={(blockType) => handleInsertBlock(idx + 1, blockType)} />}
+ {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>
);
}