Skip to content

fix: debounce output clearing during cell re-execution#12947

Merged
nstrayer merged 4 commits intomainfrom
positron-nb-output-debounce
Apr 13, 2026
Merged

fix: debounce output clearing during cell re-execution#12947
nstrayer merged 4 commits intomainfrom
positron-nb-output-debounce

Conversation

@nstrayer
Copy link
Copy Markdown
Contributor

@nstrayer nstrayer commented Apr 10, 2026

When a notebook cell is re-run, the runtime immediately clears outputs before sending new ones. This caused the output container to briefly disappear and reappear, producing a distracting flash.

lotsa-bouncing.mov

To address we defer the clear by a small amount when execution is active so fast-completing cells never flash. We also flush the deferred clear immediately when execution ends.

Result:

Screen.Recording.2026-04-10.at.1.40.28.PM.mov

Release Notes

New Features

  • N/A

Bug Fixes

  • Fixed notebook cell outputs flashing briefly when re-running a cell

QA Notes

@:notebooks @:positron-notebooks

  1. Open a Python notebook
  2. Run a cell that produces output (e.g. print("hello"))
  3. Re-run the same cell -- output should update smoothly without a flash/flicker
  4. Try with a slow cell (e.g. import time; time.sleep(2); print("done")) -- output should clear only after the delay, not flash
  5. Clear outputs manually (right-click > Clear Outputs) -- should clear immediately without delay

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 10, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:notebooks @:positron-notebooks

readme  valid tags

@nstrayer nstrayer requested review from dhruvisompura and seeM April 10, 2026 00:58
Copy link
Copy Markdown
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

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

Yay thank you! These sorts of visual flickers really bother me - glad I'm not alone.

  1. Should this rather happen in the UI layer? There are other consumers of cell outputs and they probably don't want this debounced behavior. E.g. could create a derived/debounced observable from outputs in the NotebookCodeCell. Maybe the existing debouncedObservable works?

  2. Out of scope of this change, but can we also debounce the execution status indicator and the execution count change?

    Image

@nstrayer nstrayer force-pushed the positron-nb-output-debounce branch from 3890434 to c9ff264 Compare April 10, 2026 17:34
@nstrayer
Copy link
Copy Markdown
Contributor Author

Good call. The approach I took (a new useDebouncedObservedValue() hook) made it trivial to fix the status indicator and count as well.

@nstrayer nstrayer requested a review from seeM April 10, 2026 17:35
nstrayer and others added 3 commits April 10, 2026 13:50
Uses useDebouncedObservedValue with default isUndefinedOrNull
predicate so the transient undefined during re-execution is
suppressed, preventing the [1] -> - -> [2] flash.
Copy link
Copy Markdown
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

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

Nice, super clean and works well! I also debounced the execution order in 796221d, figured it was faster to commit directly than comment

@nstrayer nstrayer merged commit 4a646df into main Apr 13, 2026
18 of 19 checks passed
@nstrayer nstrayer deleted the positron-nb-output-debounce branch April 13, 2026 16:23
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants