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(desktop): redesign the recording card and play the start animation

Luis Ortiz274efea19dfb
diff --git a/apps/desktop/scripts/check-overlay.ts b/apps/desktop/scripts/check-overlay.ts
index 21eea99..d7696bf 100644
--- a/apps/desktop/scripts/check-overlay.ts
+++ b/apps/desktop/scripts/check-overlay.ts
@@ -20,6 +20,12 @@ function settle(): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, 400));
}
+async function until(done: () => boolean, ms: number): Promise<boolean> {
+ const deadline = Date.now() + ms;
+ while (!done() && Date.now() < deadline) await new Promise((resolve) => setTimeout(resolve, 100));
+ return done();
+}
+
function overlayWindows(): BrowserWindow[] {
return BrowserWindow.getAllWindows();
}
@@ -43,9 +49,13 @@ setTimeout(() => bail(new Error('check did not finish within 60s')), 60_000).unr
app.whenReady().then(async () => {
const commands: string[] = [];
let mode: CaptureMode = 'region';
- const overlay = new CaptureOverlay(
+ const overlay: CaptureOverlay = new CaptureOverlay(
(command) => commands.push(command),
() => mode,
+ {
+ introFrame: async (): Promise<Region> => overlay.region,
+ shortcuts: () => ({ startStop: 'Alt+Shift+R', capture: 'Alt+Shift+C' }),
+ },
);
const stored: Region = { x: 120, y: 90, width: 640, height: 400 };
@@ -99,13 +109,13 @@ app.whenReady().then(async () => {
bar ? `controls at ${bar.x}, ${bar.y} (${bar.width} × ${bar.height}) in a ${workArea.width} × ${workArea.height} work area` : 'no controls window',
);
const layout = await controls?.webContents.executeJavaScript(
- "JSON.stringify({ tip: getComputedStyle(document.querySelector('#tip')).position, body: document.body.scrollHeight, win: window.innerHeight })",
+ "JSON.stringify({ tip: getComputedStyle(document.querySelector('#tip')).position, hint: getComputedStyle(document.querySelector('#keyHint')).position, body: document.body.scrollHeight, win: window.innerHeight })",
);
- const parsed = JSON.parse(String(layout ?? '{}')) as { tip?: string; body?: number; win?: number };
+ const parsed = JSON.parse(String(layout ?? '{}')) as { tip?: string; hint?: string; body?: number; win?: number };
check(
'the card measures itself and owns its own styles',
- parsed.tip === 'static' && typeof parsed.body === 'number' && parsed.body > 0 && parsed.body <= (parsed.win ?? 0) + 4,
- `hint is ${parsed.tip}, content ${parsed.body}px in a ${parsed.win}px window`,
+ parsed.tip === 'static' && parsed.hint === 'static' && typeof parsed.body === 'number' && parsed.body > 0 && parsed.body <= (parsed.win ?? 0) + 4,
+ `tip is ${parsed.tip}, key hint is ${parsed.hint}, content ${parsed.body}px in a ${parsed.win}px window`,
);
check(
@@ -116,10 +126,28 @@ app.whenReady().then(async () => {
await controls?.webContents.executeJavaScript("document.querySelector('#primary').click()");
await settle();
+ const starting = await windowWithHash('controls')?.webContents.executeJavaScript(
+ "JSON.stringify({ label: document.querySelector('#label').textContent, start: document.querySelector('#primary').disabled })",
+ );
+ const intro = overlay.introWindow;
+ const introBounds = intro?.getBounds();
+ const startCard = JSON.parse(String(starting ?? '{}')) as { label?: string; start?: boolean };
+ check(
+ 'Start plays the intro over the capture area before recording',
+ intro !== null &&
+ !commands.includes('start') &&
+ overlay.state === 'armed' &&
+ startCard.label === 'Starting…' &&
+ startCard.start === true &&
+ introBounds?.width === overlay.region.width &&
+ introBounds?.height === overlay.region.height,
+ `intro ${introBounds ? `${introBounds.width} × ${introBounds.height}` : 'missing'}, card says ${startCard.label}, commands: ${commands.join(', ') || 'none'}`,
+ );
+ const recorded = await until(() => overlay.state === 'recording', 7_000);
check(
- 'Start reaches the host and records',
- commands.includes('start') && overlay.state === 'recording',
- `commands: ${commands.join(', ') || 'none'}; state is ${overlay.state}`,
+ 'Start reaches the host and records once the intro ends',
+ recorded && commands.includes('start') && overlay.introWindow === null,
+ `commands: ${commands.join(', ') || 'none'}; state is ${overlay.state}; intro ${overlay.introWindow ? 'still open' : 'closed'}`,
);
await windowWithHash('controls')?.webContents.executeJavaScript("document.querySelector('#secondary').click()");
await settle();
@@ -153,34 +181,65 @@ app.whenReady().then(async () => {
: 'content protection applied after show, so no hide is needed',
);
const drawn = await windowWithHash('controls')?.webContents.executeJavaScript(
- "JSON.stringify({ paths: document.querySelectorAll('#mascot svg path').length, visible: !document.querySelector('#intro').hidden })",
+ "JSON.stringify({ paths: document.querySelectorAll('#mascot svg path').length, flash: document.querySelectorAll('#mascot svg .flash').length, visible: !document.querySelector('#intro').hidden, hint: document.querySelector('#keyHint').textContent })",
);
- const mascot = JSON.parse(String(drawn ?? '{}')) as { paths?: number; visible?: boolean };
+ const mascot = JSON.parse(String(drawn ?? '{}')) as { paths?: number; flash?: number; visible?: boolean; hint?: string };
check(
- 'the armed card draws the shared mascot',
- mascot.paths === 6 && mascot.visible === true,
- `${mascot.paths} mascot paths, intro visible: ${mascot.visible}`,
+ 'the armed card draws the camera mascot and the start shortcut',
+ mascot.paths === 4 && mascot.flash === 1 && mascot.visible === true && mascot.hint === 'Alt+Shift+Rstarts and stops',
+ `${mascot.paths} mascot paths, ${mascot.flash} flash, intro visible: ${mascot.visible}, hint: ${mascot.hint}`,
);
+ const evaluate = (script: string) => windowWithHash('controls')?.webContents.executeJavaScript(script);
+ const card = async (fields: string) => JSON.parse(String((await evaluate(`JSON.stringify({ ${fields} })`)) ?? '{}'));
+ const src = 'mimik-screenshot://00000000-0000-4000-8000-000000000000';
overlay.record();
await settle();
- overlay.stepCaptured(1, 'Click "Save"', 'mimik-screenshot://00000000-0000-4000-8000-000000000000');
+ const idle = await card("tip: document.querySelector('#tip').textContent, hint: document.querySelector('#keyHint').textContent");
+ check(
+ 'recording with no steps waits for the first click',
+ idle.tip === 'Waiting for your first click' && idle.hint === 'Alt+Shift+Ccaptures where the pointer is',
+ `tip: ${idle.tip}, hint: ${idle.hint}`,
+ );
+
+ overlay.showStep({ id: 'one', index: 1, title: 'Click "Save"', src, source: 'heuristic', pending: false, app: 'Explorer' });
await settle();
- const afterStep = await windowWithHash('controls')?.webContents.executeJavaScript(
- "JSON.stringify({ intro: getComputedStyle(document.querySelector('#intro')).display, title: document.querySelector('#stepTitle').textContent })",
+ const step = await card(
+ "intro: getComputedStyle(document.querySelector('#intro')).display, title: document.querySelector('#stepTitle').textContent, source: document.querySelector('#source').textContent, meta: document.querySelector('#metaText').textContent",
);
- const step = JSON.parse(String(afterStep ?? '{}')) as { intro?: string; title?: string };
check(
- 'the first step replaces the instructions',
- step.intro === 'none' && step.title === 'Click "Save"',
- `intro display: ${step.intro}, title: ${step.title}`,
+ 'the first step replaces the instructions, with its source and app',
+ step.intro === 'none' && step.title === 'Click "Save"' && step.source === 'Basic' && step.meta === 'Step 1 · Explorer',
+ `intro display: ${step.intro}, title: ${step.title}, source: ${step.source}, meta: ${step.meta}`,
);
+ overlay.showStep({ id: 'one', index: 1, title: 'Click "Save"', src, source: 'heuristic', pending: true, app: 'Explorer' });
+ await settle();
+ const writing = await card("writing: !document.querySelector('#writing').hidden, title: !document.querySelector('#stepTitle').hidden");
+ overlay.showStep({ id: 'one', index: 1, title: 'Save the file', src, source: 'ai', pending: false, app: 'Explorer' });
+ await settle();
+ const rewritten = await card("source: document.querySelector('#source').textContent, title: document.querySelector('#stepTitle').textContent");
+ check(
+ 'a pending description shows as being written, then carries the AI badge',
+ writing.writing === true && writing.title === false && rewritten.source === 'AI' && rewritten.title === 'Save the file',
+ `writing shown: ${writing.writing}, title shown: ${writing.title}; then ${rewritten.source} "${rewritten.title}"`,
+ );
+
+ await evaluate("document.querySelector('#remove').click()");
+ await settle();
+ check('removing the step reaches the host', commands.includes('remove'), `commands: ${commands.join(', ')}`);
+
overlay.setBusy(true);
await settle();
const whileBusy = await windowWithHash('controls')?.webContents.executeJavaScript(
"document.querySelector('#primary').disabled",
);
+ const veil = await card("text: document.querySelector('#veilText').textContent, remove: document.querySelector('#remove').hidden");
+ check(
+ 'a capture in flight shows the mascot over the last screenshot',
+ veil.text === 'Capturing step 2…' && veil.remove === true,
+ `veil: ${veil.text}, remove hidden: ${veil.remove}`,
+ );
overlay.setBusy(false);
await settle();
const whenIdle = await windowWithHash('controls')?.webContents.executeJavaScript(
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index 7094d85..8733c7f 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -2,10 +2,11 @@ import { join } from 'node:path';
import { app, BrowserWindow, dialog, ipcMain, Menu, nativeImage, protocol, screen, shell, Tray } from 'electron';
import { registerAiFetch } from './ai-fetch';
import { ask } from './ask';
-import { DesktopRecorder } from './capture/recorder';
+import { focusedWindow } from './capture/focused-window';
+import { DesktopRecorder, frameFor } from './capture/recorder';
import { registerScreenshotProtocol, SCREENSHOT_SCHEME, sweepScreenshots } from './capture/screenshot-store';
import { type CaptureMode, type CaptureSettings, loadSettings, saveSettings } from './capture/settings';
-import { CaptureOverlay, type OverlayCommand } from './overlay';
+import { CaptureOverlay, type OverlayCommand, type OverlayStep } from './overlay';
import { bindShortcuts, type ShortcutName, shortcutMap, unbindShortcuts } from './shortcuts';
import { checkForUpdates } from './updater';
@@ -15,7 +16,7 @@ let overlay: CaptureOverlay | null = null;
let recorder: DesktopRecorder | null = null;
let guideId: string | null = null;
let captureSettings: CaptureSettings | null = null;
-let stepCount = 0;
+let steps: OverlayStep[] = [];
function resource(file: string): string {
return app.isPackaged ? join(process.resourcesPath, file) : join(__dirname, '../../resources', file);
@@ -144,8 +145,18 @@ async function onOverlayCommand(command: OverlayCommand): Promise<void> {
overlay?.refresh();
return;
}
+ if (command === 'remove') {
+ const removed = steps.pop();
+ if (removed && guideId) {
+ await ask(mainWindow?.webContents ?? null, 'mimik:capture:removeStep', { guideId, stepId: removed.id }).catch(
+ () => undefined,
+ );
+ }
+ overlay?.showStep(steps.at(-1) ?? null);
+ return;
+ }
if (command === 'start' && !guideId) {
- stepCount = 0;
+ steps = [];
try {
guideId = await ask<string>(mainWindow?.webContents ?? null, 'mimik:capture:startGuide');
} catch (error) {
@@ -167,7 +178,7 @@ async function onOverlayCommand(command: OverlayCommand): Promise<void> {
} else if (command === 'stop' || command === 'cancel') {
recorder?.stop();
await recorder?.drain();
- if (command === 'stop' && stepCount > 0) finished = guideId;
+ if (command === 'stop' && steps.length > 0) finished = guideId;
if (finished) {
await ask(mainWindow?.webContents ?? null, 'mimik:capture:finishGuide', finished).catch(() => undefined);
}
@@ -206,9 +217,28 @@ if (!app.requestSingleInstanceLock()) {
ipcMain.handle('mimik:screenshots:sweep', (_event, keep: string[]) => sweepScreenshots(keep));
captureSettings = loadSettings();
+ const shortcutLabel = (accelerator: string | null) =>
+ accelerator?.replace(/CommandOrControl|CmdOrCtrl/g, process.platform === 'darwin' ? 'Cmd' : 'Ctrl') || null;
overlay = new CaptureOverlay(
(command) => void onOverlayCommand(command),
() => (captureSettings ?? loadSettings()).captureMode,
+ {
+ introFrame: async () => {
+ const settings = captureSettings ?? loadSettings();
+ const focused = settings.captureMode === 'window' ? await focusedWindow() : null;
+ const region = overlay?.region ?? { x: 0, y: 0, width: 0, height: 0 };
+ return frameFor(
+ settings.captureMode,
+ screen.getCursorScreenPoint(),
+ region,
+ focused?.ok ? focused.window.bounds : null,
+ );
+ },
+ shortcuts: () => {
+ const { shortcuts } = captureSettings ?? loadSettings();
+ return { startStop: shortcutLabel(shortcuts.startStop), capture: shortcutLabel(shortcuts.capture) };
+ },
+ },
);
recorder = new DesktopRecorder(
() => overlay?.region ?? { x: 0, y: 0, width: 0, height: 0 },
@@ -218,11 +248,24 @@ if (!app.requestSingleInstanceLock()) {
},
async (request) => {
try {
- const reply = await ask<{ title?: string }>(mainWindow?.webContents ?? null, 'mimik:capture:step', {
- ...request,
- guideId,
- }).catch(() => undefined);
- if (reply?.title) overlay?.stepCaptured(++stepCount, reply.title, request.image.src);
+ const reply = await ask<{ stepId?: string; title?: string; pending?: boolean }>(
+ mainWindow?.webContents ?? null,
+ 'mimik:capture:step',
+ { ...request, guideId },
+ ).catch(() => undefined);
+ if (reply?.stepId && reply.title) {
+ const step: OverlayStep = {
+ id: reply.stepId,
+ index: steps.length + 1,
+ title: reply.title,
+ src: request.image.src,
+ source: 'heuristic',
+ pending: reply.pending === true,
+ app: request.elementMeta.app?.name ?? null,
+ };
+ steps.push(step);
+ overlay?.showStep(step);
+ }
return reply;
} finally {
overlay?.setBusy(false);
@@ -241,6 +284,16 @@ if (!app.requestSingleInstanceLock()) {
applyShortcuts();
return captureSettings;
});
+ ipcMain.on('mimik:capture:described', (_event, stepId: string, description: string | null) => {
+ const step = steps.find((candidate) => candidate.id === stepId);
+ if (!step) return;
+ if (description) {
+ step.title = description;
+ step.source = 'ai';
+ }
+ step.pending = false;
+ if (step === steps.at(-1)) overlay?.showStep(step);
+ });
ipcMain.handle('mimik:capture:region', () => overlay?.region);
ipcMain.handle('mimik:capture:edit', () => overlay?.edit());
ipcMain.handle('mimik:capture:arm', () => overlay?.arm());
diff --git a/apps/desktop/src/main/overlay/index.ts b/apps/desktop/src/main/overlay/index.ts
index 8e460d3..1a70e3d 100644
--- a/apps/desktop/src/main/overlay/index.ts
+++ b/apps/desktop/src/main/overlay/index.ts
@@ -14,10 +14,44 @@ export type OverlayCommand =
| 'stop'
| 'mode:window'
| 'mode:screen'
- | 'mode:region';
+ | 'mode:region'
+ | 'remove'
+ | 'intro:done';
+
+export interface OverlayStep {
+ id: string;
+ index: number;
+ title: string;
+ src: string;
+ source: 'heuristic' | 'ai';
+ pending: boolean;
+ app: string | null;
+}
+
+export interface OverlayShortcuts {
+ startStop: string | null;
+ capture: string | null;
+}
+
+export interface OverlayView {
+ state: OverlayState;
+ region: Region;
+ step: OverlayStep | null;
+ mode: CaptureMode;
+ busy: boolean;
+ starting: boolean;
+ shortcuts: OverlayShortcuts;
+}
+
+export interface OverlayOptions {
+ introFrame?: () => Promise<Region>;
+ shortcuts?: () => OverlayShortcuts;
+}
const BORDER = 3;
const CONTROLS = { width: 300, height: 190, margin: 24 };
+const INTRO_LIMIT_MS = 6000;
+const NO_SHORTCUTS: OverlayShortcuts = { startStop: null, capture: null };
function rendererFile(): string {
return join(__dirname, '../renderer/overlay.html');
@@ -70,22 +104,23 @@ export class CaptureOverlay {
private editors: BrowserWindow[] = [];
private boundary: BrowserWindow | null = null;
private controls: BrowserWindow | null = null;
+ private intro: BrowserWindow | null = null;
+ private introDone: ((finished: boolean) => void) | null = null;
private current: OverlayState = 'hidden';
private rect: Region;
- private last: { index: number; title: string; src: string } | null = null;
+ private step: OverlayStep | null = null;
private size = { width: CONTROLS.width, height: CONTROLS.height };
private busy = false;
+ private starting = false;
constructor(
private onCommand: (command: OverlayCommand) => void,
private mode: () => CaptureMode = () => 'region',
+ private options: OverlayOptions = {},
) {
this.rect = loadRegion();
ipcMain.handle('mimik:overlay:region', () => this.rect);
- ipcMain.handle('mimik:overlay:state', () => this.current);
- ipcMain.handle('mimik:overlay:last', () => this.last);
- ipcMain.handle('mimik:overlay:mode', () => this.mode());
- ipcMain.handle('mimik:overlay:busy', () => this.busy);
+ ipcMain.handle('mimik:overlay:view', () => this.view());
ipcMain.on('mimik:overlay:setRegion', (_event, next: Region) => this.setRegion(next));
ipcMain.on('mimik:overlay:command', (_event, command: OverlayCommand) => this.command(command));
ipcMain.on('mimik:overlay:size', (_event, width: number, height: number) => this.resize(width, height));
@@ -105,9 +140,25 @@ export class CaptureOverlay {
);
}
+ get introWindow(): BrowserWindow | null {
+ return this.intro && !this.intro.isDestroyed() ? this.intro : null;
+ }
+
+ private view(): OverlayView {
+ return {
+ state: this.current,
+ region: this.rect,
+ step: this.step,
+ mode: this.mode(),
+ busy: this.busy,
+ starting: this.starting,
+ shortcuts: this.options.shortcuts?.() ?? NO_SHORTCUTS,
+ };
+ }
+
private broadcast(): void {
- for (const win of this.windows())
- win.webContents.send('mimik:overlay:update', this.current, this.rect, this.last, this.mode(), this.busy);
+ const view = this.view();
+ for (const win of this.windows()) win.webContents.send('mimik:overlay:update', view);
}
refresh(): void {
@@ -123,8 +174,8 @@ export class CaptureOverlay {
});
}
- stepCaptured(index: number, title: string, src: string): void {
- this.last = { index, title, src };
+ showStep(step: OverlayStep | null): void {
+ this.step = step ? { ...step } : null;
this.broadcast();
}
@@ -238,7 +289,51 @@ export class CaptureOverlay {
this.show('paused');
}
+ private async begin(): Promise<void> {
+ if (this.starting) return;
+ this.starting = true;
+ this.show('armed');
+ const frame = await (this.options.introFrame?.() ?? Promise.resolve(this.displayUnderCursor())).catch(() =>
+ this.displayUnderCursor(),
+ );
+ const finished = await this.playIntro(frame);
+ this.starting = false;
+ if (!finished) return;
+ this.record();
+ this.onCommand('start');
+ }
+
+ private displayUnderCursor(): Region {
+ return screen.getDisplayNearestPoint(screen.getCursorScreenPoint()).bounds;
+ }
+
+ private playIntro(frame: Region): Promise<boolean> {
+ return new Promise((resolve) => {
+ const win = overlayWindow(frame, 'intro', false);
+ this.intro = win;
+ let settled = false;
+ const done = (finished: boolean) => {
+ if (settled) return;
+ settled = true;
+ clearTimeout(limit);
+ this.introDone = null;
+ this.intro = null;
+ if (!win.isDestroyed()) win.destroy();
+ resolve(finished);
+ };
+ const limit = setTimeout(() => done(true), INTRO_LIMIT_MS);
+ this.introDone = done;
+ win.once('ready-to-show', () => {
+ win.showInactive();
+ protect(win);
+ });
+ win.once('closed', () => done(true));
+ });
+ }
+
hide(): void {
+ this.introDone?.(false);
+ this.starting = false;
this.current = 'hidden';
this.closeEditors();
for (const win of this.windows()) win.hide();
@@ -253,12 +348,25 @@ export class CaptureOverlay {
this.onCommand(command);
return;
}
+ if (command === 'intro:done') {
+ this.introDone?.(true);
+ return;
+ }
+ if (command === 'start') {
+ void this.begin();
+ return;
+ }
+ if (command === 'remove') {
+ if (!this.busy) this.onCommand(command);
+ return;
+ }
+ if (this.starting && command !== 'cancel' && command !== 'stop') return;
if (command === 'edit') this.edit();
else if (command === 'arm') this.arm();
- else if (command === 'start' || command === 'resume') this.record();
+ else if (command === 'resume') this.record();
else if (command === 'pause') this.pause();
else {
- this.last = null;
+ this.step = null;
this.hide();
}
this.onCommand(command);
@@ -281,18 +389,12 @@ export class CaptureOverlay {
destroy(): void {
this.closeEditors();
+ this.introDone?.(false);
for (const win of [this.boundary, this.controls]) if (win && !win.isDestroyed()) win.destroy();
this.boundary = null;
this.controls = null;
this.current = 'hidden';
- for (const channel of [
- 'mimik:overlay:region',
- 'mimik:overlay:state',
- 'mimik:overlay:last',
- 'mimik:overlay:mode',
- 'mimik:overlay:busy',
- ])
- ipcMain.removeHandler(channel);
+ for (const channel of ['mimik:overlay:region', 'mimik:overlay:view']) ipcMain.removeHandler(channel);
ipcMain.removeAllListeners('mimik:overlay:setRegion');
ipcMain.removeAllListeners('mimik:overlay:command');
ipcMain.removeAllListeners('mimik:overlay:size');
diff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.ts
index d8de43e..5506a5b 100644
--- a/apps/desktop/src/preload/index.ts
+++ b/apps/desktop/src/preload/index.ts
@@ -14,6 +14,8 @@ const api = {
region: (): Promise<Region> => ipcRenderer.invoke('mimik:capture:region'),
edit: (): Promise<void> => ipcRenderer.invoke('mimik:capture:edit'),
arm: (): Promise<void> => ipcRenderer.invoke('mimik:capture:arm'),
+ described: (stepId: string, description: string | null): void =>
+ ipcRenderer.send('mimik:capture:described', stepId, description),
settings: {
get: (): Promise<CaptureSettings> => ipcRenderer.invoke('mimik:capture:settings:get'),
set: (patch: Partial<CaptureSettings>): Promise<CaptureSettings> =>
diff --git a/apps/desktop/src/preload/overlay.ts b/apps/desktop/src/preload/overlay.ts
index 0835563..68770cf 100644
--- a/apps/desktop/src/preload/overlay.ts
+++ b/apps/desktop/src/preload/overlay.ts
@@ -1,35 +1,14 @@
import { contextBridge, ipcRenderer } from 'electron';
-
-interface Region {
- x: number;
- y: number;
- width: number;
- height: number;
-}
-
-interface LastStep {
- index: number;
- title: string;
- src: string;
-}
+import type { OverlayView, Region } from '../main/overlay';
const api = {
region: (): Promise<Region> => ipcRenderer.invoke('mimik:overlay:region'),
- state: (): Promise<string> => ipcRenderer.invoke('mimik:overlay:state'),
- last: (): Promise<LastStep> => ipcRenderer.invoke('mimik:overlay:last'),
- mode: (): Promise<string> => ipcRenderer.invoke('mimik:overlay:mode'),
- busy: (): Promise<boolean> => ipcRenderer.invoke('mimik:overlay:busy'),
+ view: (): Promise<OverlayView> => ipcRenderer.invoke('mimik:overlay:view'),
setRegion: (region: Region): void => ipcRenderer.send('mimik:overlay:setRegion', region),
command: (command: string): void => ipcRenderer.send('mimik:overlay:command', command),
size: (width: number, height: number): void => ipcRenderer.send('mimik:overlay:size', width, height),
- onUpdate: (
- handler: (state: string, region: Region, last: LastStep | null, mode: string, busy: boolean) => void,
- ): void => {
- ipcRenderer.on(
- 'mimik:overlay:update',
- (_event, state: string, region: Region, last: LastStep | null, mode: string, busy: boolean) =>
- handler(state, region, last, mode, busy),
- );
+ onUpdate: (handler: (view: OverlayView) => void): void => {
+ ipcRenderer.on('mimik:overlay:update', (_event, view: OverlayView) => handler(view));
},
};
diff --git a/apps/desktop/src/renderer/capture-host.ts b/apps/desktop/src/renderer/capture-host.ts
index c7bf8b8..66ec658 100644
--- a/apps/desktop/src/renderer/capture-host.ts
+++ b/apps/desktop/src/renderer/capture-host.ts
@@ -2,6 +2,7 @@ import type { CaptureStepData } from '@mimik/core/capture/sink';
import { i18n } from '@mimik/core/env';
import {
allScreenshotIds,
+ deleteStep,
getStepsForGuide,
permanentlyDeleteGuide,
updateGuideDescription,
@@ -17,6 +18,12 @@ allScreenshotIds().then((ids) => window.mimik.screenshots.sweep(ids));
window.mimik.onRequest('mimik:capture:startGuide', () => sink.startGuide());
window.mimik.onRequest('mimik:capture:step', (payload) => sink.captureStep(payload as CaptureStepData));
+window.mimik.onRequest('mimik:capture:removeStep', async (payload) => {
+ const { guideId, stepId } = payload as { guideId: string; stepId: string };
+ await deleteStep(guideId, stepId);
+ return true;
+});
+
window.mimik.onRequest('mimik:capture:finishGuide', async (payload) => {
const guideId = payload as string;
const steps = await getStepsForGuide(guideId);
diff --git a/apps/desktop/src/renderer/capture-sink.ts b/apps/desktop/src/renderer/capture-sink.ts
index e8d237a..35b48b1 100644
--- a/apps/desktop/src/renderer/capture-sink.ts
+++ b/apps/desktop/src/renderer/capture-sink.ts
@@ -20,6 +20,7 @@ import {
} from '@mimik/core/guides/service';
import { screenshotForElement } from '@mimik/core/screenshot/record';
import type { CursorMark } from '@mimik/core/screenshot/types';
+import { credentials } from './ai/credentials';
import { describeStep } from './ai/describe-step';
export type DesktopCaptureStepData = CaptureStepData & {
@@ -34,7 +35,9 @@ export class DesktopCaptureSink implements CaptureSink {
return guide.id;
}
- async captureStep(data: DesktopCaptureStepData): Promise<CaptureStepResponse & { title?: string }> {
+ async captureStep(
+ data: DesktopCaptureStepData,
+ ): Promise<CaptureStepResponse & { title?: string; pending?: boolean }> {
const stepId = crypto.randomUUID();
const meta = data.elementMeta;
const index = (await getStepsForGuide(data.guideId)).length;
@@ -62,6 +65,7 @@ export class DesktopCaptureSink implements CaptureSink {
}
const description = buildFallbackDescription(data.action, meta);
+ const pending = (await credentials()) !== null;
await createStep({
id: stepId,
@@ -76,17 +80,20 @@ export class DesktopCaptureSink implements CaptureSink {
screenshotId,
elementMeta: meta,
descriptionSource: 'heuristic',
- aiPending: true,
+ aiPending: pending,
...(data.inputValue === undefined ? {} : { inputValue: data.inputValue }),
});
await addStepToGuide(data.guideId, stepId);
- void describeStep(data.action, meta).then(async (written) => {
- if (written) await updateStepDescription(stepId, written, 'ai');
- await clearStepAiPending(stepId);
- });
+ if (pending) {
+ void describeStep(data.action, meta).then(async (written) => {
+ if (written) await updateStepDescription(stepId, written, 'ai');
+ await clearStepAiPending(stepId);
+ window.mimik.capture.described(stepId, written);
+ });
+ }
- return { stepId, title: description };
+ return { stepId, title: description, pending };
}
async updateInputStep(data: UpdateInputStepData): Promise<UpdateInputStepResponse> {
diff --git a/apps/desktop/src/renderer/icons.ts b/apps/desktop/src/renderer/icons.ts
index 910b28b..7dccb88 100644
--- a/apps/desktop/src/renderer/icons.ts
+++ b/apps/desktop/src/renderer/icons.ts
@@ -1,4 +1,17 @@
-import { Check, ChevronDown, ChevronUp, createElement, Pause, Play, Video } from 'lucide';
+import {
+ AppWindow,
+ Check,
+ ChevronDown,
+ ChevronUp,
+ Crop,
+ createElement,
+ LoaderCircle,
+ Monitor,
+ Pause,
+ Play,
+ Trash2,
+ Video,
+} from 'lucide';
const ICONS = {
video: Video,
@@ -7,6 +20,11 @@ const ICONS = {
check: Check,
chevronDown: ChevronDown,
chevronUp: ChevronUp,
+ trash: Trash2,
+ loader: LoaderCircle,
+ window: AppWindow,
+ monitor: Monitor,
+ area: Crop,
};
export type IconName = keyof typeof ICONS;
diff --git a/apps/desktop/src/renderer/overlay.css b/apps/desktop/src/renderer/overlay.css
index 5181cb6..4ddcee8 100644
--- a/apps/desktop/src/renderer/overlay.css
+++ b/apps/desktop/src/renderer/overlay.css
@@ -1,3 +1,8 @@
+@import '@fontsource/poppins/400.css';
+@import '@fontsource/poppins/500.css';
+@import '@fontsource/poppins/600.css';
+@import '@fontsource/poppins/700.css';
+
:root {
--accent: #4f46e5;
--deep: #1e1b4b;
@@ -158,6 +163,7 @@ body.controls {
border: 1px solid var(--lavender);
background: #fff;
color: var(--deep);
+ font-family: 'Poppins', system-ui, sans-serif;
box-shadow: 0 12px 30px rgba(15, 12, 45, 0.28);
overflow: hidden;
-webkit-app-region: drag;
@@ -175,60 +181,95 @@ body.controls #head {
display: flex;
align-items: center;
gap: 8px;
- padding: 11px 14px;
+ white-space: nowrap;
+ padding: 10px 10px 10px 14px;
border-bottom: 1px solid #eef2ff;
font-size: 12.5px;
}
body.controls.collapsed #head {
border-bottom: 0;
- padding: 9px 14px;
+ padding: 8px 8px 8px 14px;
}
body.controls #dot {
width: 8px;
height: 8px;
+ flex-shrink: 0;
border-radius: 50%;
- background: var(--muted);
+ background: #9ca3af;
}
body.controls[data-state='recording'] #dot {
background: #dc2626;
- animation: blink 1.4s ease-in-out infinite;
+ box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
+ animation: blink 1.6s ease-in-out infinite;
+}
+
+body.controls.collapsed[data-state='recording'] #dot {
+ background: #f87171;
}
@keyframes blink {
50% {
- opacity: 0.25;
+ opacity: 0.35;
}
}
body.controls #label {
- flex-grow: 1;
+ margin-right: auto;
font-weight: 600;
}
body.controls #counter {
+ font-size: 11.5px;
+ font-weight: 500;
font-variant-numeric: tabular-nums;
- opacity: 0.65;
+ color: var(--muted);
+}
+
+body.controls.collapsed #counter {
+ color: var(--lavender);
}
body.controls #badge {
- padding: 2px 8px;
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ padding: 3px 9px;
border-radius: 999px;
- background: var(--secondary, #eef2ff);
+ background: #eef2ff;
color: var(--accent);
- font-size: 10.5px;
+ font-size: 11px;
font-weight: 600;
}
+body.controls #pillWriting {
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ font-size: 11px;
+ color: var(--lavender);
+}
+
body.controls #collapse {
display: flex;
- padding: 3px;
+ align-items: center;
+ justify-content: center;
+ width: 28px;
+ height: 28px;
+ padding: 0;
border: 0;
+ border-radius: 8px;
background: transparent;
- color: currentColor;
- opacity: 0.6;
+ color: var(--muted);
+}
+
+body.controls.collapsed #collapse {
+ order: 9;
+ border-radius: 50%;
+ background: rgba(199, 210, 254, 0.16);
+ color: #fff;
}
body.controls #collapse svg {
@@ -241,9 +282,9 @@ body.controls #body {
}
body.controls #preview {
- height: 128px;
- margin-bottom: 11px;
- border: 1px solid var(--lavender);
+ position: relative;
+ height: 150px;
+ border: 1px solid #e0e7ff;
border-radius: 10px;
background: #eef2ff;
overflow: hidden;
@@ -257,81 +298,265 @@ body.controls #shot {
object-position: top center;
}
-body.controls #stepTitle {
- margin: 0;
+body.controls #veil {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ background: rgba(238, 242, 255, 0.72);
+}
+
+body.controls[data-state='paused'] #veil {
+ background: rgba(255, 255, 255, 0.55);
+}
+
+body.controls #veilText {
+ font-size: 11.5px;
+ font-weight: 600;
+}
+
+body.controls #veilPause {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 40px;
+ height: 40px;
+ border-radius: 50%;
+ background: var(--deep);
+ color: #fff;
+}
+
+body.controls #remove {
+ position: absolute;
+ top: 8px;
+ right: 8px;
+ justify-content: center;
+ width: 28px;
+ height: 28px;
+ padding: 0;
+ border-radius: 8px;
+ background: rgba(255, 255, 255, 0.94);
+}
+
+body.controls #remove svg {
+ width: 13px;
+ height: 13px;
+}
+
+body.controls #stepTitle,
+body.controls #writing {
+ margin: 11px 0 0;
font-size: 13px;
+ line-height: 1.45;
+}
+
+body.controls #stepTitle {
font-weight: 600;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+}
+
+body.controls #writing {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ font-weight: 500;
+ color: var(--muted);
+}
+
+body.controls #writing svg,
+body.controls #pillWriting svg {
+ color: var(--accent);
+ animation: spin 0.9s linear infinite;
+}
+
+body.controls #pillWriting svg {
+ color: var(--lavender);
+}
+
+@keyframes spin {
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+body.controls #skeleton {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ margin-top: 13px;
+}
+
+body.controls #skeleton span {
+ display: block;
+ height: 10px;
+ width: 78%;
+ border-radius: 5px;
+ background: linear-gradient(90deg, #eef2ff 0%, #e0e7ff 50%, #eef2ff 100%);
+ background-size: 200% 100%;
+ animation: shimmer 1.4s linear infinite;
+}
+
+body.controls #skeleton span + span {
+ width: 38%;
+}
+
+@keyframes shimmer {
+ from {
+ background-position: 100% 0;
+ }
+ to {
+ background-position: -100% 0;
+ }
}
body.controls #stepMeta {
- margin: 3px 0 0;
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ margin-top: 5px;
font-size: 11px;
color: var(--muted);
}
+body.controls #source {
+ padding: 3px 5px;
+ border-radius: 4px;
+ font-size: 9px;
+ font-weight: 700;
+ line-height: 1;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+}
+
+body.controls #source.basic {
+ background: var(--deep);
+ color: var(--lavender);
+}
+
+body.controls #source.ai {
+ background: #eef2ff;
+ color: var(--accent);
+}
+
body.controls #intro {
display: flex;
- gap: 11px;
+ align-items: center;
+ gap: 12px;
padding-bottom: 2px;
}
+body.controls.waiting #intro {
+ flex-direction: column;
+ gap: 8px;
+ padding: 12px 0 4px;
+ text-align: center;
+}
+
+body.controls.waiting #intro > div:last-child {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+
body.controls #mascot {
display: flex;
flex-shrink: 0;
- margin-top: 1px;
+}
+
+body.controls.waiting #mascot svg {
+ width: 76px;
+ height: 76px;
+}
+
+body.controls .flash {
+ animation: camflash 3s ease infinite;
+}
+
+@keyframes camflash {
+ 0%,
+ 88%,
+ 100% {
+ opacity: 0;
+ }
+ 92% {
+ opacity: 0.7;
+ }
}
body.controls #tip {
margin: 0;
- font-size: 12px;
- line-height: 1.55;
+ font-size: 12.5px;
+ line-height: 1.5;
+ color: var(--deep);
+}
+
+body.controls.waiting #tip {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+body.controls #keyHint {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ margin: 6px 0 0;
+ font-size: 11px;
color: var(--muted);
}
+body.controls #hintKey {
+ padding: 1px 6px;
+ border: 1px solid var(--lavender);
+ border-radius: 5px;
+ background: #eef2ff;
+ color: var(--deep);
+ font: inherit;
+ font-size: 10.5px;
+ font-weight: 600;
+}
+
body.controls #modeBlock {
padding: 14px 14px 0;
}
body.controls #modeLabel {
- margin: 0 0 8px;
+ margin: 0 0 7px;
font-size: 10.5px;
font-weight: 600;
- letter-spacing: 0.1em;
+ letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--muted);
}
body.controls #modes {
display: flex;
- gap: 2px;
- padding: 2px;
- border-radius: 10px;
- background: #eef2ff;
+ gap: 6px;
}
body.controls #foot {
display: flex;
gap: 8px;
- padding: 13px 14px 14px;
+ padding: 12px 14px 14px;
}
body.controls #foot button {
flex-grow: 1;
+ flex-basis: 0;
justify-content: center;
-}
-
-body.controls #foot button.primary {
- flex-grow: 1.3;
+ height: 40px;
}
body.controls button {
-webkit-app-region: no-drag;
display: flex;
align-items: center;
- gap: 6px;
+ gap: 7px;
padding: 9px 12px;
border: 1px solid var(--lavender);
border-radius: 10px;
@@ -339,6 +564,7 @@ body.controls button {
color: var(--deep);
font: inherit;
font-size: 13px;
+ font-weight: 600;
cursor: pointer;
}
@@ -358,8 +584,7 @@ body.controls button:disabled:hover {
body.controls button.primary {
border-color: transparent;
background: var(--deep);
- color: var(--lavender);
- font-weight: 600;
+ color: #fff;
}
body.controls button svg {
@@ -369,21 +594,22 @@ body.controls button svg {
body.controls button.mode {
flex-grow: 1;
+ flex-basis: 0;
justify-content: center;
- padding: 7px;
- border: 0;
+ gap: 5px;
+ height: 32px;
+ padding: 0 8px;
border-radius: 8px;
- background: transparent;
- color: var(--muted);
- font-size: 12px;
+ font-size: 11.5px;
}
-body.controls button.mode.active {
- background: var(--deep);
- color: var(--lavender);
- font-weight: 600;
+body.controls button.mode svg {
+ width: 13px;
+ height: 13px;
}
-body.controls.collapsed #collapse {
- order: 9;
+body.controls button.mode.active {
+ border-color: transparent;
+ background: var(--deep);
+ color: #fff;
}
diff --git a/apps/desktop/src/renderer/overlay.ts b/apps/desktop/src/renderer/overlay.ts
index 9f1511e..287b293 100644
--- a/apps/desktop/src/renderer/overlay.ts
+++ b/apps/desktop/src/renderer/overlay.ts
@@ -2,10 +2,12 @@ import './overlay.css';
import { boundary } from './overlay/boundary';
import { controls } from './overlay/controls';
import { editor } from './overlay/editor';
+import { intro } from './overlay/intro';
const [role, originX, originY] = window.location.hash.slice(1).split(':');
const origin = { x: Number(originX) || 0, y: Number(originY) || 0 };
if (role === 'editor') editor(origin);
else if (role === 'boundary') boundary();
+else if (role === 'intro') intro();
else controls();
diff --git a/apps/desktop/src/renderer/overlay/boundary.ts b/apps/desktop/src/renderer/overlay/boundary.ts
index 4b80303..f74b489 100644
--- a/apps/desktop/src/renderer/overlay/boundary.ts
+++ b/apps/desktop/src/renderer/overlay/boundary.ts
@@ -4,6 +4,6 @@ export function boundary(): void {
document.body.className = 'boundary';
document.body.append(el('div', { id: 'frame' }));
const apply = (state: string) => document.body.setAttribute('data-state', state);
- window.mimikOverlay.state().then(apply);
- window.mimikOverlay.onUpdate(apply);
+ window.mimikOverlay.view().then((view) => apply(view.state));
+ window.mimikOverlay.onUpdate((view) => apply(view.state));
}
diff --git a/apps/desktop/src/renderer/overlay/camera-mascot.ts b/apps/desktop/src/renderer/overlay/camera-mascot.ts
new file mode 100644
index 0000000..98d484e
--- /dev/null
+++ b/apps/desktop/src/renderer/overlay/camera-mascot.ts
@@ -0,0 +1,38 @@
+import {
+ CAMERA_MASCOT_DROP,
+ CAMERA_MASCOT_PARTS,
+ CAMERA_MASCOT_VIEW_BOX,
+ MASCOT_BODY,
+ MASCOT_CROWN,
+ MASCOT_FACES,
+ MASCOT_SEAM,
+} from '@mimik/ui';
+import { svg } from './svg';
+
+export function cameraMascot(size: number): SVGSVGElement {
+ const face = MASCOT_FACES.happy;
+ const camera = CAMERA_MASCOT_PARTS;
+ const line = (d: string, width: number) =>
+ svg('path', { d, stroke: 'var(--lavender)', 'stroke-width': width, fill: 'none', 'stroke-linecap': 'round' });
+ const base = svg('g', { transform: `translate(0 ${CAMERA_MASCOT_DROP})` });
+ base.append(
+ svg('rect', { ...MASCOT_BODY, fill: 'var(--deep)' }),
+ svg('path', { d: MASCOT_CROWN, fill: 'var(--violet-mid)' }),
+ svg('rect', { ...MASCOT_SEAM, fill: 'var(--lavender)' }),
+ ...face.eyes.map((d) => line(d, face.eyeWidth)),
+ line(face.mouth, face.mouthWidth),
+ );
+ const root = svg('svg', { viewBox: CAMERA_MASCOT_VIEW_BOX, width: size, height: size, 'aria-hidden': 'true' });
+ root.append(
+ base,
+ svg('rect', { ...camera.body, fill: 'var(--violet-mid)', stroke: 'var(--violet-mid)', 'stroke-width': 2 }),
+ svg('circle', { ...camera.lensRing, fill: 'var(--deep)', stroke: 'var(--violet-mid)', 'stroke-width': 2 }),
+ svg('circle', { ...camera.lens, fill: '#080818' }),
+ svg('circle', { ...camera.glint, fill: 'var(--lavender)', opacity: 0.4 }),
+ svg('rect', { ...camera.flashUnit, fill: 'var(--lavender)', opacity: 0.7 }),
+ svg('circle', { ...camera.flash, fill: 'var(--lavender)', class: 'flash' }),
+ svg('circle', { ...camera.light, fill: 'var(--accent)' }),
+ ...camera.hands.map((hand) => svg('ellipse', { ...hand, fill: 'var(--deep)' })),
+ );
+ return root;
+}
diff --git a/apps/desktop/src/renderer/overlay/controls.ts b/apps/desktop/src/renderer/overlay/controls.ts
index c1d9b2c..242c4e4 100644
--- a/apps/desktop/src/renderer/overlay/controls.ts
+++ b/apps/desktop/src/renderer/overlay/controls.ts
@@ -1,18 +1,12 @@
+import type { OverlayView } from '../../main/overlay';
import { icon } from '../icons';
+import { cameraMascot } from './camera-mascot';
import { el } from './el';
-import { mascot } from './mascot';
-import type { Region } from './types';
-
-interface LastStep {
- index: number;
- title: string;
- src: string;
-}
const MODES = [
- { id: 'window', label: 'Window' },
- { id: 'screen', label: 'Screen' },
- { id: 'area', label: 'Area' },
+ { id: 'window', label: 'Window', glyph: 'window' },
+ { id: 'screen', label: 'Screen', glyph: 'monitor' },
+ { id: 'area', label: 'Area', glyph: 'area' },
] as const;
const MODE_COMMAND: Record<string, string> = {
@@ -32,22 +26,39 @@ export function controls(): void {
const label = el('span', { id: 'label' }, 'Ready');
const counter = el('span', { id: 'counter' });
const badge = el('span', { id: 'badge' });
+ const pillWriting = el('span', { id: 'pillWriting' }, icon('loader', 12), 'writing');
const collapse = el('button', { id: 'collapse', type: 'button', title: 'Collapse' });
collapse.append(icon('chevronDown'));
- const head = el('div', { id: 'head' }, dot, label, counter, badge, collapse);
+ const head = el('div', { id: 'head' }, dot, label, counter, badge, pillWriting, collapse);
const shot = el('img', { id: 'shot', alt: '' });
- const preview = el('div', { id: 'preview' }, shot);
+ const veilText = el('span', { id: 'veilText' });
+ const veilMascot = el('div', { id: 'veilMascot' }, cameraMascot(56));
+ const veilPause = el('span', { id: 'veilPause' }, icon('pause', 16));
+ const veil = el('div', { id: 'veil' }, veilMascot, veilPause, veilText);
+ const remove = el('button', { id: 'remove', type: 'button', title: 'Remove this step' });
+ remove.setAttribute('aria-label', 'Remove this step');
+ remove.append(icon('trash', 13));
+ const preview = el('div', { id: 'preview' }, shot, veil, remove);
+
const stepTitle = el('p', { id: 'stepTitle' });
- const stepMeta = el('p', { id: 'stepMeta' });
+ const writing = el('p', { id: 'writing' }, icon('loader', 13), 'Writing step description…');
+ const skeleton = el('div', { id: 'skeleton' }, el('span', {}), el('span', {}));
+ const source = el('span', { id: 'source' });
+ const metaText = el('span', { id: 'metaText' });
+ const stepMeta = el('div', { id: 'stepMeta' }, source, metaText);
+
const tip = el('p', { id: 'tip' });
- const intro = el('div', { id: 'intro' }, el('div', { id: 'mascot' }, mascot()), tip);
- const body = el('div', { id: 'body' }, preview, stepTitle, stepMeta, intro);
+ const hintKey = el('kbd', { id: 'hintKey' });
+ const hintText = el('span', {});
+ const hint = el('p', { id: 'keyHint' }, hintKey, hintText);
+ const intro = el('div', { id: 'intro' }, el('div', { id: 'mascot' }, cameraMascot(56)), el('div', {}, tip, hint));
+ const body = el('div', { id: 'body' }, preview, stepTitle, writing, skeleton, stepMeta, intro);
const modeLabel = el('p', { id: 'modeLabel' }, 'Capture mode');
const modeRow = el('div', { id: 'modes' });
- const modeButtons = MODES.map(({ id, label: text }) => {
- const button = el('button', { type: 'button', className: 'mode' }, text);
+ const modeButtons = MODES.map(({ id, label: text, glyph }) => {
+ const button = el('button', { type: 'button', className: 'mode' }, icon(glyph, 13), text);
button.dataset.mode = id;
button.addEventListener('click', () => window.mimikOverlay.command(MODE_COMMAND[id]));
modeRow.append(button);
@@ -65,17 +76,34 @@ export function controls(): void {
let shownIcon = '';
let shownChevron = '';
+ let shownMode = '';
- const render = (state: string, _region?: Region, last?: LastStep | null, mode?: string, busy = false) => {
+ const render = (view: OverlayView) => {
+ const { state, step, busy, starting, mode, shortcuts } = view;
const armed = state === 'armed';
+ const recording = state === 'recording';
+ const paused = state === 'paused';
+ const waiting = recording && !step && !busy;
+ const pending = Boolean(step?.pending);
+
document.body.setAttribute('data-state', state);
document.body.classList.toggle('collapsed', collapsed);
-
- label.textContent = state === 'recording' ? 'Recording' : state === 'paused' ? 'Paused' : 'Ready';
- counter.textContent = last ? String(last.index) : '';
- counter.hidden = !last;
- badge.textContent = mode === 'screen' ? 'Screen' : mode === 'region' ? 'Area' : 'Window';
- badge.hidden = state !== 'armed';
+ document.body.classList.toggle('waiting', waiting);
+ document.body.classList.toggle('busy', busy);
+
+ label.textContent = starting ? 'Starting…' : recording ? 'Recording' : paused ? 'Paused' : 'Ready';
+ const count = step?.index ?? 0;
+ counter.textContent = `${count} ${count === 1 ? 'step' : 'steps'}`;
+ counter.hidden = armed;
+
+ const modeId = MODE_ID[mode] ?? 'window';
+ if (modeId !== shownMode) {
+ shownMode = modeId;
+ const shown = MODES.find((candidate) => candidate.id === modeId) ?? MODES[0];
+ badge.replaceChildren(icon(shown.glyph, 12), shown.label);
+ }
+ badge.hidden = !armed;
+ pillWriting.hidden = !(collapsed && pending);
const chevron = collapsed ? 'up' : 'down';
if (chevron !== shownChevron) {
@@ -84,67 +112,76 @@ export function controls(): void {
}
collapse.title = collapsed ? 'Expand' : 'Collapse';
- if (last) {
- if (shot.getAttribute('src') !== last.src) shot.src = last.src;
- stepTitle.textContent = last.title;
- stepMeta.textContent = `Step ${last.index}`;
- }
- preview.hidden = !last;
- stepTitle.hidden = !last;
- stepMeta.hidden = !last;
+ if (step && shot.getAttribute('src') !== step.src) shot.src = step.src;
+ preview.hidden = armed || !(busy || step);
+ shot.hidden = !step;
+ veil.hidden = !(busy || paused);
+ veilMascot.hidden = !busy;
+ veilPause.hidden = busy || !paused;
+ veilText.hidden = !busy;
+ veilText.textContent = `Capturing step ${count + 1}…`;
+ remove.hidden = !step || busy || armed;
+
+ const settled = Boolean(step) && !busy && !paused;
+ stepTitle.textContent = step?.title ?? '';
+ stepTitle.hidden = !settled || pending;
+ writing.hidden = !settled || !pending;
+ skeleton.hidden = !busy;
+ stepMeta.hidden = !settled;
+ source.hidden = pending;
+ source.textContent = step?.source === 'ai' ? 'AI' : 'Basic';
+ source.className = step?.source === 'ai' ? 'ai' : 'basic';
+ metaText.textContent = [step ? `Step ${step.index}` : '', step?.app ?? ''].filter(Boolean).join(' · ');
+
+ intro.hidden = !(armed || waiting);
tip.textContent = armed
? 'Press Start, then work as you normally would. Every click becomes a step.'
- : 'Waiting for your first click.';
- intro.hidden = Boolean(last) || state === 'paused';
- body.hidden = collapsed || (state === 'paused' && !last);
+ : 'Waiting for your first click';
+ const key = armed ? shortcuts.startStop : shortcuts.capture;
+ hint.hidden = !key;
+ hintKey.textContent = key ?? '';
+ hintText.textContent = armed ? 'starts and stops' : 'captures where the pointer is';
+ body.hidden = collapsed || (paused && !step);
- modes.hidden = collapsed || state !== 'paused';
- for (const button of modeButtons) button.classList.toggle('active', button.dataset.mode === MODE_ID[mode ?? '']);
+ modes.hidden = collapsed || !paused;
+ for (const button of modeButtons) button.classList.toggle('active', button.dataset.mode === modeId);
if (state !== shownIcon) {
shownIcon = state;
secondary.replaceChildren();
- if (!armed) secondary.append(icon(state === 'recording' ? 'pause' : 'play'));
- secondary.append(armed ? 'Close' : state === 'recording' ? 'Pause' : 'Resume');
+ if (!armed) secondary.append(icon(recording ? 'pause' : 'play'));
+ secondary.append(armed ? 'Close' : recording ? 'Pause' : 'Resume');
primary.replaceChildren(icon(armed ? 'video' : 'check'));
primary.append(armed ? 'Start' : 'Finish');
}
- secondary.dataset.command = armed ? 'cancel' : state === 'recording' ? 'pause' : 'resume';
+ secondary.dataset.command = armed ? 'cancel' : recording ? 'pause' : 'resume';
primary.dataset.command = armed ? 'start' : 'stop';
- primary.disabled = busy && !armed;
+ primary.disabled = starting || (busy && !armed);
foot.hidden = collapsed;
requestAnimationFrame(report);
};
- let latest: [string, Region | undefined, LastStep | null | undefined, string | undefined, boolean] = [
- 'armed',
- undefined,
- null,
- undefined,
- false,
- ];
- const paint = () => render(...latest);
+ let latest: OverlayView | null = null;
+ const paint = () => {
+ if (latest) render(latest);
+ };
primary.addEventListener('click', () => window.mimikOverlay.command(primary.dataset.command ?? 'start'));
secondary.addEventListener('click', () => window.mimikOverlay.command(secondary.dataset.command ?? 'cancel'));
+ remove.addEventListener('click', () => window.mimikOverlay.command('remove'));
collapse.addEventListener('click', () => {
collapsed = !collapsed;
paint();
});
shot.addEventListener('load', report);
- Promise.all([
- window.mimikOverlay.state(),
- window.mimikOverlay.last(),
- window.mimikOverlay.mode(),
- window.mimikOverlay.busy(),
- ]).then(([state, last, mode, busy]) => {
- latest = [state, undefined, last, mode, busy];
+ window.mimikOverlay.view().then((view) => {
+ latest = latest ?? view;
paint();
});
- window.mimikOverlay.onUpdate((state, region, last, mode, busy) => {
- latest = [state, region, last, mode, busy];
+ window.mimikOverlay.onUpdate((view) => {
+ latest = view;
paint();
});
}
diff --git a/apps/desktop/src/renderer/overlay/editor.ts b/apps/desktop/src/renderer/overlay/editor.ts
index 5175487..946c44e 100644
--- a/apps/desktop/src/renderer/overlay/editor.ts
+++ b/apps/desktop/src/renderer/overlay/editor.ts
@@ -108,7 +108,7 @@ export function editor(origin: { x: number; y: number }): void {
rect = current;
paint();
});
- window.mimikOverlay.onUpdate((_state, current) => {
+ window.mimikOverlay.onUpdate(({ region: current }) => {
rect = current;
paint();
});
diff --git a/apps/desktop/src/renderer/overlay/intro.ts b/apps/desktop/src/renderer/overlay/intro.ts
new file mode 100644
index 0000000..55f2365
--- /dev/null
+++ b/apps/desktop/src/renderer/overlay/intro.ts
@@ -0,0 +1,6 @@
+import { showStartNotification } from '@mimik/core/capture/start-notification';
+
+export function intro(): void {
+ document.body.className = 'intro';
+ void showStartNotification().then(() => window.mimikOverlay.command('intro:done'));
+}