feat(cli): width-aware item-list table (TASK-2030)#894
Merged
Conversation
TASK-2030 (PLAN-1985). Manual ANSI-safe renderer replaces tabwriter; terminal-width-aware title truncation; drops the modifier BY column.
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
Rewrites
PrintItemTableininternal/cli/format.goto be terminal-width-aware and ANSI-safe. Refs TASK-2030 (PLAN-1985).The old renderer used
text/tabwriter, which counts ANSI color escape bytes as visible width — so on a TTY (wherefatih/coloremits codes) the header misaligned by ~12 columns. It also had no terminal-width awareness (long titles blew out the layout) and surfaced a uselessBY(modifier) column while omitting STATUS/PRIORITY.Changes
tabwriterfor this function. All width math goes through a newdisplayWidth(s)helper that strips SGR escapes (\x1b[…m, compiled once as a package var) and counts runes.term.GetSize(os.Stdout.Fd()), falling back to 120 columns when piped/non-TTY. Only the title is truncated (with…); the ref is never truncated.REF/TITLE · STATUS · PRIORITY · COLLECTION · UPDATED. Drops theBYcolumn. STATUS/PRIORITY are parsed from the item'sfieldsJSON and rendered via the existingColorizedStatus/PriorityColorhelpers (dim—when absent).PrintItemTablenow just probes width and delegates to an unexportedrenderItemTable(w io.Writer, items, maxWidth)core, tested against abytes.Bufferwith a fixed width.func PrintItemTable(items []models.Item)is unchanged; callers (cmd_item.go) are untouched.Notes / decisions
titleBudgetis floored at 0 and the flexible header obeys the same budget as data rows.Gates
go build ./...— PASSgo vet ./...— PASSmake lint(golangci-lint) — PASS (0 issues)go test ./internal/cli/... ./cmd/pad/...— PASSCodex review
Verdict: CLEAN (4 rounds). Caught and fixed: header-not-fitting-budget in the degraded narrow regime, and mid-escape title slicing for titles containing embedded ANSI. The two originally-flagged scope items (rune-width approximation; narrow-terminal overflow) are explicitly accepted per the task/DR-1.