Skip to content

claude: add multi-account adapter view - #3

Open
salty-flower wants to merge 2 commits into
psimaker:mainfrom
salty-flower:feature/claude-swap-accounts
Open

claude: add multi-account adapter view#3
salty-flower wants to merge 2 commits into
psimaker:mainfrom
salty-flower:feature/claude-swap-accounts

Conversation

@salty-flower

Copy link
Copy Markdown

Summary

  • add an optional schema-v1 Claude account adapter view
  • show per-account 5-hour, 7-day, and scoped usage windows
  • support explicit account switching with serialized requests
  • preserve claude-swap identity fields and display alias > organizationName > email
  • keep the normal Claude provider card as a safe fallback for missing or invalid adapter data

Compatibility

The adapter remains optional and credential-free. Existing adapters that only
provide email continue to work; claude-swap's organizationName and optional
alias are retained when present.

Verification

  • rebased cleanly onto psimaker/codexbar-plasmoid main at 09e6bc6
  • git diff --check passes
  • parser identity test passes for alias, organization name, and email fallback

claude: preserve account identity labels

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread contents/ui/main.qml Outdated
activeAccountNumber: parsedAccounts.value.activeAccountNumber,
loading: false,
error: "",
fetchedAt: Date.now()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread contents/ui/main.qml Outdated
}
if (operation === "switch" && typeof slot === "number" && isFinite(slot)
&& Math.floor(slot) === slot && slot > 0)
return prefix + quoted + " --switch-to " + slot + " --json 2>/dev/null"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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>
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.

1 participant