mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-17 10:03:08 +00:00
refactor(store): Extract utility functions into store/utils/
Move pure utility functions from app-store.ts and type files into dedicated utils modules for better separation of concerns: - theme-utils.ts: Theme and font storage utilities - shortcut-utils.ts: Keyboard shortcut parsing/formatting - usage-utils.ts: Usage limit checking All utilities are re-exported from store/utils/index.ts and app-store.ts maintains backward compatibility for existing imports. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
34
apps/ui/src/store/utils/usage-utils.ts
Normal file
34
apps/ui/src/store/utils/usage-utils.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { ClaudeUsage } from '../types/usage-types';
|
||||
|
||||
/**
|
||||
* Check if Claude usage is at its limit (any of: session >= 100%, weekly >= 100%, OR cost >= limit)
|
||||
* Returns true if any limit is reached, meaning auto mode should pause feature pickup.
|
||||
*/
|
||||
export function isClaudeUsageAtLimit(claudeUsage: ClaudeUsage | null): boolean {
|
||||
if (!claudeUsage) {
|
||||
// No usage data available - don't block
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check session limit (5-hour window)
|
||||
if (claudeUsage.sessionPercentage >= 100) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check weekly limit
|
||||
if (claudeUsage.weeklyPercentage >= 100) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check cost limit (if configured)
|
||||
if (
|
||||
claudeUsage.costLimit !== null &&
|
||||
claudeUsage.costLimit > 0 &&
|
||||
claudeUsage.costUsed !== null &&
|
||||
claudeUsage.costUsed >= claudeUsage.costLimit
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user