Skip to content

feat(paseo-omp): show and switch the session's OMP account - #634

Open
taemire wants to merge 9 commits into
omercnet:mainfrom
taemire:feat/paseo-omp-session-account
Open

taemire wants to merge 9 commits into
omercnet:mainfrom
taemire:feat/paseo-omp-session-account

Conversation

@taemire

@taemire taemire commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Second part of the split of #631: the session account. Stacked on #632 (tags) and #633 (OMP Plugin provider); until they merge, this diff also shows theirs.

Problem

With several logins per provider, the quota UI could not say which account the session uses or move it to another one, and the pill showed the provider's busiest account even when the session no longer used it.

Changes

  • The popover marks the login the session uses with IN USE and lists it first in the current provider. A live OMP Plugin session answers through its runtime (get_logout_accounts, now marked implemented); any other OMP session, including bundled omp, is matched through the session id Paseo stores to the pin OMP records (session:sticky:<provider>:<session id>). Both read the agent's own store, chosen on the server from the provider Paseo reports; an agent Paseo cannot look up gets no marks.
  • Every other login linked to recorded usage gets a Switch button that sends /session pin OAuth credential #<id>. It is disabled while the agent is running or initializing, since Paseo would interrupt the turn and OMP does not pin while it streams. Its accessible name is the login label, and its hit slop gives a 44px target.
  • A provider's only stored credential, API keys included, shows ONLY LOGIN instead of Switch; it gets IN USE only when OMP reports or recorded it.
  • Logins link to recorded usage only by OMP's identity rule (organization, then email, else account id). A login without any identity, such as a Copilot login, links to no usage: one login and one usage key do not prove ownership, so a replaced login never inherits its predecessor's usage. A login in use, or the provider's only one, that no usage row matches is still named at the top of its provider with IN USE or ONLY LOGIN and no limits.
  • When two logins link to the same usage account, the one in use keeps IN USE.
  • The pill shows the usage of the account in use, such as 13%, with the provider and account in its tooltip. It falls back to the provider's highest usage, tooltip all accounts, when the account in use is unknown or has no usage value.
  • Accounts are separated by a divider; three notices that repeated each row were removed.

What reaches the client

As listed in the README: a SHA-256 hash of each usage account key (the raw key stays on the server), and for the session's logins OMP's credential id, OMP's login label (email or raw account id, plus organization name), whether the login is in use or the only stored credential, and the hashes of the usage accounts it links to. Credential data and tokens are never read.

Known limit

OMP's get_logout_accounts decides active by identity, so in a live OMP Plugin session a login without one (Copilot) never shows IN USE, even when pinned. The popover keeps OMP's answer; bundled omp sessions read the recorded pin and do show it.

Verification

  • npm run check, npm run typecheck: passed.
  • npm test: 100 files passed, 1 skipped; 1515 tests passed, 8 skipped.
  • New tests cover identity matching (Team seats sharing an account id, one email in two organizations, org-scoped beside org-less, a replaced login, an identity-less login), store scoping, agent lookup through the registered RPC, the sole-login and API-key rules, Switch disabled during a turn, overlapping usage keys, the pill fallback without a usage value, and the unlinked login line. Each was confirmed to fail with its fix reverted.
  • Live isolated daemon, omp-plugin agent seeded with fictional logins on example.invalid: after /session pin OAuth credential #3 the popover showed IN USE on that login and Switch on the others; pressing Switch sent /session pin OAuth credential #2, OMP confirmed the pin, and the pill followed to that account. An identity-less Copilot login rendered as the unlinked line.

