Skip to content

Show premium-session quota in freebuff session-ended banner#618

Merged
jahooma merged 3 commits intomainfrom
freebuff-session-ended-banner-quota
May 8, 2026
Merged

Show premium-session quota in freebuff session-ended banner#618
jahooma merged 3 commits intomainfrom
freebuff-session-ended-banner-quota

Conversation

@jahooma
Copy link
Copy Markdown
Contributor

@jahooma jahooma commented May 7, 2026

Summary

When a freebuff session ends, the banner that replaces the input box now shows your daily premium-session usage — N of 5 premium sessions used today — so you can see how many free sessions you have left without waiting until the next time you open the picker.

  • Server (web/src/server/free-session/public-api.ts): unified attachRateLimit to thread the quota snapshot onto queued, active, and ended responses. The active-response change also fixes the markFreebuffSessionEnded path (called from the chat-completions error handler in send-message.ts) — the prior session in the store now always carries the snapshot, so the banner has data even when the session ends mid-chat instead of via grace-window polling.
  • Type (common/src/types/freebuff-session.ts): added rateLimitsByModel? to the 'ended' wire variant + a small getRateLimitsByModel(session) helper used on both sides.
  • CLI (cli/src/components/session-ended-banner.tsx): renders the count next to the "Your freebuff session has ended." line, amber when exhausted (matches the waiting-room landing color rule).
  • CLI (cli/src/hooks/use-freebuff-session.ts): markFreebuffSessionEnded and the in-poll active|ended → none synthesis path both forward whichever snapshot is available so the banner stays populated through state transitions.

Behavior change worth noting

active responses on non-premium models (e.g. Minimax) now include rateLimitsByModel if the user has used any premium sessions today (filtered through the existing onlyUsedRateLimitsByModel). This is consistent with how queued already worked, and makes the quota line surface uniformly across UI states.

Test plan

  • bun run typecheck clean in common, cli, and web
  • All 86 free-session tests in web/src/server/free-session/__tests__/ pass
  • CLI component tests have the same pass/fail count as main (4 pre-existing failures in MessageBlockStore, unrelated)
  • Manual TUI verification: launch freebuff, run a premium model to session expiry, confirm banner shows "1 of 5 premium sessions used today"
  • Manual TUI verification: trigger a session_expired error mid-chat (e.g. by waiting through grace), confirm the banner still shows the count
  • Visual: confirm color is muted at <5/5 and amber/secondary at 5/5

🤖 Generated with Claude Code

Server now attaches `rateLimitsByModel` to active and ended responses (in
addition to queued), and the banner shows "N of 5 premium sessions used
today" when the session ends — matching the waiting-room landing line so
users can see how many free sessions they have left for the day.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jahooma and others added 2 commits May 7, 2026 14:24
Drops the inline `'rateLimitsByModel' in session` pattern from the
waiting-room screen and model selector now that `getRateLimitsByModel`
exists in common, and lifts `formatSessionUnits` out of waiting-room
so the session-ended banner doesn't carry a duplicate. Adds a regression
test for the ended view's full-snapshot quota behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the premium-session quota into the box title and drop the
redundant "Your freebuff session has ended" line — the title already
says it. Border goes amber when the cap is hit so the warning signal
survives the move (titles can't carry per-char color). Press Enter
becomes bold foreground instead of green primary, and "Change model
(ESC)" relaxes to "Change model   Esc" with Esc muted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jahooma jahooma merged commit 84cc946 into main May 8, 2026
35 checks passed
@jahooma jahooma deleted the freebuff-session-ended-banner-quota branch May 8, 2026 00:43
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