Skip to content

feat(format): visualize tab characters in table output#573

Merged
apstndb merged 3 commits intomainfrom
issue-568-tab-char-visualization
Mar 20, 2026
Merged

feat(format): visualize tab characters in table output#573
apstndb merged 3 commits intomainfrom
issue-568-tab-char-visualization

Conversation

@apstndb
Copy link
Owner

@apstndb apstndb commented Mar 19, 2026

Summary

  • Replace tab characters in table cell values with visible arrow () plus padding spaces to the next tab stop, using go-tabwrap v0.1.2's ExpandTabFunc for accurate column tracking
  • In styled mode, the arrow is rendered dim (\033[2m→\033[22m); in plain mode, a plain is used
  • Integrate tab visualization as a preprocessing step in writeRowInternal, before wrapping — tabs become regular characters so wrap works normally

Details

  • Add tab_visualize.go with visualizeTab (delegates to Condition.ExpandTabFunc) and visualizeTabsInRow (per-cell preprocessing respecting Styled config)
  • Add visualizedCell type that carries both plain (for width calculation) and styled (for display) representations
  • Upgrade go-tabwrap v0.1.1 → v0.1.2 for the new ExpandTabFunc API
  • Add comprehensive tests: tab-stop math, CJK widths, newline column resets, width preservation, styled/unstyled modes, and end-to-end table rendering

Test plan

  • make check passes (test + lint + fmt-check)
  • TestVisualizeTab covers tab-stop positions, CJK, newlines, multiple tabs
  • TestVisualizeTab_WidthPreserved verifies display width matches original tab expansion
  • TestVisualizeTabsInRow_* tests styled/unstyled cell handling
  • TestWriteTable_WithTabs validates end-to-end table rendering

Fixes #568

…ap ExpandTabFunc

Replace tab characters with visible arrow (→) plus padding spaces in table
output, using go-tabwrap v0.1.2's ExpandTabFunc for correct tab-stop column
tracking. This makes tabs visible and preserves alignment.

- Add tab_visualize.go with visualizeTab and visualizeTabsInRow
- Integrate tab visualization in TableStreamingFormatter.writeRowInternal
- Add comprehensive tests for tab visualization
- Upgrade go-tabwrap v0.1.1 → v0.1.2

Fixes #568

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the table output formatting by introducing a feature to visually represent tab characters within table cells. This change significantly improves the readability and debugging experience for users by making implicit tab expansions explicit, while maintaining correct column alignment and supporting both styled and unstyled output modes.

Highlights

  • Tab Visualization: Tab characters in table cell values are now replaced with a visible arrow (→) and padding spaces, ensuring accurate column tracking using go-tabwrap's ExpandTabFunc.
  • Styling: In styled mode, the tab visualization arrow is rendered dim (e.g., �[2m→�[22m), while in plain mode, a simple '→' is used.
  • Integration: Tab visualization is integrated as a preprocessing step in writeRowInternal before text wrapping, allowing wrap functionality to operate on the expanded characters normally.
  • Dependency Update: The go-tabwrap dependency has been upgraded from v0.1.1 to v0.1.2 to leverage the new ExpandTabFunc API.
  • New Files: New files tab_visualize.go and tab_visualize_test.go were added to implement and thoroughly test the tab visualization logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Mar 19, 2026

Code Metrics Report

📊 View detailed coverage report (available for 7 days)

main (3c3afb0) #573 (ac3f387) +/-
Coverage 70.5% 70.7% +0.1%
Code to Test Ratio 1:1.2 1:1.2 +0.0
Test Execution Time 1m14s 1m11s -3s
Details
  |                     | main (3c3afb0) | #573 (ac3f387) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          70.5% |          70.7% | +0.1% |
  |   Files             |             74 |             75 |    +1 |
  |   Lines             |           6944 |           6988 |   +44 |
+ |   Covered           |           4902 |           4945 |   +43 |
+ | Code to Test Ratio  |          1:1.2 |          1:1.2 |  +0.0 |
  |   Code              |          16154 |          16241 |   +87 |
+ |   Test              |          20820 |          21086 |  +266 |
+ | Test Execution Time |          1m14s |          1m11s |   -3s |

Code coverage of files in pull request scope (78.3% → 85.0%)

Files Coverage +/- Status
internal/mycli/format/streaming_table.go 78.5% +0.2% modified
internal/mycli/format/tab_visualize.go 97.6% +97.6% added

Reported by octocov

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature to visualize tab characters in table output, enhancing readability for users. The implementation correctly leverages the go-tabwrap library for accurate tab stop calculations and provides both styled and unstyled output options. The new tests are comprehensive and cover various scenarios, including CJK characters and newline handling, ensuring the robustness of the tab visualization logic. The update to go-tabwrap to v0.1.2 is appropriate for accessing the necessary ExpandTabFunc API. A high-severity issue was identified regarding the loss of dimming style for visualized tab characters during text wrapping, which needs to be addressed to maintain consistent styling.

…in WithText

Rename visualizedCell to tabVisualizedCell for clarity since the type is
specific to tab visualization. Fix WithText to return a tabVisualizedCell
that re-applies dim styling to arrow characters and preserves cellStyle,
so wrapped segments maintain consistent tab visualization.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@apstndb
Copy link
Owner Author

apstndb commented Mar 19, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a new feature to visualize tab characters in table output, which is a valuable enhancement for readability. The implementation correctly leverages the go-tabwrap library and provides comprehensive test coverage for various scenarios, including CJK characters and width preservation. The integration into the TableStreamingFormatter as a preprocessing step before wrapping ensures that the tab visualization works seamlessly with existing layout logic. The changes to go.mod and go.sum correctly reflect the dependency update.

Store only the styled string in tabVisualizedCell and lazily derive the
plain version via stripANSI on first RawText() call. This reduces
ExpandTabFunc to a single call per cell and eliminates the plain field
from initialization. Move stripANSI from test to production code, change
visualizeTab to accept a styled bool parameter, and switch
tabVisualizedCell to pointer receivers for mutable caching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@apstndb
Copy link
Owner Author

apstndb commented Mar 19, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature to visualize tab characters in table output, enhancing readability and debugging for users. The implementation is well-structured, separating the tab visualization logic into a new tab_visualize.go file. The approach of using go-tabwrap for accurate column tracking and handling both styled and plain output is robust. Comprehensive tests cover various scenarios, including CJK widths and newline resets, ensuring the correctness and reliability of the new functionality. The dependency update for go-tabwrap is appropriate for leveraging the new ExpandTabFunc API. Overall, this is a solid and well-executed feature.

@apstndb
Copy link
Owner Author

apstndb commented Mar 20, 2026

/gemini summary

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request introduces a significant enhancement to table output formatting by making tab characters explicitly visible. It replaces tabs with a → symbol and appropriate spacing, ensuring correct column alignment and readability. The feature is seamlessly integrated into the table rendering pipeline, supporting both styled and plain text outputs, and is backed by a dependency upgrade and thorough testing.

Highlights

  • Tab Visualization: Tab characters in table cell values are now replaced with a visible arrow (→) plus padding spaces, using go-tabwrap's ExpandTabFunc for accurate column tracking.
  • Styling: In styled mode, the arrow is rendered dim (\033[2m→\033[22m); in plain mode, a plain → is used.
  • Integration: Tab visualization is integrated as a preprocessing step in writeRowInternal, before wrapping, ensuring wrap functionality operates normally on the expanded characters.
  • Dependency Update: The go-tabwrap dependency was upgraded from v0.1.1 to v0.1.2 to leverage the new ExpandTabFunc API.
  • New Components: Introduced tab_visualize.go with visualizeTab and visualizeTabsInRow functions, and a tabVisualizedCell type to handle styled and plain representations.
  • Comprehensive Testing: Added extensive tests covering tab-stop math, CJK widths, newline column resets, width preservation, styled/unstyled modes, and end-to-end table rendering.
Changelog
  • go.mod
    • Updated go-tabwrap dependency to version 0.1.2.
  • go.sum
    • Updated module checksums for go-tabwrap to version 0.1.2.
  • internal/mycli/format/streaming_table.go
    • Integrated tab visualization by calling visualizeTabsInRow before row wrapping.
  • internal/mycli/format/tab_visualize.go
    • Added new file defining functions and types for visualizing tab characters in table cells, including visualizeTab, visualizeTabsInRow, and tabVisualizedCell.
  • internal/mycli/format/tab_visualize_test.go
    • Added new file containing comprehensive tests for tab visualization logic, covering various scenarios like tab-stop math, CJK widths, and styled/unstyled output.
Activity
  • gemini-code-assist[bot] provided an initial summary of the pull request.
  • github-actions[bot] posted a code metrics report, indicating a slight increase in overall coverage and significant coverage for the newly added files.
  • apstndb requested a Gemini review.
  • apstndb requested another Gemini review.
  • apstndb requested a Gemini summary.
  • gemini-code-assist[bot] identified an issue with visualizedCell.WithText not preserving styling for wrapped segments; apstndb addressed this by renaming the type to tabVisualizedCell and fixing WithText to re-apply dim styling and preserve cellStyle.
  • gemini-code-assist[bot] questioned if tabVisualizedCell.WithText was dead code; apstndb clarified its necessity as part of the Cell interface and its role in cell wrapping.
  • gemini-code-assist[bot] suggested adding t.Helper() to stripANSI in tests; apstndb explained that stripANSI is a pure string transformation, not a test helper, and does not require t.Helper().

@apstndb apstndb merged commit f3a08a1 into main Mar 20, 2026
2 checks passed
@apstndb apstndb deleted the issue-568-tab-char-visualization branch March 20, 2026 16:45
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.

Tab character visualization in cell values

1 participant