The session pinned to lee@example.invalid (credential #2):

Pill Popover
Pill: the in-use account's 12% Popover: IN USE on the pinned login, Switch on the others, dividers and badges

The pill tooltip reads Anthropic · lee@example.invalid (Example Team) · 12% (last recorded usage, not live).

JangMinSeok added 9 commits November 16, 2026 22:43
- Read each account's plan and organization from OMP's cached usage reports and show them as badges.
- Show an Anthropic organization named after the account's email as Personal.
- Show reset countdowns a day or more away as days and hours.
- Move plan and organization badges into the account heading row and its accessibility label.
- Accounts cards show the plan and organization badges the quota popover shows, from OMP's cached usage report, and drop OMP's parenthesized organization from the label once a badge shows it.
- One tag rule in shared/account-tags.ts serves both views; `tags` defaults to an empty list.
…ve session

- Paseo shows an OMP Plugin agent's model as an opaque id, so the quota pill and popover could not tell its provider and summarized every provider.
- New RPC paseo-omp.session-model-provider asks the agent's live session, which maps the id back to OMP's model; a closed or unknown agent answers null and keeps the old summary.
- The pill asks only for agents that are not closed and reuses the answer until the agent's model or status changes; the open popover asks again on the same changes.
- The quota popover lists the session's OMP logins (get_logout_accounts, or the stored session pin for a bundled omp agent), marks the one in use IN USE, a provider's only stored credential ONLY LOGIN, and offers Switch, which sends `/session pin OAuth credential #<id>`.
- Logins link to recorded usage server-side by OMP's identity rule within the agent's own store.
- The composer pill shows the in-use account's usage; dividers separate accounts and redundant notices are gone.
…ion account review gaps

- Switch is disabled while the agent is running or initializing: Paseo interrupts a running turn on send, and OMP does not pin while it streams. Its accessible name uses the login label and its hit area grows by 8px.
- Two logins sharing a usage account keep IN USE on the one in use.
- The pill falls back to the provider peak when the account in use has no usage value, and its tooltip then says all accounts.
- Tests cover Paseo's agent lookup through the registered RPC; a comment names the two parts of OMP's identity rules the matcher leaves out.
- README lists what reaches the client and the limit of the Copilot single-login link.
…an unlinked login in use

- Drop the rule that linked a provider's single identity-less login to its single usage account: one login and one usage key do not prove ownership, so a replaced Copilot login no longer inherits its predecessor's usage.
- A login OMP names in use, or the provider's only one, that no usage row matches is named at the top of its provider with IN USE or ONLY LOGIN and no limits, for every provider alike.
- Switch's hit slop brings its touch target to 44px; test fixtures drop token- and host-shaped values.
…s login in use

- OMP's get_logout_accounts decides `active` by identity, so a pinned Copilot login reads as not in use in a live OMP Plugin session; the popover keeps OMP's answer.
@taemire
taemire requested a review from omercnet as a code owner November 16, 2026 14:47
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6ab88b28-8a66-4e90-8cc9-94dcebd4aba7
Commits

Reviewing files that changed from the base of the PR and between 5e26f04 and 837aa01.

Files selected for processing: 25

  • paseo-omp/README.md
  • paseo-omp/client/omp-accounts-section.tsx
  • paseo-omp/client/quota-popover.tsx
  • paseo-omp/client/quota-state.ts
  • paseo-omp/index.client.tsx
  • paseo-omp/index.server.ts
  • paseo-omp/server/omp-accounts.ts
  • paseo-omp/server/provider/omp-rpc-protocol.ts
  • paseo-omp/server/provider/omp-rpc.ts
  • paseo-omp/server/provider/session.ts
  • paseo-omp/server/quota.ts
  • paseo-omp/server/subagents.ts
  • paseo-omp/shared/account-tags.ts
  • paseo-omp/shared/omp-accounts.ts
  • paseo-omp/shared/quota.ts
  • paseo-omp/tests/helpers/provider-harness.ts
  • paseo-omp/tests/omp-accounts-state.test.ts
  • paseo-omp/tests/omp-accounts.test.ts
  • paseo-omp/tests/omp-state.test.ts
  • paseo-omp/tests/omp-store-client.test.ts
  • paseo-omp/tests/profile-pills.test.ts
  • paseo-omp/tests/provider-subagent-control.test.ts
  • paseo-omp/tests/quota-popover-session-provider.test.tsx
  • paseo-omp/tests/quota-popover.test.tsx
  • paseo-omp/tests/quota-state.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@baz-reviewer

baz-reviewer Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Review this PR on Baz

Baz Summary

Show which OMP login an agent session uses, scope quota summaries to that account, and let users switch credentials through /session pin. Extend runtime RPCs, server-side identity matching, profile-aware store resolution, account metadata, and quota UI presentation while preserving credential privacy and handling opaque or closed sessions.

Topics

TopicDetails
Metadata and contracts Read cached usage metadata to attach plan and organization information to quota and account records, normalize personal and business labels, and document profile scoping, identity matching, security boundaries, and user-visible quota behavior.
Modified files (1)
  • paseo-omp/README.md
Latest Contributors(0)
UserCommitDate
Account-aware quota UI Display the active account first, distinguish IN USE and ONLY LOGIN, provide guarded Switch actions, and update quota pills, tooltips, reset countdowns, dividers, provider badges, and opaque-model fallback behavior.
Modified files (6)
  • paseo-omp/client/omp-accounts-section.tsx
  • paseo-omp/client/quota-popover.tsx
  • paseo-omp/client/quota-state.ts
  • paseo-omp/server/omp-accounts.ts
  • paseo-omp/shared/account-tags.ts
  • paseo-omp/shared/omp-accounts.ts
Latest Contributors(0)
UserCommitDate
Session account resolution Resolve active session logins through live OMP runtime data or persisted session pins, match them to hashed usage accounts using OMP identity rules, scope reads to the agent’s store, and expose safe RPCs for provider detection and account switching.
Modified files (8)
  • paseo-omp/index.client.tsx
  • paseo-omp/index.server.ts
  • paseo-omp/server/provider/omp-rpc-protocol.ts
  • paseo-omp/server/provider/omp-rpc.ts
  • paseo-omp/server/provider/session.ts
  • paseo-omp/server/quota.ts
  • paseo-omp/server/subagents.ts
  • paseo-omp/shared/quota.ts
Latest Contributors(0)
UserCommitDate
Comprehensive verification Verify runtime protocol support, identity matching, profile isolation, provider lookup, quota fallback, account ordering, switching behavior, accessibility states, and UI rendering across unit, integration, and harness tests.
Modified files (10)
  • paseo-omp/tests/helpers/provider-harness.ts
  • paseo-omp/tests/omp-accounts-state.test.ts
  • paseo-omp/tests/omp-accounts.test.ts
  • paseo-omp/tests/omp-state.test.ts
  • paseo-omp/tests/omp-store-client.test.ts
  • paseo-omp/tests/profile-pills.test.ts
  • paseo-omp/tests/provider-subagent-control.test.ts
  • paseo-omp/tests/quota-popover-session-provider.test.tsx
  • paseo-omp/tests/quota-popover.test.tsx
  • paseo-omp/tests/quota-state.test.ts
Latest Contributors(0)
UserCommitDate


Merger  Activate to get a short verdict whether this PR is good to go or not

Skills  Activate Skill Maintainer to keep your skills up to date

Planner  This PR would have been improved with Baz Planner - Try it now

Comment on lines +833 to +837
/** A fresh HOME, so the daemon default store is `<home>/.omp/agent` and profiles sit beside it. */
async function home(): Promise<string> {
const root = await mkdtemp(join(tmpdir(), "paseo-omp-session-accounts-"));
quotaRoots.push(root);
for (const name of LOCATION_ENV) vi.stubEnv(name, undefined);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Env isolation placed in helper, not beforeEach

A future test can use the runner’s inherited ambient location settings if it skips home(), since cleanup happens only there; add a beforeEach that stubs PASEO_OMP_AGENT_DIR, OMP_AGENT_DIR, PI_CODING_AGENT_DIR, OMP_PROFILE, PI_PROFILE, PI_CONFIG_DIR, and XDG_DATA_HOME to undefined.

Severity guidelines

Want Baz to fix this for you? Activate Fixer You can also update your AI coding guidelines based on this comment by apply pr to [branch name]

Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
paseo-omp/tests/quota-state.test.ts around lines 833-837, the `session account` tests
clear OMP/Paseo location environment variables only inside the `home()` helper, leaving
tests that do not call it exposed to the runner environment. Add a `beforeEach` for the
describe block that stubs every variable in `LOCATION_ENV` to `undefined`, and remove
the duplicated cleanup loop from `home()` while retaining its temporary HOME setup.

Comment on lines +535 to +537
const inUse = await accountInUse(agentId, entry.quotaProvider);
const current = pills.get(agentId);
if (disposed || current !== entry || current.quota !== handle) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale account lookup overwrites quota pill

After /session pin switches to another login for the same provider, an in-flight quota lookup for the old login can still update the unchanged pill, showing stale percentage and severity until the next 30-second refresh; include the pinned login or a request generation in the completion check before applying the result.

Severity

Want Baz to fix this for you? Activate Fixer

Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
paseo-omp/index.client.tsx around lines 535-537, update the `refreshQuotaStatus` account
lookup and pill update logic so a `/session pin` change cannot apply a stale
`accountInUse` result. Capture a session/request generation or account identity before
awaiting `accountInUse`, then re-check it after the await along with the existing
`PillEntry` and quota-handle checks, discarding the result if the agent’s active login
has changed. Keep the change scoped to the quota refresh flow and ensure the generation
is advanced whenever the session pin state changes.

Comment thread paseo-omp/server/quota.ts
Comment on lines +114 to +115
const matches = reports
.filter((report) => report.provider === provider && report.key.endsWith(`:${accountKey}`))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quota accounts inherit tags from collisions

A quota can inherit the wrong plan or organization because endsWith lets composite account keys collide; extract the full account_key from the cache key and compare it for exact equality instead.

Severity

Want Baz to fix this for you? Activate Fixer

Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
`paseo-omp/server/quota.ts` around lines 109-115, the `accountTags` function incorrectly
uses `report.key.endsWith(...)`, allowing composite account keys to collide and inherit
another account’s tags. Refactor the cache-key matching to extract the encoded
account_key according to the cache-key format and compare it exactly to `accountKey`,
while still checking the provider. Add or update coverage for overlapping keys such as
`|email:x` versus `x`.

Comment thread paseo-omp/server/quota.ts
Comment on lines +394 to +398
const oauth = logins.filter((login) => login.type === "oauth");
const keys = quotaAccountKeysFor(
databasePath,
input.provider,
oauth.map((login) => login.credentialId),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Drops sole API-key login from session accounts

Providers whose only stored credential is an API key never show the ONLY LOGIN row because resolveListOmpSessionAccounts keeps only OAuth rows and onlyLogin requires oauth.length === 1; include API-key credentials so this matches the stored-credential query, schema, and PR description.

Severity

Want Baz to fix this for you? Activate Fixer

Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
`paseo-omp/server/quota.ts` around lines 394-410, update `resolveListOmpSessionAccounts`
so API-key rows from `sessionLogins` are not filtered out of the returned `accounts`.
Keep `quotaAccountKeysFor` limited to OAuth credentials, but compute `onlyLogin` from
all stored credentials and map API-key rows with an empty quota-account list, preserving
their label, type, and active state so a sole API key is shown as ONLY LOGIN.

Comment thread paseo-omp/server/quota.ts
return sessionId ? storedSessionLogins(databasePath, input.provider, sessionId) : [];
}
try {
return await controls.listProviderAccounts(input.provider);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Session-accounts RPC accepts unrelated provider input

resolveListOmpSessionAccounts can expose another provider’s OAuth login identifiers, organization, credential IDs, and active status because it accepts any schema-valid provider; validate the provider against controls.modelProvider() on the live path and the verified stored provider before forwarding or querying.

Severity

Want Baz to fix this for you? Activate Fixer

Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
`paseo-omp/server/quota.ts` around lines 430-430, the `sessionLogins` logic trusts
`input.provider` when calling `listProviderAccounts` or querying stored credentials,
even though the output must describe the session's current model provider. Refactor
`resolveListOmpSessionAccounts`/`sessionLogins` to verify the provider first—use the
live controls' `modelProvider()` on the live path and the agent's verified provider on
the stored path—and reject or return no accounts when they differ. Ensure the
unverified caller-supplied provider is never forwarded to OMP or used in database
queries.

@omercnet omercnet left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

thanks @taemire, the Switch gate and the identity-only linking look right. i had the own commits (4bee23f, a2c9427, 0060ea5, 837aa01) reviewed against the SDK and the OMP source. the Paseo SDK has five statuses (initializing, idle, running, error, closed) and a permission wait stays running, so the gate at client/quota-popover.tsx:251-258 covers it. send() has no queue or reject option (only steer and interrupt, and interrupt is the default), so leave activeTurnBehavior out. the linking matches OMP's own rule and i found no wrong IN USE or wrong Switch target. nothing blocks this once 632 and 633 are in.

one small ask: the status can go stale between render and click, so in switchTo (quota-popover.tsx:82-94) re-read it right before sending, for example const live = paseo.agents.ref(agentId).current()?.status and return when it is running or initializing, and assert in the test that send gets no second argument.

smaller, none block: add get_logout_accounts to OMP_RPC_DIAGNOSTIC_COMMANDS (server/provider/omp-rpc-protocol.ts:636-658) so a failure carries its command. README.md:38 should say that live IN USE needs OMP 18.7.0 or newer (older OMP lacks get_logout_accounts and the popover then says it could not read the account) and that the label can also carry a project id or enterprise url. server/quota.ts:223 checks the usage side for the org-only shortcut where OMP's limitMatchesActiveAccount checks the login side, so an org-only login may not link, a comment or a fix would do. the pill now makes one list-session-accounts call per pilled OMP agent every 30 s (index.client.tsx:531-551), each reloading OMP's credential store, so consider caching per store. the provider regex at shared/quota.ts:71 rejects ids with an underscore, which only costs the IN USE mark. baz's thread at tests/quota-state.test.ts:837 is valid but hygiene, the other four are not defects, please resolve all five with a line each since main needs them resolved.

once 632 and 633 are squash-merged, git rebase --onto origin/main 12c773a should drop their commits cleanly. i can push the status re-read on top if you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants