Skip to content

Skip column truncation when stdout is piped (non-TTY)#148

Merged
sjmiller609 merged 1 commit intomainfrom
hypeship/fix-pipe-truncation
Apr 10, 2026
Merged

Skip column truncation when stdout is piped (non-TTY)#148
sjmiller609 merged 1 commit intomainfrom
hypeship/fix-pipe-truncation

Conversation

@sjmiller609
Copy link
Copy Markdown
Contributor

@sjmiller609 sjmiller609 commented Apr 10, 2026

Summary

Fixes CLI table output truncation when stdout is piped to other tools (grep, awk, cat, etc.).

Before: kernel browsers list | grep hype returned nothing because URLs and other columns were truncated even in pipe mode.

After:

  • TTY (interactive terminal): columns truncate to fit terminal width (unchanged)
  • Non-TTY (piped): full column values output without truncation

This follows the standard CLI pattern used by docker ps, kubectl get, etc.

Changes

  • pkg/table/table.go: Skip truncateTableData when stdout is not a TTY; add IsStdoutTTY() helper
  • cmd/browsers.go: truncateURL skips truncation in non-TTY mode

Test plan

  • kernel browsers list in terminal — columns still truncate to fit width
  • kernel browsers list | cat — full URLs visible, no truncation
  • kernel browsers list | grep <pattern> — matches found in full output
  • All existing tests pass (go test ./...)

Note

Low Risk
Low risk: changes are limited to CLI formatting behavior and only affect output when stdout is not a terminal (piped), with no impact on API calls or data mutation.

Overview
Stops truncating CLI output when stdout is piped (non-TTY) so full column values are preserved for tools like grep/awk.

pkg/table.PrintTableNoPad now truncates columns only for terminal output and adds a shared table.IsStdoutTTY() helper; cmd/browsers.go’s truncateURL also skips truncation when not on a TTY.

Reviewed by Cursor Bugbot for commit b003810. Bugbot is set up for automated code reviews on this repo. Configure here.

When stdout is not a terminal (e.g. piped to grep, awk, cat), output
full column values without truncation. This follows the standard CLI
pattern used by docker ps, kubectl get, etc.

- Table column truncation in PrintTableNoPad now checks IsTerminal
- truncateURL also skips truncation in non-TTY mode
- TTY behavior (truncate to terminal width) is unchanged

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sjmiller609 sjmiller609 marked this pull request as ready for review April 10, 2026 16:03
@firetiger-agent
Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: This PR modifies CLI output formatting in the browsers command, not the kernel API endpoints or Temporal workflows specified in the filter.

To monitor this PR anyway, reply with @firetiger monitor this.

@sjmiller609 sjmiller609 merged commit 9f7b3df into main Apr 10, 2026
2 checks passed
@sjmiller609 sjmiller609 deleted the hypeship/fix-pipe-truncation branch April 10, 2026 16:05
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b003810. Configure here.

termWidth = 80 // fallback
// Only truncate columns when outputting to a terminal.
// When piped (non-TTY), output full values so grep/awk/etc. work correctly.
if term.IsTerminal(int(os.Stdout.Fd())) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated TTY check instead of using new helper

Low Severity

PrintTableNoPad calls term.IsTerminal(int(os.Stdout.Fd())) inline at the same time the new IsStdoutTTY() helper — which does exactly the same thing — is introduced in the same file. The helper exists specifically to centralize this check and is already exported for use by cmd/browsers.go, but PrintTableNoPad doesn't use it. If the TTY detection logic ever changes, it would need updating in two places.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b003810. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants