Skip to content

Add a Label helper for short display strings - #1

Open
JohnCampionJr wants to merge 1 commit into
mainfrom
feat/label-helper
Open

Add a Label helper for short display strings#1
JohnCampionJr wants to merge 1 commit into
mainfrom
feat/label-helper

Conversation

@JohnCampionJr

@JohnCampionJr JohnCampionJr commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

User description

Renders a short display label: capitalises the first letter, truncates anything long enough to break a single-line layout.

Reuses Truncate rather than duplicating the shortening logic.


Generated description

Below is a concise technical summary of the changes proposed in this PR:
Add the Label text helper to trim values, capitalize the first letter, substitute (none) for blank input, and reuse Truncate for single-line display limits. Cover the formatting behavior with focused tests.

Latest Contributors(1)
UserCommitDate
john@brightshore.ioAdd a Label helper for...August 27, 2026
Review this PR on Baz | Customize your next review

Summary by cubic

Adds a Label helper in internal/text that renders short display strings: it capitalises the first letter and truncates anything long enough to break a single-line layout, reusing the existing Truncate logic. Blank or whitespace-only values return (none).

Written for commit a22f0b2. Summary will update on new commits.

Review in cubic

Note

Add Label helper for short display strings in internal/text

Adds a Label utility in label.go that trims input whitespace, returns "(none)" for blank strings, upper-cases the first character, and truncates the result to a caller-specified limit via the existing Truncate function. Includes tests in label_test.go covering blank and capitalization cases.

📊 Macroscope summarized a22f0b2. 1 file reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

Capitalises the first letter and truncates anything long enough to break a
single-line layout.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4633072a-76a8-465d-b27e-5a79a582a37a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

Comment thread internal/text/label.go
return "(none)"
}

return Truncate(strings.ToUpper(trimmed[:1])+trimmed[1:], limit)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium text/label.go:13

Label("éclair", limit) returns corrupted replacement characters instead of Éclair. trimmed[:1] splits the two-byte UTF-8 encoding of é, so strings.ToUpper receives invalid byte fragments; index the string by runes before upper-casing the first one.

Suggested change
return Truncate(strings.ToUpper(trimmed[:1])+trimmed[1:], limit)
runes := []rune(trimmed)
return strings.ToUpper(string(runes[0]))+string(runes[1:])
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @internal/text/label.go around line 13:

`Label("éclair", limit)` returns corrupted replacement characters instead of `Éclair`. `trimmed[:1]` splits the two-byte UTF-8 encoding of `é`, so `strings.ToUpper` receives invalid byte fragments; index the string by runes before upper-casing the first one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Label() capitalizes only the first byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp[bot], chatgpt-codex-connector[bot], copilot-pull-request-reviewer[bot].

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes only the first byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes by byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (comment)

@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: a22f0b2a83

ℹ️ 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/text/label.go
return "(none)"
}

return Truncate(strings.ToUpper(trimmed[:1])+trimmed[1:], limit)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Capitalize a complete rune instead of one byte

When a non-ASCII value begins with a multibyte UTF-8 character, trimmed[:1] splits that character before passing it to strings.ToUpper; for example, Label("éclair", 10) returns invalid UTF-8 rather than "Éclair". Decode the first rune before upper-casing and concatenating the remainder.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Label() slices the first character by byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp[bot], chatgpt-codex-connector[bot], Copilot.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes only the first byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp[bot], chatgpt-codex-connector[bot], copilot-pull-request-reviewer[bot].

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes only the first byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes only the first byte of value, corrupting multi-byte UTF-8 characters (internal/text/label.go:13), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes by byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (comment)

Comment thread internal/text/label.go
func Label(value string, limit int) string {
trimmed := strings.TrimSpace(value)
if trimmed == "" {
return "(none)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply the requested limit to the blank placeholder

For blank input and any positive limit below 6, this early return produces "(none)", exceeding the caller's requested display limit even though nonblank labels are truncated. Pass the placeholder through the same truncation path so blank values cannot break the constrained layout.

Useful? React with 👍 / 👎.

@githail
githail Bot requested a lite review from Copilot August 27, 2026 04:26
@githail

githail Bot commented Aug 27, 2026

Copy link
Copy Markdown

@coderabbitai review

@githail

githail Bot commented Aug 27, 2026

Copy link
Copy Markdown

@cubic-dev-ai review

@githail

githail Bot commented Aug 27, 2026

Copy link
Copy Markdown

@macroscopeapp review

@githail githail Bot removed the githail:queued label Aug 27, 2026
@cubic-dev-ai

cubic-dev-ai Bot commented Aug 27, 2026

Copy link
Copy Markdown

@cubic-dev-ai review

@githail[bot] I can't start this review because you've reached your trial's review limit. Trial plans have lower review limits than paid plans. Upgrade now to resume reviews.

To help optimise your usage, you can tune cubic to get the most out of your usage limits:

Learn more →

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

Adds a new internal/text.Label helper for generating short, single-line display strings by trimming input, substituting (none) for blank values, capitalizing the first character, and truncating via the existing Truncate helper.

Changes:

  • Added Label(value, limit) helper in internal/text to standardize short display labels.
  • Added unit tests covering basic blank/capitalization behavior for Label.

Reviewed changes

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

File Description
internal/text/label.go Introduces the Label helper that trims, substitutes (none), capitalizes, and truncates using Truncate.
internal/text/label_test.go Adds initial tests for blank-input handling and capitalization.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/text/label.go
Comment on lines +3 to +13
import "strings"

// Label renders a short display label for a value, upper-casing the first letter and
// truncating anything long enough to break a single-line layout.
func Label(value string, limit int) string {
trimmed := strings.TrimSpace(value)
if trimmed == "" {
return "(none)"
}

return Truncate(strings.ToUpper(trimmed[:1])+trimmed[1:], limit)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Label() slices the first character by byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp[bot], chatgpt-codex-connector[bot], Copilot.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes only the first byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp[bot], chatgpt-codex-connector[bot], copilot-pull-request-reviewer[bot].

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes only the first byte, corrupting multi-byte UTF-8 input (internal/text/label.go:13), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (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.

Merged into Label() capitalizes only the first byte of value, corrupting multi-byte UTF-8 characters (internal/text/label.go:13), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #1 (comment)

Comment on lines +5 to +15
func TestLabelBlank(t *testing.T) {
if got := Label(" ", 10); got != "(none)" {
t.Errorf("got %q", got)
}
}

func TestLabelCapitalises(t *testing.T) {
if got := Label("hello", 10); got != "Hello" {
t.Errorf("got %q", got)
}
}
@githail

githail Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review reconciled — 4 findings from 3 reviewers

Findings

CRITICAL — Truncate() panics on non-positive limit for non-blank Label input · internal/text/label.go:13 · copilot-pull-request-reviewer
Truncate(s, max) only guards len(s) <= max; for any non-blank trimmed value, Label passes limit straight through. Label("hello", 0) reaches s[:max-1] with max-1 == -1, and Label("hello", -1) gives max-1 == -2 — both panic with 'slice bounds out of range'. Verified by reading internal/text/truncate.go at the PR head commit (a22f0b2); Label never validates limit before calling Truncate.

MAJOR — Label() capitalizes by byte, corrupting multi-byte UTF-8 input · internal/text/label.go:13 · macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer
Label("éclair", limit) returns corrupted output instead of "Éclair": trimmed[:1] takes only the first byte (0xC3) of the 2-byte UTF-8 encoding of 'é', and trimmed[1:] starts mid-rune, so both halves are invalid UTF-8 once concatenated. Any input starting with a multi-byte rune is affected. Confirmed by reading the code; no test exercises non-ASCII input. Fix by decoding the first rune (e.g. []rune(trimmed)) before upper-casing.

MINOR — Blank-value placeholder bypasses the requested limit · internal/text/label.go:7 · chatgpt-codex-connector
For blank/whitespace-only value, Label returns the literal "(none)" (6 chars) via an early return, before Truncate is ever called. Any limit < 6 — e.g. Label(" ", 3) — yields a 6-character result that exceeds the caller's requested limit, unlike non-blank input which is correctly truncated.

NIT — label_test.go has no coverage for truncation, Unicode, or non-positive limit · internal/text/label_test.go:15 · copilot-pull-request-reviewer
The two existing tests cover only a blank input and a plain-ASCII capitalization case. None of the three defects above (byte-slice corruption, negative-slice panic, untruncated placeholder) have regression coverage.

Coverage

Absent: coderabbitai, baz-reviewer — this verdict is incomplete, not clean.
Not verified: Did not check whether any caller elsewhere in the repo actually invokes Label with limit<=0 or non-ASCII values — assessed purely from the diff and internal/text/truncate.go at the PR head. All review-thread comments from 'githail[bot]' (prior runs of this same reconciler, e.g. 'Merged into ...' notices) were treated as self-referential automation artifacts, not independent reviewer evidence, and excluded from sources/duplicates/counts. chatgpt-codex-connector left findings but is not in the configured reviewer list, so it is reported as an extra source rather than under 'absent'. The passing 'test' check and the neutral 'Macroscope - Correctness Check' do not exercise the Unicode/limit<=0 paths, so neither contradicts nor confirms any cluster beyond what's stated.

Verdict: incomplete

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants