Skip to content

fix: stop server sidebar tile rendering a literal "0" badge#3379

Open
jeanfbrito wants to merge 1 commit into
masterfrom
fix/server-tile-zero-badge
Open

fix: stop server sidebar tile rendering a literal "0" badge#3379
jeanfbrito wants to merge 1 commit into
masterfrom
fix/server-tile-zero-badge

Conversation

@jeanfbrito

@jeanfbrito jeanfbrito commented Jun 26, 2026

Copy link
Copy Markdown
Member

What changed

The per-server sidebar tile rendered a literal "0" overlay whenever a server's unread badge was the number 0.

ServerButton.tsx guarded its mention <Badge> with:

{mentionCount && <Badge variant='secondary'>{mentionCount}</Badge>}

Because 0 && <Badge> evaluates to 0, React renders the number as a text node — the stray "0" on the tile. Coerced the guard to a boolean (!!mentionCount) so a zero count renders nothing.

Why it surfaced now

PR #3369 (restore unread badge on Rocket.Chat 7.8.0+ servers) made injected.ts emit setBadge(0) explicitly via setBadge(alertIndicator ?? 0). Servers now carry badge: 0 where they previously carried undefined. SideBar/index.tsx maps that to mentionCount={0}, which hit the falsy-number render path.

Scope

The aggregate badge sinks (selectGlobalBadge, tray title, dock) already collapse an all-zero state to undefined, so only the per-server tile was affected — those are left unchanged.

Test

Added a regression test asserting mentionCount={0} renders no "0" text.

Tests: 10 passed, 10 total

Summary by CodeRabbit

  • Bug Fixes
    • Fixed mention badges so a 0 count no longer appears as a visible badge.
    • Server list items now only show a badge when there is at least one mention, improving clarity.

The per-server sidebar tile rendered a literal "0" overlay whenever a
server's unread badge was the number 0.

PR #3369 (restore unread badge on 7.8.0+ servers) made injected.ts emit
setBadge(0) explicitly via `setBadge(alertIndicator ?? 0)`, so servers
now carry `badge: 0` where they previously carried `undefined`.
SideBar/index.tsx maps that to `mentionCount={0}`, and ServerButton
guarded the Badge with `{mentionCount && <Badge>...}`. Because
`0 && <Badge>` evaluates to `0`, React renders the number as a text
node — the stray "0" on the tile.

Coerce the guard to a boolean (`!!mentionCount`) so a zero count renders
nothing. Add a regression test asserting mentionCount={0} produces no
"0" text.

The aggregate badge sinks (selectGlobalBadge, tray title, dock) already
collapse an all-zero state to undefined, so only the per-server tile was
affected and they are left unchanged.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 86601adb-820c-469d-b37c-f05d4e946b2d

📥 Commits

Reviewing files that changed from the base of the PR and between 251b22d and c81051d.

📒 Files selected for processing (2)
  • src/ui/components/SideBar/ServerButton.spec.tsx
  • src/ui/components/SideBar/ServerButton.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: check (ubuntu-latest)
  • GitHub Check: check (macos-latest)
  • GitHub Check: check (windows-latest)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (actions)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{tsx,ts}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{tsx,ts}: MANDATORY: Use Fuselage components for all UI work. Only create custom components when Fuselage doesn't provide what's needed
Import UI components from @rocket.chat/fuselage and check Theme.d.ts for valid color tokens
Use React functional components with hooks
Use PascalCase for component file names

Files:

  • src/ui/components/SideBar/ServerButton.tsx
  • src/ui/components/SideBar/ServerButton.spec.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Redux actions must follow FSA (Flux Standard Action) pattern
Avoid unnecessary comments — write self-documenting code through clear naming
Always verify libraries by checking official docs and .d.ts files in node_modules/. Never assume props, tokens, or APIs work without verification
Avoid subjective descriptors ('smart', 'excellent', 'dumb') in documentation and comments
Use measurable descriptions in code documentation: 'reduced memory usage', 'improved by X%' instead of subjective claims
NEVER invent metrics — don't include estimated time spent or speculated user counts. Only include numbers from actual logs, error messages, or documented sources

Files:

  • src/ui/components/SideBar/ServerButton.tsx
  • src/ui/components/SideBar/ServerButton.spec.tsx
🔇 Additional comments (2)
src/ui/components/SideBar/ServerButton.tsx (1)

207-209: LGTM!

src/ui/components/SideBar/ServerButton.spec.tsx (1)

102-106: LGTM!


Walkthrough

The server button mention badge now uses an explicit boolean check, and a test was added to confirm a zero mention count does not render a literal 0 badge.

Changes

Mention badge rendering

Layer / File(s) Summary
Badge boolean check
src/ui/components/SideBar/ServerButton.tsx, src/ui/components/SideBar/ServerButton.spec.tsx
The mention badge condition now uses an explicit boolean coercion, and a test covers the zero-count case to ensure no 0 badge is shown.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

type: bug

🚥 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 clearly and concisely describes the main fix: preventing a literal "0" badge on the server sidebar tile.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

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.

1 participant