π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
refactor(extension): use the shared isLive for recording or paused
Luis Ortize9ea5d2627c9
diff --git a/src/entrypoints/background/navigation.ts b/src/entrypoints/background/navigation.tsindex 9f51ece..e2d5d3a 100644--- a/src/entrypoints/background/navigation.ts+++ b/src/entrypoints/background/navigation.ts@@ -1,5 +1,5 @@import { logger } from '@mimik/core/logger';-import { type CaptureSnapshot, CaptureState } from '@/core/capture/machine';+import { isLive } from '@/core/capture/is-live';import { getTab } from '@/lib/browser-api/get-tab';import { onHistoryStateUpdated } from '@/lib/browser-api/on-history-state-updated';import { onNavigationCompleted } from '@/lib/browser-api/on-navigation-completed';@@ -10,16 +10,12 @@ import { TabMessage } from '@/lib/tab-messages';import { getActor, waitUntilReady } from './actor';import { injectContentScript, isInjectableTab } from './tab-manager';-function isLive(state: CaptureSnapshot): boolean {- return state.value === CaptureState.RECORDING || state.value === CaptureState.PAUSED;-}-export function registerNavigationListeners() {onNavigationCompleted(async (details) => {if (details.frameId !== 0) return;await waitUntilReady();const state = getActor().getSnapshot();- if (isLive(state)) {+ if (isLive(state.value)) {logger.debug('URL changed (navigation) β', details.url);getActor().send({ type: 'URL_CHANGED', url: details.url });}@@ -29,7 +25,7 @@ export function registerNavigationListeners() {if (details.frameId !== 0) return;await waitUntilReady();const state = getActor().getSnapshot();- if (isLive(state)) {+ if (isLive(state.value)) {logger.debug('URL changed (SPA pushState) β', details.url);getActor().send({ type: 'URL_CHANGED', url: details.url });}@@ -38,7 +34,7 @@ export function registerNavigationListeners() {onTabActivated(async (activeInfo) => {await waitUntilReady();const state = getActor().getSnapshot();- if (!isLive(state)) return;+ if (!isLive(state.value)) return;if (!state.context.currentGuideId) return;try {@@ -59,7 +55,7 @@ export function registerNavigationListeners() {if (changeInfo.status !== 'complete') return;await waitUntilReady();const state = getActor().getSnapshot();- if (!isLive(state)) return;+ if (!isLive(state.value)) return;if (!isInjectableTab(tab)) return;try {diff --git a/src/entrypoints/background/step-pipeline.ts b/src/entrypoints/background/step-pipeline.tsindex 3a37bf4..dca67c9 100644--- a/src/entrypoints/background/step-pipeline.ts+++ b/src/entrypoints/background/step-pipeline.ts@@ -2,6 +2,7 @@ import { logger } from '@mimik/core/logger';import { queueDescription } from '@/core/capture/ai/description-queue';import { AI_CREDENTIAL_SETTINGS, resolveAiCredentials } from '@/core/capture/ai/keys';import type { DOMContext } from '@/core/capture/dom/context';+import { isLive } from '@/core/capture/is-live';import { CaptureState } from '@/core/capture/machine';import { buildFallbackDescription } from '@/core/capture/step-description';import {@@ -56,10 +57,6 @@ function isRecording(): boolean {return getActor().getSnapshot().value === CaptureState.RECORDING;}-function isRecordingOrPaused(): boolean {- return getActor().getSnapshot().value !== CaptureState.IDLE;-}-let stepWrites: Promise<unknown> = Promise.resolve();function writeInOrder(write: () => Promise<void>): Promise<void> {@@ -140,7 +137,7 @@ export async function handleFinalizeInputStep(elementMeta: ElementMeta,domContext: DOMContext | undefined,) {- if (!isRecordingOrPaused()) return;+ if (!isLive(getActor().getSnapshot().value)) return;const screenshotId = await takeScreenshot(stepId, elementMeta);await updateStepCapture(stepId, elementMeta, screenshotId);diff --git a/src/ui/sidepanel/App.tsx b/src/ui/sidepanel/App.tsxindex 8accf18..edb8a6a 100644--- a/src/ui/sidepanel/App.tsx+++ b/src/ui/sidepanel/App.tsx@@ -1,3 +1,4 @@+import { isLive } from '@mimik/core/capture/is-live';import { logger } from '@mimik/core/logger';import { Button, Input, TooltipProvider } from '@mimik/ui';import { Globe, Search, Settings, Video } from 'lucide-react';@@ -63,7 +64,7 @@ export function App() {},onDisconnect: () => setIsAlive(false),onStateUpdate: (update) => {- const live = update.state === CaptureState.RECORDING || update.state === CaptureState.PAUSED;+ const live = isLive(update.state);const isPaused = update.state === CaptureState.PAUSED;setPaused(isPaused);setPauseReason(isPaused ? (update.pauseReason ?? null) : null);