mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-21 23:33:07 +00:00
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>
35 lines
875 B
TypeScript
35 lines
875 B
TypeScript
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;
|
|
}
|