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 📖

refactor(desktop): name the shortcut settings record and pause, keeping saved shortcuts

Luis Ortizb7de051e194d
diff --git a/apps/desktop/scripts/check-overlay.ts b/apps/desktop/scripts/check-overlay.ts
index 6e67d7c..6885411 100644
--- a/apps/desktop/scripts/check-overlay.ts
+++ b/apps/desktop/scripts/check-overlay.ts
@@ -69,7 +69,7 @@ app.whenReady().then(async () => {
() => mode,
{
introFrame: async (): Promise<Rect> => overlay.region,
- shortcuts: () => ({ startStop: 'Alt+Shift+R', capture: 'Alt+Shift+C' }),
+ shortcuts: () => ({ record: 'Alt+Shift+R', capture: 'Alt+Shift+C' }),
},
);
@@ -467,12 +467,12 @@ app.whenReady().then(async () => {
'the controls bar is ignored, a point away from it is not',
);
- const keys = { startStop: 'Alt+Shift+F13', pauseResume: 'Alt+Shift+F14', capture: 'Alt+Shift+F15' };
+ const keys = { record: 'Alt+Shift+F13', pause: 'Alt+Shift+F14', capture: 'Alt+Shift+F15' };
const fired: string[] = [];
const refusedIdle = bindShortcuts(shortcutMap(keys, false), (name) => fired.push(name));
const idleOnly =
- globalShortcut.isRegistered(keys.startStop) &&
- !globalShortcut.isRegistered(keys.pauseResume) &&
+ globalShortcut.isRegistered(keys.record) &&
+ !globalShortcut.isRegistered(keys.pause) &&
!globalShortcut.isRegistered(keys.capture);
const refusedRecording = bindShortcuts(shortcutMap(keys, true), (name) => fired.push(name));
const allThree = Object.values(keys).every((key) => globalShortcut.isRegistered(key));
@@ -500,7 +500,7 @@ app.whenReady().then(async () => {
'the same map is a no-op, so a shortcut never unregisters itself from inside its own handler',
);
- const clash = bindShortcuts(shortcutMap({ ...keys, startStop: 'NotAKey+@@' }, false), () => {});
+ const clash = bindShortcuts(shortcutMap({ ...keys, record: 'NotAKey+@@' }, false), () => {});
unbindShortcuts();
check(
'an unusable accelerator is reported, not thrown',
diff --git a/apps/desktop/src/main/__tests__/recorder-rules.test.ts b/apps/desktop/src/main/__tests__/recorder-rules.test.ts
index 3aab309..500a219 100644
--- a/apps/desktop/src/main/__tests__/recorder-rules.test.ts
+++ b/apps/desktop/src/main/__tests__/recorder-rules.test.ts
@@ -74,15 +74,22 @@ describe('capture settings', () => {
typingDebounceMs: 50,
recordKeys: 'yes' as never,
captureMode: 'sideways' as never,
- shortcuts: { startStop: ' ', pauseResume: null, capture: 'Alt+F2' } as never,
+ shortcuts: { record: ' ', pause: null, capture: 'Alt+F2' } as never,
});
expect(knobs.screenshotDelayMs).toBe(2000);
expect(knobs.typingDebounceMs).toBe(MIN_TYPING_DEBOUNCE_MS);
expect(normaliseSettings({ typingDebounceMs: 90_000 }).typingDebounceMs).toBe(MAX_TYPING_DEBOUNCE_MS);
expect(knobs.recordKeys).toBe(DEFAULT_CAPTURE_SETTINGS.recordKeys);
expect(knobs.captureMode).toBe(DEFAULT_CAPTURE_SETTINGS.captureMode);
- expect(knobs.shortcuts).toEqual({ startStop: null, pauseResume: null, capture: 'Alt+F2' });
- expect(normaliseSettings({}).shortcuts.startStop).toBe(DEFAULT_CAPTURE_SETTINGS.shortcuts.startStop);
+ expect(knobs.shortcuts).toEqual({ record: null, pause: null, capture: 'Alt+F2' });
+ expect(normaliseSettings({}).shortcuts.record).toBe(DEFAULT_CAPTURE_SETTINGS.shortcuts.record);
+ });
+
+ it('keeps the shortcuts saved under their earlier names', () => {
+ const saved = normaliseSettings({
+ shortcuts: { startStop: 'Ctrl+Alt+R', pauseResume: null, capture: 'Alt+F2' } as never,
+ });
+ expect(saved.shortcuts).toEqual({ record: 'Ctrl+Alt+R', pause: null, capture: 'Alt+F2' });
});
});
diff --git a/apps/desktop/src/main/capture/settings.ts b/apps/desktop/src/main/capture/settings.ts
index eba06aa..102b06b 100644
--- a/apps/desktop/src/main/capture/settings.ts
+++ b/apps/desktop/src/main/capture/settings.ts
@@ -11,8 +11,8 @@ export const MIN_TYPING_DEBOUNCE_MS = 200;
export const MAX_TYPING_DEBOUNCE_MS = 5000;
export interface CaptureShortcuts {
- startStop: string | null;
- pauseResume: string | null;
+ record: string | null;
+ pause: string | null;
capture: string | null;
}
@@ -36,8 +36,8 @@ export const DEFAULT_CAPTURE_SETTINGS: CaptureSettings = {
typingDebounceMs: 1000,
zoomLevel: null,
shortcuts: {
- startStop: 'Alt+Shift+R',
- pauseResume: 'Alt+Shift+P',
+ record: 'Alt+Shift+R',
+ pause: 'Alt+Shift+P',
capture: 'Alt+Shift+C',
},
};
@@ -53,12 +53,14 @@ function accelerator(value: unknown, fallback: string | null): string | null {
return trimmed === '' ? null : trimmed;
}
-function shortcuts(input: Partial<CaptureShortcuts> | undefined): CaptureShortcuts {
+type LegacyShortcuts = Partial<Record<'startStop' | 'pauseResume', unknown>>;
+
+function shortcuts(input: (Partial<CaptureShortcuts> & LegacyShortcuts) | undefined): CaptureShortcuts {
const given = input ?? {};
const fallback = DEFAULT_CAPTURE_SETTINGS.shortcuts;
return {
- startStop: accelerator(given.startStop, fallback.startStop),
- pauseResume: accelerator(given.pauseResume, fallback.pauseResume),
+ record: accelerator('record' in given ? given.record : given.startStop, fallback.record),
+ pause: accelerator('pause' in given ? given.pause : given.pauseResume, fallback.pause),
capture: accelerator(given.capture, fallback.capture),
};
}
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index 9bacbff..b0ad34c 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -287,7 +287,7 @@ function applyShortcuts(): void {
function onShortcut(name: ShortcutName): void {
if (!overlay) return;
const state = capture.getSnapshot().value;
- if (name === 'startStop') {
+ if (name === 'record') {
if (state === CaptureState.IDLE) {
whenPermitted(() => {
insert = null;
@@ -299,7 +299,7 @@ function onShortcut(name: ShortcutName): void {
overlay.run(state === CaptureState.ARMED ? 'start' : 'stop');
return;
}
- if (name === 'pauseResume') {
+ if (name === 'pause') {
if (state === CaptureState.RECORDING) overlay.run('pause');
else if (state === CaptureState.PAUSED) overlay.run('resume');
return;
@@ -477,7 +477,7 @@ if (!app.requestSingleInstanceLock()) {
},
shortcuts: () => {
const { shortcuts } = captureSettings ?? loadSettings();
- return { startStop: labelOf(shortcuts.startStop), capture: labelOf(shortcuts.capture) };
+ return { record: labelOf(shortcuts.record), capture: labelOf(shortcuts.capture) };
},
},
);
diff --git a/apps/desktop/src/main/overlay/index.ts b/apps/desktop/src/main/overlay/index.ts
index 5127a60..8f3f3d6 100644
--- a/apps/desktop/src/main/overlay/index.ts
+++ b/apps/desktop/src/main/overlay/index.ts
@@ -50,7 +50,7 @@ export interface OverlayProgress {
}
interface OverlayShortcuts {
- startStop: string | null;
+ record: string | null;
capture: string | null;
}
@@ -96,7 +96,7 @@ const BORDER = 3;
const CONTROLS = { width: 300, height: 190, margin: 24 };
const INTRO_LIMIT_MS = 6000;
const HIDE_SETTLE_MS = 60;
-const NO_SHORTCUTS: OverlayShortcuts = { startStop: null, capture: null };
+const NO_SHORTCUTS: OverlayShortcuts = { record: null, capture: null };
function rendererFile(): string {
return join(__dirname, '../renderer/overlay.html');
diff --git a/apps/desktop/src/main/shortcuts.ts b/apps/desktop/src/main/shortcuts.ts
index b63664b..333e680 100644
--- a/apps/desktop/src/main/shortcuts.ts
+++ b/apps/desktop/src/main/shortcuts.ts
@@ -5,8 +5,8 @@ export type ShortcutName = keyof CaptureShortcuts;
export function shortcutMap(shortcuts: CaptureShortcuts, recording: boolean): Record<ShortcutName, string | null> {
return {
- startStop: shortcuts.startStop,
- pauseResume: recording ? shortcuts.pauseResume : null,
+ record: shortcuts.record,
+ pause: recording ? shortcuts.pause : null,
capture: recording ? shortcuts.capture : null,
};
}
@@ -18,7 +18,7 @@ export function sameShortcuts(
a: Record<ShortcutName, string | null> | null,
b: Record<ShortcutName, string | null>,
): boolean {
- return a !== null && a.startStop === b.startStop && a.pauseResume === b.pauseResume && a.capture === b.capture;
+ return a !== null && a.record === b.record && a.pause === b.pause && a.capture === b.capture;
}
export function unbindShortcuts(): void {
diff --git a/apps/desktop/src/renderer/overlay/controls.ts b/apps/desktop/src/renderer/overlay/controls.ts
index 69eb889..0d6577e 100644
--- a/apps/desktop/src/renderer/overlay/controls.ts
+++ b/apps/desktop/src/renderer/overlay/controls.ts
@@ -285,7 +285,7 @@ export function controls(): void {
: resting
? i18n.t('desktop.tipPaused')
: i18n.t('desktop.tipWaiting');
- const key = armed ? shortcuts.startStop : shortcuts.capture;
+ const key = armed ? shortcuts.record : shortcuts.capture;
hint.hidden = intro.hidden || resting || !key || Boolean(narration);
voice.hidden = collapsed || !narration;
const voiceFailed = Boolean(narration?.reason);
diff --git a/apps/desktop/src/renderer/settings/SettingsPanel.tsx b/apps/desktop/src/renderer/settings/SettingsPanel.tsx
index a66b796..009906e 100644
--- a/apps/desktop/src/renderer/settings/SettingsPanel.tsx
+++ b/apps/desktop/src/renderer/settings/SettingsPanel.tsx
@@ -52,8 +52,8 @@ const MODES: { id: CaptureSettings['captureMode']; labelKey: string; Icon: typeo
{ id: 'area', labelKey: 'desktop.modeArea', Icon: Crop },
];
const KEYS: { id: keyof CaptureShortcuts; labelKey: string }[] = [
- { id: 'startStop', labelKey: 'desktop.shortcutStartStop' },
- { id: 'pauseResume', labelKey: 'desktop.shortcutPauseResume' },
+ { id: 'record', labelKey: 'desktop.shortcutRecord' },
+ { id: 'pause', labelKey: 'desktop.shortcutPause' },
{ id: 'capture', labelKey: 'desktop.shortcutCapture' },
];
diff --git a/packages/locales/de.yml b/packages/locales/de.yml
index e135754..29cfab4 100644
--- a/packages/locales/de.yml
+++ b/packages/locales/de.yml
@@ -280,8 +280,8 @@ desktop:
captureModeHint: "Fenster folgt der App, die du anklickst."
screenshotDelayHint: "Wartezeit vor dem Screenshot, für Menüs mit Animation."
seconds: "s"
- shortcutStartStop: "Aufnahme starten oder beenden"
- shortcutPauseResume: "Pausieren oder fortsetzen"
+ shortcutRecord: "Aufnahme starten oder beenden"
+ shortcutPause: "Pausieren oder fortsetzen"
shortcutCapture: "Jetzt einen Schritt aufnehmen"
shortcutPress: "Tasten drücken…"
shortcutClear: "Löschen"
diff --git a/packages/locales/en.yml b/packages/locales/en.yml
index 16397bb..06e2c7a 100644
--- a/packages/locales/en.yml
+++ b/packages/locales/en.yml
@@ -280,8 +280,8 @@ desktop:
captureModeHint: "Window follows the app you click."
screenshotDelayHint: "Wait before taking the screenshot, for menus that animate."
seconds: "s"
- shortcutStartStop: "Start or finish a recording"
- shortcutPauseResume: "Pause or resume"
+ shortcutRecord: "Start or finish a recording"
+ shortcutPause: "Pause or resume"
shortcutCapture: "Capture a step now"
shortcutPress: "Press keys…"
shortcutClear: "Clear"
diff --git a/packages/locales/es.yml b/packages/locales/es.yml
index 87a4646..96464d0 100644
--- a/packages/locales/es.yml
+++ b/packages/locales/es.yml
@@ -280,8 +280,8 @@ desktop:
captureModeHint: "Ventana sigue a la app en la que haces clic."
screenshotDelayHint: "Espera antes de la captura, para menús con animación."
seconds: "s"
- shortcutStartStop: "Iniciar o finalizar una grabación"
- shortcutPauseResume: "Pausar o reanudar"
+ shortcutRecord: "Iniciar o finalizar una grabación"
+ shortcutPause: "Pausar o reanudar"
shortcutCapture: "Capturar un paso ahora"
shortcutPress: "Pulsa las teclas…"
shortcutClear: "Borrar"
diff --git a/packages/locales/fr.yml b/packages/locales/fr.yml
index 9b87d46..e9d81d9 100644
--- a/packages/locales/fr.yml
+++ b/packages/locales/fr.yml
@@ -280,8 +280,8 @@ desktop:
captureModeHint: "Fenêtre suit l’application sur laquelle vous cliquez."
screenshotDelayHint: "Attente avant la capture, pour les menus animés."
seconds: "s"
- shortcutStartStop: "Démarrer ou terminer un enregistrement"
- shortcutPauseResume: "Mettre en pause ou reprendre"
+ shortcutRecord: "Démarrer ou terminer un enregistrement"
+ shortcutPause: "Mettre en pause ou reprendre"
shortcutCapture: "Capturer une étape maintenant"
shortcutPress: "Appuyez sur les touches…"
shortcutClear: "Effacer"
diff --git a/packages/locales/pt-BR.yml b/packages/locales/pt-BR.yml
index 368bd71..8e21011 100644
--- a/packages/locales/pt-BR.yml
+++ b/packages/locales/pt-BR.yml
@@ -280,8 +280,8 @@ desktop:
captureModeHint: "Janela acompanha o app em que você clica."
screenshotDelayHint: "Espera antes da captura, para menus com animação."
seconds: "s"
- shortcutStartStop: "Iniciar ou finalizar uma gravação"
- shortcutPauseResume: "Pausar ou retomar"
+ shortcutRecord: "Iniciar ou finalizar uma gravação"
+ shortcutPause: "Pausar ou retomar"
shortcutCapture: "Capturar uma etapa agora"
shortcutPress: "Pressione as teclas…"
shortcutClear: "Limpar"
diff --git a/packages/locales/ru.yml b/packages/locales/ru.yml
index 693b42a..0b25792 100644
--- a/packages/locales/ru.yml
+++ b/packages/locales/ru.yml
@@ -280,8 +280,8 @@ desktop:
captureModeHint: "«Окно» следует за приложением, в котором вы кликаете."
screenshotDelayHint: "Подождать перед скриншотом, для меню с анимацией."
seconds: с
- shortcutStartStop: Начать или закончить запись
- shortcutPauseResume: Пауза или продолжение
+ shortcutRecord: Начать или закончить запись
+ shortcutPause: Пауза или продолжение
shortcutCapture: Записать шаг сейчас
shortcutPress: Нажмите клавиши…
shortcutClear: Очистить
diff --git a/packages/locales/zh-CN.yml b/packages/locales/zh-CN.yml
index ee93c09..ea2a572 100644
--- a/packages/locales/zh-CN.yml
+++ b/packages/locales/zh-CN.yml
@@ -280,8 +280,8 @@ desktop:
captureModeHint: "窗口模式跟随你点击的应用。"
screenshotDelayHint: "截图前等待,适用于带动画的菜单。"
seconds: "秒"
- shortcutStartStop: "开始或结束录制"
- shortcutPauseResume: "暂停或继续"
+ shortcutRecord: "开始或结束录制"
+ shortcutPause: "暂停或继续"
shortcutCapture: "立即捕获一步"
shortcutPress: "请按下按键…"
shortcutClear: "清除"