feat(worker): guest transcript image upload + code block fixes#3
Open
wangjs-jacky wants to merge 1 commit into
Open
feat(worker): guest transcript image upload + code block fixes#3wangjs-jacky wants to merge 1 commit into
wangjs-jacky wants to merge 1 commit into
Conversation
- Add POST /api/v1/transcript-image guest endpoint (no auth): accepts raw image bytes, mime from X-Image-Type (Content-Type fallback), 5MB cap (413), rejects non-image/empty (400), returns 201 with same-origin URL. - Introduce imagesStore(env) adapter: R2 (env.IMAGES) when bound, else PAGES_KV fallback (img: prefixed keys, base64 value with chunked encode). Route authed /upload-image and serveImage through it (same backend, backward compatible for existing images/... keys). - Fix code block styling in both document/chat themes: white-space:pre + overflow-x:auto horizontal scroll, max-width:100%, min-width:0; chat grid minmax(0,1fr), turn-body/markdown min-width:0, bubble overflow:hidden; inline code word-break; tab-size:2. - Strip fence language identifier line in renderMarkdown so ```bash / ```json no longer render the language token as content.
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
Follow-up to the transcript publishing feature (#2). Adds guest image hosting for transcripts and fixes code-block rendering.
1. Guest image upload —
POST /api/v1/transcript-imageLets a transcript embed images that load same-origin over HTTPS. Previously a publisher had to reference images hosted elsewhere; if that host was HTTP or used an untrusted cert, browsers blocked them as mixed content and the images silently failed. Now images can be uploaded to the worker itself and served from
/images/....X-Image-Type(falls back toContent-Type). 5MB cap (413), non-image/empty (400).imagesStore(env)adapter: uses R2IMAGESwhen bound (unchanged behavior); falls back toPAGES_KVwhen no R2 is enabled (base64-wrapped), so the worker works on accounts without R2.serveImage/handleUploadImagerewired through the same adapter — existing authed/api/v1/upload-imageand existingimages/...objects behave identically.2. Code block fixes
<pre>now scrolls horizontally (overflow-x:auto,max-width:100%,white-space:pre) so long lines (e.g. shell scripts) don't break the layout; chat-theme bubble columns useminmax(0,1fr)+min-width:0to stop wide code from overflowing the message column.```bash/```jsonpreviously showedbash/jsonas the first line of the block. This also improves/api/v1/publishoutput (the only shared-render change).Verification
Deployed to a test worker (KV-backed, no R2) and verified end-to-end: image upload → 201 same-origin URL → GET returns the exact bytes; transcript with a long bash block renders without a stray language line and scrolls instead of overflowing.