Repository navigation
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
||
| /** | ||
| * Reports what the CLI is doing to the terminal with the Program Status | ||
| * Protocol (OSC 7501): https://www.superlogical.com/rex/docs/build/program-status |
There was a problem hiding this comment.
Do you think it's worth indicating against which revision of OSC 7501 this implementation supports? The newest revision is 0.4
| if (ENABLE_VALUES.has(override)) { | ||
| return true; | ||
| } | ||
| if (settings && settings.enableProgramStatus === false) { |
There was a problem hiding this comment.
We should consider adding an option to configure it from settings (e.g. --enable-program-status, --no-enable-program-status and document this setting)
There was a problem hiding this comment.
Just sharing my thoughts on feature detection/enablement part
We could consider feature detection as per Program Status spec
To avoid waiting, send primary device attributes (CSI c) right after the query. Every terminal answers that, so if its reply arrives first, the protocol is unsupported.
But in general terminal emulators should ignore unknown OSC sequences
Detection is optional. Terminals MUST ignore unknown OSCs, so a program MAY send reports without querying first, for example when it cannot read replies.
Additionally, such detection adds overhead to every CLI command
Default opt-in should be a deliberate choice, but FYI it should be safe
| { kind: 'permission' } | ||
| ); | ||
|
|
||
| if (!answers.confirmation && !this.isBulk) { |
There was a problem hiding this comment.
output() calls confirm() at the very end, after the result has already been set. In bulk mode, isBulk has also been reset to false by then, so the bulk guard here doesn't apply. cancel() then overwrites whatever outcome was stored.
I could repro it with the following
printf 'fileID\n111\n222\n333\n' > bulk.csv; echo '{}' > out.json
BOX_PROGRAM_STATUS=1 ./bin/run files:get --bulk-file-path bulk.csv --token fake \
--save-to-file-path out.json 2>status.log
Then answering NO to a prompt
Decoded reports:
working 100 Bulk files:get: 3/3 entries
blocked permission File .../out.json already exists — overwrite?
working 100 Bulk files:get: 3/3 entries
idle Cancelled box files:get
Answering "Yes" gives
error Bulk files:get: 3 of 3 entries failed
Which is what I'd expect in both cases, no matter the prompt answer. I think we may consider cancel to keep the outcome already set
| } | ||
|
|
||
| function runChunkedUpload(uploader, size) { | ||
| function runChunkedUpload(uploader, size, onProgress) { |
There was a problem hiding this comment.
Non-blocking: the bar and PSP progress are calculated separately here and in files:download. That's fine for now, but a shared helper later would stop them from drifting apart.
Coverage Report for CI Build 39361948155Coverage increased (+0.3%) to 85.19%Details
Uncovered Changes
Coverage Regressions8 previously-covered lines in 4 files lost coverage.
Coverage Stats💛 - Coveralls |
Summary
Reports what the CLI is doing using the Program Status Protocol (OSC 7501), so terminals that support it can show command state outside the terminal (for example on tabs or in a session list). Terminals that don't support it ignore the sequences.
workingwhen a command starts, with progress for downloads, chunked uploads, and bulk input;blockedduring confirmation prompts, questions, and browser sign-in; anddone,error, oridle(cancelled or interrupted) when it ends.--help.BOX_PROGRAM_STATUS=0or"enableProgramStatus": falsein~/.box/settings.json, and forced on withBOX_PROGRAM_STATUS=1. Also off whenTERM=dumb.Changes
src/program-status.js: newProgramStatusreporter plusformatReport,sanitizeText,truncateUtf8, andisEnabled.src/box-command.js: starts and finishes reporting around each command, and reportsblockedaroundconfirm()andprompt().files/foldersupload and download,files:versions,files:zip,login,logout,configure:environments:delete,configure:environments:set-current) andsrc/modules/upload.jsreport progress and prompts.Testing
test/program-status.test.jscovers formatting, sanitizing, enablement, state transitions, signals, prompts, and full command runs, including bulk progress and failures.blockedon auth while waiting for the browser, plus timeout and invalid-callback errors.test/helpers/setup.jssetsBOX_PROGRAM_STATUS=0for the whole test run so existing output assertions aren't affected when tests run in a TTY.Made with Cursor