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: share the saved badge and the guide page, and group narration and voice-over under ai in the extension settings

Luis Ortiz5a7b14fc1e63
diff --git a/apps/desktop/src/renderer/App.tsx b/apps/desktop/src/renderer/App.tsx
index 57a0aab..84882f9 100644
--- a/apps/desktop/src/renderer/App.tsx
+++ b/apps/desktop/src/renderer/App.tsx
@@ -2,7 +2,7 @@ import type { CaptureInsert } from '@mimik/core/capture/capture-insert';
import { i18n, localStorage } from '@mimik/core/env';
import {
AppFrame,
- GuideContent,
+ GuidePage,
LibraryContent,
navigate,
SearchModal,
@@ -100,17 +100,13 @@ export function App() {
}
>
{route.page === 'guide' ? (
- <main className="flex-1 py-10 px-6">
- <div className="mx-auto max-w-[780px]">
- <GuideContent
- key={guideKey}
- guideId={route.guideId}
- initialStepId={route.stepId}
- initialTool={route.tool}
- onCaptureMore={(insert) => setSheet({ insert })}
- />
- </div>
- </main>
+ <GuidePage
+ key={guideKey}
+ guideId={route.guideId}
+ initialStepId={route.stepId}
+ initialTool={route.tool}
+ onCaptureMore={(insert) => setSheet({ insert })}
+ />
) : (
<main className="flex-1 flex flex-col py-8 px-6">
<LibraryContent category={route.category} />
diff --git a/apps/desktop/src/renderer/settings/GeneralSettings.tsx b/apps/desktop/src/renderer/settings/GeneralSettings.tsx
index 63cb23d..adda34e 100644
--- a/apps/desktop/src/renderer/settings/GeneralSettings.tsx
+++ b/apps/desktop/src/renderer/settings/GeneralSettings.tsx
@@ -8,7 +8,7 @@ import { Row } from './Row';
const LOGIN_HINT = navigator.userAgent.includes('Mac') ? 'desktop.startAtLoginHintMac' : 'desktop.startAtLoginHint';
-export function GeneralSettings() {
+export function GeneralSettings({ onSaved }: { onSaved: () => void }) {
const [version, setVersion] = useState('');
const [atLogin, setAtLogin] = useState(false);
@@ -30,7 +30,10 @@ export function GeneralSettings() {
<Switch
checked={atLogin}
label={i18n.t('desktop.startAtLogin')}
- onChange={async (next) => setAtLogin(await window.mimik.openAtLogin.set(next))}
+ onChange={async (next) => {
+ setAtLogin(await window.mimik.openAtLogin.set(next));
+ onSaved();
+ }}
/>
</Row>
</Card>
diff --git a/apps/desktop/src/renderer/settings/SettingsDialog.tsx b/apps/desktop/src/renderer/settings/SettingsDialog.tsx
index 76b8659..17c4b39 100644
--- a/apps/desktop/src/renderer/settings/SettingsDialog.tsx
+++ b/apps/desktop/src/renderer/settings/SettingsDialog.tsx
@@ -1,15 +1,17 @@
import { i18n } from '@mimik/core/env';
-import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@mimik/ui';
+import { Dialog, DialogContent, DialogHeader, DialogTitle, SavedBadge, useSavedFlash } from '@mimik/ui';
import { SettingsPanel } from './SettingsPanel';
export function SettingsDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) {
+ const { saved, flash } = useSavedFlash();
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent aria-describedby={undefined} className="gap-0 overflow-hidden p-0 sm:max-w-[880px]">
- <DialogHeader className="border-b border-border px-6 py-4">
+ <DialogHeader className="flex-row items-center border-b border-border py-4 pr-12 pl-6">
<DialogTitle className="text-[15px] font-bold">{i18n.t('settings.title')}</DialogTitle>
+ <SavedBadge saved={saved} />
</DialogHeader>
- <SettingsPanel />
+ <SettingsPanel onSaved={flash} />
</DialogContent>
</Dialog>
);
diff --git a/apps/desktop/src/renderer/settings/SettingsPanel.tsx b/apps/desktop/src/renderer/settings/SettingsPanel.tsx
index 4d7b88b..7c68fb2 100644
--- a/apps/desktop/src/renderer/settings/SettingsPanel.tsx
+++ b/apps/desktop/src/renderer/settings/SettingsPanel.tsx
@@ -57,13 +57,13 @@ const KEYS: { id: keyof CaptureShortcuts; labelKey: string }[] = [
{ id: 'capture', labelKey: 'desktop.shortcutCapture' },
];
-export function SettingsPanel() {
+export function SettingsPanel({ onSaved }: { onSaved: () => void }) {
const [section, setSection] = useState<Section>(() => {
const reopened = sessionStorage.getItem(REOPEN_SETTINGS) as Section | null;
sessionStorage.removeItem(REOPEN_SETTINGS);
return reopened ?? 'general';
});
- const keys = useApiKeys();
+ const keys = useApiKeys({ onChange: onSaved });
const microphone = useMicrophoneGate();
const [settings, setSettings] = useState<CaptureSettings | null>(null);
@@ -74,6 +74,7 @@ export function SettingsPanel() {
const save = async (patch: Partial<CaptureSettings>) => {
setSettings((current) => current && { ...current, ...patch });
setSettings(await window.mimik.capture.settings.set(patch));
+ onSaved();
};
return (
@@ -103,22 +104,28 @@ export function SettingsPanel() {
<div className="flex flex-col gap-3.5">
{section === 'ai' && (
<>
- <AiSettings keys={keys} onOpenKeys={() => setSection('keys')} />
+ <AiSettings keys={keys} onOpenKeys={() => setSection('keys')} onChange={onSaved} />
<NarrationSettings
keys={keys}
onOpenKeys={() => setSection('keys')}
+ onChange={onSaved}
onRequestAccess={requestMicrophoneAccess}
access={microphone.row}
microphoneDisabled={microphone.locked}
liveMeter
/>
- <VoiceoverSettings keys={keys.keys} listVoices={fetchVoices} onOpenKeys={() => setSection('keys')} />
+ <VoiceoverSettings
+ keys={keys.keys}
+ listVoices={fetchVoices}
+ onOpenKeys={() => setSection('keys')}
+ onChange={onSaved}
+ />
</>
)}
{section === 'keys' && <ApiKeysSettings state={keys} validate={validateApiKey} />}
- {section === 'branding' && <BrandingSettings />}
+ {section === 'branding' && <BrandingSettings onChange={onSaved} />}
{section === 'capture' && settings && (
<>
@@ -201,7 +208,7 @@ export function SettingsPanel() {
</>
)}
- {section === 'general' && <GeneralSettings />}
+ {section === 'general' && <GeneralSettings onSaved={onSaved} />}
{section === 'shortcuts' && settings && (
<Card icon={Command} title={i18n.t('desktop.cardGlobalKeys')} hint={i18n.t('desktop.cardGlobalKeysHint')}>
diff --git a/packages/ui/src/common/components/SavedBadge.tsx b/packages/ui/src/common/components/SavedBadge.tsx
new file mode 100644
index 0000000..fde9076
--- /dev/null
+++ b/packages/ui/src/common/components/SavedBadge.tsx
@@ -0,0 +1,17 @@
+import { i18n } from '@mimik/core/env';
+import { Check } from 'lucide-react';
+
+export function SavedBadge({ saved, className = '' }: { saved: boolean; className?: string }) {
+ return (
+ <span
+ aria-live="polite"
+ className={`ml-auto flex items-center gap-1 text-[11px] font-semibold transition-opacity duration-300 ${
+ saved ? 'opacity-100' : 'opacity-0'
+ } ${className}`}
+ style={{ color: 'var(--color-success)' }}
+ >
+ <Check size={12} />
+ {i18n.t('settings.saved')}
+ </span>
+ );
+}
diff --git a/packages/ui/src/common/hooks/use-saved-flash.ts b/packages/ui/src/common/hooks/use-saved-flash.ts
new file mode 100644
index 0000000..58d2e3f
--- /dev/null
+++ b/packages/ui/src/common/hooks/use-saved-flash.ts
@@ -0,0 +1,16 @@
+import { useCallback, useEffect, useState } from 'react';
+
+const SAVED_BADGE_MS = 1600;
+
+export function useSavedFlash(): { saved: boolean; flash: () => void } {
+ const [flashedAt, setFlashedAt] = useState(0);
+ const flash = useCallback(() => setFlashedAt(Date.now()), []);
+
+ useEffect(() => {
+ if (!flashedAt) return;
+ const badge = window.setTimeout(() => setFlashedAt(0), SAVED_BADGE_MS);
+ return () => window.clearTimeout(badge);
+ }, [flashedAt]);
+
+ return { saved: flashedAt > 0, flash };
+}
diff --git a/packages/ui/src/guide/components/GuidePage.tsx b/packages/ui/src/guide/components/GuidePage.tsx
new file mode 100644
index 0000000..168e1b8
--- /dev/null
+++ b/packages/ui/src/guide/components/GuidePage.tsx
@@ -0,0 +1,14 @@
+import type { ComponentProps } from 'react';
+import { useFullview } from '../../stores/use-fullview';
+import { GuideContent } from './GuideContent';
+
+export function GuidePage(props: ComponentProps<typeof GuideContent>) {
+ const widened = useFullview((s) => s.historyOpen || s.transcriptOpen);
+ return (
+ <main className="flex-1 py-10 px-6">
+ <div className={`mx-auto ${widened ? 'max-w-[1032px]' : 'max-w-[720px]'}`}>
+ <GuideContent {...props} />
+ </div>
+ </main>
+ );
+}
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index 00ee41b..c30480e 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -1,46 +1,29 @@
export { AiSettings } from './ai/components/AiSettings';
export { ApiKeysSettings } from './ai/components/ApiKeysSettings';
export { KeyStatusNote } from './ai/components/KeyStatusNote';
-export { KeyWarningNote } from './ai/components/KeyWarningNote';
-export { MissingKeyNote } from './ai/components/MissingKeyNote';
-export { ModelList } from './ai/components/ModelList';
-export { ProviderSelect } from './ai/components/ProviderSelect';
export { SecretInput } from './ai/components/SecretInput';
-export { useAiSettings } from './ai/hooks/use-ai-settings';
-export { type ApiKeysState, useApiKeys } from './ai/hooks/use-api-keys';
+export { useApiKeys } from './ai/hooks/use-api-keys';
export { useKeyCheck } from './ai/hooks/use-key-check';
-export { ColorPicker } from './annotation/components/ColorPicker';
export { BrandingSettings } from './branding/components/BrandingSettings';
export { CameraMascot } from './common/components/CameraMascot';
export { FaviconImg } from './common/components/FaviconImg';
+export { SavedBadge } from './common/components/SavedBadge';
export { Segmented } from './common/components/Segmented';
export { SettingsCard } from './common/components/SettingsCard';
export { Switch } from './common/components/Switch';
+export { useSavedFlash } from './common/hooks/use-saved-flash';
export { getDomainInitial } from './common/lib/domain-initial';
export { formatRelativeTime } from './common/lib/format-relative-time';
-export {
- CAMERA_MASCOT_DROP,
- CAMERA_MASCOT_PARTS,
- CAMERA_MASCOT_VIEW_BOX,
- MASCOT_ASPECT,
- MASCOT_BODY,
- MASCOT_CROWN,
- MASCOT_CROWN_SPLIT,
- MASCOT_FACES,
- MASCOT_SEAM,
- MASCOT_VIEW_BOX,
-} from './common/lib/mascot-shapes';
export { Button } from './components/ui/button';
export { Dialog, DialogContent, DialogHeader, DialogTitle } from './components/ui/dialog';
export { Input } from './components/ui/input';
-export { Popover, PopoverContent, PopoverTrigger } from './components/ui/popover';
export { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './components/ui/select';
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './components/ui/tooltip';
export { ExportPreviewModal } from './export/components/ExportPreviewModal';
export { VoiceoverSettings } from './export/components/VoiceoverSettings';
export { BlockCard } from './guide/components/BlockCard';
export { EmptyGuideState } from './guide/components/EmptyGuideState';
-export { GuideContent } from './guide/components/GuideContent';
+export { GuidePage } from './guide/components/GuidePage';
export { ScreenshotView } from './guide/components/ScreenshotView';
export { StepCard } from './guide/components/StepCard';
export { StepSourceBadge } from './guide/components/StepSourceBadge';
@@ -57,6 +40,5 @@ export type { StepProps } from './onboarding/types';
export { SearchModal } from './search/components/SearchModal';
export { useFullview } from './stores/use-fullview';
export { MicrophoneAccessRow } from './voice/components/MicrophoneAccessRow';
-export { MicrophonePicker } from './voice/components/MicrophonePicker';
export { NarrationSettings } from './voice/components/NarrationSettings';
export { VoiceNotice } from './voice/components/VoiceNotice';
diff --git a/src/ui/fullview/App.tsx b/src/ui/fullview/App.tsx
index b0a8f2c..442ea4c 100644
--- a/src/ui/fullview/App.tsx
+++ b/src/ui/fullview/App.tsx
@@ -1,4 +1,4 @@
-import { AppFrame, GuideContent, LibraryContent, SearchModal, TooltipProvider, useFullview, useRoute } from '@mimik/ui';
+import { AppFrame, GuidePage, LibraryContent, SearchModal, TooltipProvider, useRoute } from '@mimik/ui';
import { browser } from '#imports';
import { openSidebar } from '@/lib/browser-api/open-sidebar';
import { UpdateNotice } from '@/ui/shared/UpdateNotice';
@@ -6,10 +6,6 @@ import { BackgroundVoiceNotice } from './components/BackgroundVoiceNotice';
export function FullViewApp() {
const route = useRoute();
- const { historyOpen, transcriptOpen } = useFullview((s) => ({
- historyOpen: s.historyOpen,
- transcriptOpen: s.transcriptOpen,
- }));
return (
<TooltipProvider>
@@ -29,11 +25,7 @@ export function FullViewApp() {
)}
{route.page === 'guide' && (
- <main className="flex-1 py-10 px-6">
- <div className={`mx-auto ${historyOpen || transcriptOpen ? 'max-w-[1032px]' : 'max-w-[720px]'}`}>
- <GuideContent guideId={route.guideId} initialStepId={route.stepId} initialTool={route.tool} />
- </div>
- </main>
+ <GuidePage guideId={route.guideId} initialStepId={route.stepId} initialTool={route.tool} />
)}
{import.meta.env.BROWSER !== 'firefox' && <BackgroundVoiceNotice />}
diff --git a/src/ui/shared/SettingsView.tsx b/src/ui/shared/SettingsView.tsx
index 35c8c12..2cd612f 100644
--- a/src/ui/shared/SettingsView.tsx
+++ b/src/ui/shared/SettingsView.tsx
@@ -6,12 +6,13 @@ import {
ApiKeysSettings,
BrandingSettings,
NarrationSettings,
+ SavedBadge,
SettingsCard,
Switch,
useApiKeys,
VoiceoverSettings,
} from '@mimik/ui';
-import { ArrowLeft, Bug, Check, ChevronRight, EyeOff, Keyboard, Shield, Star } from 'lucide-react';
+import { ArrowLeft, Bug, ChevronRight, EyeOff, Keyboard, Shield, Star } from 'lucide-react';
import { type ReactNode, useCallback, useEffect, useState } from 'react';
import { localStorage } from '@/lib/browser-api/local-storage';
import { sendMessage } from '@/lib/messaging';
@@ -71,31 +72,22 @@ export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
macAddress: 'blurPresets.macAddress',
};
- const savedBadge = (
- <span
- aria-live="polite"
- className={`ml-auto flex items-center gap-1 text-[11px] font-semibold transition-opacity duration-300 ${
- saved ? 'opacity-100' : 'opacity-0'
- }`}
- style={{ color: 'var(--color-success)' }}
- >
- <Check size={12} />
- {i18n.t('settings.saved')}
- </span>
- );
+ const savedBadge = <SavedBadge saved={saved} />;
const sections: Record<SettingsSection, ReactNode> = {
- ai: <AiSettings keys={keys} onOpenKeys={openKeys} onChange={queue} />,
- narration: (
- <NarrationSettings
- keys={keys}
- onOpenKeys={openKeys}
- onChange={queue}
- onRequestAccess={import.meta.env.BROWSER !== 'firefox' ? requestMicrophoneAccess : undefined}
- liveMeter
- />
+ ai: (
+ <>
+ <AiSettings keys={keys} onOpenKeys={openKeys} onChange={queue} />
+ <NarrationSettings
+ keys={keys}
+ onOpenKeys={openKeys}
+ onChange={queue}
+ onRequestAccess={import.meta.env.BROWSER !== 'firefox' ? requestMicrophoneAccess : undefined}
+ liveMeter
+ />
+ <VoiceoverSettings keys={keys.keys} listVoices={listVoices} onOpenKeys={openKeys} onChange={queue} />
+ </>
),
- 'voice-over': <VoiceoverSettings keys={keys.keys} listVoices={listVoices} onOpenKeys={openKeys} onChange={queue} />,
branding: <BrandingSettings onChange={queue} />,
'smart-blur': (
<SettingsCard icon={EyeOff} title={i18n.t('settings.smartBlur')} className="space-y-1 [&>*:first-child]:mb-2">
@@ -196,8 +188,6 @@ export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
</div>
{sections.ai}
{sections.branding}
- {sections.narration}
- {sections['voice-over']}
{sections['smart-blur']}
{sections.keys}
<div className="flex items-start gap-2 px-3 py-2.5 rounded-lg bg-secondary text-[10px] text-muted-foreground leading-relaxed">
diff --git a/src/ui/shared/hooks/use-settings-autosave.ts b/src/ui/shared/hooks/use-settings-autosave.ts
index 2c22f5d..5326de6 100644
--- a/src/ui/shared/hooks/use-settings-autosave.ts
+++ b/src/ui/shared/hooks/use-settings-autosave.ts
@@ -1,10 +1,10 @@
import { localStorage } from '@mimik/core/env';
import { logger } from '@mimik/core/logger';
-import { useCallback, useEffect, useRef, useState } from 'react';
+import { useSavedFlash } from '@mimik/ui';
+import { useCallback, useEffect, useRef } from 'react';
import { changedSettings, type SettingsSnapshot } from '@/ui/shared/lib/changed-settings';
const SAVE_DEBOUNCE_MS = 400;
-const SAVED_BADGE_MS = 1600;
export interface SettingsAutosave {
saved: boolean;
@@ -12,7 +12,7 @@ export interface SettingsAutosave {
}
export function useSettingsAutosave(stored: SettingsSnapshot, ready: boolean): SettingsAutosave {
- const [saved, setSaved] = useState(false);
+ const { saved, flash } = useSavedFlash();
const snapshot = useRef<SettingsSnapshot | null>(null);
const pending = useRef<SettingsSnapshot>({});
const timer = useRef<number | undefined>(undefined);
@@ -23,12 +23,11 @@ export function useSettingsAutosave(stored: SettingsSnapshot, ready: boolean): S
if (Object.keys(patch).length === 0) return;
try {
await localStorage.set(patch);
- setSaved(true);
+ flash();
} catch (err) {
logger.error('Settings autosave failed', err);
- setSaved(false);
}
- }, []);
+ }, [flash]);
const queue = useCallback(
(patch: SettingsSnapshot) => {
@@ -59,11 +58,5 @@ export function useSettingsAutosave(stored: SettingsSnapshot, ready: boolean): S
[flush],
);
- useEffect(() => {
- if (!saved) return;
- const badge = window.setTimeout(() => setSaved(false), SAVED_BADGE_MS);
- return () => window.clearTimeout(badge);
- }, [saved]);
-
return { saved, queue };
}
diff --git a/src/ui/shared/lib/settings-section.ts b/src/ui/shared/lib/settings-section.ts
index 9920c63..fa9107b 100644
--- a/src/ui/shared/lib/settings-section.ts
+++ b/src/ui/shared/lib/settings-section.ts
@@ -1,9 +1,7 @@
-import { AudioLines, EyeOff, ImageIcon, Keyboard, KeyRound, Mic, Sparkles } from 'lucide-react';
+import { EyeOff, ImageIcon, Keyboard, KeyRound, Sparkles } from 'lucide-react';
export const SETTINGS_SECTIONS = [
- { id: 'ai', label: 'settings.aiDescriptions', Icon: Sparkles },
- { id: 'narration', label: 'settings.voiceNarration', Icon: Mic },
- { id: 'voice-over', label: 'settings.voiceover', Icon: AudioLines },
+ { id: 'ai', label: 'settings.aiSection', Icon: Sparkles },
{ id: 'branding', label: 'settings.branding', Icon: ImageIcon },
{ id: 'smart-blur', label: 'settings.smartBlur', Icon: EyeOff },
{ id: 'keys', label: 'settings.cardKeyboard', Icon: Keyboard },