feat(usage): implement limit optimization and session planning features#248
Open
amitashwinibhagat wants to merge 1 commit into
Open
feat(usage): implement limit optimization and session planning features#248amitashwinibhagat wants to merge 1 commit into
amitashwinibhagat wants to merge 1 commit into
Conversation
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.
|
Thanks for doing this –– looks like it would be very helpful! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 orderSessionPlanningSettings— 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 fieldSessionLimitObservation— Records high-usage observations per reset window for auto-estimationServices
LimitOptimizationTipService— Recommendation engine that ranks tips based on session percentage, peak hours, MCP configuration, and proximity to limit. Supports rotating contextual tipsSessionPlanningService— 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 executionClaudeCodeOptimizationService— 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 templateUI 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 actionsLimitOptimizationGuideView— Full guide with category-filtered tip cards showing action-style and risk-level badges, with copy buttons for actionable commandsLimitHygieneCard— Claude Code settings card showing diagnostics, expandable "Before You Prompt" checklist, and copyable handoff templateSessionOverlapCard— Menu bar popover card displaying active session state or next planned ping timeContextualTipCard— Rotating actionable tip in the popover based on current usageUpdated Existing Components
Profile/ProfileManager— AddedsessionPlanningSettingsfield with backward compatibility and update methodsAutoStartSessionService— Extracted publicstartSession(for:source:)for planned overlap use; replaced hardcoded"Hi"withConstants.SessionPlanning.dummyPromptNotificationManager— Added session overlap reminder, planned ping success, and waste warning notificationsMenuBarManager— IntegratedSessionPlanningServicestart/stop andrecordUsagecallsFormatterHelper— AddedtimeString(from:)helperPopoverContentView— AddedSessionOverlapCardandContextualTipCardGeneralSettingsView— AddedSessionPlanningSettingsViewand guide navigation linkClaudeCodeView— AddedLimitHygieneCardLocalization
en.lproj/Localizable.stringsand all 12 non-English locales with English fallbacksscripts/validate_localizations.sh)Tests
SessionPlanningServiceTests— Lead time calculations, ping timing, day boundaries, duration clamping, backward-compatible decodingLimitOptimizationTipServiceTests— Catalog completeness (21 tips), recommendation engine logic, rotating tips, actionable filteringClaudeCodeOptimizationServiceTests— Checklist items, template content, diagnostics thresholds, read-only behavior verificationImportant Guidelines
UserDefaultsand standard Keychain access (without group identifiers) instead.Checklist