π¬ 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
feat(capture): show a spinner while an AI step description is generating
Luis Ortiz7298a0cb8d29
diff --git a/src/core/guides/service.ts b/src/core/guides/service.tsindex 9a63d8d..f203900 100644--- a/src/core/guides/service.ts+++ b/src/core/guides/service.ts@@ -143,6 +143,10 @@ export async function updateStepDescription(stepId: string, description: string)await db.steps.update(stepId, { description });}+export async function clearStepAiPending(stepId: string, description?: string): Promise<void> {+ await db.steps.update(stepId, description ? { description, aiPending: false } : { aiPending: false });+}+export async function getStepsForGuide(guideId: string): Promise<Step[]> {return db.steps.where('guideId').equals(guideId).sortBy('index');}diff --git a/src/core/guides/types.ts b/src/core/guides/types.tsindex e2c21b0..c9fb392 100644--- a/src/core/guides/types.ts+++ b/src/core/guides/types.ts@@ -22,6 +22,7 @@ export interface Step {screenshotId?: string;elementMeta?: ElementMeta;inputValue?: string;+ aiPending?: boolean;}export interface ScreenshotBounds {diff --git a/src/entrypoints/background/step-pipeline.ts b/src/entrypoints/background/step-pipeline.tsindex 9877929..d2f086f 100644--- a/src/entrypoints/background/step-pipeline.ts+++ b/src/entrypoints/background/step-pipeline.ts@@ -3,7 +3,7 @@ import type { DOMContext } from '@/core/capture/dom/context';import { CaptureState } from '@/core/capture/machine';import { buildFallbackDescription } from '@/core/capture/step-description';import { db } from '@/core/guides/db';-import { addStepToGuide, createStep, saveScreenshot, updateStepDescription } from '@/core/guides/service';+import { addStepToGuide, clearStepAiPending, createStep, saveScreenshot } from '@/core/guides/service';import type { ElementMeta, Screenshot, Step } from '@/core/guides/types';import { DEFAULT_TARGET_COLOR } from '@/core/screenshot/types';import { captureVisibleTab, localStorage } from '@/lib/browser-api';@@ -53,8 +53,13 @@ async function tryAIDescription(stepId: string, domContext: DOMContext) {const provider = (settings.aiProvider as string) || 'openai';const model = (settings.aiModel as string) || 'gpt-4o-mini';- const description = await getAIDescription(domContext, provider, model, settings.aiApiKey as string);- if (description) await updateStepDescription(stepId, description);+ try {+ const description = await getAIDescription(domContext, provider, model, settings.aiApiKey as string);+ await clearStepAiPending(stepId, description || undefined);+ } catch (err) {+ await clearStepAiPending(stepId);+ throw err;+ }}export async function handleCaptureStep(data: CaptureStepData): Promise<CaptureStepResponse> {@@ -69,6 +74,8 @@ export async function handleCaptureStep(data: CaptureStepData): Promise<CaptureSconst screenshotId = await takeScreenshot(stepId, data.elementMeta);+ const willUseAI = data.action !== 'input' && !!data.domContext && !!(await localStorage.get(['aiApiKey'])).aiApiKey;+await createStep({id: stepId,guideId,@@ -79,6 +86,7 @@ export async function handleCaptureStep(data: CaptureStepData): Promise<CaptureStimestamp: Date.now(),screenshotId,elementMeta: data.elementMeta,+ aiPending: willUseAI,});await addStepToGuide(guideId, stepId);diff --git a/src/ui/sidepanel/StepCard.tsx b/src/ui/sidepanel/StepCard.tsxindex a747c51..58d4493 100644--- a/src/ui/sidepanel/StepCard.tsx+++ b/src/ui/sidepanel/StepCard.tsx@@ -1,4 +1,4 @@-import { Check, Copy, Trash2 } from 'lucide-react';+import { Check, Copy, Loader2, Trash2 } from 'lucide-react';import { useEffect, useRef, useState } from 'react';import { i18n } from '#imports';import { replaceScreenshot } from '@/core/guides/service';@@ -131,7 +131,12 @@ export default function StepCard({<span className="flex items-center justify-center w-[22px] h-[22px] rounded-full text-[11px] font-bold shrink-0 bg-primary text-primary-foreground">{step.index + 1}</span>- {readOnly ? (+ {step.aiPending ? (+ <span className="flex items-center gap-1.5 text-[13px] font-medium leading-snug flex-1 text-muted-foreground">+ <Loader2 size={13} className="animate-spin" />+ {i18n.t('editor.writingStepDescription')}+ </span>+ ) : readOnly ? (<p className="text-[13px] font-medium leading-snug flex-1 text-foreground whitespace-pre-wrap">{step.description}</p>