Skip to content

fix: size menu bar item to fit content, avoiding truncation - #34

Merged
lonewolfyx merged 1 commit into
mainfrom
feat/dynamic-menubar-width
Jul 16, 2026
Merged

lonewolfyx merged 1 commit into
mainfrom
feat/dynamic-menubar-width

Conversation

@lonewolfyx

@lonewolfyx lonewolfyx commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

The status item used a fixed 76pt width, which could truncate the weekly prefix/percent text when content was wider and leave excess padding when narrower.

Replace it with dynamic sizing driven by the view's actual content.
MenuBarQuotaView now exposes preferredWidth (computed from the icon, weekly prefix label, percent label, and their spacing) and an intrinsicContentSize override. AppDelegate configures the status item with NSStatusItem.variableLength and syncs statusItem.length to preferredWidth on every snapshot update, so the item always matches its content - no truncation, no extra padding.

Also extract layout magic numbers into a Metrics enum and refresh intrinsic size after each update.

Summary by CodeRabbit

  • New Features

    • The menu bar quota indicator now automatically adjusts its width to fit its displayed content.
  • Bug Fixes

    • Improved menu bar layout consistency by dynamically updating the indicator size when its content changes.
    • Refined spacing, padding, and icon alignment for a more consistent appearance.
    • Improved handling of empty or unavailable quota information.

The status item used a fixed 76pt width, which could truncate the weekly prefix/percent text when content was wider and leave excess padding when narrower.

Replace it with dynamic sizing driven by the view's actual content.
MenuBarQuotaView now exposes preferredWidth (computed from the icon, weekly prefix label, percent label, and their spacing) and an intrinsicContentSize override. AppDelegate configures the status item with NSStatusItem.variableLength and syncs statusItem.length to preferredWidth on every snapshot update, so the item always matches its content - no truncation, no extra padding.

Also extract layout magic numbers into a Metrics enum and refresh intrinsic size after each update.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5acd6a5a-07f6-41cd-9229-2bf1836fde2c

📥 Commits

Reviewing files that changed from the base of the PR and between 74c169f and 9538cb7.

📒 Files selected for processing (2)
  • Sources/AgentBar/App/AppDelegate.swift
  • Sources/AgentBar/UI/MenuBarQuotaView.swift

📝 Walkthrough

Walkthrough

The status-bar item now uses variable length derived from MenuBarQuotaView.preferredWidth. The quota view centralizes layout metrics, recalculates intrinsic sizing from label content, handles empty snapshots, and invalidates its intrinsic content size after updates.

Changes

Dynamic status item sizing

Layer / File(s) Summary
Quota view sizing and updates
Sources/AgentBar/UI/MenuBarQuotaView.swift
Layout metrics are centralized, preferred width uses label intrinsic widths, snapshot handling covers both states, and intrinsic sizing is invalidated after label updates.
Status item integration
Sources/AgentBar/App/AppDelegate.swift
The status item uses variable length, the quota view is constrained to status-bar thickness, and the item length follows the view’s preferred width.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

✨ 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 feat/dynamic-menubar-width

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.

@lonewolfyx
lonewolfyx merged commit af210ee into main Jul 16, 2026
1 check was pending
@lonewolfyx
lonewolfyx deleted the feat/dynamic-menubar-width branch July 16, 2026 05:36
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