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.

@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 (is supported now)

@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?

@webknjaz
Copy link
Member

@bluetech
Copy link
Member Author

@The-Compiler thanks for the suggestion, in the end I was able to get access to an old apple laptop.

@webknjaz Yes, I think ConEmu invented these sequences. There is a link in the code, but I will also link it in the changelog.

bluetech and others added 3 commits September 16, 2025 15:16
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]>
@bluetech bluetech force-pushed the terminal-tab-progress branch from c99e5ed to f1b1c0a Compare September 16, 2025 12:36
@bluetech
Copy link
Member Author

  • Updated the changelog.
  • Changed the code to use match, reads more nicely (I wish it were an expression instead of a statement...)

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Thanks! Tested it and the feature works well on Windows.

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
4 participants