feat(upload): send the draft name as name Upload-Metadata - #134
Merged
Conversation
…chor The draft's human-facing title (projects.name) now rides the upload so the server/consumer can label the artifact instead of showing a UUID. Sent only on each unit's session anchor -- the merged video, or the segment ordering manifest -- read fresh at upload time (like the transcript) so a last-second rename wins, and omitted entirely when the draft was never named. Free-form titles can carry accents/emoji, so `name` uses a UTF-8-safe base64 (encodeURIComponent -> byte string -> btoa) via Hermes-guaranteed globals; the ASCII-only btoa used for artifactId/filename/kind would corrupt them. base64 output has no comma, so a name with commas can't break the comma-joined metadata header. Requires a server that reads the `name` Upload-Metadata key (mieweb/pulsevault with the display-name change); older servers ignore the unknown key harmlessly.
jlocala1
force-pushed
the
feat/upload-draft-name
branch
from
July 28, 2026 19:37
14a5186 to
e570dc0
Compare
morepriyam
marked this pull request as ready for review
July 28, 2026 22:08
There was a problem hiding this comment.
Pull request overview
Adds support for sending a draft’s human-readable title alongside TUS uploads via the Upload-Metadata header (name key), so downstream consumers can label uploaded artifacts with the draft name instead of a UUID.
Changes:
- Add
getDraftName(draftId)to read the latest draft title at upload time. - Thread optional
namethrough upload artifact specs/transports and include it inUpload-Metadata(UTF-8-safe base64). - Extend TUS client tests to verify
namepresence/omission and UTF-8 round-trip for non-ASCII titles.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/features/upload/upload-manager.ts | Fetches draft name at upload time and attaches it only to session-anchor artifacts (merged video / ordering manifest). |
| src/features/upload/types.ts | Extends UploadArtifactSpec with optional name. |
| src/features/upload/tus-client.ts | Adds UTF-8-safe base64 encoding and emits optional name in Upload-Metadata. |
| src/features/upload/tus-client.test.ts | Adds coverage for ASCII name, omission when unset, and UTF-8 non-ASCII round-trip. |
| src/features/upload/transports/tus-server-transport.ts | Threads name from artifact spec into uploadViaTus options. |
| src/db/drafts.ts | Introduces getDraftName for fresh-at-upload-time title lookup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
morepriyam
self-requested a review
July 28, 2026 22:11
# Conflicts: # src/features/upload/upload-manager.ts
A lone surrogate in a draft title (e.g. a value pasted truncated mid-emoji) makes encodeURIComponent throw, which would fail the whole upload while building Upload-Metadata. base64EncodeUtf8 now returns null in that case and the caller omits the optional name field rather than crashing. Adds a test.
morepriyam
enabled auto-merge
July 29, 2026 02:27
morepriyam
disabled auto-merge
July 29, 2026 02:28
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.
Send the draft name with the upload
The draft's title (
projects.name) now rides the upload as thenameUpload-Metadatakey, so the server/consumer can label the artifact instead of showing a UUID.What
getDraftName(draftId)(db/drafts.ts), read fresh at upload time (like the transcript) so a rename right before upload wins; returnsundefinedwhen never named so it drops straight into the optional field.nameuses a UTF-8-safe base64 (encodeURIComponent→ byte string →btoa) via Hermes-guaranteed globals; the ASCII-onlybtoaused forartifactId/filename/kindwould corrupt them. base64 output contains no comma, so a name with commas can't break the comma-joined header.Tests
tus-client.test.ts: ASCII name present + omitted-when-unset, and a non-ASCII UTF-8 round-trip.tsc --noEmitclean,jest24/24.Depends on
mieweb/pulsevault#56 (server-side
nameparsing/persistence). Land + publish that first, then this. Against an older server the unknownnamekey is ignored harmlessly — so this is safe to merge whenever, it just has no effect until the server understands it. Draft until #56 ships.