Add terminal client detection to the RUN section#124
Merged
Conversation
Display the terminal program, version, TERM type, color support, shell, and terminal dimensions in the RUN section of the report. This information helps diagnose rendering issues when users share reports, since ANSI escape sequences and unicode character support vary across terminal clients. Detection checks TERM_PROGRAM, LC_TERMINAL (for SSH sessions), and WT_SESSION (for Windows Terminal) environment variables, with TERM type and terminal dimensions as supplementary details. Falls back to "Unknown" when no terminal information is available. The Terminal line is added to the integration test's non-deterministic row filter since it varies across environments.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds terminal client detection to the RUN section of the git-metrics report. Knowing which terminal emulator is in use helps diagnose rendering issues when users share reports, since terminals differ in ANSI, unicode, and color support.
Changes:
- Added
GetTerminalInformation()topkg/utils/utils.gothat detects the terminal program via environment variables (TERM_PROGRAM,LC_TERMINAL,WT_SESSION) and collects supplementary details (TERM type, color support, shell, dimensions). - Integrated the new terminal line into the RUN section display and added it to the integration test non-deterministic row filter.
- Added unit tests for the new function.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pkg/utils/utils.go |
New GetTerminalInformation() function for detecting terminal client info |
pkg/display/sections/run_information.go |
Added Terminal line to the RUN section output |
script/remove-non-deterministic-rows |
Filter ^Terminal rows in integration tests |
pkg/utils/utils_test.go |
Three unit tests for GetTerminalInformation plus two helper functions |
Replace the custom contains/stringContains helper functions with strings.Contains from the standard library and add a strings import. Replace the manual save/defer/restore boilerplate in TestGetTerminalInformationWithTermProgram and TestGetTerminalInformationFallsBackToUnknown with t.Setenv, which automatically restores the original value when the test ends. Strengthen TestGetTerminalInformationFallsBackToUnknown to assert result == "Unknown" rather than just non-empty, so the test actually catches regressions in the fallback path.
steffen
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Display the terminal client information in the RUN section of the report to help diagnose rendering issues when users share reports. Terminal emulators differ significantly in ANSI escape sequence support, unicode rendering, and color depth, so knowing the terminal makes it much easier to reproduce and fix display problems.
Changes
pkg/utils/utils.go—GetTerminalInformation()Detects the terminal client by checking the following environment variables in order:
TERM_PROGRAM+TERM_PROGRAM_VERSION— set by most terminal emulators (iTerm2, Apple Terminal, VSCode, WarpTerminal, Ghostty, Alacritty, etc.)LC_TERMINAL+LC_TERMINAL_VERSION— fallback for SSH sessions (iTerm2 propagates these)WT_SESSION— Windows Terminal detectionSupplementary details shown in parentheses:
TERMtype (e.g.xterm-256color)COLORTERMcolor support level (e.g.truecolor)SHELL)golang.org/x/term(e.g.120×30)Falls back to
"Unknown"when no terminal information is available.Example output:
pkg/display/sections/run_information.goAdded
Terminalline betweenMachineandGit metrics version.script/remove-non-deterministic-rowsAdded
^Terminalto the integration test filter since the value varies across environments.pkg/utils/utils_test.goAdded 3 tests:
TestGetTerminalInformationReturnsNonEmptyTestGetTerminalInformationWithTermProgramTestGetTerminalInformationFallsBackToUnknown