🎬 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(desktop): add a General section with language, startup and updates
Luis Ortize1d787d1ef60
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.tsindex dabbb07..e164893 100644--- a/apps/desktop/src/main/index.ts+++ b/apps/desktop/src/main/index.ts@@ -308,7 +308,11 @@ if (!app.requestSingleInstanceLock()) {return opensAtLogin();});ipcMain.handle('mimik:version', () => app.getVersion());+ ipcMain.handle('mimik:updates:check', () => checkForUpdates({ notifyWhenUpToDate: true }));ipcMain.handle('mimik:screenshots:sweep', (_event, keep: string[]) => sweepScreenshots(keep));+ ipcMain.on('mimik:app:relocalise', () => {+ for (const win of BrowserWindow.getAllWindows()) win.webContents.reload();+ });captureSettings = loadSettings();const shortcutLabel = (accelerator: string | null) =>diff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.tsindex 3a3c6c6..07fe9b0 100644--- a/apps/desktop/src/preload/index.ts+++ b/apps/desktop/src/preload/index.ts@@ -42,6 +42,10 @@ const api = {}});},+ relocalise: (): void => ipcRenderer.send('mimik:app:relocalise'),+ updates: {+ check: (): Promise<void> => ipcRenderer.invoke('mimik:updates:check'),+ },screenshots: {sweep: (keep: string[]): Promise<number> => ipcRenderer.invoke('mimik:screenshots:sweep', keep),},diff --git a/apps/desktop/src/renderer/App.tsx b/apps/desktop/src/renderer/App.tsxindex 56235b0..0a9d2af 100644--- a/apps/desktop/src/renderer/App.tsx+++ b/apps/desktop/src/renderer/App.tsx@@ -2,11 +2,12 @@ import { GuideContent, LibraryContent, navigate, SearchModal, TooltipProvider, Timport { useEffect, useState } from 'react';import { CaptureSheet } from './CaptureSheet';import { GuideZoom } from './GuideZoom';+import { REOPEN_SETTINGS } from './settings/lib/reopen-settings';import { SettingsDialog } from './settings/SettingsDialog';export function App() {const route = useRoute();- const [settingsOpen, setSettingsOpen] = useState(false);+ const [settingsOpen, setSettingsOpen] = useState(() => sessionStorage.getItem(REOPEN_SETTINGS) !== null);const [sheetOpen, setSheetOpen] = useState(false);useEffect(() => {diff --git a/apps/desktop/src/renderer/__tests__/app-locale.test.ts b/apps/desktop/src/renderer/__tests__/app-locale.test.tsnew file mode 100644index 0000000..cb493a7--- /dev/null+++ b/apps/desktop/src/renderer/__tests__/app-locale.test.ts@@ -0,0 +1,18 @@+import { describe, expect, it } from 'vitest';+import { appLocale } from '../lib/app-locale';++describe('appLocale', () => {+ it('takes the language picked in settings', () => {+ expect(appLocale('de', 'en-US')).toBe('de');+ });++ it('follows the system when nothing or an unknown language is picked', () => {+ expect(appLocale(null, 'fr-CA')).toBe('fr');+ expect(appLocale('system', 'zh-CN')).toBe('zh-CN');+ expect(appLocale(undefined, 'pt-PT')).toBe('pt-BR');+ });++ it('falls back to English for a language Mimik does not ship', () => {+ expect(appLocale(null, 'ja-JP')).toBe('en');+ });+});diff --git a/apps/desktop/src/renderer/core-env.ts b/apps/desktop/src/renderer/core-env.tsindex d870465..b725c39 100644--- a/apps/desktop/src/renderer/core-env.ts+++ b/apps/desktop/src/renderer/core-env.ts@@ -1,7 +1,13 @@import { configureCore } from '@mimik/core/env';import type { Settings, SettingsKey } from '@mimik/core/guides/types';import { type Messages, translate } from '@mimik/core/i18n/translate';+import de from '@mimik/locales/de.yml';import en from '@mimik/locales/en.yml';+import es from '@mimik/locales/es.yml';+import fr from '@mimik/locales/fr.yml';+import ptBR from '@mimik/locales/pt-BR.yml';+import zhCN from '@mimik/locales/zh-CN.yml';+import { type AppLocale, appLocale } from './lib/app-locale';async function mainFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;@@ -18,10 +24,24 @@ async function mainFetch(input: RequestInfo | URL, init?: RequestInit): Promise<return new Response(reply.body, { status: reply.status, statusText: reply.statusText, headers: reply.headers });}+const MESSAGES: Record<AppLocale, Messages> = {+ en: en as Messages,+ de: de as Messages,+ es: es as Messages,+ fr: fr as Messages,+ 'pt-BR': ptBR as Messages,+ 'zh-CN': zhCN as Messages,+};++const locale = appLocale(window.localStorage.getItem('appLanguage')?.replace(/^"|"$/g, ''), navigator.language);+configureCore({client: 'desktop',fetch: mainFetch,- t: (key, substitutions) => translate(en as Messages, key, substitutions),+ t: (key, substitutions) => {+ const text = translate(MESSAGES[locale], key, substitutions);+ return text === key ? translate(MESSAGES.en, key, substitutions) : text;+ },assetUrl: (path) => new URL(path.replace(/^\//, ''), document.baseURI).href,storage: {get: async <K extends SettingsKey>(keys: readonly K[]) => {diff --git a/apps/desktop/src/renderer/lib/app-locale.ts b/apps/desktop/src/renderer/lib/app-locale.tsnew file mode 100644index 0000000..8883034--- /dev/null+++ b/apps/desktop/src/renderer/lib/app-locale.ts@@ -0,0 +1,11 @@+export const APP_LOCALES = ['en', 'de', 'es', 'fr', 'pt-BR', 'zh-CN'] as const;++export type AppLocale = (typeof APP_LOCALES)[number];++export function appLocale(chosen: string | null | undefined, system: string): AppLocale {+ const known = (code: string | null | undefined) => APP_LOCALES.find((locale) => locale === code);+ const base = system.split('-')[0]?.toLowerCase();+ return (+ known(chosen) ?? known(system) ?? APP_LOCALES.find((locale) => locale.split('-')[0].toLowerCase() === base) ?? 'en'+ );+}diff --git a/apps/desktop/src/renderer/settings/AppLanguage.tsx b/apps/desktop/src/renderer/settings/AppLanguage.tsxnew file mode 100644index 0000000..94cb2f6--- /dev/null+++ b/apps/desktop/src/renderer/settings/AppLanguage.tsx@@ -0,0 +1,36 @@+import { AI_LANGUAGES } from '@mimik/core/capture/ai/prompts';+import { i18n, localStorage } from '@mimik/core/env';+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@mimik/ui';+import { useEffect, useState } from 'react';+import { REOPEN_SETTINGS } from './lib/reopen-settings';++export function AppLanguage() {+ const [chosen, setChosen] = useState('system');++ useEffect(() => {+ localStorage.get(['appLanguage']).then(({ appLanguage }) => appLanguage && setChosen(appLanguage));+ }, []);++ const change = async (next: string) => {+ setChosen(next);+ await localStorage.set({ appLanguage: next });+ sessionStorage.setItem(REOPEN_SETTINGS, 'general');+ window.mimik.relocalise();+ };++ return (+ <Select value={chosen} onValueChange={change}>+ <SelectTrigger aria-label={i18n.t('desktop_appLanguage')} className="h-9 w-56">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="system">{i18n.t('desktop_languageSystem')}</SelectItem>+ {AI_LANGUAGES.map((language) => (+ <SelectItem key={language.code} value={language.code}>+ {language.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ );+}diff --git a/apps/desktop/src/renderer/settings/GeneralSettings.tsx b/apps/desktop/src/renderer/settings/GeneralSettings.tsxnew file mode 100644index 0000000..f034a6b--- /dev/null+++ b/apps/desktop/src/renderer/settings/GeneralSettings.tsx@@ -0,0 +1,46 @@+import { i18n } from '@mimik/core/env';+import { Button, Switch } from '@mimik/ui';+import { Languages, Power, RefreshCw } from 'lucide-react';+import { useEffect, useState } from 'react';+import { AppLanguage } from './AppLanguage';+import { Card } from './Card';+import { Row } from './Row';++export function GeneralSettings() {+ const [version, setVersion] = useState('');+ const [atLogin, setAtLogin] = useState(false);++ useEffect(() => {+ window.mimik.version().then(setVersion);+ window.mimik.openAtLogin.get().then(setAtLogin);+ }, []);++ return (+ <>+ <Card icon={Languages} title={i18n.t('desktop_cardLanguage')}>+ <Row label={i18n.t('desktop_appLanguage')} hint={i18n.t('desktop_appLanguageHint')}>+ <AppLanguage />+ </Row>+ </Card>++ <Card icon={Power} title={i18n.t('desktop_cardStartup')}>+ <Row label={i18n.t('desktop_startAtLogin')} hint={i18n.t('desktop_startAtLoginHint')}>+ <Switch+ checked={atLogin}+ label={i18n.t('desktop_startAtLogin')}+ onChange={async (next) => setAtLogin(await window.mimik.openAtLogin.set(next))}+ />+ </Row>+ </Card>++ <Card icon={RefreshCw} title={i18n.t('desktop_cardUpdates')}>+ <Row label={i18n.t('desktop_version', [version])} hint={i18n.t('desktop_versionHint')}>+ <Button variant="outline" size="sm" onClick={() => window.mimik.updates.check()}>+ <RefreshCw size={14} />+ {i18n.t('desktop_checkUpdates')}+ </Button>+ </Row>+ </Card>+ </>+ );+}diff --git a/apps/desktop/src/renderer/settings/SettingsPanel.tsx b/apps/desktop/src/renderer/settings/SettingsPanel.tsxindex 5b87651..59068e1 100644--- a/apps/desktop/src/renderer/settings/SettingsPanel.tsx+++ b/apps/desktop/src/renderer/settings/SettingsPanel.tsx@@ -1,19 +1,32 @@import { validateApiKey } from '@mimik/core/capture/ai/validate';import { i18n } from '@mimik/core/env';import { AiSettings, BrandingSettings, Switch, useKeyCheck } from '@mimik/ui';-import { AppWindow, Command, Crop, ImageIcon, Keyboard, Monitor, MonitorPlay, Sparkles } from 'lucide-react';+import {+ AppWindow,+ Command,+ Crop,+ ImageIcon,+ Keyboard,+ Monitor,+ MonitorPlay,+ SlidersHorizontal,+ Sparkles,+} from 'lucide-react';import { useEffect, useState } from 'react';import type { CaptureSettings, CaptureShortcuts } from '../../main/capture/settings';import { Card } from './Card';+import { GeneralSettings } from './GeneralSettings';+import { REOPEN_SETTINGS } from './lib/reopen-settings';import { zoomLevels } from './lib/zoom-levels';import { Row } from './Row';import { Segmented } from './Segmented';import { ShortcutRecorder } from './ShortcutRecorder';import { Slider } from './Slider';-type Section = 'capture' | 'ai' | 'branding' | 'shortcuts';+type Section = 'general' | 'capture' | 'ai' | 'branding' | 'shortcuts';const SECTIONS: { id: Section; labelKey: string; Icon: typeof AppWindow }[] = [+ { id: 'general', labelKey: 'desktop_generalSection', Icon: SlidersHorizontal },{ id: 'capture', labelKey: 'desktop_capturingSection', Icon: MonitorPlay },{ id: 'ai', labelKey: 'settings_aiDescriptions', Icon: Sparkles },{ id: 'branding', labelKey: 'settings_branding', Icon: ImageIcon },@@ -32,7 +45,11 @@ const KEYS: { id: keyof CaptureShortcuts; labelKey: string }[] = [];export function SettingsPanel() {- const [section, setSection] = useState<Section>('capture');+ const [section, setSection] = useState<Section>(() => {+ const reopened = sessionStorage.getItem(REOPEN_SETTINGS) as Section | null;+ sessionStorage.removeItem(REOPEN_SETTINGS);+ return reopened ?? 'general';+ });const keyCheck = useKeyCheck(validateApiKey);const [settings, setSettings] = useState<CaptureSettings | null>(null);@@ -53,13 +70,16 @@ export function SettingsPanel() {key={item.id}type="button"onClick={() => setSection(item.id)}- className={`mb-0.5 flex h-9 w-full items-center gap-2.5 rounded-[9px] px-3 text-left text-sm transition-colors ${+ className={`mb-0.5 flex min-h-9 w-full items-start gap-2.5 rounded-[9px] px-3 py-2 text-left text-sm leading-5 transition-colors ${section === item.id? 'bg-secondary font-semibold text-foreground': 'text-foreground hover:bg-secondary/60'}`}>- <item.Icon size={15} className={section === item.id ? 'text-accent' : 'text-muted-foreground'} />+ <item.Icon+ size={15}+ className={`mt-0.5 shrink-0 ${section === item.id ? 'text-accent' : 'text-muted-foreground'}`}+ />{i18n.t(item.labelKey)}</button>))}@@ -152,6 +172,8 @@ export function SettingsPanel() {</>)}+ {section === 'general' && <GeneralSettings />}+{section === 'shortcuts' && settings && (<Card icon={Command} title={i18n.t('desktop_cardGlobalKeys')} hint={i18n.t('desktop_cardGlobalKeysHint')}>{KEYS.map((key) => (diff --git a/apps/desktop/src/renderer/settings/lib/reopen-settings.ts b/apps/desktop/src/renderer/settings/lib/reopen-settings.tsnew file mode 100644index 0000000..5eb70f7--- /dev/null+++ b/apps/desktop/src/renderer/settings/lib/reopen-settings.ts@@ -0,0 +1 @@+export const REOPEN_SETTINGS = 'mimik:reopen-settings';diff --git a/packages/core/src/guides/types.ts b/packages/core/src/guides/types.tsindex 5d7ddb1..97c5901 100644--- a/packages/core/src/guides/types.ts+++ b/packages/core/src/guides/types.ts@@ -91,6 +91,7 @@ export interface Settings {guideMeManual: boolean;mimikBlurMode: boolean;onboardingCompleted: boolean;+ appLanguage: string;}export type SettingsKey = keyof Settings;diff --git a/src/locales/de.yml b/src/locales/de.ymlindex 6abe4df..6a9cbc4 100644--- a/src/locales/de.yml+++ b/src/locales/de.yml@@ -169,6 +169,18 @@ desktop:startSheetTitle: Aufnahme startenstartButton: StartenshortcutsSection: "Tastenkürzel"+ generalSection: "Allgemein"+ appLanguage: "App-Sprache"+ appLanguageHint: "Die Sprache der Mimik-Oberfläche. KI-Beschreibungen haben eine eigene Einstellung."+ languageSystem: "Wie das System"+ cardLanguage: "Sprache"+ cardStartup: "Start"+ cardUpdates: "Updates"+ startAtLogin: "Beim Anmelden starten"+ startAtLoginHint: "Mimik startet im Infobereich, ohne Fenster."+ version: "Version $1"+ versionHint: "Mimik sucht bei jedem Start nach Updates."+ checkUpdates: "Nach Updates suchen"cardScreenshots: "Screenshots"cardKeyboard: "Tippen und Tasten"cardGlobalKeys: "Globale Tasten"diff --git a/src/locales/en.yml b/src/locales/en.ymlindex ce5b3cb..a9e0434 100644--- a/src/locales/en.yml+++ b/src/locales/en.yml@@ -169,6 +169,18 @@ desktop:startSheetTitle: Start a capturestartButton: StartshortcutsSection: "Shortcuts"+ generalSection: "General"+ appLanguage: "App language"+ appLanguageHint: "The language of Mimik's own screens. AI descriptions have their own setting."+ languageSystem: "Same as the system"+ cardLanguage: "Language"+ cardStartup: "Startup"+ cardUpdates: "Updates"+ startAtLogin: "Start at login"+ startAtLoginHint: "Mimik opens in the tray, without a window."+ version: "Version $1"+ versionHint: "Mimik looks for updates each time it starts."+ checkUpdates: "Check for updates"cardScreenshots: "Screenshots"cardKeyboard: "Typing and keys"cardGlobalKeys: "Global keys"diff --git a/src/locales/es.yml b/src/locales/es.ymlindex 10d01a3..9f3afbc 100644--- a/src/locales/es.yml+++ b/src/locales/es.yml@@ -169,6 +169,18 @@ desktop:startSheetTitle: Iniciar una capturastartButton: IniciarshortcutsSection: "Atajos"+ generalSection: "General"+ appLanguage: "Idioma de la app"+ appLanguageHint: "El idioma de las pantallas de Mimik. Las descripciones con IA tienen su propio ajuste."+ languageSystem: "Igual que el sistema"+ cardLanguage: "Idioma"+ cardStartup: "Inicio"+ cardUpdates: "Actualizaciones"+ startAtLogin: "Abrir al iniciar sesión"+ startAtLoginHint: "Mimik se abre en la bandeja, sin ventana."+ version: "Versión $1"+ versionHint: "Mimik busca actualizaciones cada vez que se inicia."+ checkUpdates: "Buscar actualizaciones"cardScreenshots: "Capturas de pantalla"cardKeyboard: "Escritura y teclas"cardGlobalKeys: "Teclas globales"diff --git a/src/locales/fr.yml b/src/locales/fr.ymlindex 99f20bb..a1c7110 100644--- a/src/locales/fr.yml+++ b/src/locales/fr.yml@@ -169,6 +169,18 @@ desktop:startSheetTitle: Démarrer une capturestartButton: DémarrershortcutsSection: "Raccourcis"+ generalSection: "Général"+ appLanguage: "Langue de l’application"+ appLanguageHint: "La langue des écrans de Mimik. Les descriptions IA ont leur propre réglage."+ languageSystem: "Comme le système"+ cardLanguage: "Langue"+ cardStartup: "Démarrage"+ cardUpdates: "Mises à jour"+ startAtLogin: "Lancer à l’ouverture de session"+ startAtLoginHint: "Mimik s’ouvre dans la zone de notification, sans fenêtre."+ version: "Version $1"+ versionHint: "Mimik recherche les mises à jour à chaque démarrage."+ checkUpdates: "Rechercher des mises à jour"cardScreenshots: "Captures d’écran"cardKeyboard: "Saisie et touches"cardGlobalKeys: "Touches globales"diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.ymlindex 941f4d6..d80047f 100644--- a/src/locales/pt-BR.yml+++ b/src/locales/pt-BR.yml@@ -169,6 +169,18 @@ desktop:startSheetTitle: Iniciar uma capturastartButton: IniciarshortcutsSection: "Atalhos"+ generalSection: "Geral"+ appLanguage: "Idioma do app"+ appLanguageHint: "O idioma das telas do Mimik. As descrições por IA têm uma configuração própria."+ languageSystem: "Igual ao sistema"+ cardLanguage: "Idioma"+ cardStartup: "Inicialização"+ cardUpdates: "Atualizações"+ startAtLogin: "Abrir ao iniciar a sessão"+ startAtLoginHint: "O Mimik abre na bandeja, sem janela."+ version: "Versão $1"+ versionHint: "O Mimik procura atualizações sempre que é iniciado."+ checkUpdates: "Procurar atualizações"cardScreenshots: "Capturas de tela"cardKeyboard: "Digitação e teclas"cardGlobalKeys: "Teclas globais"diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.ymlindex 6f24fb2..01a4e7b 100644--- a/src/locales/zh-CN.yml+++ b/src/locales/zh-CN.yml@@ -169,6 +169,18 @@ desktop:startSheetTitle: 开始捕获startButton: 开始shortcutsSection: "快捷键"+ generalSection: "通用"+ appLanguage: "应用语言"+ appLanguageHint: "Mimik 界面的语言。AI 描述有单独的设置。"+ languageSystem: "跟随系统"+ cardLanguage: "语言"+ cardStartup: "启动"+ cardUpdates: "更新"+ startAtLogin: "登录时启动"+ startAtLoginHint: "Mimik 在托盘中打开,不显示窗口。"+ version: "版本 $1"+ versionHint: "Mimik 每次启动时都会检查更新。"+ checkUpdates: "检查更新"cardScreenshots: "屏幕截图"cardKeyboard: "输入与按键"cardGlobalKeys: "全局快捷键"