Skip to content

Show upload progress for the legacy upload command - #52

Merged
ErikSom merged 2 commits into
mainfrom
upload-progress
Nov 27, 2026
Merged

ErikSom merged 2 commits into
mainfrom
upload-progress

Conversation

@ErikSom

@ErikSom ErikSom commented Nov 27, 2026

Copy link
Copy Markdown
Member

Summary

poki upload used to print uploading... and then go quiet until the server answered, so a large build on a slow connection looked stuck. It now draws a live progress line:

uploading...
[################--------------]  54%  13.8 MB / 25.2 MB  7.6 MB/s
  • The multipart body is written in 64 KiB slices. Each write callback reports the bytes the socket has taken, and the progress line redraws at most every 100 ms, plus a final redraw at 100%.
  • The line appears only when stdout is a TTY. Piped, captured and CI output is byte-identical to before, which keeps the compatibility guarantee for the legacy command.
  • Content-Length, the request body and the inactivity timeout are unchanged. If the response arrives before the body has finished sending, the line still ends cleanly, so later output starts on a new row.
  • The line stays one column narrower than the terminal so it doesn't wrap. Units are decimal (KB/MB/GB).

poki versions upload is unchanged. It sends through fetch with a FormData body, and showing progress there would mean streaming the body, which drops the known Content-Length. That is a separate decision.

Test plan

  • yarn validate (lint, typecheck, all tests, package check, build)
  • New test/upload-progress.test.ts: covers formatting, throttling, ending the line exactly once, and the non-TTY no-op. An end-to-end postToP4D run through a loopback server checks that the body and Content-Length arrive intact, and that the human text is unchanged in both TTY and non-TTY modes.
  • Rendered in a real pseudo-terminal (80 columns) against a throttled local server: 39 smooth redraws, longest line 66 characters.
  • Try poki upload against production with a large build

🤖 Generated with Claude Code

`poki upload` printed "uploading..." and then nothing until the server
answered, so a large build on a slow connection looked stuck. The body
is now written in 64 KiB slices, and each write callback updates a
progress line with the percentage, bytes sent, and transfer rate.

The line is drawn only when stdout is a terminal. Piped, captured, and
CI output is byte-identical to before, which keeps the compatibility
guarantee for the legacy command. Content-Length, the body, and the
inactivity timeout are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/upload-progress.ts Resolved
Comment thread src/p4d.ts Resolved
The bar never shrank below 10 columns, so on a 40-column terminal the
line reached 48 characters and wrapped, and each redraw left part of
the previous one behind. Narrow terminals now drop the rate, then the
byte counts, then the bar, and always keep the line shorter than the
terminal.

An interrupt exits without settling the request, so the error document
continued the unfinished progress line. The line's finish is now an
interrupt cleanup, unregistered once the request settles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ErikSom
ErikSom merged commit dd2cbe8 into main Nov 27, 2026
11 checks passed
@ErikSom
ErikSom deleted the upload-progress branch November 27, 2026 14:54
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.

2 participants