Skip to content

[lldb] Turn on OSC 9;4 graphical progress in supported terminals#185541

Merged
JDevlieghere merged 2 commits intollvm:mainfrom
JDevlieghere:enable-graphical-progress
Mar 12, 2026
Merged

[lldb] Turn on OSC 9;4 graphical progress in supported terminals#185541
JDevlieghere merged 2 commits intollvm:mainfrom
JDevlieghere:enable-graphical-progress

Conversation

@JDevlieghere
Copy link
Copy Markdown
Member

In #162162, I added support for OSC 9;4 graphical progress. I put it behind the show-progress setting because I didn't have a reliable way to detect whether the escape code was supported by the terminal.

Since then, more tools have added support for it, most notably Claude Code and Homebrew. While I still don't have a good way to detect this, there are a handful of known terminals that are easy enough to identify.

This PR toggles the default of show-progress to on again and puts showing the progress behind a check for those known terminals (Windows Terminal, ConEmu & Ghostty).

This means that if you're running in one of those, you'll get the visual progress by default unless you set show-progress to off. The downside is that if you're on an unrecognized terminal, you can't force it on any longer by setting show-progress to on. I think that's a fair trade-off as the setting wasn't really advertised and I doubt many people are using that. As a workaround, they can set OSC_PROGRESS to spoof an OSC-supporting terminal.

In llvm#162162, I added support for OSC 9;4 graphical progress. I put it
behind the `show-progress` setting because I didn't have a reliable way
to detect whether the escape code was supported by the terminal.

Since then, more tools have added support for it, most notably Claude
Code and Homebrew. While I still don't have a good way to detect this,
there are a handful of known terminals that are easy enough to identify.

This PR toggles the default of `show-progress` to on again and puts
showing the progress behind a check for those known terminals (Windows
Terminal, ConEmu & Ghostty).

This means that if you're running in one of those, you'll get the visual
progress by default unless you set `show-progress` to off. The downside
is that if you're on an unrecognized terminal, you can't force it on any
longer by setting `show-progress` to on. I think that's a fair trade-off
as the setting wasn't really advertised and I doubt many people are
using that. As a workaround, they can set `OSC_PROGRESS` to spoof an
OSC-supporting terminal.
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Mar 10, 2026

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

In #162162, I added support for OSC 9;4 graphical progress. I put it behind the show-progress setting because I didn't have a reliable way to detect whether the escape code was supported by the terminal.

Since then, more tools have added support for it, most notably Claude Code and Homebrew. While I still don't have a good way to detect this, there are a handful of known terminals that are easy enough to identify.

This PR toggles the default of show-progress to on again and puts showing the progress behind a check for those known terminals (Windows Terminal, ConEmu & Ghostty).

This means that if you're running in one of those, you'll get the visual progress by default unless you set show-progress to off. The downside is that if you're on an unrecognized terminal, you can't force it on any longer by setting show-progress to on. I think that's a fair trade-off as the setting wasn't really advertised and I doubt many people are using that. As a workaround, they can set OSC_PROGRESS to spoof an OSC-supporting terminal.


Full diff: https://github.com/llvm/llvm-project/pull/185541.diff

2 Files Affected:

  • (modified) lldb/source/Core/CoreProperties.td (+1-1)
  • (modified) lldb/source/Core/Debugger.cpp (+26-1)
diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td
index c9141959a50f2..03326b130e067 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -184,7 +184,7 @@ let Definition = "debugger", Path = "" in {
   def ShowProgress
       : Property<"show-progress", "Boolean">,
         Global,
-        DefaultFalse,
+        DefaultTrue,
         Desc<"Whether to show progress using Operating System Command (OSC) "
              "Sequences in supporting terminal emulators.">;
   def ShowProgressAnsiPrefix: Property<"show-progress-ansi-prefix", "String">,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 05c2ed13374ae..a993e17162f73 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2077,6 +2077,30 @@ void Debugger::CancelForwardEvents(const ListenerSP &listener_sp) {
   m_forward_listener_sp.reset();
 }
 
+/// Conservative heuristic to detect whether OSC 9;4 progress is supported by
+/// the current terminal.
+static bool TerminalSupportsOSCProgress() {
+  static std::once_flag g_once_flag;
+  static bool g_supports_osc_progress = false;
+
+  std::call_once(g_once_flag, []() {
+    std::array<const char *, 4> g_known_env_vars = {
+        "WT_SESSION",            // Windows Terminal
+        "ConEmuPID",             // ConEmu
+        "GHOSTTY_RESOURCES_DIR", // Ghostty
+        "OSC_PROGRESS",          // Override
+    };
+    for (const char *env_var : g_known_env_vars) {
+      if (std::getenv(env_var)) {
+        g_supports_osc_progress = true;
+        return;
+      }
+    }
+  });
+
+  return g_supports_osc_progress;
+}
+
 bool Debugger::IsEscapeCodeCapableTTY() {
   if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
     File &file = stream_sp->GetUnlockedFile();
@@ -2305,7 +2329,8 @@ void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
     }
 
     // Show progress using Operating System Command (OSC) sequences.
-    if (GetShowProgress() && IsEscapeCodeCapableTTY()) {
+    if (GetShowProgress() && IsEscapeCodeCapableTTY() &&
+        TerminalSupportsOSCProgress()) {
       if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
 
         // Clear progress if this was the last progress event.

Comment thread lldb/source/Core/CoreProperties.td
Comment thread lldb/source/Core/Debugger.cpp Outdated
Comment thread lldb/source/Core/Debugger.cpp Outdated
Comment thread lldb/source/Core/Debugger.cpp Outdated
@JDevlieghere JDevlieghere merged commit 4ad2c53 into llvm:main Mar 12, 2026
10 checks passed
@JDevlieghere JDevlieghere deleted the enable-graphical-progress branch March 12, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants