feat(editor): expose window.gitmost bridge to insert recordings as audio blocks

Add a stable native-host JS-API on window.gitmost so the gitmost.app
WKWebView wrapper can hand a recorded audio file to the current page as an
audio block without depending on editor internals (atoms/Tiptap/Yjs).

- page-editor.tsx: register/tear down window.gitmost only while an editable
  page editor is mounted (ready=true, version=1). insertRecording validates
  mime/size, decodes base64 in 4-char-aligned chunks, rejects oversized
  payloads before decoding (too-large), reuses the existing uploadAudioAction
  pipeline, resolves machine-readable error codes
  (no-editor/bad-type/too-large/insert-failed) and never throws. Cleanup is
  identity-guarded so an unmounting PageEditor cannot disable a newer live
  registration.
- editor-ext audio-upload: return the uploaded attachment from the upload fn
  so the bridge can report success + attachmentId. Backward compatible:
  existing fire-and-forget callers ignore the return value; the error path
  still swallows and returns undefined (no re-throw).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
claude_code
2026-06-23 02:24:28 +03:00
parent da058bb6a0
commit 10fe605159
2 changed files with 185 additions and 1 deletions

View File

@@ -128,6 +128,11 @@ const handleAudioUpload =
.run();
disposePreviewFile();
}
// Return the uploaded attachment so callers that await this (e.g. the
// gitmost native bridge) can report success and the attachment id.
// Existing fire-and-forget callers ignore the return value.
return attachment;
} catch (error) {
clearTimeout(insertPlaceholderTimeout);