Consolidate server/web media file-type tables into one shared module - #844
Merged
Conversation
The text-extension table, MIME-to-extension table, and upload accept list were each maintained in two or three copies across the server and web, and had drifted: the server accepted .mjs/.cjs/.bash/.zsh uploads the web viewer would not render as text (and the web file picker would not offer), the web accepted .env files the server rejected with a 400, and the web extensionForMime named pasted mp4/PDF blobs .png. All tables now live in a single dependency-free module, apps/server/src/shared/media-file-types.ts, imported by the server media helpers and by web (same cross-boundary pattern as use-templates.ts -> templates/arg-parser). The accept list is derived from the same sets, so the picker filter can no longer drift from the server's validation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…chable dotfile test MediaContent's hand-maintained ACCEPTED_EXTENSIONS literal (the third copy of the accept list) now consumes STARTUP_FILE_ACCEPT, and the bare-dotfile unit test is removed since sanitizeUploadedFileName strips leading dots before the upload routes ever call isMediaFile. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 29, 2026
selfcontained
added a commit
that referenced
this pull request
Jul 29, 2026
…849) AGENT_TYPES, CLI_AGENT_TYPES, and their predicates/sanitizers were duplicated verbatim between apps/server/src/agent-type-settings.ts and apps/web/src/lib/agent-types.ts; same for IDE_TYPES between apps/server/src/ide-settings.ts and apps/web/src/lib/ide-types.ts. Adding an agent type meant editing both copies. Move the pure constants and predicates into dependency-free apps/server/src/shared/agent-types.ts and shared/ide-types.ts, following the media-file-types.ts shape from #844: the server settings modules re-export so their importers are untouched, and the web lib modules re-export across the workspace boundary so web importers keep their "@/lib/..." specifiers. Pool-dependent getters stay on the server; display labels and web-only helpers stay in web. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
selfcontained
added a commit
that referenced
this pull request
Jul 30, 2026
) Covers apps/web/src/lib/media-upload.ts (isAcceptedUploadFile extension pre-filter incl. a parity test against the server's authoritative isMediaFile, and uploadAgentMedia's FormData payload: endpoint, method, file bytes/name, source default and override, inject flag semantics, error propagation) and stripTimestamp in media-file-utils.ts (suffix and mid-name stripping, date-only and hyphen-less near-misses left intact). 17 tests; 9-mutant battery all killed. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
selfcontained
added a commit
that referenced
this pull request
Jul 30, 2026
…#852) Media & Sharing deep-dive against the consolidated shared media-file-types module (#844): the format examples, upload accepted-type claims, clipboard-paste wording, and inject delivery claims all verified accurate. One gap: the sandboxed HTML lightbox preview from #850 had no docs coverage — added a Lightbox previews section (per-type rendering, sandbox isolation, Open in tab, copy-source behavior) and html to the dispatch_share format examples. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 31, 2026
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.
What
The media file-type tables were maintained in duplicate (or triplicate) across the server/web boundary and had already drifted into real bugs:
apps/server/src/shared/media.tsandapps/web/src/components/app/media-file-utils.ts. Server had.mjs/.cjs/.bash/.zshthe web lacked (uploads accepted but rendered as opaque files, and the pickers filtered them out); web had.envthe server lacked (uploads rejected with a 400)..bin; the web copy inlib/media-upload.tsnamed pasted mp4/PDF/unknown blobs.png.STARTUP_FILE_ACCEPTinlib/media-accept.tsandACCEPTED_EXTENSIONSinmedia-content.tsx(the media-sidebar "Share file" picker), both lagging the server the same way.All tables now live in one dependency-free module,
apps/server/src/shared/media-file-types.ts(union of both text tables). The server'sshared/media.tsre-exports the predicates so its importers are untouched, and the web modules import across the workspace boundary — the same patternuse-templates.tsalready uses fortemplates/arg-parser. Every accept list is now derived from the same sets, so pickers can no longer drift from server validation.Why it's tech debt
Backlog item #1 from the 2026-07-21 audit (server↔web duplication is the dominant debt category in this codebase). Four copies of the same concept, all requiring parallel edits, already diverged.
Intentional behavior deltas (the drift, fixed)
.envuploads (e.g.config.env); web pickers/viewers now accept + render.mjs/.cjs/.bash/.zshas text..mp4/.pdfnames (were.png); unknown non-image blobs get.bin.Validation
pnpm run check, unit tests (server 2362 + web 481 + extension),finalize:web, e2e (174 passed) all green..envupload returns 201 (was 400),.xyzstill 400,.mjsrenders syntax-highlighted in the media lightbox.isMediaFile.media-content.tsxaccept literal; unreachable dotfile test), both fixed in 45093a2 and verified resolved.Next up
Backlog item: mirrored agent-type/IDE-type modules (
agent-type-settings.tsvslib/agent-types.ts,ide-settings.tsvslib/ide-types.ts).🤖 Generated with Claude Code