Repository navigation
Run the main process on Cottontail; fix DOCX open and a startup crash - #32
Merged
Merged
Conversation
parseDocx passed { arrayBuffer } to mammoth.convertToHtml, but that
option only exists in Mammoth's browser build. The Node build bundled
into the main process reads { path | buffer | file } and rejects
anything else with "Could not find file in options", so every DOCX
open threw. Pass { buffer } instead (a Buffer view over the same
ArrayBuffer — no copy).
Claude-Session: https://claude.ai/code/session_01Y1BX9DkxUarJzFn2oVp12k
The useEditorState selector added in #31 called editor.getText(), which dereferences editor.state / editor.schema — both unset until EditorContent mounts a view. On the welcome screen the selector runs first, threw, and the error boundary took over the whole app. Read editor.state?.doc guardedly and count words from textBetween instead. Also drop the standalone @tiptap/extension-underline: StarterKit v3 already registers underline, and the duplicate logged a TipTap warning at startup. Claude-Session: https://claude.ai/code/session_01Y1BX9DkxUarJzFn2oVp12k
Switch build.mainProcess to "cottontail", Electrobun 2's JavaScriptCore runtime, so the packaged app no longer ships the Bun binary. Bun stays the dev tool (install, scripts, tests); src/bun/ keeps its name and its Bun.file/Bun.write calls, which Cottontail implements. Verified with the real src/bun/fileParser.ts under the exact cottontail binary that ships in the bundle: MuPDF WASM renders pages, Mammoth parses DOCX, Bun.file/Bun.write/Buffer all behave. The dev app launches with a clean main-process and webview log. Size (dev build, macOS arm64): 79 MB -> 73 MB on disk; the runtime binary is 60.6 MB -> 55.2 MB raw, 24.4 MB -> 20.9 MB zipped. Also ignore .cottontail-tmp/, Hutch's scratch directory. Claude-Session: https://claude.ai/code/session_01Y1BX9DkxUarJzFn2oVp12k
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the main process from Bun to Cottontail, Electrobun 2's JavaScriptCore runtime, and fixes two bugs found while verifying it — one pre-existing, one from #31.
1.
fix: DOCX files failed to open(pre-existing, since the initial commit)parseDocxpassed{ arrayBuffer }to Mammoth, but that option only exists in Mammoth's browser build. The Node build that gets bundled into the main process accepts{ path | buffer | file }and rejects everything else withCould not find file in options— so every DOCX open threw, on Bun and Cottontail alike. Now passes{ buffer: Buffer.from(arrayBuffer) }(a view, no copy).2.
fix: word-count selector crashed the UI before the editor mounted(regression from #31)The
useEditorStateselector callededitor.getText(), which readseditor.state/editor.schema— both unset untilEditorContentmounts a view. On the welcome screen the selector runs first, threw, and the error boundary replaced the whole app. The selector now readseditor.state?.docguardedly. Also removes the standalone@tiptap/extension-underline(StarterKit v3 already registers it; the duplicate logged a warning at startup).3.
feat: run the main process on Cottontailbuild.mainProcess: "cottontail". Bun remains the dev tool (install/scripts/tests);src/bun/keeps its name and itsBun.file/Bun.writecalls, which Cottontail implements. README updated..cottontail-tmp/(Hutch scratch) added to.gitignore.Verification
src/bun/fileParser.tsexecuted under the exactcottontailbinary from the built bundle (SHA-matched to the Hutch store copy) — MuPDF opens an 8-page PDF and renders page 1 at 2× to a PNG data URL; Mammoth converts a DOCX with heading/bold/italic to HTML;Bun.file().arrayBuffer(),.exists(),Bun.write, and Buffer base64 round-trips all pass.electrobun build+run --env=dev) launches with a clean main-process log and no webview console errors (the first launch, before fix 2, showed the error-boundary crash).bun test38 pass,tsc --noEmitclean,vite buildclean.Size (dev build, macOS arm64)
.appon diskSmaller, but well short of Electrobun's ~15 MiB headline for a Cottontail hello-world — this is the
--env=devbuild, and the remaining bulk is the runtime binary itself (ICU etc.). Worth re-measuringbuild:stablebefore drawing conclusions.https://claude.ai/code/session_01Y1BX9DkxUarJzFn2oVp12k