omkxr / Writing

Building a macOS menu bar app for developer usage tracking

Quota meter is a macOS menu bar app. It answers one question: how much usage is left before this session runs out. The window is a menu. That constraint decided more of the design than the data did. The app is in development. There is no public release and no usage number on this site.

The menu is the product

A menu bar extra does not get a normal window. The useful state has to be readable in the bar itself: a short label, and a menu that opens on click. I keep the bar label to the thing that changes, the remaining allowance, and put the breakdown in the menu. A label that needs a paragraph has already failed.

The menu lists the session, the last successful refresh, and the failure if the last refresh failed. I do not animate the bar to draw attention. The number changing is the event. Motion inside a 22 pixel status item is how a utility becomes an ad.

Refresh has to be boring

Usage numbers go stale, and polling too often is its own outage. The app refreshes on a timer while it is open, refreshes when the menu opens, and backs off when a request fails. A failed refresh keeps the last good value on screen and marks it stale. Replacing a known value with a spinner, or with zero, is a lie.

I do not refresh from a background schedule that survives the app. If the app is not running, it is not reporting. A menu bar utility that wakes the machine to update a label is the wrong shape.

type MeterState =
  | { status: "ready"; remaining: string; refreshedAt: string }
  | { status: "stale"; remaining: string; refreshedAt: string; error: string }
  | { status: "signed-out" }
  | { status: "unknown" }

Sign-in is the sharp edge

The meter is only useful with an account. The token does not belong in the label, the menu, or a log line. It belongs in the keychain, and the menu should be able to say "signed out" without dumping the reason in a way that includes the token. A 401 clears the session and shows the sign-in action. It does not retry the same token in a loop.

I also do not put the provider's raw payload in the menu. The menu shows the fields the utility needs. Extra fields stay in memory for that refresh and are dropped.

Native constraints I am keeping

The app is an accessory, not a Dock citizen. It should launch quickly, use little memory, and quit cleanly. I am not embedding a web view to draw a menu. Text, a few lines, and a sign-in button are enough, and they look like the rest of the menu bar.

Sandboxing and the keychain are part of the design, not a release checklist at the end. If a later build needs a network entitlement, that entitlement is for the usage endpoint only. The app does not need to read the user's files to show a remaining balance.

What I am not claiming

There is no App Store page for this app. I am not publishing a certification, a download count, or a measured battery impact. The engineering point is narrower: a usage meter should show the last known truth, say when that truth is old, and never treat a missing response as an empty account.

The menu also should not become a settings app. Refresh interval, if it is configurable at all, is one control. I am not adding charts, history, or a second window. A menu bar item that opens a dashboard has stopped being a menu bar item. If the number needs a longer explanation, that explanation belongs in the product the usage came from, not in a 200 pixel menu.

Have something worth building?
Reading the page… 0 layers