Skip to content

feat(upload): send the draft name as name Upload-Metadata - #134

Merged
morepriyam merged 3 commits into
mieweb:mainfrom
jlocala1:feat/upload-draft-name
Jul 29, 2026
Merged

feat(upload): send the draft name as name Upload-Metadata#134
morepriyam merged 3 commits into
mieweb:mainfrom
jlocala1:feat/upload-draft-name

Conversation

@jlocala1

Copy link
Copy Markdown
Contributor

Send the draft name with the upload

The draft's title (projects.name) now rides the upload as the name Upload-Metadata key, so the server/consumer can label the artifact instead of showing a UUID.

What

  • New getDraftName(draftId) (db/drafts.ts), read fresh at upload time (like the transcript) so a rename right before upload wins; returns undefined when never named so it drops straight into the optional field.
  • Sent only on each unit's session anchor — the merged video, or the segment ordering manifest — and omitted entirely when the draft has no name.
  • 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 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 --noEmit clean, jest 24/24.

Depends on

mieweb/pulsevault#56 (server-side name parsing/persistence). Land + publish that first, then this. Against an older server the unknown name key is ignored harmlessly — so this is safe to merge whenever, it just has no effect until the server understands it. Draft until #56 ships.

…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
jlocala1 force-pushed the feat/upload-draft-name branch from 14a5186 to e570dc0 Compare July 28, 2026 19:37
@morepriyam
morepriyam marked this pull request as ready for review July 28, 2026 22:08
Copilot AI review requested due to automatic review settings July 28, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 name through upload artifact specs/transports and include it in Upload-Metadata (UTF-8-safe base64).
  • Extend TUS client tests to verify name presence/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.

Comment thread src/features/upload/tus-client.ts Outdated
@morepriyam
morepriyam self-requested a review July 28, 2026 22:11
# Conflicts:
#	src/features/upload/upload-manager.ts
Copilot AI review requested due to automatic review settings July 28, 2026 22:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

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.
Copilot AI review requested due to automatic review settings July 28, 2026 22:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@morepriyam morepriyam left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@morepriyam
morepriyam enabled auto-merge July 29, 2026 02:27
@morepriyam
morepriyam disabled auto-merge July 29, 2026 02:28
@morepriyam
morepriyam merged commit c59e0a2 into mieweb:main Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants