Repository navigation
Progress: store scoped while state with start time and delay swapped - #332735
SteVen Batten (sbatten) merged 3 commits into
Conversation
ScopedProgressIndicator.showWhile passed the configured delay as whileStart and Date.now() as whileDelay into ProgressIndicatorState.While, reversing the parameter contract introduced with the class. The replay formula happens to be symmetric under this particular swap so no visible misbehavior exists today, but the delay-vs-timestamp guard reads a wall clock value and any future reader of these fields gets wrong meanings. Pass start time and delay in the declared order and pin the stored fields with a regression test. Test Plan: node build/next/index.ts transpile ELECTRON_ENABLE_LOGGING=1 .build/electron/Code-OSS.exe test/unit/electron/index.js --crash-reporter-directory=.build/crashes --run vs/workbench/services/progress/test/browser/progressIndicator.test.js 3 passing (1 failing before the change: whileDelay held a timestamp)
There was a problem hiding this comment.
Pull request overview
Corrects swapped whileStart and whileDelay arguments in scoped progress state.
Changes:
- Restores the declared argument order.
- Adds regression coverage for stored state and replay behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
progressIndicator.ts |
Corrects While state construction. |
progressIndicator.test.ts |
Adds regression coverage. |
Suppressed comments (1)
src/vs/workbench/services/progress/test/browser/progressIndicator.test.ts:161
- This assertion assumes fewer than two seconds pass before scope activation, so a preempted or debug CI run can fail even though replay is correct. Once the full delay has elapsed,
onDidScopeActivateintentionally callsshow(undefined); accept that case (or use a fake clock) rather than imposing the> 3000wall-clock bound.
assert.strictEqual(true, typeof testProgressBar.fShowDelay === 'number' && testProgressBar.fShowDelay > 3000 && testProgressBar.fShowDelay <= 5000, `unexpected show delay: ${testProgressBar.fShowDelay}`);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Same content, matching the one-line inline comment convention.
|
Addressed in 39418af: both explanatory comments condensed to single lines. |
SteVen Batten (sbatten)
left a comment
There was a problem hiding this comment.
🤖 Approving. showWhile now passes (promise, Date.now(), delay || 0), which matches the ProgressIndicatorState.While constructor order (whilePromise, whileStart, whileDelay). Initial display is unchanged; the fix only affects the stored state replayed when a scope reactivates.
Verification: source-based controlled-clock checks against main and this head. For ordinary reopen timing the replay arithmetic gives the same result for both argument orders, so the swap is masked there. With a zero/omitted delay and the wall clock moving backward, main replays show(1000) while this PR replays show(undefined) (immediate). The repository Electron test suite was not run.
Nonblocking suggestion: the new test reads private state and asserts a real-time bound (> 3000 ms), which passes on main too and can flake under scheduling pauses. Consider a controlled clock instead: start at a positive timestamp (e.g. 100000), showWhile(promise, 0) in an inactive scope, move the clock back to 99000, activate the scope and assert show received exactly undefined.
Co-authored-by: Copilot <[email protected]>
0362247
Fixes #332734
ScopedProgressIndicator.showWhilepassed the configured delay aswhileStartandDate.now()aswhileDelayintoProgressIndicatorState.While, reversing the parameter contract. Wrong since the class was introduced, and line 305 remains the only construction site.Honest scope note: today this produces no visible misbehavior, because the single replay formula
whileDelay - (Date.now() - whileStart)happens to be algebraically symmetric under exactly this swap (verified symbolically, on a numeric grid, and by executing both orders against the compiled module). The defect is latent: thewhileDelay > 0guard reads a wall-clock timestamp and can never be false, and any future reader of these fields gets values opposite to their names. The change puts start time and delay back in the declared order; the new test pins the stored fields so any future re-swap fails immediately.Draft until #332734 receives triage.
How was this tested
The new test constructs a scoped indicator with a delayed
showWhile, asserts the stored state fields (whileDelay === 5000,whileStartwithin the capture window), and exercises the replay on scope reopen. Against the unfixed source it fails withwhileDelayholding a raw timestamp; with this change: 3 passing, 0 failing.Additional verification performed during development:
ProgressIndicatorState.While