[PR #14670] progress: suppress ANSI escape sequences when not connected to a terminal #77071

Open
opened 2026-05-05 09:47:02 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14670
Author: @majiayu000
Created: 3/6/2026
Status: 🔄 Open

Base: mainHead: fix/issue-14571-suppress-control-chars


📝 Commits (1)

  • 860046d progress: suppress ANSI escape sequences when not connected to a terminal

📊 Changes

2 files changed (+67 additions, -1 deletions)

View changed files

📝 progress/progress.go (+13 -1)
progress/progress_test.go (+54 -0)

📄 Description

Summary

Suppress ANSI escape sequences in the progress package when stderr is not connected to a terminal. This prevents control character garbage when piping ollama run output.

Fixes #14571

Changes

  • Add TTY detection in NewProgress() via term.IsTerminal() (already a dependency)
  • Skip render() entirely when not a TTY
  • Skip ANSI output in Stop() and StopAndClear() when not a TTY

Test plan

  • Added progress/progress_test.go with 3 tests verifying non-TTY behavior
  • go test ./progress/ -v passes

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14670 **Author:** [@majiayu000](https://github.com/majiayu000) **Created:** 3/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/issue-14571-suppress-control-chars` --- ### 📝 Commits (1) - [`860046d`](https://github.com/ollama/ollama/commit/860046d635220af75f45ba2f52c9eee9d84ca05a) progress: suppress ANSI escape sequences when not connected to a terminal ### 📊 Changes **2 files changed** (+67 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `progress/progress.go` (+13 -1) ➕ `progress/progress_test.go` (+54 -0) </details> ### 📄 Description ## Summary Suppress ANSI escape sequences in the `progress` package when stderr is not connected to a terminal. This prevents control character garbage when piping `ollama run` output. Fixes #14571 ## Changes - Add TTY detection in `NewProgress()` via `term.IsTerminal()` (already a dependency) - Skip `render()` entirely when not a TTY - Skip ANSI output in `Stop()` and `StopAndClear()` when not a TTY ## Test plan - Added `progress/progress_test.go` with 3 tests verifying non-TTY behavior - `go test ./progress/ -v` passes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 09:47:02 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#77071