π¬ 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
fix(desktop): keep a step whose screenshot fails, without a picture
Luis Ortizc9ea24d429fa
diff --git a/apps/desktop/scripts/check-pipeline.ts b/apps/desktop/scripts/check-pipeline.tsindex cf40567..4166d29 100644--- a/apps/desktop/scripts/check-pipeline.ts+++ b/apps/desktop/scripts/check-pipeline.ts@@ -93,6 +93,26 @@ app.whenReady().then(async () => {await recorder.capture({ x: region.x + 400, y: region.y + 300 });const results = await ask<CheckResult[]>(win.webContents, 'mimik:check:verify', guideId, 60_000);+ const blindGuide = await ask<string>(win.webContents, 'mimik:capture:startGuide');+ let blindRequest: CaptureRequest | null = null;+ const blind = new DesktopRecorder(+ () => region,+ (fn) => fn(),+ (request) => {+ blindRequest = request;+ return ask(win.webContents, 'mimik:capture:step', { ...request, guideId: blindGuide });+ },+ { grab: () => Promise.reject(new Error('display gone')), settings: () => settings, lookup: () => Promise.resolve(null) },+ );+ await blind.capture({ x: region.x + 60, y: region.y + 60 });+ const blindSteps = (await ask<string[] | null>(win.webContents, 'mimik:check:steps', blindGuide, 20_000)) ?? [];+ await ask(win.webContents, 'mimik:check:cleanup', [blindGuide], 20_000).catch(() => undefined);+ results.push({+ name: 'a failed screenshot still writes the step, without a picture',+ ok: blindSteps.length === 1 && blindRequest !== null && (blindRequest as CaptureRequest).image === undefined,+ detail: `${blindSteps.length} step written, image ${(blindRequest as CaptureRequest | null)?.image ? 'sent' : 'absent'}`,+ });+const userSettings = loadSettings();const clamped = normaliseSettings({ screenshotDelayMs: 5000 });const stored = saveSettings({ screenshotDelayMs: 750, keepClicksBeyondArea: true });diff --git a/apps/desktop/src/main/capture/recorder.ts b/apps/desktop/src/main/capture/recorder.tsindex 3279de7..fa5a138 100644--- a/apps/desktop/src/main/capture/recorder.ts+++ b/apps/desktop/src/main/capture/recorder.ts@@ -66,7 +66,7 @@ export interface Point {export interface CaptureRequest {action: string;elementMeta: ElementMeta;- image: CaptureImage;+ image?: CaptureImage;inputValue?: string;zoomLevel?: number;}@@ -460,15 +460,24 @@ export class DesktopRecorder {const settings = this.settings();const region = this.region();- const frame = await taken;+ const lost = (error: unknown) => {+ process.stderr.write(`mimik: screenshot failed: ${error instanceof Error ? error.message : String(error)}\n`);+ return null;+ };+ const frame = await taken.catch(lost);const found = await (place ?? focusedWindow());const framed = frameFor(settings.captureMode, point, region, found.ok ? found.window.bounds : null);- const shot = await frame(framed);- const scale = shot.scaleFactor;-- const screenshotId = randomUUID();- const src = writeScreenshot(screenshotId, shot.png);- this.saved(src);+ const image = frame+ ? await frame(framed)+ .then((shot) => {+ const screenshotId = randomUUID();+ const src = writeScreenshot(screenshotId, shot.png);+ this.saved(src);+ return { screenshotId, src, width: shot.width, height: shot.height, scale: shot.scaleFactor };+ })+ .catch(lost)+ : null;+ const scale = image?.scale ?? screen.getDisplayNearestPoint(point).scaleFactor;const local = { x: point.x - framed.x, y: point.y - framed.y };const target = await element;@@ -490,12 +499,9 @@ export class DesktopRecorder {...(target?.children.length ? { children: target.children } : {}),...(found.ok ? { app: found.window.app, window: { title: found.window.title } } : {}),},- image: {- screenshotId,- src,- width: shot.width,- height: shot.height,- },+ ...(image+ ? { image: { screenshotId: image.screenshotId, src: image.src, width: image.width, height: image.height } }+ : {}),...(inputValue === undefined ? {} : { inputValue }),...(settings.zoomLevel === null ? {} : { zoomLevel: settings.zoomLevel }),});diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.tsindex a769bd0..b0c0bf8 100644--- a/apps/desktop/src/main/index.ts+++ b/apps/desktop/src/main/index.ts@@ -379,7 +379,7 @@ if (!app.requestSingleInstanceLock()) {id: reply.stepId,index: steps.length + 1 + (insert?.afterStep ?? 0),title: reply.title,- src: request.image.src,+ src: request.image?.src ?? '',source: 'heuristic',pending: reply.pending === true,app: request.elementMeta.app?.name ?? null,diff --git a/apps/desktop/src/renderer/overlay/controls.ts b/apps/desktop/src/renderer/overlay/controls.tsindex 163a1da..ecb2a30 100644--- a/apps/desktop/src/renderer/overlay/controls.ts+++ b/apps/desktop/src/renderer/overlay/controls.ts@@ -177,7 +177,7 @@ export function controls(): void {printingStep = false;if (aiWait) clearTimeout(aiWait);aiWait = null;- if (printed && printed.id !== landedId) land(printed.src, printed.id);+ if (printed?.src && printed.id !== landedId) land(printed.src, printed.id);}if (!printingStep && !landing) landedId = step?.id ?? null;const capturing = printingStep || landing;@@ -230,7 +230,7 @@ export function controls(): void {aim.style.top = `${(height - shownHeight) / 2 + aimed.y * shownHeight}px`;}printing.textContent = `Capturing step ${printingIndex}`;- shot.hidden = !step;+ shot.hidden = !step?.src;veil.hidden = !paused || capturing;remove.hidden = !step || capturing || armed;