Skip to content

Protect URL columns from being dropped in selectColumns() - #320

Merged
jeremy merged 3 commits into
mainfrom
protect-url-columns-from-drop
Mar 16, 2026
Merged

Protect URL columns from being dropped in selectColumns()#320
jeremy merged 3 commits into
mainfrom
protect-url-columns-from-drop

Conversation

@jeremy

@jeremy jeremy commented Mar 16, 2026

Copy link
Copy Markdown
Member

Summary

  • The column-dropping loop in selectColumns() now skips URL columns instead of removing them when the table exceeds terminal width. A dropped URL is useless; an overflowing table at least keeps the link clickable.
  • Restores the original long URL in TestStyledRenderTablePreservesURLs (the short URL was a workaround for the old dropping behavior).
  • Adds TestSelectColumnsPreservesURLColumnsWhenOverflowing to directly verify URL columns survive the drop loop.

Follows up on #309 which fixed the width budget mismatch but revealed this worse problem — accurate URL widths could cause the column to be dropped entirely.

Test plan

  • Existing URL preservation tests pass with longer URLs
  • New test verifies URL column survives when total exceeds 80-char width
  • Full unit and e2e suites green

Summary by cubic

Keep URL columns visible by skipping the 40-char cap and preventing them from being dropped in selectColumns(). This keeps links clickable even when the table exceeds terminal width.

  • Bug Fixes
    • Detect URL cells via formatTableCell() and flag columns with containsURL.
    • Use full measured width for URL columns; when over budget, drop only non-URL columns from the right.
    • Strengthened tests: longer fixture URL, forced overflow with width 60, and a found-or-fail assertion in the URL suffix test.

Written for commit 9939dda. Summary will update on new commits.

@jeremy
jeremy requested a review from a team as a code owner March 16, 2026 02:09
Copilot AI review requested due to automatic review settings March 16, 2026 02:09
@github-actions github-actions Bot added tests Tests (unit and e2e) output Output formatting and presentation bug Something isn't working labels Mar 16, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the generic table renderer’s column-selection logic to ensure URL-bearing columns are not removed when the table exceeds terminal width, prioritizing clickability over strict width fitting.

Changes:

  • Track whether each column contains URL values during width measurement (containsURL).
  • Update the column-dropping loop to skip URL columns and only drop non-URL columns.
  • Add/adjust unit tests to verify URL width handling and that URL columns survive overflow scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/output/render.go Adds per-column URL detection and prevents URL columns from being dropped during width-based column removal.
internal/output/output_test.go Adds tests covering URL width exemption and URL-column preservation under overflow conditions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/output/output_test.go
jeremy added 2 commits March 15, 2026 19:30
The column-dropping loop removed URL columns first (lowest priority) when
their accurate width pushed the total past the terminal width. A dropped
URL is worse than a garbled one — an overflowing table at least keeps the
link clickable. Now the loop skips URL columns and drops only non-URL
columns from the right.
Add a found-or-fail assertion so the test actually fails if the URL
column gets dropped instead of silently passing with zero assertions.
@jeremy
jeremy force-pushed the protect-url-columns-from-drop branch from 1f719b0 to 8ea3dd0 Compare March 16, 2026 02:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ea3dd06af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/output/output_test.go Outdated
The fixture totalled 79 chars which fit within width 80, so the drop
loop never fired and the test passed vacuously with both old and new
logic. Use width 60 to force the overflow path.
Copilot AI review requested due to automatic review settings March 16, 2026 02:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the generic table column-selection logic so URL-bearing columns are preserved even when the table exceeds terminal width, ensuring links remain usable/clickable in styled output.

Changes:

  • Update selectColumns() to drop the rightmost non-URL column when over the width budget (instead of always dropping the rightmost column).
  • Restore a longer real-world URL in TestStyledRenderTablePreservesURLs now that URL columns aren’t removed.
  • Add a focused unit test ensuring URL columns survive the column-dropping loop when overflow persists.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/output/render.go Adjusts the column-dropping loop to preserve URL columns under width overflow.
internal/output/output_test.go Updates URL preservation fixture and adds a new overflow regression test for URL columns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeremy
jeremy merged commit d373d29 into main Mar 16, 2026
30 checks passed
@jeremy
jeremy deleted the protect-url-columns-from-drop branch March 16, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working output Output formatting and presentation tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants