Skip to content

fix(left-bar): honor bracketed tag prefix in group badge abbreviation#1020

Merged
pedramamini merged 3 commits into
rcfrom
fix/1017-bracketed-group-abbreviation
May 30, 2026
Merged

fix(left-bar): honor bracketed tag prefix in group badge abbreviation#1020
pedramamini merged 3 commits into
rcfrom
fix/1017-bracketed-group-abbreviation

Conversation

@pedramamini
Copy link
Copy Markdown
Collaborator

@pedramamini pedramamini commented May 19, 2026

Summary

  • Group names like [ARP] Auditoria Relatório Pessoal were rendering as [ARP on the bookmark badge — the closing bracket was being lopped off.
  • Root cause: abbreviateGroupName fell through to the multi-word initials path, which collected the first character of each word. The bracketed first word [ARP] contributed only [, then A, R, P from the trailing words — never the closing ].
  • Fix: detect a [TAG] prefix up front and use the tag (sans brackets) as the short form. Treats the bracketed prefix as the user's stated preferred short form, which is the convention they were already using.
  • Covered by new test cases in formatters.test.ts.

Closes #1017

Test plan

  • npm run test -- formatters — all 78 formatter tests pass, including new bracketed-prefix cases
  • npm run lint — clean
  • Smoke-test in the Left Bar: bookmark an agent whose group name starts with a [TAG] prefix and confirm the badge renders the tag in full

Summary by CodeRabbit

  • Bug Fixes

    • Corrected group-name abbreviation so leading bracketed tags (e.g., "[TAG] Name") are used as the short form when appropriate, and large bracket tags fall back to initials of the remaining name instead of producing truncated fragments. Numeric-only bracket prefixes are treated as non-tags and abbreviated from the rest of the name.
  • Tests

    • Added test coverage for bracketed-prefix and fallback behaviors.

Review Change Stack

For groups named like `[ARP] Auditoria Relatório Pessoal`, the multi-word
initials path took only the leading `[` of the bracketed first word, producing
`[ARP` on the bookmark badge with the closing bracket lopped off. Detect the
`[TAG]` prefix up front and use the tag (sans brackets) as the short form.

Closes #1017
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5225ebe9-670c-4395-a883-e2f6cdcb9210

📥 Commits

Reviewing files that changed from the base of the PR and between f112ec7 and 11f02e6.

📒 Files selected for processing (1)
  • src/__tests__/shared/formatters.test.ts

📝 Walkthrough

Walkthrough

Adds early detection of leading bracketed tags (e.g., [ARP]) in abbreviateGroupName: when the extracted tag length is within max it is returned as the abbreviation. Tests verify tag extraction, oversized-tag fallback to initials, and numeric-bracket exclusion.

Changes

Bracketed Prefix Abbreviation

Layer / File(s) Summary
Bracketed tag prefix detection and test coverage
src/shared/formatters.ts, src/__tests__/shared/formatters.test.ts
abbreviateGroupName adds an early rule to match and return leading [...] tag prefixes (e.g., ARP from [ARP] Auditoria ...) when the extracted tag fits within max, preventing initials logic from cutting the bracket. New tests verify extraction behavior, prefix handling for short names, oversized-tag fallback, and that numeric bracket prefixes are ignored.

🎯 2 (Simple) | ⏱️ ~10 minutes

I hopped upon the code today,
Found brackets in my way,
I pulled the tag out nice and neat,
So short names look complete. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(left-bar): honor bracketed tag prefix in group badge abbreviation' clearly and specifically describes the main change: fixing the group badge abbreviation to properly handle bracketed tag prefixes.
Linked Issues check ✅ Passed The PR directly addresses Issue #1017 by implementing logic to detect and preserve bracketed tag prefixes in group names, preventing truncation in badge rendering.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the abbreviateGroupName function and adding corresponding tests; no out-of-scope changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1017-bracketed-group-abbreviation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 19, 2026

Greptile Summary

This PR fixes a display bug where group names with a [TAG] prefix (e.g., [ARP] Auditoria Relatório Pessoal) were rendered as [ARP in the bookmark badge because the multi-word initials path grabbed the opening bracket as the first "word" character and dropped the closing bracket.

  • src/shared/formatters.ts: Adds a bracketed-tag early-exit at the top of abbreviateGroupName; if the tag content fits within max, it is returned directly as the user's stated preferred short form.
  • src/__tests__/shared/formatters.test.ts: New test block covers the primary fix, bracket-only names, and the over-max fallthrough edge case where the tag is too long to use directly.

Confidence Score: 5/5

The change is a small, well-isolated early-exit in a pure formatting function with no side-effects; it cannot affect any code path that does not involve a bracketed-prefix group name.

The fix correctly handles the bracketed tag prefix before the rest of the function runs, guards against empty/whitespace-only tags, and leaves all existing strategies untouched. The new test block covers the primary fix, the bracket-only edge case, and the over-max fallthrough; all 78 formatter tests pass. The only caller (SessionItem.tsx) passes no options, so the default max:10 applies and the new path behaves predictably for real group names.

No files require special attention.

Important Files Changed

Filename Overview
src/shared/formatters.ts Adds a bracketed-tag early-exit to abbreviateGroupName; logic is correct and well-guarded against empty/whitespace tags.
src/tests/shared/formatters.test.ts New test block covers the happy path, bracket-only input, and the over-max fallthrough edge case; all assertions are traceable to the implementation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([abbreviateGroupName]) --> B{trimmed empty?}
    B -- yes --> C[return empty]
    B -- no --> D{starts with TAG prefix?}
    D -- "yes, tag fits max" --> E["return tag — e.g. ARP"]
    D -- "no / tag too long" --> F{trimmed fits max?}
    F -- yes --> G[return full name]
    F -- no --> H{has ampersand or and?}
    H -- yes --> I["conjunction acronym — e.g. A&C"]
    H -- no --> J{multi-word?}
    J -- yes --> K["initials — e.g. ACL"]
    J -- no --> L["devowel — e.g. Engnrng"]
    L --> M{still too long?}
    M -- yes --> N[hard truncate]
    M -- no --> O[return devoweled]
Loading

Reviews (1): Last reviewed commit: "fix(left-bar): honor bracketed tag prefi..." | Re-trigger Greptile

…-drop logic

Merging current rc surfaced a semantic conflict between two fixes for the same
problem: rc's firstLetter() now skips leading non-letters (so "[1] A/B" → "AB"),
while #1020 added a tag-prefix-wins rule. Scope the tag rule to letter-bearing
tags so pure-numbering prefixes like "[1]" still fall through to the initials
path, and update the stale "[VeryLongTagName] X" expectation to "VX" (rc's
bracket-skipping output, which no longer lops a leading "[").
@pedramamini pedramamini merged commit 9c232d4 into rc May 30, 2026
4 checks passed
@pedramamini pedramamini deleted the fix/1017-bracketed-group-abbreviation branch May 30, 2026 04:06
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.

1 participant