claude: add multi-account adapter view - #3
Conversation
claude: preserve account identity labels
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dbc29ef8a7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| activeAccountNumber: parsedAccounts.value.activeAccountNumber, | ||
| loading: false, | ||
| error: "", | ||
| fetchedAt: Date.now() |
There was a problem hiding this comment.
Preserve adapter usage freshness timestamps
When a schema-v1 adapter returns a valid list backed by cached per-account usage, stamping the whole response with Date.now() makes every Claude account card report that the quota was just updated and keeps the stale check tied to the poll time rather than the measurement time. In the case where the adapter falls back to last-known usage after a fetch failure, users can be shown stale quota as fresh; carry the row-level usageFetchedAt/usageAgeSeconds through parsing and use that for the card timestamp/staleness instead.
Useful? React with 👍 / 👎.
| } | ||
| if (operation === "switch" && typeof slot === "number" && isFinite(slot) | ||
| && Math.floor(slot) === slot && slot > 0) | ||
| return prefix + quoted + " --switch-to " + slot + " --json 2>/dev/null" |
There was a problem hiding this comment.
Wrap account switches in a timeout
The list and normal CLI probes are timeout-wrapped, but an explicit --switch-to can still block indefinitely if the adapter hangs on a credential lock, keychain prompt, or backend call. In that scenario claudeSwitchInFlight never gets cleared, so the account view stops refreshing and all switch buttons remain disabled until the plasmoid is reloaded; apply the same bounded execution pattern to the switch command.
Useful? React with 👍 / 👎.
Address Codex PR psimaker#3 review feedback: - Wrap `--switch-to` in `timeout -k 5 30` like the list probe so a hung adapter (credential lock, keychain prompt, or backend call) cannot leave claudeSwitchInFlight set and disable every switch button until the plasmoid is reloaded. The existing 124/137 exit-code path surfaces the "Timed out…" message and clears the in-flight flag in handleData. - Parse optional per-account `usageFetchedAt` (ISO 8601) or `usageAgeSeconds` (non-negative seconds) into `usageMeasuredAt`, and use it for the card timestamp and staleness, falling back to the poll timestamp when the adapter omits freshness. This stops cached or last-known usage from reading as fresh just because the widget polled again. Backward compatible: adapters that report no freshness behave exactly as before. Co-Authored-By: Claude <noreply@anthropic.com>
Summary
alias > organizationName > emailCompatibility
The adapter remains optional and credential-free. Existing adapters that only
provide email continue to work; claude-swap's
organizationNameand optionalaliasare retained when present.Verification
psimaker/codexbar-plasmoidmainat09e6bc6git diff --checkpasses