Skip to content

feat: WebCodecs media fast path, inline diff approval, local folder search (Wave M2) - #210

Merged
PaulKinlan merged 1 commit into
mainfrom
feat/wave-m2-webcodecs-diff-rag
Nov 29, 2026
Merged

PaulKinlan merged 1 commit into
mainfrom
feat/wave-m2-webcodecs-diff-rag

Conversation

@PaulKinlan

@PaulKinlan PaulKinlan commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Wave M2 flagship upgrades for Co-do.

1. WebCodecs + mediabunny fast path for ffmpeg

  • New src/wasm-tools/adapters/webcodecs-fast-path.ts. It contains a pure planner (planFastPath, parseTimecode, parseBitrate, parseScaleFilter, …), plus detectWebCodecsSupport, selectMediaEngine, and executeFastPath, which lazily import()s mediabunny@1.65.2.
  • ffmpeg-adapter.ts validates the input first, then tries the fast path for trim/remux/transcode/scale/fps jobs between MP4, MOV, WebM and MKV. When it succeeds, the ~31 MB FFmpeg WASM core is never instantiated.
  • It falls back to FFmpeg on:
    • unsupported flags or containers
    • missing WebCodecs (copy-only remuxes don't need it)
    • an invalid conversion
    • any track that would be dropped
    • any thrown error
  • New optional engine param: auto (default), ffmpeg or webcodecs.
  • mediabunny is split into its own lazy chunk that only ffmpeg-adapter imports, so it is not in the main bundle.

2. Inline unified diff in the permission approval dialog

  • write_file, create_file and edit_file pass a lazily computed { diffPreview: { path, before, after } } context to checkPermission. It is computed only when the permission level is ask.
  • src/diff-preview.ts builds the model, using prefix/suffix trimming so small edits to big files still preview, plus row and cell caps.
  • The renderer uses only createElement/textContent/setAttribute (no innerHTML). A unit test uses a fake DOM that throws on innerHTML and checks that a <script>/onerror payload stays text.
  • The dialog shows line numbers, +/− stats, a new-file badge and screen-reader labels ("Added:"/"Removed:"). Colours are WCAG-AA in light and dark mode, with forced-colors support.
  • The edit logic now lives in a pure src/file-edits.ts, so the preview and the actual write use exactly the same transform.

3. Local Folder Search (opt-in, 100% client-side)

  • src/folder-search/ contains:
    • VectorDB, which follows the idb-vector-style contract (insert/update/delete/query → {object,key,similarity}) with pluggable backends. It is a small local store rather than an extra dependency.
    • A deterministic hashed TF + trigram EmbeddingProvider: no model download, works offline, and can be swapped out.
    • Incremental indexing keyed by file size:mtime signatures and the provider id.
    • Hybrid ranking: 0.65 cosine + 0.35 keyword, at most 2 hits per file.
  • The index is stored in IndexedDB (co-do-db v7, folder-index store), scoped per workspace.
  • Ctrl/⌘+K quick panel: an ARIA combobox + listbox with arrow/Enter navigation. Picking a result inserts path:start-end into the prompt. There is also a sidebar button that only appears once a folder is open.
  • search_folder_semantic agent tool, gated by the existing permission system (default Ask, under the new Local Search group).

4. Docs and housekeeping

  • README now opens with a Quickstart, Highlights and a Mermaid architecture diagram, and links to the new docs/local-folder-search.md and docs/webcodecs-fast-path.md. CLAUDE.md is updated.
  • deno.json was already removed on main and git grep -i deno finds nothing, so nothing was left to remove.
  • Added .github/workflows/ci.yml, a lean type-check + Vitest + build:web-only job. The existing Playwright visual workflow is still disabled as it was.
  • Playwright now launches Chromium with --mute-audio --use-mock-keychain --password-store=basic.
  • Every package-lock.json resolved URL points at https://registry.npmjs.org/, and npm ci --ignore-scripts --dry-run exits 0.

Verification

  • npm run type-check: passes.
  • npm run test:unit: 456 tests across 12 files pass. 182 are new: 138 for the fast path, 16 for the diff preview/edits, 28 for folder search.
  • npm run build: passes. It builds the WASM tools, runs tsc and vite, and copies 38 C-built WASM binaries.
  • Playwright: the new Ctrl+K accessibility test passes, including the axe scan. The other Playwright tests time out locally on waitForLoadState('networkidle') because the version-check-worker request never finishes. This happens on main too, so this PR didn't cause it.

…al folder search

- ffmpeg tool: plan supported trim/remux/transcode/scale jobs (mp4/mov/webm/mkv)
  and run them through WebCodecs + mediabunny@1.65.2 before loading the ~31 MB
  FFmpeg WASM core; clean fallback to FFmpeg on unsupported args, missing
  WebCodecs, invalid conversions or dropped tracks. New optional engine param.
- Permission dialog: XSS-safe (DOM/textContent only) unified before/after diff
  for write_file/create_file/edit_file with line numbers, +/- stats, new-file
  badge and WCAG-AA light/dark colours. Edit logic extracted to file-edits.ts.
- Local Folder Search: opt-in, on-device semantic + keyword index in IndexedDB
  (idb-vector-style VectorDB, deterministic TF+trigram embeddings behind a
  pluggable provider, incremental reindex). Ctrl/Cmd+K panel and
  permission-gated search_folder_semantic agent tool. DB version 7.
- Docs: README quickstart + Mermaid architecture, docs/local-folder-search.md,
  docs/webcodecs-fast-path.md; CLAUDE.md updates.
- Tests: unit tests for fast-path planner/selector/fallback, diff generator and
  renderer XSS safety, vector store and folder index; a11y test for the panel.
- CI: lean type-check + Vitest + build workflow; Playwright launches Chromium
  with --mute-audio --use-mock-keychain --password-store=basic.
@PaulKinlan
PaulKinlan merged commit 78cc262 into main Nov 29, 2026
2 checks passed
@PaulKinlan
PaulKinlan deleted the feat/wave-m2-webcodecs-diff-rag branch November 29, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant