🎬 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(guideme): surface a roadblock state with a manual mark-as-complete
Luis Ortize4e8c71f818c
diff --git a/src/core/guideme/content.ts b/src/core/guideme/content.tsindex e7fa538..24c9e37 100644--- a/src/core/guideme/content.ts+++ b/src/core/guideme/content.ts@@ -5,7 +5,7 @@ import { sendMessage } from '@/lib/messaging';import { findElement } from './finder';import { GuideMeOverlay } from './overlay';import type { GuideMeSession } from './session';-import { SESSION_KEY, STEP_KEY } from './session';+import { BLOCKED_KEY, SESSION_KEY, STEP_KEY } from './session';const MAX_RETRIES = 5;const RETRY_INTERVAL_MS = 1000;@@ -16,6 +16,8 @@ export class GuideMeController {private clickHandler: ((e: Event) => void) | null = null;private currentTarget: HTMLElement | null = null;private currentStepIndex = -1;+ private watchTimer: ReturnType<typeof setInterval> | null = null;+ private blocked: number | null = null;constructor() {if (window.self !== window.top) return;@@ -33,6 +35,7 @@ export class GuideMeController {browser.storage.local.onChanged.removeListener(this.storageListener);this.storageListener = null;}+ this.stopWatching();this.removeActionDetection();this.destroyOverlay();}@@ -52,38 +55,55 @@ export class GuideMeController {const step = data[STEP_KEY] as Step | null;if (!session?.active || !step) {+ this.stopWatching();this.removeActionDetection();this.destroyOverlay();+ this.blocked = null;return;}this.showStep(step, session.activeStepIndex);}- private async showStep(step: Step, stepIndex: number) {+ private showStep(step: Step, stepIndex: number) {this.removeActionDetection();this.destroyOverlay();+ this.stopWatching();this.currentStepIndex = stepIndex;- if (!step.elementMeta) return;+ const meta = step.elementMeta;+ if (!meta) return;- let element: HTMLElement | null = null;- for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {- const result = findElement(step.elementMeta);- if (result.element) {- element = result.element;- break;+ let attempts = 0;+ const attach = () => {+ const { element } = findElement(meta);+ if (!element) {+ attempts += 1;+ if (attempts === MAX_RETRIES) this.setBlocked(stepIndex);+ return;}- if (attempt < MAX_RETRIES - 1) {- await new Promise((r) => setTimeout(r, RETRY_INTERVAL_MS));- }- }+ this.stopWatching();+ this.setBlocked(null);+ this.overlay = new GuideMeOverlay();+ this.overlay.show(step.description, stepIndex + 1, element);+ this.setupActionDetection(step, element);+ };- if (!element) return;+ attach();+ if (!this.overlay) this.watchTimer = setInterval(attach, RETRY_INTERVAL_MS);+ }++ private setBlocked(stepIndex: number | null) {+ if (this.blocked === stepIndex) return;+ this.blocked = stepIndex;+ browser.storage.local+ .set({ [BLOCKED_KEY]: stepIndex })+ .catch((err) => logger.warn('Failed to flag guide me roadblock', err));+ }- this.overlay = new GuideMeOverlay();- this.overlay.show(step.description, stepIndex + 1, element);- this.setupActionDetection(step, element);+ private stopWatching() {+ if (this.watchTimer) clearInterval(this.watchTimer);+ this.watchTimer = null;}private setupActionDetection(step: Step, target: HTMLElement) {diff --git a/src/core/guideme/session.ts b/src/core/guideme/session.tsindex b209c52..c9d3c5a 100644--- a/src/core/guideme/session.ts+++ b/src/core/guideme/session.ts@@ -10,10 +10,11 @@ export interface GuideMeSession {const SESSION_KEY = 'guideMeSession';const STEP_KEY = 'guideMeStep';+const BLOCKED_KEY = 'guideMeBlocked';export async function startSession(guideId: string, totalSteps: number, firstStep: Step): Promise<void> {const session: GuideMeSession = { guideId, activeStepIndex: 0, totalSteps, active: true };- await localStorage.set({ [SESSION_KEY]: session, [STEP_KEY]: firstStep });+ await localStorage.set({ [SESSION_KEY]: session, [STEP_KEY]: firstStep, [BLOCKED_KEY]: null });}export async function advanceSession(nextStep: Step, nextIndex: number): Promise<void> {@@ -23,6 +24,7 @@ export async function advanceSession(nextStep: Step, nextIndex: number): Promiseawait localStorage.set({[SESSION_KEY]: { ...session, activeStepIndex: nextIndex },[STEP_KEY]: nextStep,+ [BLOCKED_KEY]: null,});}@@ -33,11 +35,12 @@ export async function completeSession(): Promise<void> {await localStorage.set({[SESSION_KEY]: { ...session, active: false },[STEP_KEY]: null,+ [BLOCKED_KEY]: null,});}export async function cancelSession(): Promise<void> {- await localStorage.set({ [SESSION_KEY]: null, [STEP_KEY]: null });+ await localStorage.set({ [SESSION_KEY]: null, [STEP_KEY]: null, [BLOCKED_KEY]: null });}export async function getSession(): Promise<GuideMeSession | null> {@@ -45,4 +48,4 @@ export async function getSession(): Promise<GuideMeSession | null> {return (data[SESSION_KEY] as GuideMeSession) || null;}-export { SESSION_KEY, STEP_KEY };+export { BLOCKED_KEY, SESSION_KEY, STEP_KEY };diff --git a/src/locales/en.yml b/src/locales/en.ymlindex f15eeb3..013e813 100644--- a/src/locales/en.yml+++ b/src/locales/en.yml@@ -44,6 +44,8 @@ library:guideme:live: Live+ roadblock: "We hit a roadblock. Try taking action on the screen to move forward."+ markComplete: "Mark as complete"stepOf: "Step $1 of $2"noDescription: No descriptionprev: Prevdiff --git a/src/locales/es.yml b/src/locales/es.ymlindex daf815e..8d65f29 100644--- a/src/locales/es.yml+++ b/src/locales/es.yml@@ -44,6 +44,8 @@ library:guideme:live: En vivo+ roadblock: "Nos encontramos con un obstáculo. Actúa en la pantalla para avanzar."+ markComplete: "Marcar como completado"stepOf: "Paso $1 de $2"noDescription: Sin descripciónprev: Anteriordiff --git a/src/locales/fr.yml b/src/locales/fr.ymlindex 4acdfe5..7078b40 100644--- a/src/locales/fr.yml+++ b/src/locales/fr.yml@@ -44,6 +44,8 @@ library:guideme:live: En direct+ roadblock: "Nous avons rencontré un obstacle. Agissez à l'écran pour continuer."+ markComplete: "Marquer comme terminé"stepOf: "Étape $1 sur $2"noDescription: Aucune descriptionprev: "Préc."diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.ymlindex c136f77..1623ea2 100644--- a/src/locales/pt-BR.yml+++ b/src/locales/pt-BR.yml@@ -44,6 +44,8 @@ library:guideme:live: Ao vivo+ roadblock: "Encontramos um obstáculo. Aja na tela para avançar."+ markComplete: "Marcar como concluído"stepOf: "Passo $1 de $2"noDescription: Sem descriçãoprev: Anteriordiff --git a/src/ui/sidepanel/GuideMeView.tsx b/src/ui/sidepanel/GuideMeView.tsxindex 35e5ead..08a0f86 100644--- a/src/ui/sidepanel/GuideMeView.tsx+++ b/src/ui/sidepanel/GuideMeView.tsx@@ -1,8 +1,8 @@-import { ArrowLeft, Check, ChevronLeft, ChevronRight } from 'lucide-react';+import { ArrowLeft, Check, ChevronLeft, ChevronRight, TriangleAlert } from 'lucide-react';import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { browser, i18n } from '#imports';import type { GuideMeSession } from '@/core/guideme/session';-import { SESSION_KEY } from '@/core/guideme/session';+import { BLOCKED_KEY, SESSION_KEY } from '@/core/guideme/session';import { getGuide } from '@/core/guides/service';import type { Guide, Screenshot, Step } from '@/core/guides/types';import { sendMessage } from '@/lib/messaging';@@ -68,6 +68,7 @@ export default function GuideMeView({ guideId, onExit, onComplete }: GuideMeViewconst [activeStepIndex, setActiveStepIndex] = useState(0);const [viewedStepIndex, setViewedStepIndex] = useState(0);const [showExitConfirm, setShowExitConfirm] = useState(false);+ const [blockedStepIndex, setBlockedStepIndex] = useState<number | null>(null);const objectUrlsRef = useRef<Map<string, string>>(new Map());const loadGuide = useCallback(async () => {@@ -86,6 +87,9 @@ export default function GuideMeView({ guideId, onExit, onComplete }: GuideMeViewuseEffect(() => {const handler = (changes: Record<string, { newValue?: unknown }>) => {+ if (changes[BLOCKED_KEY]) {+ setBlockedStepIndex((changes[BLOCKED_KEY].newValue as number | null) ?? null);+ }if (!changes[SESSION_KEY]) return;const session = changes[SESSION_KEY].newValue as GuideMeSession | null;if (!session) return;@@ -102,12 +106,13 @@ export default function GuideMeView({ guideId, onExit, onComplete }: GuideMeView}, [guideId, onComplete]);useEffect(() => {- browser.storage.local.get([SESSION_KEY]).then((result: Record<string, unknown>) => {+ browser.storage.local.get([SESSION_KEY, BLOCKED_KEY]).then((result: Record<string, unknown>) => {const session = result[SESSION_KEY] as GuideMeSession | null;if (session?.active) {setActiveStepIndex(session.activeStepIndex);setViewedStepIndex(session.activeStepIndex);}+ setBlockedStepIndex((result[BLOCKED_KEY] as number | null) ?? null);});}, []);@@ -157,6 +162,8 @@ export default function GuideMeView({ guideId, onExit, onComplete }: GuideMeViewif (!data) return <p className="text-sm text-purple p-4">{i18n.t('guideme.guideNotFound')}</p>;const totalSteps = data.steps.length;+ const isBlocked =+ blockedStepIndex !== null && blockedStepIndex === activeStepIndex && viewedStepIndex === activeStepIndex;return (<div className="min-h-screen bg-card flex flex-col relative">@@ -222,6 +229,22 @@ export default function GuideMeView({ guideId, onExit, onComplete }: GuideMeView</div>)}+ {isBlocked && (+ <div className="mx-4 mb-3 rounded-lg bg-secondary p-3">+ <p className="flex items-start gap-2 text-[12px] leading-relaxed text-foreground">+ <TriangleAlert size={14} className="shrink-0 mt-0.5 text-accent" />+ {i18n.t('guideme.roadblock')}+ </p>+ <button+ onClick={() => sendMessage('guideMeStepCompleted', { stepIndex: activeStepIndex }).catch(() => {})}+ className="mt-2.5 flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-[12px] font-semibold text-foreground hover:border-accent hover:text-accent transition-colors"+ >+ <Check size={13} strokeWidth={3} />+ {i18n.t('guideme.markComplete')}+ </button>+ </div>+ )}+<div className="flex items-center justify-between px-4 pb-3"><buttononClick={() => setViewedStepIndex((i) => Math.max(0, i - 1))}