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): let the capture settings set the zoom level

Luis Ortizbd4d2a2bc4aa
diff --git a/AGENTS.md b/AGENTS.md
index de97574..7aaa7a7 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -599,6 +599,12 @@ gives 2.25, a 1200 px window gives 1, and a small one gives 1 — the same butto
every page of the guide, which a fixed fraction of the frame cannot do. The level is stored beside
the region in `edits.zoomLevel`, so it can be re-derived or overridden later without recapturing.
+`zoomLevel` in capture settings overrides the automatic choice; `null` means derive it. Main cannot
+value-import core, so `settings.ts` carries its own three-line `snapZoom` rather than the one in
+`record.ts` — the same constraint that keeps `clamp` local in `capture/screenshot.ts`. The renderer
+has no such limit and reads `MIN_ZOOM`, `MAX_ZOOM` and `ZOOM_STEP` from core to build the picker, so
+the list of levels cannot drift from the snapping.
+
It goes in `edits.viewport` rather than `bounds` because `resolveViewport` returns that verbatim, so
the region is exactly what was computed rather than what the padding rule makes of it, and
`resolveFrameViewport` gives the video exporter the same starting frame before it eases toward
@@ -829,6 +835,7 @@ read by main rather than by core, because none of them mean anything to the exte
| `captureTyping` | on | Whether typing becomes a step |
| `typingDebounceMs` | 1200, clamped to 200–5000 | Quiet time that closes a typing session |
| `typingSmartDetection` | on | Off means the keystroke buffer is used and the field's value is never read |
+| `zoomLevel` | automatic | How far a step zooms toward the click: `null` derives it, or 1–5 in 0.25 steps |
| `shortcuts` | three accelerators | Global keys for start/stop, pause/resume and capture now |
`normaliseSettings` runs on every read and write, so an out-of-range delay clamps and an unknown
diff --git a/apps/desktop/src/main/capture/recorder.ts b/apps/desktop/src/main/capture/recorder.ts
index d268d58..517b97e 100644
--- a/apps/desktop/src/main/capture/recorder.ts
+++ b/apps/desktop/src/main/capture/recorder.ts
@@ -68,6 +68,7 @@ export interface CaptureRequest {
image: CaptureImage;
inputValue?: string;
cursor?: CursorMark;
+ zoomLevel?: number;
}
export interface RecorderHooks {
@@ -411,6 +412,7 @@ export class DesktopRecorder {
...(settings.showCursor && action === 'click'
? { cursor: { x: local.x, y: local.y, style: settings.cursorStyle, scale } }
: {}),
+ ...(settings.zoomLevel === null ? {} : { zoomLevel: settings.zoomLevel }),
});
}
diff --git a/apps/desktop/src/main/capture/settings.ts b/apps/desktop/src/main/capture/settings.ts
index ae38c78..3296088 100644
--- a/apps/desktop/src/main/capture/settings.ts
+++ b/apps/desktop/src/main/capture/settings.ts
@@ -10,6 +10,9 @@ const EVERY_CURSOR_STYLE: Record<CursorStyle, true> = { arrow: true, hand: true,
export const CURSOR_STYLES = Object.keys(EVERY_CURSOR_STYLE) as CursorStyle[];
export const CAPTURE_MODES: CaptureMode[] = ['window', 'screen', 'region'];
export const MAX_SCREENSHOT_DELAY_MS = 2000;
+const MIN_ZOOM = 1;
+const MAX_ZOOM = 5;
+const ZOOM_STEP = 0.25;
export const MIN_TYPING_DEBOUNCE_MS = 200;
export const MAX_TYPING_DEBOUNCE_MS = 5000;
@@ -29,6 +32,7 @@ export interface CaptureSettings {
captureTyping: boolean;
typingDebounceMs: number;
typingSmartDetection: boolean;
+ zoomLevel: number | null;
shortcuts: CaptureShortcuts;
}
@@ -42,6 +46,7 @@ export const DEFAULT_CAPTURE_SETTINGS: CaptureSettings = {
captureTyping: true,
typingDebounceMs: 1200,
typingSmartDetection: true,
+ zoomLevel: null,
shortcuts: {
startStop: 'Alt+Shift+R',
pauseResume: 'Alt+Shift+P',
@@ -74,6 +79,10 @@ function file(): string {
return join(app.getPath('userData'), 'capture-settings.json');
}
+function snapZoom(zoom: number): number {
+ return Math.min(Math.max(Math.round(zoom / ZOOM_STEP) * ZOOM_STEP, MIN_ZOOM), MAX_ZOOM);
+}
+
export function normaliseSettings(input: Partial<CaptureSettings>): CaptureSettings {
const delay = Number(input.screenshotDelayMs);
const debounce = input.typingDebounceMs === undefined ? Number.NaN : Number(input.typingDebounceMs);
@@ -93,6 +102,7 @@ export function normaliseSettings(input: Partial<CaptureSettings>): CaptureSetti
? Math.min(Math.max(Math.round(debounce), MIN_TYPING_DEBOUNCE_MS), MAX_TYPING_DEBOUNCE_MS)
: DEFAULT_CAPTURE_SETTINGS.typingDebounceMs,
typingSmartDetection: flag(input.typingSmartDetection, DEFAULT_CAPTURE_SETTINGS.typingSmartDetection),
+ zoomLevel: Number.isFinite(Number(input.zoomLevel)) ? snapZoom(Number(input.zoomLevel)) : null,
shortcuts: shortcuts(input.shortcuts),
};
}
diff --git a/apps/desktop/src/renderer/SettingsPanel.tsx b/apps/desktop/src/renderer/SettingsPanel.tsx
index 4993093..7cacecf 100644
--- a/apps/desktop/src/renderer/SettingsPanel.tsx
+++ b/apps/desktop/src/renderer/SettingsPanel.tsx
@@ -1,5 +1,6 @@
import { validateApiKey } from '@mimik/core/capture/ai/validate';
import { i18n } from '@mimik/core/env';
+import { MAX_ZOOM, MIN_ZOOM, ZOOM_STEP } from '@mimik/core/screenshot/record';
import { CURSOR_STYLES } from '@mimik/core/screenshot/types';
import { Input } from '@mimik/ui/components/ui/input';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@mimik/ui/components/ui/select';
@@ -32,6 +33,11 @@ const KEYS: { id: keyof CaptureShortcuts; labelKey: string }[] = [
const NUMBER = 'h-9 w-24 rounded-lg border-border text-[13px] font-medium';
+const ZOOM_LEVELS = Array.from(
+ { length: Math.round((MAX_ZOOM - MIN_ZOOM) / ZOOM_STEP) + 1 },
+ (_, i) => MIN_ZOOM + i * ZOOM_STEP,
+);
+
function Field({ label, children }: { label: string; children: ReactNode }) {
return (
<label className="flex items-center gap-3 text-sm text-foreground">
@@ -180,6 +186,29 @@ export default function SettingsPanel() {
<span className="text-sm text-muted-foreground">{i18n.t('desktop_milliseconds')}</span>
</Field>
+ <label className="flex items-center gap-3 text-sm text-foreground">
+ <span className="mr-auto flex flex-col gap-0.5">
+ {i18n.t('desktop_zoomLevel')}
+ <span className="text-xs text-muted-foreground">{i18n.t('desktop_zoomLevelHint')}</span>
+ </span>
+ <Select
+ value={settings.zoomLevel === null ? 'auto' : String(settings.zoomLevel)}
+ onValueChange={(v) => save({ zoomLevel: v === 'auto' ? null : Number(v) })}
+ >
+ <SelectTrigger className="h-9 w-48">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="auto">{i18n.t('desktop_zoomAuto')}</SelectItem>
+ {ZOOM_LEVELS.map((level) => (
+ <SelectItem key={level} value={String(level)}>
+ {String(level)}&times;
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </label>
+
{settings.captureMode === 'region' && (
<Toggle
checked={settings.captureOutsideClicks}
diff --git a/apps/desktop/src/renderer/capture-sink.ts b/apps/desktop/src/renderer/capture-sink.ts
index 2e54d4a..a2dc4ca 100644
--- a/apps/desktop/src/renderer/capture-sink.ts
+++ b/apps/desktop/src/renderer/capture-sink.ts
@@ -22,7 +22,11 @@ import { screenshotForElement } from '@mimik/core/screenshot/record';
import type { CursorMark } from '@mimik/core/screenshot/types';
import { describeStep } from './ai';
-export type DesktopCaptureStepData = CaptureStepData & { cursor?: CursorMark; inputValue?: string };
+export type DesktopCaptureStepData = CaptureStepData & {
+ cursor?: CursorMark;
+ inputValue?: string;
+ zoomLevel?: number;
+};
export class DesktopCaptureSink implements CaptureSink {
async startGuide(): Promise<string> {
@@ -49,6 +53,7 @@ export class DesktopCaptureSink implements CaptureSink {
cursor: data.cursor ?? null,
targetColor,
zoom: 'click',
+ zoomLevel: data.zoomLevel,
},
meta,
);
diff --git a/src/locales/de.yml b/src/locales/de.yml
index 97c2439..9bdb5a9 100644
--- a/src/locales/de.yml
+++ b/src/locales/de.yml
@@ -185,6 +185,9 @@ desktop:
cardKeyboard: "Tastatur"
cardGlobalKeys: "Globale Tasten"
cardGlobalKeysHint: "Werden jeder Anwendung entzogen, solange Mimik läuft."
+ zoomLevel: "Auf den Klick zoomen"
+ zoomLevelHint: "Neue Aufzeichnungen starten hier. Automatisch hält alle Schritte gleich groß."
+ zoomAuto: "Automatisch"
captureKeys: "Kürzel und benannte Tasten aufzeichnen"
captureTyping: "Eingaben aufzeichnen"
typingDebounce: "Eingabeschritt beenden nach"
diff --git a/src/locales/en.yml b/src/locales/en.yml
index 12b997a..75bb0f3 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -185,6 +185,9 @@ desktop:
cardKeyboard: "Keyboard"
cardGlobalKeys: "Global keys"
cardGlobalKeysHint: "Taken from every application while Mimik is running."
+ zoomLevel: "Zoom toward the click"
+ zoomLevelHint: "New recordings start here. Automatic keeps every step the same size."
+ zoomAuto: "Automatic"
captureKeys: "Record shortcuts and named keys"
captureTyping: "Record what you type"
typingDebounce: "Close a typing step after"
diff --git a/src/locales/es.yml b/src/locales/es.yml
index cba8e2b..5f4d7b9 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -185,6 +185,9 @@ desktop:
cardKeyboard: "Teclado"
cardGlobalKeys: "Teclas globales"
cardGlobalKeysHint: "Se toman de todas las aplicaciones mientras Mimik está en ejecución."
+ zoomLevel: "Acercar hacia el clic"
+ zoomLevelHint: "Las grabaciones nuevas empiezan aquí. Automático mantiene todos los pasos del mismo tamaño."
+ zoomAuto: "Automático"
captureKeys: "Registrar atajos y teclas con nombre"
captureTyping: "Registrar lo que escribes"
typingDebounce: "Cerrar el paso de escritura tras"
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index 986f34d..6966342 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -185,6 +185,9 @@ desktop:
cardKeyboard: "Clavier"
cardGlobalKeys: "Touches globales"
cardGlobalKeysHint: "Prises à toutes les applications tant que Mimik est en cours d’exécution."
+ zoomLevel: "Zoomer vers le clic"
+ zoomLevelHint: "Les nouveaux enregistrements partent d’ici. Automatique garde toutes les étapes à la même taille."
+ zoomAuto: "Automatique"
captureKeys: "Enregistrer les raccourcis et touches nommées"
captureTyping: "Enregistrer ce que vous tapez"
typingDebounce: "Clôturer l'étape de saisie après"
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index 17b17ca..455bbcd 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -185,6 +185,9 @@ desktop:
cardKeyboard: "Teclado"
cardGlobalKeys: "Teclas globais"
cardGlobalKeysHint: "Retiradas de todos os aplicativos enquanto o Mimik estiver em execução."
+ zoomLevel: "Aproximar no clique"
+ zoomLevelHint: "Novas gravações começam aqui. Automático mantém todas as etapas do mesmo tamanho."
+ zoomAuto: "Automático"
captureKeys: "Registrar atalhos e teclas nomeadas"
captureTyping: "Registrar o que você digita"
typingDebounce: "Encerrar a etapa de digitação após"
diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml
index ef0eac0..8aa02c2 100644
--- a/src/locales/zh-CN.yml
+++ b/src/locales/zh-CN.yml
@@ -185,6 +185,9 @@ desktop:
cardKeyboard: "键盘"
cardGlobalKeys: "全局快捷键"
cardGlobalKeysHint: "Mimik 运行期间会从所有应用程序中接管这些按键。"
+ zoomLevel: "向点击处缩放"
+ zoomLevelHint: "新录制从这里开始。自动会让每一步保持相同大小。"
+ zoomAuto: "自动"
captureKeys: "记录快捷键和命名按键"
captureTyping: "记录输入内容"
typingDebounce: "输入步骤结束延迟"