Skip to content

Conversation

bluetech
Copy link
Member

Use OSC 9;4 ANSI sequences terminal progress to notify the terminal emulator about progress, so it can display it to the user (e.g. on the terminal tab).

Fix #13072.

bluetech and others added 3 commits September 14, 2025 14:15
The `write` method does some processing on the input, namely markup and
adding to the current line. `write_raw` skips these parts. It is useful
for emitting invisible escape sequences.
Return how many items have been reported in the progress so far. This
cleans up the code a bit, but also allows grabbing this info without
accessing the internals. We can consider making this property public
separately.
Use OSC 9;4 ANSI sequences terminal progress to notify the terminal
emulator about progress, so it can display it to the user (e.g. on the
terminal tab).

Fix pytest-dev#13072.

Co-Authored-By: Anna Tasiopoulou <[email protected]>
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 14, 2025
@bluetech
Copy link
Member Author

bluetech commented Sep 14, 2025

This replaces PR #13395.

While searching the web for OSC 9;4, I found some reports that this sequence conflicts with OSC 9 usage by the iTerm terminal emulator, which uses it for generating desktop notifications. So this might end up generating a bunch of notifications on such terminals... I will need to test if that is indeed the case. Though I don't have easy access to macOS so if someone's able to test it that would be appreciated :)

For reference I tested it on:

  • Supported: Gnome Terminal, Ptyxis, Kitty (though for some reason the reset doesn't work?)
  • Not supported (ignored): Ghostty

@The-Compiler
Copy link
Member

Though I don't have easy access to macOS so if someone's able to test it that would be appreciated :)

For what it's worth, I can recommend Scaleway for this. They charge 0.11€/h for a Mac Mini you can access remotely, so you pay 2.64€ for the minimum of 24h to try something out. Could easily get it back after via our OpenCollective too. Only caveat is that you need to remember to disable it after 24h, because you can't do that in advance sadly.

@webknjaz
Copy link
Member

@bluetech could you include links to relevant docs/standards for future reference?

@@ -0,0 +1,6 @@
Added support for displaying test session progress in the terminal tab using the OSC 9;4; ANSI sequence.
Copy link
Member

Choose a reason for hiding this comment

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

Should this be highlighted?

Suggested change
Added support for displaying test session progress in the terminal tab using the OSC 9;4; ANSI sequence.
Added support for displaying test session progress in the terminal tab using the ``OSC 9;4;`` ANSI sequence.

@webknjaz
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal tab progress reporting using OSC 9;4; ANSI sequence
3 participants