Skip to content

Add OpenAI limit probe prototype#14

Merged
cbusillo merged 31 commits intodesign/local-limit-probefrom
feature/openai-limit-probe
May 7, 2026
Merged

Add OpenAI limit probe prototype#14
cbusillo merged 31 commits intodesign/local-limit-probefrom
feature/openai-limit-probe

Conversation

@cbusillo
Copy link
Copy Markdown
Owner

@cbusillo cbusillo commented May 5, 2026

Summary

  • Add redacted live Codex/OpenAI rate-limit probing for percent-window subscription pressure
  • Add Gemini Code Assist and Claude local-status probes, then extract them into reusable ContextPanelCore connectors
  • Add ProviderConnectorRuntime plus redacted HTTP/process abstractions for app refreshers
  • Add JSON snapshot storage/history and a SnapshotStoreProbe for app/widget cache smoke testing
  • Wire the SwiftUI preview shell to the snapshot cache with local Codex/Claude refresh controls and setup/cache state
  • Use cached OpenAI percent-window limits for the fast-mode forecast headline
  • Add a WidgetKit cache-only glance target and preview layouts for small/medium/large widget states
  • Refine the glance UX around decisions: real window labels, provider text badges, tightest-window rollups, and fast-mode verdicts
  • Let Gemini Code Assist use installed Gemini CLI OAuth client metadata transiently, with env/flag override support
  • Add configured-account snapshot refresh so local multi-account data can populate the app/widget cache
  • Add a subscription-only Claude statusline cache path for five-hour/weekly percent windows when Claude Code provides them
  • Update provider research, architecture docs, and README with current connector/cache confidence and safety boundaries

Provider Evidence

  • OpenAI/Codex: direct backend usage endpoint returns percent windows, reset times, plan type, credits, and additional buckets from local Codex-style auth.
  • Google/Gemini: local Gemini CLI auth plus installed CLI OAuth client metadata returned live Code Assist quota buckets in local configured-account refresh.
  • Anthropic/Claude: official Claude Code statusline docs expose rate_limits.five_hour and rate_limits.seven_day for Pro/Max subscribers after an API response. Context Panel now reads only a sanitized statusline cache, never auth, Keychain, raw transcripts, prompts, or raw session JSON.

Local Data Smoke

  • Seeded local, untracked Context Panel account config with ~/.codex/auth.json, ~/.code/auth.json, ~/.gemini/oauth_creds.json, and Claude local status.
  • swift run SnapshotStoreProbe --output ~/Library/Application\ Support/Context\ Panel/Snapshots --configured-accounts returned 4 reports and 16 normalized limits before Claude statusline cache population.
  • Synthetic Claude statusline JSON smoke writes five-hour and weekly percent/reset cache successfully.
  • Snapshot contains live OpenAI 5-hour/weekly percent windows and Gemini daily model buckets; token values and raw provider responses are not stored or printed.

UX Decisions

  • No abstract provider shapes; providers use short text badges plus labels.
  • Provider collapse should show the binding/tightest window, not an average or a sum across nested windows.
  • Window rows should say Hourly, 5-hour, Daily, Weekly, etc. instead of primary/secondary.
  • Claude subscription usage is subscription-only: statusline five-hour/weekly percent windows when available; otherwise allowance unknown.
  • Fast mode is a first-class verdict because it is the main action decision.

Planning

Refs #3
Refs #12
Refs #17
Updates #5
Updates #6
Updates #9
Updates #15
Updates #16

Validation

  • scripts/commit-gate.sh
  • scripts/claude-statusline-cache.sh synthetic statusline JSON smoke
  • swift run CodexRateLimitProbe
  • swift run ClaudeLimitProbe
  • swift run SnapshotStoreProbe --codex-auth ~/.codex/auth.json --include-claude
  • swift run SnapshotStoreProbe --output ~/Library/Application\ Support/Context\ Panel/Snapshots --configured-accounts
  • swift run ContextPanelPreview with screenshot inspection
  • Gemini connector fixture tests
  • Official provider docs cited in docs/provider-usage-access.md
  • Design export preserved in docs/design-direction.md

Comment thread Sources/ClaudeLimitProbe/main.swift Fixed
@cbusillo
Copy link
Copy Markdown
Owner Author

cbusillo commented May 6, 2026

Update after Claude/Every Code investigation:

  • Verified the local Claude status-line cache populated after an interactive Claude session: 5-hour and weekly subscription percent/reset windows are available when Claude Code runs the status-line hook.
  • Smoke-tested non-interactive claude -p --output-format stream-json --verbose: it emitted rate_limit_info with status/window/reset metadata, but no used_percentage, so it is not enough for the main subscription-percent glance.
  • Added stale handling so old Claude status-line readings are marked stale instead of looking healthy/live forever.
  • Updated Implement Anthropic usage connector strategy #17/Add Claude status-line setup onboarding #18 with the fresh-install and Every Code/non-interactive limitation.

Validation: scripts/commit-gate.sh passed with 56 tests on 0e0b32d.

@cbusillo
Copy link
Copy Markdown
Owner Author

cbusillo commented May 6, 2026

Claude/Every Code follow-up on 5a4d139:

  • Reframed Claude as unsolved for official non-interactive subscription percent. claude -p/Every Code does not expose used_percentage; status-line percentages only come from interactive Claude.
  • Added an Every Code-compatible fallback: scripts/claude-ccusage-cache.sh writes sanitized ccusage blocks --json --offline aggregate block data to Context Panel app support.
  • ClaudeLocalStatusConnector now reads that cache as an estimated 5-hour token window with confidence: estimated, and explicitly notes that official subscription percentage is unavailable in claude -p.
  • The connector reads cache files only during refresh; it does not shell out to ccusage from the app/widget path.
  • Real local smoke: cache helper populated ccusage-blocks-cache.json; swift run ClaudeLimitProbe reported one healthy estimated Claude row from Every Code/Claude sessions.

Validation: swift test --filter Claude, swift test --filter ProviderConnectorTests, and scripts/commit-gate.sh passed with 59 tests.

@cbusillo
Copy link
Copy Markdown
Owner Author

cbusillo commented May 7, 2026

Native app/widget packaging slice is locally green:

  • Added XcodeGen project.yml plus generated ContextPanel.xcodeproj.
  • Added native ContextPanel app target, embedded ContextPanelWidgetExtension WidgetKit extension target, and shared static ContextPanelCore target.
  • Added app/widget App Group entitlements for group.com.shinycomputers.contextpanel.
  • Wired the app and widget snapshot store to the shared App Group container.
  • Updated release docs/README with the native Xcode build path.

Validation:

  • scripts/commit-gate.sh passed with 62 tests.
  • xcodegen generate --spec project.yml succeeded.
  • xcodebuild -project ContextPanel.xcodeproj -scheme ContextPanel -configuration Debug -destination 'platform=macOS' -allowProvisioningUpdates build succeeded.
  • codesign --verify --deep --strict passed for the Debug app bundle.

This gets us from SwiftPM widget compilation to a real embedded .appex inside Context Panel.app. Next release work is archive/export/notarization and widget-gallery screenshot QA.

@cbusillo cbusillo merged commit 9a668f7 into design/local-limit-probe May 7, 2026
3 checks passed
@cbusillo cbusillo deleted the feature/openai-limit-probe branch May 7, 2026 13:44
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