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 📖

docs: record the release fixes and the custom-server key rule

davbio719edf3a2b19
diff --git a/AGENTS.md b/AGENTS.md
index d5e0bc4..f764157 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -50,7 +50,7 @@ src/
│ ├── transfer/ # .mimik bundle: export/import a guide between browsers
│ │ ├── schema.ts # BundleManifest + validation of untrusted files
│ │ ├── flatten.ts # flattenScreenshot (bakes redactions before a guide leaves)
-│ │ ├── scrub.ts # scrubValues (removes typed values from prose)
+│ │ ├── scrub.ts # scrubValues + scrubUrl (removes typed values from prose and URLs)
│ │ ├── bundle.ts # exportGuideAsBundle (zip via fflate)
│ │ └── parse.ts # readBundle (unzip + validate)
│ └── guides/ # Data layer: types, Dexie DB, CRUD service, title rules, transcript timeline
@@ -222,6 +222,12 @@ start, not the recording's.
and only `deleteTranscripts` clears it, so an edit replaces `description` and leaves it, and `restoreNarratedDescription`
can put the spoken text back with its `narration` source. That is the whole answer to "an edit
overwrote what I said": the step editor offers the restore only while the two actually differ.
+The reverse holds too: narration that lands on a step the user already edited (`manual`) writes only
+`narratedDescription` and leaves the edit alone. Speech from a later slice about a step an earlier slice
+already narrated (words after the final click, or after a resume with no new click) is appended to what
+that step said rather than replacing it: `applyNarrationToSteps` takes the slice's `epochMs` and appends
+when the step was captured before it. A stop still hands the transcriber every step, because the host
+skips transcription entirely when it is given none, and the tail would never reach the transcript.
The dashboard's transcript panel is the answer to the other half. It shares the side-panel column
with version history, so the store keeps them mutually exclusive, and the TopNav button only appears
@@ -248,8 +254,14 @@ not enough on its own: a step narration wrote holds the same words in `descripti
go into every export while transcripts go into none, so `forgetSpokenWords` also puts any step still
sourced `narration` back on its rule-based text (`buildFallbackDescription`, source `heuristic`), and
strips the sentences an `addedByHand` line pushed into a step — those are stamped `manual`, so the
-source alone would have left verbatim speech behind. A description the user or the AI wrote is
-otherwise left alone. `mergeGuideInto` re-keys transcripts onto the
+source alone would have left verbatim speech behind. On a step that carried spoken text (it has a
+`narratedDescription`) it strips that spoken prefix and any trailing sentence matching a line that is
+unclaimed or claimed by the same step, because a snapshot can hold a line that
+`restoreNarratedDescription` has since released. A step narration never touched loses only its own
+`addedByHand` lines, and is otherwise left alone, whatever its text happens to end with.
+`duplicateGuide` copies the transcript rows onto the copy's step ids, so a copy that carries spoken
+text can still delete it, and `bundleStep` drops `narratedDescription` so a `.mimik` file never carries
+it. `mergeGuideInto` re-keys transcripts onto the
guide it merges into and records the redirect in the `guideMerges` table (Dexie `version(5)`, swept by
`permanentlyDeleteGuide`), and
`saveTranscript` resolves the owning guide before it writes — by the guide a line's step now sits on,
@@ -304,8 +316,12 @@ WebM).
list) and ElevenLabs (`/text-to-speech/{voice}`, per-account catalog via `listVoices`). Both return
mp3. OpenAI is the default because most users already hold that key, and `resolveVoiceoverConfig`
borrows it from AI descriptions on the same terms `resolveVoiceApiKey` uses — both sides OpenAI, or
-nothing. **Holding a key never turns narration on**; `exportOptions.voiceover` defaults to false and
-only the user flips it. Keys are stored per provider (`voiceoverApiKeys`) so switching does not lose
+nothing. Both go through `resolveBorrowableOpenAIKey`, which also refuses a key saved against a custom
+`aiBaseUrl`: that key belongs to the user's own server, and sending it to `api.openai.com` leaks it.
+**Holding a key never turns narration on**; `exportOptions.voiceover` defaults to false and only the
+user flips it, for the current panel session only. It is never persisted: `saveExportOptions` stores it
+as false and `loadExportOptions` returns it as false, so no caller can inherit a paid option from
+storage, and the export panel, which stays mounted between opens, turns it off again on close. Keys are stored per provider (`voiceoverApiKeys`) so switching does not lose
one, and a voice id is validated against the provider that issued it — an ElevenLabs id selected
under OpenAI falls back to OpenAI's default rather than being sent and rejected. ElevenLabs ids are
taken on trust, since the account catalog is larger than the shipped list.
@@ -424,6 +440,7 @@ Font: Poppins (loaded via `@fontsource/poppins`).
- **The restart has to outlive the flush.** Stopping narration leaves the phase on `'transcribing'` for a whole API round-trip, and `canStartNarrationNow` refuses that phase, so a single attempt on resume always failed and the mic never came back while the panel went on showing narration as enabled. `restartNarrationOnceTranscriptionSettles` retries while `isNarrationSettling()` holds, up to `NARRATION_RESTART_ATTEMPTS` waits on `whenNarrationSettled()`, then calls `reportNarrationLost` so the panel stops claiming the mic is on. It stops *immediately* when the phase is anything else: a start that failed on its own 8s timeout leaves the phase `'idle'`, and retrying there would call `startVoiceCapture` a second time, get `already-recording`, and `closeVoiceHost()` a host that had just started. It is deliberately *not* awaited by `resumeCapture` — the panel is waiting on that reply — so its rejection is caught rather than left unhandled
- **`narrationWasLive` lives in the machine context**, not a module variable, because the worker can be evicted while the recording sits paused. Per the note above, a snapshot persisted before the key existed restores it as `undefined`, so it is read as `=== true`. Its *source* cannot be the module-level `phase` either, which an eviction resets to `'idle'`: `pauseCapture` calls `isNarrationLive()`, which asks the host when the phase says nothing, and counts `'transcribing'` as live so a second pause during the first one's flush does not lose the flag
- **`claimTranscription`/`releaseTranscription` are a matched pair** and every path that reports `'transcribing'` uses them, `recoverNarration` included — a claim without `markNarrationPending` made `whenNarrationSettled()` resolve instantly and burned both restart attempts in one tick. They count outstanding transcriptions rather than holding one slot, because a pause followed by a stop claims twice; `releaseTranscription` returns whether it owned the claim, so a failed stop cannot report an error over a terminal `idle`
+- **Resume and Stop wait for a pause still in flight** (`whenPauseSettled`). A Resume that landed while the pause was flushing used to restart the mic before the pause stopped it, leaving the recording live with narration gone
- **Pausing waits for the frames to drain.** `broadcastStopCaptureAndFlush` is answered only once each content script's queue is idle, because `CaptureController.stop()` enqueues the input session's finalize. `handleFinalizeInputStep` is therefore gated on "not IDLE" rather than `RECORDING`: it only ever completes a step the user finished before pausing, and `enterBlurMode` awaits the flush before opening the overlay so that screenshot cannot catch it
- **Navigation listeners treat `PAUSED` as live** (`navigation.ts:isLive`). `URL_CHANGED` has to keep flowing or the first step after a resume is stamped with the pre-pause URL, which Guide Me then replays to; injection has to keep running or a tab opened mid-pause is deaf to the resume broadcast
- **Blur mode pauses via that state**, and a top frame booting into `PAUSED`/`'blur'` re-opens the overlay, so a navigation mid-blur still has a Done button. `exitBlurMode` and the panel's Resume both broadcast `DISMISS_BLUR` before resuming, which closes the overlay but keeps the masks the user just picked; only the end of a recording sends `CLEAR_BLUR` to remove them
@@ -434,6 +451,8 @@ Font: Poppins (loaded via `@fontsource/poppins`).
- **Recording notification** uses `animationend` event (not hardcoded delays) for timing
- **Font loading** uses `@fontsource/poppins` (CSP-safe, no CDN dependency)
- **Cross-context sync** via BroadcastChannel — star/delete events update other views without full reload
+- **A blur redaction blurs past its own box and clips back to it** (`drawBlurRedaction` in `core/screenshot/draw.ts`). Blurring only the box's pixels averages transparency in at the edges, so the sharp original showed through a ~12px band on every side, and a box drawn snugly around one line of text stayed readable. It blurs `BLUR_MARGIN` pixels beyond the box, and lays a coarse copy of the box underneath first, so where the image itself ends and the blur still thins, what shows is that copy and not the text. The coarse copy is built from the part of the box inside the image, so a box that crosses the edge of a crop is covered too
+- **Bundle URLs are scrubbed part by part** (`scrubUrl`): with typed text stripped, each path segment, query value and fragment is decoded, compared against the typed values (a short value only as a whole part) and re-encoded, and the scheme and host are never touched, so typing a word that also appears in the domain cannot corrupt the URL. Outside full mode a `data:` URL keeps only `data:`, and a `file:` URL in origin mode only `file://`
- **Bundle export flattens before it ships** — `redact` annotations are drawn at render time, so `screenshot.blob` still holds the unblurred capture. `flattenScreenshot` burns redactions into the pixels and drops the annotation, and bakes an *explicit* crop (rebasing annotations and resolving `bounds` into an explicit target). The automatic zoom-to-target crop stays as data. Anything that ships a screenshot outside the browser must go through the renderer
-- **Guide titles are single-line**, normalised by `sanitizeGuideTitle` on every write path: `updateGuideTitle`, `importGuide`, `revertToSnapshot` and the AI meta path. Each renderer downstream already assumed it. The HTML and PDF covers clamp to `MAX_TITLE_LINES`, their running headers to one line, the video cover card wraps to two, the sidepanel truncates, and Markdown writes `# <title>`, where a newline ends the heading and spills the rest into the body. A fifth write path needs the same call. `MAX_TITLE_LENGTH` bounds the AI-generated title only (`core/capture/ai/meta.ts`); a typed title is deliberately uncapped, since every renderer above already clamps and a silent stop at 70 characters gave the user no reason for it
+- **Guide titles are single-line**, normalised by `sanitizeGuideTitle` on every write path: `updateGuideTitle`, `importGuide`, `revertToSnapshot`, `duplicateGuide` and the AI meta path. Each renderer downstream already assumed it. The HTML and PDF covers clamp to `MAX_TITLE_LINES`, their running headers to one line, the video cover card wraps to two, the sidepanel truncates, and Markdown writes `# <title>`, where a newline ends the heading and spills the rest into the body. A sixth write path needs the same call. `MAX_TITLE_LENGTH` bounds the AI-generated title only (`core/capture/ai/meta.ts`); a typed title is deliberately uncapped, since every renderer above already clamps and a silent stop at 70 characters gave the user no reason for it
- **Imports re-mint every id** — `importGuide` mints new guide/step/screenshot ids in one Dexie transaction. Reusing the ids in the file would let a shared guide overwrite one the recipient recorded. It also clears `aiPending`, which no background job will ever resolve for an imported step
diff --git a/README.es.md b/README.es.md
index e9221ee..8dc7e7b 100644
--- a/README.es.md
+++ b/README.es.md
@@ -192,7 +192,7 @@ vuelve atrás con el historial de versiones.
Actívala en el panel de exportación y cada paso del vídeo se leerá en voz alta, con tu propia clave
de OpenAI o ElevenLabs. Si ya configuraste una clave de OpenAI para las descripciones con IA, Mimik
-la reutiliza: no hay que registrarse en nada más. Los pasos narrados permanecen en pantalla hasta que
+la reutiliza: no hay que registrarse en nada más, salvo que las descripciones con IA usen un servidor propio, cuya clave no sale de ahí. Los pasos narrados permanecen en pantalla hasta que
la voz termina, así que nada se corta, y los clips se guardan en caché local para que volver a
exportar la misma guía no cueste nada.
diff --git a/README.fr.md b/README.fr.md
index 4941ff3..fe4f59d 100644
--- a/README.fr.md
+++ b/README.fr.md
@@ -192,7 +192,7 @@ réordonne ou supprime en lot, et reviens en arrière via l'historique de versio
Activez-la dans le panneau d'export et chaque étape de la vidéo est lue à voix haute, avec votre
propre clé OpenAI ou ElevenLabs. Si vous avez déjà renseigné une clé OpenAI pour les descriptions IA,
-Mimik la réutilise : rien d'autre à créer. Les étapes narrées restent à l'écran jusqu'à la fin de la
+Mimik la réutilise : rien d'autre à créer, sauf si les descriptions IA passent par votre propre serveur, dont la clé reste là. Les étapes narrées restent à l'écran jusqu'à la fin de la
voix, donc rien n'est coupé, et les clips sont mis en cache localement pour que réexporter le même
guide ne coûte rien.
diff --git a/README.md b/README.md
index 7a62ef1..9ca30ad 100644
--- a/README.md
+++ b/README.md
@@ -193,8 +193,8 @@ through version history.
### 🔊 Video voice-over (optional)
Turn it on in the export panel and every step of a video export is read aloud, using your own OpenAI
-or ElevenLabs key. If you already set an OpenAI key for AI descriptions, Mimik reuses it — there is
-nothing else to sign up for. Narrated steps hold on screen until the voice finishes, so nothing gets
+or ElevenLabs key. If you already set an OpenAI key for AI descriptions, Mimik reuses it (unless those point at a custom
+server, whose key stays there) — there is nothing else to sign up for. Narrated steps hold on screen until the voice finishes, so nothing gets
cut off, and clips are cached locally so re-exporting the same guide costs nothing.
Off by default: holding a key never turns narration on, you do.
diff --git a/README.pt-BR.md b/README.pt-BR.md
index 9395f91..31c44df 100644
--- a/README.pt-BR.md
+++ b/README.pt-BR.md
@@ -192,7 +192,7 @@ volta atrás pelo histórico de versões.
Ative no painel de exportação e cada passo do vídeo será lido em voz alta, com sua própria chave da
OpenAI ou ElevenLabs. Se você já configurou uma chave da OpenAI para as descrições com IA, o Mimik
-reaproveita — não há mais nada para assinar. Passos narrados ficam na tela até a voz terminar, então
+reaproveita — não há mais nada para assinar, a menos que as descrições com IA usem um servidor próprio, cuja chave fica só lá. Passos narrados ficam na tela até a voz terminar, então
nada é cortado, e os clipes ficam em cache local para que reexportar o mesmo guia não custe nada.
Desligada por padrão: ter uma chave nunca liga a narração; você liga.
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 91eb989..3a4f581 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -183,7 +183,7 @@ Mimik 可以在几秒内把任何重复性的浏览器任务变成一份可分
### 🔊 视频配音(可选)
在导出面板中开启后,视频的每个步骤都会被朗读出来,使用你自己的 OpenAI 或 ElevenLabs 密钥。如果你
-已经为 AI 描述配置了 OpenAI 密钥,Mimik 会直接复用,无需再注册其他服务。有配音的步骤会一直停留到
+已经为 AI 描述配置了 OpenAI 密钥,Mimik 会直接复用,无需再注册其他服务;但如果 AI 描述指向自定义服务器,该密钥只用于那台服务器。有配音的步骤会一直停留到
语音结束,因此不会被截断;音频片段会缓存在本地,重新导出同一份指南不会产生额外费用。
默认关闭:拥有密钥并不会自动开启配音,需要你手动开启。