Skip to content

feat(usage): implement limit optimization and session planning features#248

Open
amitashwinibhagat wants to merge 1 commit into
hamed-elfayome:mainfrom
amitashwinibhagat:main
Open

feat(usage): implement limit optimization and session planning features#248
amitashwinibhagat wants to merge 1 commit into
hamed-elfayome:mainfrom
amitashwinibhagat:main

Conversation

@amitashwinibhagat

@amitashwinibhagat amitashwinibhagat commented May 25, 2026

Copy link
Copy Markdown

Description

This PR implements the Limit Optimization feature set, giving users actionable guidance for staying within Claude usage limits across Claude.ai, Claude Code, and Claude Cowork. It adds a 21-tip contextual recommendation system, a Session Overlap Planner for managing the 5-hour rolling window, and read-only Claude Code diagnostics. All new user-facing strings are localized across 13 languages, and comprehensive unit tests cover the new calculation and recommendation logic.

Changes

Models

  • LimitOptimizationTip — Catalog of 21 tips across Claude.ai (9), Claude Code (8), and Claude Cowork (4) categories, with metadata for action style, risk level, and sort order
  • SessionPlanningSettings — Profile-scoped settings for the Session Overlap Planner, including planned work start time, typical time-to-limit, auto-estimation toggle, ping mode (reminder vs auto-send), waste warnings, and plan-mode tips. Backward-compatible decoding for profiles without this field
  • SessionLimitObservation — Records high-usage observations per reset window for auto-estimation

Services

  • LimitOptimizationTipService — Recommendation engine that ranks tips based on session percentage, peak hours, MCP configuration, and proximity to limit. Supports rotating contextual tips
  • SessionPlanningService — Runtime loop (60s interval) that computes recommended ping times, deduplicates reminders, records observations at ≥90% usage, and optionally auto-sends dummy prompts. Clears one-off plans after execution
  • ClaudeCodeOptimizationService — Read-only diagnostics for MCP server count, CLAUDE.md size, and settings entries. Provides copyable checklist items (/context, /clear, /compact, /rewind) and a session handoff template

UI Components

  • SessionPlanningSettingsView — Settings card with educational copy about 5-hour windows, time picker, duration slider with auto-estimation, ping mode toggle, and live recommendation display with quick actions
  • LimitOptimizationGuideView — Full guide with category-filtered tip cards showing action-style and risk-level badges, with copy buttons for actionable commands
  • LimitHygieneCard — Claude Code settings card showing diagnostics, expandable "Before You Prompt" checklist, and copyable handoff template
  • SessionOverlapCard — Menu bar popover card displaying active session state or next planned ping time
  • ContextualTipCard — Rotating actionable tip in the popover based on current usage

Updated Existing Components

  • Profile / ProfileManager — Added sessionPlanningSettings field with backward compatibility and update methods
  • AutoStartSessionService — Extracted public startSession(for:source:) for planned overlap use; replaced hardcoded "Hi" with Constants.SessionPlanning.dummyPrompt
  • NotificationManager — Added session overlap reminder, planned ping success, and waste warning notifications
  • MenuBarManager — Integrated SessionPlanningService start/stop and recordUsage calls
  • FormatterHelper — Added timeString(from:) helper
  • PopoverContentView — Added SessionOverlapCard and ContextualTipCard
  • GeneralSettingsView — Added SessionPlanningSettingsView and guide navigation link
  • ClaudeCodeView — Added LimitHygieneCard

Localization

  • Added 90+ new keys to en.lproj/Localizable.strings and all 12 non-English locales with English fallbacks
  • All localization files pass validation (scripts/validate_localizations.sh)

Tests

  • SessionPlanningServiceTests — Lead time calculations, ping timing, day boundaries, duration clamping, backward-compatible decoding
  • LimitOptimizationTipServiceTests — Catalog completeness (21 tips), recommendation engine logic, rotating tips, actionable filtering
  • ClaudeCodeOptimizationServiceTests — Checklist items, template content, diagnostics thresholds, read-only behavior verification

Important Guidelines

  • Do NOT use App Groups Keychain with app group identifiers. This app is distributed outside the App Store via a Developer ID certificate. App Group entitlements require Keychain access prompts on every launch, which breaks the user experience. Use standard UserDefaults and standard Keychain access (without group identifiers) instead.
  • Follow existing code patterns and architecture (MVVM, protocol-oriented)
  • Add localization keys for any new user-facing strings (9 languages supported)
  • Test on macOS 14.0+ (Sonoma)

Checklist

  • I have tested these changes on a running build
  • I have attached screenshots/recordings for any visual changes (REQUIRED — see Screenshots section above)
  • I have not introduced App Group or grouped Keychain usage
  • I have added localization keys for any new user-facing strings (90+ keys added to all 13 locales)

Add services, models, and UI components to provide users with
contextual tips for optimizing usage limits and managing session
planning settings. Includes comprehensive unit tests and
internationalization support.
@dan-orth

Copy link
Copy Markdown

Thanks for doing this –– looks like it would be very helpful!

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.

2 participants