Skip to content

feat(core): add OSC 9;4 progress indicator support to TUI#33325

Merged
FrozenPandaz merged 1 commit intomasterfrom
feat/tui-ghostty-progress-indicator
Nov 3, 2025
Merged

feat(core): add OSC 9;4 progress indicator support to TUI#33325
FrozenPandaz merged 1 commit intomasterfrom
feat/tui-ghostty-progress-indicator

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

Current Behavior

The Nx TUI doesn't provide any visual feedback about task progress outside of the terminal window itself. Users need to keep the terminal visible to see task completion status.

Expected Behavior

With this PR, the TUI now displays real-time task completion progress in the terminal window chrome (tabs, title bars, dock icons) using the OSC 9;4 escape sequence. This provides at-a-glance progress feedback even when the terminal is minimized or in the background.

Related Issue(s)

N/A - This is a new feature enhancement

Implementation Details

What is OSC 9;4?

OSC 9;4 is a terminal escape sequence for displaying progress indicators, originally from ConEmu and now supported by multiple modern terminals.

Key Changes

  • Added update_ghostty_progress() method to calculate and display task completion percentage
  • Added clear_ghostty_progress() method to hide progress when done
  • Integrated progress updates into task lifecycle (start, status update, exit)
  • Uses ST terminator (\x1b\\) for maximum terminal compatibility
  • Writes to stderr to avoid conflicts with TUI rendering on stdout

Supported Terminals

  • Ghostty - Full support
  • Windows Terminal (v1.6+) - Full support
  • VTE-based terminals (GNOME Terminal, Ptyxis) - Full support
  • Other terminals - Gracefully ignore sequences (no errors)

Terminal Compatibility Note

The implementation uses the ST (String Terminator) escape sequence rather than BEL, as this is preferred by Ghostty and required by VTE-based terminals, while remaining compatible with Windows Terminal.

Testing

Tested with:

  • Building the native module successfully
  • Rust formatting and linting passes
  • Running nx commands with the TUI active

The progress indicator updates in real-time as tasks complete and clears automatically when the TUI exits.

@FrozenPandaz FrozenPandaz requested review from a team as code owners November 1, 2025 00:47
@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Nov 3, 2025 4:53pm

@netlify
Copy link
Copy Markdown

netlify Bot commented Nov 1, 2025

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 08e2161
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6908dc8825a6e40008e01252
😎 Deploy Preview https://deploy-preview-33325--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Nov 1, 2025

View your CI Pipeline Execution ↗ for commit 08e2161

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 39m 22s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 1m 47s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 10s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-03 17:31:14 UTC

@Stanzilla
Copy link
Copy Markdown
Contributor

Why name it after ghostty when it is not really ghostty specific though?

@FrozenPandaz
Copy link
Copy Markdown
Contributor Author

Why name it after ghostty when it is not really ghostty specific though?

Good point. Thanks!

Adds support for terminal progress indicators using the OSC 9;4 escape sequence. This displays task completion progress in the terminal window chrome (tabs, title bars) for compatible terminals.

Key features:
- Real-time progress updates as tasks complete
- Automatic cleanup on TUI exit
- Uses ST terminator for maximum compatibility
- Writes to stderr to avoid conflicts with TUI rendering

Supported terminals:
- Ghostty (full support)
- Windows Terminal v1.6+ (full support)
- VTE-based terminals like GNOME Terminal and Ptyxis (full support)
- Other terminals gracefully ignore the sequences

cleanup(core): consolidate terminal progress clearing in app instance

Add std::io::Write to top-level imports in lifecycle.rs and app.rs, move restore_terminal to instance method on AppLifeCycle to reuse app.clear_terminal_progress() instead of duplicating logic, and remove redundant local imports from functions.

cleanup(core): remove redundant progress update in start_tasks

The terminal progress indicator only changes when tasks transition from incomplete to completed states. Starting tasks (NotStarted → InProgress) doesn't change the percentage, making this call redundant.

cleanup(core): cache incomplete task count for progress calculation

Maintain incomplete_task_count on the App struct instead of recalculating it every time we update terminal progress. This avoids iterating through the entire task_status_map on each status update.

cleanup(core): cache incomplete task count for progress calculation

Maintain incomplete_task_count on the App struct instead of recalculating it every time we update terminal progress. This avoids iterating through the entire task_status_map on each status update.

cleanup(core): cache incomplete task count for progress calculation

Maintain incomplete_task_count on the App struct instead of recalculating it every time we update terminal progress. This avoids iterating through the entire task_status_map on each status update.

cleanup(core): move restore_terminal back to standalone function

Make clear_terminal_progress a static method in App so it can be called without an instance. Convert restore_terminal back to a standalone #[napi] function in lifecycle.rs rather than an instance method on AppLifeCycle.
@FrozenPandaz FrozenPandaz merged commit 4017b61 into master Nov 3, 2025
20 checks passed
@FrozenPandaz FrozenPandaz deleted the feat/tui-ghostty-progress-indicator branch November 3, 2025 18:27
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 9, 2025

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 9, 2025
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.

3 participants