-
Notifications
You must be signed in to change notification settings - Fork 260
Fix hyperlink ANSI escape codes appearing in non-terminal output #6015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s in non-terminal environments Co-authored-by: wbreza <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but requires a couple updates.
cli/azd/extensions/azure.foundry.ai.agents/internal/pkg/agents/agent_api/models.go
Outdated
Show resolved
Hide resolved
…t unrelated extension changes Co-authored-by: hemarina <[email protected]>
…ode duplication Co-authored-by: wbreza <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more changes.
…minal wrapper Co-authored-by: hemarina <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
/check-enforcer override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix ASCII escape codes in URLs when running in non-terminal environments (GitHub Actions)
Changes
output.WithHyperlink()to check terminal state and return raw URLs when not in a terminalux.Hyperlink()to check terminal state and return raw URLs when not in a terminalinternal/terminalpackage withIsTerminal()functioninput.IsTerminal()- callers now useterminal.IsTerminal()directlyTechnical Details
The issue occurs in two functions that generate ANSI hyperlink escape codes:
cli/azd/pkg/output/colors.go-WithHyperlink()functioncli/azd/pkg/ux/ux.go-Hyperlink()functionBoth functions unconditionally generate ANSI escape codes like
\033]8;;URL\007TEXT\033]8;;\007which appear as raw escape sequences in GitHub Actions logs.Solution Implemented
Created a new lower-level package
cli/azd/internal/terminalthat contains theIsTerminal()function with all the terminal detection logic:AZD_FORCE_TTYenvironment variable for user overrideresource.IsRunningOnCI()and forces non-TTY modeisatty.IsTerminal()for both stdout and stdin as fallbackNon-terminal output simplified: When not in a terminal, both hyperlink functions now return just the raw URL, ignoring the text parameter. This matches the expected behavior shown in the issue screenshots.
Updated all callers:
cmd/container.go- Updated to callterminal.IsTerminal()directlypkg/input/console.go- Removed wrapper function, callers now useterminal.IsTerminal()directlypkg/output/colors.go- UpdatedWithHyperlink()to return only URL in non-terminal modepkg/ux/ux.go- UpdatedHyperlink()to return only URL in non-terminal modeThis eliminates code duplication and provides a single source of truth for terminal detection across the codebase.
Files Modified
cli/azd/internal/terminal/terminal.go: CentralizedIsTerminal()functioncli/azd/cmd/container.go: Updated to useterminal.IsTerminal()directlycli/azd/pkg/input/console.go: RemovedIsTerminal()wrapper functioncli/azd/pkg/output/colors.go: Simplified non-terminal output to return only URLcli/azd/pkg/output/colors_test.go: Updated test expectationscli/azd/pkg/ux/ux.go: Simplified non-terminal output to return only URLcli/azd/pkg/ux/ux_test.go: Updated test expectationscli/azd/.vscode/cspell.yaml: Added "surveyterm" to dictionaryTesting
Expected Output
Before (with escape codes in GitHub Actions):
After (clean URL in GitHub Actions):
azd deploycontains ASCII escape codes + duplicated in GitHub Action #5999Original prompt
azd deploycontains ASCII escape codes + duplicated in GitHub Action #5999💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.