Address problem(s) in OpenAI Dashboard#825
Merged
ratulsarna merged 1 commit intosteipete:mainfrom May 1, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Improves robustness of CodexBar’s OpenAI Dashboard integration by stabilizing locale/route handling, waiting for full dashboard hydration, enriching scrape results with API data, filtering out non-Codex “Skillusage:*” services, and improving error messaging/timeouts.
Changes:
- Force English localization for dashboard WebView loads and API requests; support current/legacy usage routes; improve dashboard “ready” signaling.
- Filter “Skillusage:*” entries out of Codex usage breakdown everywhere it’s ingested/decoded/rendered.
- Improve credit parsing for localized formats; add retry behavior and clearer user-facing errors; add targeted test coverage.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/CodexBarTests/OpenAIDashboardParserTests.swift | Adds tests for spaced limit labels and localized/thousands credit parsing. |
| Tests/CodexBarTests/OpenAIDashboardModelsTests.swift | New tests for Skillusage filtering and snapshot decoding behavior. |
| Tests/CodexBarTests/OpenAIDashboardFetcherCreditsWaitTests.swift | Tests for English headers, API request construction, route handling, and API payload mapping. |
| Tests/CodexBarTests/CodexUserFacingErrorTests.swift | Tests for mapping timeout/network dashboard errors into actionable guidance. |
| Tests/CodexBarTests/CodexManagedOpenAIWebRefreshTests.swift | Tests retry-after-timeout behavior and updated fetch timeout expectations. |
| Sources/CodexBarCore/OpenAIWeb/OpenAIDashboardWebViewCache.swift | Injects preferred language script + uses a localized URLRequest for WebView loads. |
| Sources/CodexBarCore/OpenAIWeb/OpenAIDashboardScrapeScript.swift | Improves usage breakdown extraction + filters Skillusage services + better credits-history scraping/scroll behavior. |
| Sources/CodexBarCore/OpenAIWeb/OpenAIDashboardParser.swift | Enhances credit amount parsing and adds more flexible “5 h / 7 d” limit detection. |
| Sources/CodexBarCore/OpenAIWeb/OpenAIDashboardFetcher.swift | Adds API preflight enrichment, English request headers, improved “ready” gating, Skillusage filtering on decode. |
| Sources/CodexBarCore/OpenAIDashboardModels.swift | Ensures snapshots sanitize usage breakdown and adds centralized Skillusage filtering utilities. |
| Sources/CodexBar/UsageStore+OpenAIWeb.swift | Increases primary timeout; retries after WebView timeout by importing cookies and re-fetching; extends cookie import API. |
| Sources/CodexBar/UsageStore+HistoricalPace.swift | Prevents historical backfill from using Skillusage-contaminated breakdowns. |
| Sources/CodexBar/UsageBreakdownChartMenuView.swift | Ensures displayed breakdown excludes Skillusage entries. |
| Sources/CodexBar/StatusItemController+Menu.swift | Hides usage breakdown submenu when filtered breakdown is empty. |
| Sources/CodexBar/StatusItemController+HostedSubmenus.swift | Filters Skillusage services before rendering breakdown chart submenu item. |
| Sources/CodexBar/Providers/Codex/CodexConsumerProjection.swift | Maps OpenAI web timeout/network errors into clearer user-facing messages; filters Skillusage for display logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+787
to
+811
| var queue: [Any] = [json] | ||
| var seen = 0 | ||
| while !queue.isEmpty, seen < 2000 { | ||
| let current = queue.removeFirst() | ||
| seen += 1 | ||
| if let string = current as? String, string.contains("@") { | ||
| return string | ||
| } | ||
| if let dictionary = current as? [String: Any] { | ||
| for (key, value) in dictionary { | ||
| if key.lowercased() == "email", | ||
| let string = value as? String, | ||
| string.contains("@") | ||
| { | ||
| return string | ||
| } | ||
| queue.append(value) | ||
| } | ||
| } else if let array = current as? [Any] { | ||
| queue.append(contentsOf: array) | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
Comment on lines
+484
to
+487
| const allTableRows = () => Array.from(document.querySelectorAll('tbody tr')).map(tr => { | ||
| const cells = Array.from(tr.querySelectorAll('td')).map(td => textOf(td)); | ||
| return cells; | ||
| }).filter(looksLikeCreditsEventRow); |
| } | ||
|
|
||
| private static func looksOpenAIWebNetworkError(lower: String) -> Bool { | ||
| lower.contains("nsurlerrordomain") |
This was referenced May 4, 2026
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.
Problems addressed
Implemented fixes
It is not entirely perfect, but at least it's in a much more usable state than before