Merged
Conversation
faf5e08 to
e717ae2
Compare
AmethystLiang
approved these changes
Mar 8, 2026
Contributor
AmethystLiang
left a comment
There was a problem hiding this comment.
AI Code Review (Claude)
Overall: Approve. Well-structured PR with clear commit separation and a thorough write-up. The three bugs are real and the fixes are correct.
Fix 1: Double-escaped regex (\\u2318 → \u2318)
Correct fix. The double backslashes were causing SyntaxError: Invalid regular expression flags which killed all JS on the page.
Fix 2: Send button always disabled
Correct. Setting innerHTML doesn't fire the input event, so updateSendBtn() was never called when initial text was present. Using requestAnimationFrame is the right approach to ensure the DOM has settled before checking content.
Fix 3: Static text import for bundling
Replacing runtime readFileSync with a static import ... with { type: "text" } is the right call — lets Bun inline the HTML at build time and fixes the ENOENT after bundling/compiling.
Minor observations:
getEditorHtml()is now a trivial wrapper (return _editorHtmlContent) — could be inlined intobuildEditorHtml()in a follow-up.- The
@ts-ignoreis well-documented. Worth consideringmodule: "ESNext"in tsconfig later to remove it.
Ship it.
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.
The
message draftcommand had a few issues with it. I've fixed them all. This should permanently close #49.Issue 1
Every
\indraft-editor.html's<script>block is/was escaped for some reason at some point using a double backslash(\\). In a JS regex literal,\\/is parsed as\\(literal backslash) followed by/(closes the regex) — the parser then tries to read the remaining code as regex flags and throws:This kills all JavaScript on the page.
Issue 2
The send button in a draft message was always disabled. When initial text is provided
editor.innerHTML = ...doesn't fire theinputevent, soupdateSendBtn()was never called.Issue 3
getEditorHtml()loads the HTML at runtime viareadFileSyncrelative toimport.meta.url. This works from source but fails after bundling (dist/index.js) or compiling (bun build --compile) because the HTML file doesn't exist at the resolved path:Fixed by replacing the runtime
readFileSyncwith a staticimport ... with { type: "text" }, which Bun inlines into the bundle at build time. A sibling.d.tsfile types the import as string since bun-types declares*.htmlasHTMLBundle(meant for Bun.serve HTML routes, not text imports).Works for source,
bun build --outdir, andbun build --compile.Note: The import has a
@ts-ignorebecausemodule: "ES2022"in tsconfig doesn't support import attributes syntax. Changing tomodule: "ESNext"would remove the need for it.. no behavioral difference sincenoEmit: trueand Bun handles bundling regardless.Style changes
It looks like draft-editor.html was added before oxfmt commit hooks. So I separated the style commit out so its an easier to read diff.
Commits
fix: repair double-escaped regex patterns in draft editor\\→\in the<script>block +updateSendBtn()fixstyle: format draft-editor.html (oxfmt)fix: inline draft-editor.html into bundle via static text importreadFileSyncwith static text import