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): show what's new after an update, with the extension's notice now shared

Luis Ortizc1a9320dc4b5
diff --git a/apps/desktop/src/renderer/App.tsx b/apps/desktop/src/renderer/App.tsx
index ff1df7d..0ed9a7f 100644
--- a/apps/desktop/src/renderer/App.tsx
+++ b/apps/desktop/src/renderer/App.tsx
@@ -7,6 +7,7 @@ import {
navigate,
SearchModal,
TooltipProvider,
+ UpdateNotice,
useFullview,
useRoute,
VoiceNotice,
@@ -16,6 +17,7 @@ import { CaptureSheet } from './CaptureSheet';
import { DesktopOnboarding } from './DesktopOnboarding';
import { GuideZoom } from './GuideZoom';
import { useNarrationUpdate } from './hooks/use-narration-update';
+import { useUpdateNotice } from './hooks/use-update-notice';
import { PermissionsDialog } from './PermissionsDialog';
import { REOPEN_SETTINGS } from './settings/lib/reopen-settings';
import { SettingsDialog } from './settings/SettingsDialog';
@@ -25,6 +27,7 @@ export function App() {
const narration = useNarrationUpdate();
const [settingsOpen, setSettingsOpen] = useState(() => sessionStorage.getItem(REOPEN_SETTINGS) !== null);
const [settingsOnKeys, setSettingsOnKeys] = useState(false);
+ const updateNotice = useUpdateNotice();
const [sheet, setSheet] = useState<{ insert?: CaptureInsert } | null>(null);
const [guideKey, setGuideKey] = useState(0);
const [onboarded, setOnboarded] = useState<boolean | null>(null);
@@ -131,6 +134,7 @@ export function App() {
setSettingsOpen(true);
}}
/>
+ <UpdateNotice {...updateNotice} className="fixed bottom-6 left-1/2 -translate-x-1/2 z-50" />
{sheet && <CaptureSheet insert={sheet.insert} onClose={() => setSheet(null)} />}
<PermissionsDialog open={permissionsOpen} onClose={closePermissions} />
</TooltipProvider>
diff --git a/apps/desktop/src/renderer/hooks/use-update-notice.ts b/apps/desktop/src/renderer/hooks/use-update-notice.ts
new file mode 100644
index 0000000..5599e0d
--- /dev/null
+++ b/apps/desktop/src/renderer/hooks/use-update-notice.ts
@@ -0,0 +1,18 @@
+import { useEffect, useState } from 'react';
+import { updatedVersion } from '../lib/updated-version';
+
+export function useUpdateNotice(): { version: string | undefined; onDismiss: () => void } {
+ const [version, setVersion] = useState<string>();
+
+ useEffect(() => {
+ void window.mimik.version().then((running) => setVersion(updatedVersion(window.localStorage, running)));
+ }, []);
+
+ return {
+ version,
+ onDismiss: () => {
+ setVersion(undefined);
+ window.localStorage.removeItem('mimik.updateNotice');
+ },
+ };
+}
diff --git a/apps/desktop/src/renderer/lib/__tests__/updated-version.test.ts b/apps/desktop/src/renderer/lib/__tests__/updated-version.test.ts
new file mode 100644
index 0000000..6546cb7
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/__tests__/updated-version.test.ts
@@ -0,0 +1,26 @@
+import { beforeEach, describe, expect, it } from 'vitest';
+import { updatedVersion } from '../updated-version';
+
+describe('updatedVersion', () => {
+ beforeEach(() => {
+ localStorage.clear();
+ });
+
+ it('stays quiet on the first launch', () => {
+ expect(updatedVersion(localStorage, '1.1.1')).toBeUndefined();
+ });
+
+ it('announces the new version after an update, and keeps it until dismissed', () => {
+ updatedVersion(localStorage, '1.1.1');
+ expect(updatedVersion(localStorage, '1.2.0')).toBe('1.2.0');
+ expect(updatedVersion(localStorage, '1.2.0')).toBe('1.2.0');
+
+ localStorage.removeItem('mimik.updateNotice');
+ expect(updatedVersion(localStorage, '1.2.0')).toBeUndefined();
+ });
+
+ it('stays quiet when the same version starts again', () => {
+ updatedVersion(localStorage, '1.1.1');
+ expect(updatedVersion(localStorage, '1.1.1')).toBeUndefined();
+ });
+});
diff --git a/apps/desktop/src/renderer/lib/updated-version.ts b/apps/desktop/src/renderer/lib/updated-version.ts
new file mode 100644
index 0000000..14027e1
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/updated-version.ts
@@ -0,0 +1,9 @@
+const SEEN_VERSION = 'mimik.seenVersion';
+const UPDATE_NOTICE = 'mimik.updateNotice';
+
+export function updatedVersion(storage: Storage, running: string): string | undefined {
+ const seen = storage.getItem(SEEN_VERSION);
+ if (seen !== null && seen !== running) storage.setItem(UPDATE_NOTICE, running);
+ storage.setItem(SEEN_VERSION, running);
+ return storage.getItem(UPDATE_NOTICE) ?? undefined;
+}
diff --git a/apps/extension/src/ui/fullview/App.tsx b/apps/extension/src/ui/fullview/App.tsx
index 789cce8..b0ca164 100644
--- a/apps/extension/src/ui/fullview/App.tsx
+++ b/apps/extension/src/ui/fullview/App.tsx
@@ -1,17 +1,18 @@
import type { CaptureInsert } from '@mimik/core/capture/capture-insert';
-import { AppFrame, GuidePage, LibraryContent, SearchModal, TooltipProvider, useRoute } from '@mimik/ui';
+import { AppFrame, GuidePage, LibraryContent, SearchModal, TooltipProvider, UpdateNotice, useRoute } from '@mimik/ui';
import { useState } from 'react';
import { browser } from '#imports';
import { startInsertRecording } from '@/capture/start-insert-recording';
import { openSidebar } from '@/lib/browser-api/open-sidebar';
import { sendMessage } from '@/lib/messaging';
-import { UpdateNotice } from '@/ui/shared/UpdateNotice';
+import { useUpdateNotice } from '@/ui/shared/hooks/use-update-notice';
import { BackgroundVoiceNotice } from './components/BackgroundVoiceNotice';
import { CaptureTabDialog } from './components/CaptureTabDialog';
export function FullViewApp() {
const route = useRoute();
const [pendingInsert, setPendingInsert] = useState<CaptureInsert | null>(null);
+ const updateNotice = useUpdateNotice();
return (
<TooltipProvider>
@@ -22,7 +23,7 @@ export function FullViewApp() {
settingsExternal
>
<SearchModal />
- <UpdateNotice className="fixed bottom-6 left-1/2 -translate-x-1/2 z-50" />
+ <UpdateNotice {...updateNotice} className="fixed bottom-6 left-1/2 -translate-x-1/2 z-50" />
{route.page === 'library' && (
<main className="flex-1 flex flex-col p-8">
diff --git a/apps/extension/src/ui/shared/hooks/use-update-notice.ts b/apps/extension/src/ui/shared/hooks/use-update-notice.ts
new file mode 100644
index 0000000..8692d63
--- /dev/null
+++ b/apps/extension/src/ui/shared/hooks/use-update-notice.ts
@@ -0,0 +1,19 @@
+import { useEffect, useState } from 'react';
+import { dismissUpdateNotice } from '@/lib/update-notice/dismiss-update-notice';
+import { readUpdateNotice } from '@/lib/update-notice/read-update-notice';
+
+export function useUpdateNotice(): { version: string | undefined; onDismiss: () => void } {
+ const [version, setVersion] = useState<string>();
+
+ useEffect(() => {
+ readUpdateNotice().then(setVersion);
+ }, []);
+
+ return {
+ version,
+ onDismiss: () => {
+ setVersion(undefined);
+ void dismissUpdateNotice();
+ },
+ };
+}
diff --git a/apps/extension/src/ui/sidepanel/App.tsx b/apps/extension/src/ui/sidepanel/App.tsx
index 4107546..40ba742 100644
--- a/apps/extension/src/ui/sidepanel/App.tsx
+++ b/apps/extension/src/ui/sidepanel/App.tsx
@@ -1,6 +1,6 @@
import { isLive } from '@mimik/core/capture/is-live';
import { logger } from '@mimik/core/logger';
-import { Button, Input, TooltipProvider, VoiceNotice } from '@mimik/ui';
+import { Button, Input, TooltipProvider, UpdateNotice, VoiceNotice } from '@mimik/ui';
import { Globe, Search, Settings, Video } from 'lucide-react';
import { useCallback, useEffect, useState } from 'react';
import { browser, i18n } from '#imports';
@@ -19,8 +19,8 @@ import { sendMessage } from '@/lib/messaging';
import { getVoiceStatus } from '@/lib/offscreen/get-voice-status';
import { connectToBackground } from '@/lib/port/connect-to-background';
import type { PanelAiUpdate, PanelVoiceUpdate } from '@/lib/port/types';
+import { useUpdateNotice } from '@/ui/shared/hooks/use-update-notice';
import { SettingsView } from '@/ui/shared/SettingsView';
-import { UpdateNotice } from '@/ui/shared/UpdateNotice';
import { GuideEditor } from './GuideEditor';
import { GuideMeCompletion } from './GuideMeCompletion';
import { GuideMeView } from './GuideMeView';
@@ -38,6 +38,7 @@ type View =
export function App() {
const [isAlive, setIsAlive] = useState(false);
+ const updateNotice = useUpdateNotice();
const [view, setView] = useState<View>({ name: 'library' });
const [search, setSearch] = useState('');
const [activeUrl, setActiveUrl] = useState<string>();
@@ -272,7 +273,7 @@ export function App() {
</div>
<div className="flex-1 px-5 pt-5">
- <UpdateNotice className="mb-4" />
+ <UpdateNotice {...updateNotice} className="mb-4" />
<div className="relative mb-5">
<Search size={15} className="absolute left-3.5 top-1/2 -translate-y-1/2 text-purple" />
diff --git a/apps/extension/src/ui/shared/UpdateNotice.tsx b/packages/ui/src/common/components/UpdateNotice.tsx
similarity index 64%
rename from apps/extension/src/ui/shared/UpdateNotice.tsx
rename to packages/ui/src/common/components/UpdateNotice.tsx
index ee2e3f0..a89f4a8 100644
--- a/apps/extension/src/ui/shared/UpdateNotice.tsx
+++ b/packages/ui/src/common/components/UpdateNotice.tsx
@@ -1,25 +1,17 @@
import { i18n } from '@mimik/core/env';
import { Sparkles, X } from 'lucide-react';
-import { useEffect, useState } from 'react';
-import { dismissUpdateNotice } from '@/lib/update-notice/dismiss-update-notice';
-import { readUpdateNotice } from '@/lib/update-notice/read-update-notice';
const RELEASES_URL = 'https://github.com/westpoint-io/mimik/releases';
-export function UpdateNotice({ className = '' }: { className?: string }) {
- const [version, setVersion] = useState<string>();
-
- useEffect(() => {
- readUpdateNotice().then(setVersion);
- }, []);
+interface UpdateNoticeProps {
+ version: string | undefined;
+ onDismiss: () => void;
+ className?: string;
+}
+export function UpdateNotice({ version, onDismiss, className = '' }: UpdateNoticeProps) {
if (!version) return null;
- const dismiss = () => {
- setVersion(undefined);
- dismissUpdateNotice();
- };
-
return (
<div
role="status"
@@ -31,13 +23,13 @@ export function UpdateNotice({ className = '' }: { className?: string }) {
href={RELEASES_URL}
target="_blank"
rel="noreferrer"
- onClick={dismiss}
+ onClick={onDismiss}
className="text-[11px] font-semibold text-accent hover:underline"
>
{i18n.t('common.whatsNew')}
</a>
<button
- onClick={dismiss}
+ onClick={onDismiss}
aria-label={i18n.t('common.close')}
className="ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors"
>
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index f5b061a..f1020b1 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -11,6 +11,7 @@ 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 { UpdateNotice } from './common/components/UpdateNotice';
export { useSavedFlash } from './common/hooks/use-saved-flash';
export { formatRelativeTime } from './common/lib/format-relative-time';
export { Button } from './components/ui/button';