Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions daemon/codex-usage-daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ def minutes_until_epoch(epoch_seconds: Any) -> int:
return max(0, round((reset - utc_now()).total_seconds() / 60))


def epoch_seconds_in_past(epoch_seconds: Any, slack_seconds: int = 0) -> bool:
"""True if `epoch_seconds` is more than `slack_seconds` in the past."""
try:
reset = float(epoch_seconds)
except (TypeError, ValueError):
return False
return reset + slack_seconds < time.time()


def minutes_until_local_time(hour: int, minute: int) -> int:
now = datetime.now().astimezone()
reset = now.replace(hour=hour, minute=minute, second=0, microsecond=0)
Expand Down Expand Up @@ -817,8 +826,19 @@ def claude_hook_limits_snapshot() -> UsageSnapshot | None:
if five_used is None or week_used is None:
return None

five_reset = minutes_until_epoch(five_hour.get("resets_at"))
week_reset = minutes_until_epoch(seven_day.get("resets_at"))
# If either reset time has already passed, the percentages in this file
# are logically stale even though the file's mtime may be recent (claude
# code writes this on every status-line refresh but doesn't reset the
# percentages until the next real session crosses the boundary). Falling
# through here lets the plan-usage / activity sources provide fresh
# numbers instead of showing 100% used on a window that already reset.
five_resets_at = five_hour.get("resets_at") if five_hour else None
week_resets_at = seven_day.get("resets_at") if seven_day else None
if epoch_seconds_in_past(five_resets_at) or epoch_seconds_in_past(week_resets_at):
return None

five_reset = minutes_until_epoch(five_resets_at)
week_reset = minutes_until_epoch(week_resets_at)

return UsageSnapshot(
session_pct=remaining_pct_from_used(float(five_used)),
Expand Down
6 changes: 5 additions & 1 deletion ios/CodexMeterApp/CodexMeterApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1600;
LastUpgradeCheck = 2650;
TargetAttributes = {
2DA90E0FD071B0F94B375F91 = {
ProvisioningStyle = Automatic;
Expand Down Expand Up @@ -428,6 +428,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -449,6 +450,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.codexmeter.ios;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -494,6 +496,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -508,6 +511,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.codexmeter.ios;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
version = "1.7">
LastUpgradeVersion = "2650"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
runPostActionsOnFailure = "NO">
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -28,8 +27,7 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "NO">
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -52,8 +50,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<CommandLineArguments>
</CommandLineArguments>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -75,8 +71,6 @@
ReferencedContainer = "container:CodexMeterApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -94,8 +88,6 @@
ReferencedContainer = "container:CodexMeterApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
version = "1.7">
LastUpgradeVersion = "2650"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
runPostActionsOnFailure = "NO">
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -28,8 +27,7 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "NO">
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -52,8 +50,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<CommandLineArguments>
</CommandLineArguments>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -74,17 +70,13 @@
ReferencedContainer = "container:CodexMeterApp.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<CommandLineArguments>
</CommandLineArguments>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand Down
Loading
Loading