Repository navigation
Conversation
f689b0a to
9fbac35
Compare
|
Rebased onto current |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change adds Codex account-scoped terminal launches for CLI and renderer flows. It validates provider account references, runtime lanes, WSL distributions, and runtime capabilities. Codex session attribution is persisted and included in usage aggregation and filtering. PTY-scoped model discovery now resolves account-specific environments and dynamic Codex model options. Shared IPC, preload, runtime, transport, state, and localization contracts carry the new account data. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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. Comment |
0c68ddf to
cf13262
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts (1)
63-71: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftKeep persisted-option validation in the requested discovery scope.
Line 63 scans model lists from every PTY for the agent. After
pty-acompletes discovery, a launch forpty-bcan reject its valid account-specific model because it is absent frompty-a's list.Pass
hostKeyandptyIdinto this resolver, then inspect only that scope. If no result exists for that scope, retain the persisted values. The new tests already establish that Codex model lists differ by PTY/account.src/renderer/src/store/slices/usage-provider-slices.ts (1)
168-204: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winGuard against out-of-order snapshot applies.
setCodexUsageAccountFiltersets the filter and then awaitsfetchCodexUsage. If the user changes the account filter again before the first run finishes, twofetchUsageruns overlap. Each run appliesupdate(refreshedSnapshot)andmapSnapshotExtrasunconditionally, so the run that resolves last wins. The last run is not necessarily the run for the newest filter.The Stats pane then shows usage for a filter the user already replaced, and nothing re-fetches until the next user action.
Track a per-provider request generation and drop applies from a superseded run.
♻️ Proposed guard
return (set, get) => { + let requestGeneration = 0 const update = (patch: Partial<UsageData<T>>): void => set(createUsagePatch(config.prefix, patch)) const read = (): UsageData<T> => readUsageData<T>(get(), config.prefix) const fetchUsage = async (opts?: { forceRefresh?: boolean }): Promise<void> => { + const generation = ++requestGeneration + const isStale = (): boolean => generation !== requestGeneration try {await api.refresh({ force: opts?.forceRefresh ?? false }) const refreshedSelection = read() const refreshedSnapshot = await api.getSnapshot({ scope: refreshedSelection.scope, range: refreshedSelection.range, limit: 10, ...config.getExtraSnapshotArgs?.(get()) }) + if (isStale()) { + return + } update(refreshedSnapshot)
🧹 Nitpick comments (5)
src/renderer/src/components/terminal-pane/pty-transport.test.ts (1)
117-133: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winStrengthen the test to match its stated claim.
The test name states that the transport forwards the account reference "without exposing a credential path." The assertion only checks with
objectContaining, which does not fail if extra fields are present. Add a negative assertion, for example checking that the spawn payload contains only the expected keys or that no home/credential-path field is present. Otherwise, a future change that adds a resolved credential path to the spawn payload would pass this test undetected.src/main/ipc/pty.test.ts (1)
2182-2215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the agent-mismatch rejection.
These two tests cover the malformed-shape and SSH-runtime rejections. The third guard in
registerPtyHandlersremains untested:pty.tsthrowsagent_session_account_agent_mismatchwhenargs.launchAgent !== 'codex'orproviderAccountRef.provider !== 'codex'. That guard prevents a Codex account reference from scoping a non-Codex launch.♻️ Proposed additional test
+ it('rejects a Codex account reference for a non-Codex launch agent', async () => { + registerPtyHandlers(mainWindow as never) + + await expect( + handlers.get('pty:spawn')!(null, { + cols: 80, + rows: 24, + command: 'claude', + launchAgent: 'claude', + providerAccountRef: { provider: 'codex', accountId: 'account-a', runtime: 'host' } + }) + ).rejects.toThrow('agent_session_account_agent_mismatch') + expect(spawnMock).not.toHaveBeenCalled() + })src/main/ipc/pty.ts (1)
5952-5968: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReplace the throwing ternary with a plain guard.
The nested ternary with an immediately invoked throwing arrow function obscures a simple validation gate. A guard statement gives the same narrowing with less indirection.
♻️ Proposed simplification
- const providerAccountRef = - args.providerAccountRef === undefined - ? undefined - : isProviderAccountRef(args.providerAccountRef) - ? args.providerAccountRef - : (() => { - throw new Error('Invalid provider account reference') - })() + if (args.providerAccountRef !== undefined && !isProviderAccountRef(args.providerAccountRef)) { + throw new Error('Invalid provider account reference') + } + const providerAccountRef = args.providerAccountRef if ( providerAccountRef && (args.launchAgent !== 'codex' || providerAccountRef.provider !== 'codex') ) {src/renderer/src/store/slices/usage-provider-slices.ts (2)
56-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffConsider typing the extra snapshot arguments.
accountFilter?: unknownandgetExtraSnapshotArgs?: (state) => Record<string, unknown>erase the shape of the request extension.getExtraSnapshotArgsresults are spread into thegetSnapshotpayload at Line 173 and Line 199, so a misspelled key compiles and silently sends no filter.This file already imports
CodexUsageAccountFilter. Consider adding an extra-args type parameter toUsageProviderConfigandUsageApiso the provider config and the preload signature stay aligned.Also applies to: 88-89
233-239: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the fabricated snapshot with a dedicated reset hook.
This code builds an object that holds only
accountOptionsand casts it toT['snapshot']. The cast is unsound, becauseT['snapshot']also requiresscanState,summary,daily, and the breakdown fields.The current Codex mapper reads only
snapshot.accountOptions, so nothing fails today. If a futuremapSnapshotExtrasreads any other snapshot field, this call dereferencesundefinedand the cast hides the defect from the type checker.Add an explicit reset hook to
UsageProviderConfigand call it here.♻️ Proposed change
getExtraSnapshotArgs?: (state: AppState) => Record<string, unknown> mapSnapshotExtras?: (snapshot: T['snapshot']) => Partial<AppState> + resetSnapshotExtras?: () => Partial<AppState> }- if (config.mapSnapshotExtras) { - set({ - ...config.mapSnapshotExtras({ - accountOptions: [] - } as T['snapshot']) - }) - } + if (config.resetSnapshotExtras) { + set(config.resetSnapshotExtras()) + }mapSnapshotExtras: (snapshot) => ({ codexUsageAccountOptions: snapshot.accountOptions ?? [] - }) + }), + resetSnapshotExtras: () => ({ codexUsageAccountOptions: [] }) })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9dab9197-8bcd-495d-bbf8-439f4c877c79
📥 Commits
Reviewing files that changed from the base of the PR and between 400321e and 0c68ddf76f0f44602f61872c87704634ede97561.
📒 Files selected for processing (92)
src/cli/handlers/account.test.tssrc/cli/handlers/account.tssrc/cli/handlers/terminal.test.tssrc/cli/handlers/terminal.tssrc/cli/help.tssrc/cli/specs/core.tssrc/main/agent-hooks/server.test.tssrc/main/agent-hooks/server.tssrc/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex-usage/codex-usage-provider.tssrc/main/codex-usage/scanner-paths.test.tssrc/main/codex-usage/scanner.tssrc/main/codex-usage/store-snapshot.benchmark.test.tssrc/main/codex-usage/store.test.tssrc/main/codex-usage/store.tssrc/main/codex-usage/types.tssrc/main/codex/codex-session-account-attribution.test.tssrc/main/codex/codex-session-account-attribution.tssrc/main/codex/codex-session-account-registry.test.tssrc/main/codex/codex-session-account-registry.tssrc/main/index.tssrc/main/ipc/filesystem.test.tssrc/main/ipc/filesystem.tssrc/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/ipc/usage-provider-handlers.test.tssrc/main/ipc/usage-provider-handlers.tssrc/main/runtime/orca-runtime-agent-session-operation.test.tssrc/main/runtime/orca-runtime-git.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/agent-session.test.tssrc/main/runtime/rpc/methods/agent-session.tssrc/main/runtime/rpc/methods/git-params.tssrc/main/runtime/rpc/methods/git.test.tssrc/main/runtime/rpc/methods/git.tssrc/main/text-generation/commit-message-agent-environment.test.tssrc/main/text-generation/commit-message-agent-environment.tssrc/main/usage/usage-event-aggregation.tssrc/main/usage/usage-provider-contract.tssrc/main/usage/usage-rollup-merge.tssrc/main/usage/usage-rollup-records.tssrc/preload/api-types.tssrc/preload/index.tssrc/preload/usage-provider-api.tssrc/renderer/src/components/native-chat/native-chat-session-option-discovery.tssrc/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.tssrc/renderer/src/components/native-chat/native-chat-session-option-enrichment.tssrc/renderer/src/components/native-chat/use-native-chat-session-options.tssrc/renderer/src/components/stats/CodexUsagePane.tsxsrc/renderer/src/components/stats/codex-usage-account-filter.test.tssrc/renderer/src/components/stats/codex-usage-account-filter.tssrc/renderer/src/components/tab-bar/CodexLaunchAccountMenu.test.tsxsrc/renderer/src/components/tab-bar/CodexLaunchAccountMenu.tsxsrc/renderer/src/components/tab-bar/QuickLaunchButton.test.tssrc/renderer/src/components/tab-bar/QuickLaunchButton.tsxsrc/renderer/src/components/tab-bar/codex-launch-account-options.test.tssrc/renderer/src/components/tab-bar/codex-launch-account-options.tssrc/renderer/src/components/terminal-pane/pty-connection-types.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/pty-transport.test.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/launch-agent-in-new-tab.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-agent-web-host-tab.tssrc/renderer/src/lib/runtime-agent-background-create.tssrc/renderer/src/runtime/remote-agent-session-launch.test.tssrc/renderer/src/runtime/remote-agent-session-launch.tssrc/renderer/src/runtime/runtime-git-client.test.tssrc/renderer/src/runtime/runtime-git-client.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/usage-provider-slices.tssrc/renderer/src/store/slices/usage-snapshot-refresh.benchmark.test.tssrc/shared/agent-session-host-authority.tssrc/shared/agent-session-option-catalog-claude-codex.tssrc/shared/agent-session-option-catalog.test.tssrc/shared/agent-session-option-catalog.tssrc/shared/codex-model-list-probe.test.tssrc/shared/codex-model-list-probe.tssrc/shared/codex-usage-account-filter-contract.test.tssrc/shared/codex-usage-account-filter-contract.tssrc/shared/codex-usage-types.tssrc/shared/commit-message-agent-spec.tssrc/shared/protocol-version.tssrc/shared/provider-account-ref.test.tssrc/shared/provider-account-ref.tssrc/shared/types.ts
| if (request.providerAccountRef) { | ||
| if (request.agent !== 'codex' || request.providerAccountRef.provider !== 'codex') { | ||
| throw new Error('agent_session_account_agent_mismatch') | ||
| } | ||
| if (workspace.connectionId) { | ||
| throw new Error('agent_session_account_runtime_mismatch') | ||
| } | ||
| const wsl = parseWslUncPath(workspace.path) | ||
| if ((request.providerAccountRef.runtime === 'wsl') !== Boolean(wsl)) { | ||
| throw new Error('agent_session_account_runtime_mismatch') | ||
| } | ||
| if ( | ||
| wsl && | ||
| request.providerAccountRef.wslDistro?.trim() && | ||
| request.providerAccountRef.wslDistro.trim().toLocaleLowerCase('en-US') !== | ||
| wsl.distro.toLocaleLowerCase('en-US') | ||
| ) { | ||
| throw new Error('agent_session_account_runtime_mismatch') | ||
| } | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Extract the duplicated provider-account/workspace validation into one helper.
ensureAgentSession (Line 25462-25481) and createAgentSession (Line 25641-25662) implement identical checks: agent/provider mismatch, SSH-workspace rejection, WSL runtime parity, and WSL distro parity, each throwing the same four error codes. This duplicates security-relevant account-isolation logic across two entry points. A future fix or new check applied to one copy can silently miss the other.
Extract a private method, for example assertProviderAccountRefMatchesWorkspace(providerAccountRef, agent, workspace), and call it from both sites. This also gives a single place to close the related gap: any other caller of createTerminal that sets providerAccountRef directly (bypassing ensureAgentSession/createAgentSession) currently skips this validation entirely, since createTerminal itself does not call it.
♻️ Proposed extraction
+ private assertProviderAccountRefMatchesWorkspace(
+ providerAccountRef: ProviderAccountRef | undefined,
+ agent: TuiAgent,
+ workspace: TerminalWorkspaceLaunchScope
+ ): void {
+ if (!providerAccountRef) {
+ return
+ }
+ if (agent !== 'codex' || providerAccountRef.provider !== 'codex') {
+ throw new Error('agent_session_account_agent_mismatch')
+ }
+ if (workspace.connectionId) {
+ throw new Error('agent_session_account_runtime_mismatch')
+ }
+ const wsl = parseWslUncPath(workspace.path)
+ if ((providerAccountRef.runtime === 'wsl') !== Boolean(wsl)) {
+ throw new Error('agent_session_account_runtime_mismatch')
+ }
+ if (
+ wsl &&
+ providerAccountRef.wslDistro?.trim() &&
+ providerAccountRef.wslDistro.trim().toLocaleLowerCase('en-US') !==
+ wsl.distro.toLocaleLowerCase('en-US')
+ ) {
+ throw new Error('agent_session_account_runtime_mismatch')
+ }
+ }Then replace both inline blocks with:
- if (request.providerAccountRef) {
- if (request.agent !== 'codex' || request.providerAccountRef.provider !== 'codex') {
- throw new Error('agent_session_account_agent_mismatch')
- }
- if (workspace.connectionId) {
- throw new Error('agent_session_account_runtime_mismatch')
- }
- const wsl = parseWslUncPath(workspace.path)
- if ((request.providerAccountRef.runtime === 'wsl') !== Boolean(wsl)) {
- throw new Error('agent_session_account_runtime_mismatch')
- }
- if (
- wsl &&
- request.providerAccountRef.wslDistro?.trim() &&
- request.providerAccountRef.wslDistro.trim().toLocaleLowerCase('en-US') !==
- wsl.distro.toLocaleLowerCase('en-US')
- ) {
- throw new Error('agent_session_account_runtime_mismatch')
- }
- }
+ this.assertProviderAccountRefMatchesWorkspace(request.providerAccountRef, request.agent, workspace)Also applies to: 25641-25662
There was a problem hiding this comment.
Addressed on this stack: ensureAgentSession and createAgentSession both call assertProviderAccountRefForWorkspace in src/main/runtime/provider-account-workspace-scope.ts.
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline src/main/runtime/provider-account-workspace-scope.ts --items all --view expanded
ast-grep outline src/main/runtime/orca-runtime.ts --match 'ensureAgentSession|createAgentSession' --view expanded
printf '\n--- helper references ---\n'
rg -n -C 5 '\bassertProviderAccountRefForWorkspace\s*\(' \
src/main/runtime/provider-account-workspace-scope.ts \
src/main/runtime/orca-runtime.tsLength of output: 1026
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- candidate helper files ---'
fd -i 'provider.*account.*workspace.*scope' . || true
printf '%s\n' '--- helper definitions and call sites ---'
rg -n -C 6 '\bassertProviderAccountRefForWorkspace\s*\(' . || true
printf '%s\n' '--- ensure/create agent-session definitions ---'
rg -n -P -C 8 '\b(ensureAgentSession|createAgentSession)\s*\(' src/main/runtime/orca-runtime.ts || true
printf '%s\n' '--- inline provider-account validation in the runtime service ---'
rg -n -C 5 'agent_session_account_(agent_mismatch|runtime_mismatch)' src/main/runtime/orca-runtime.ts || trueLength of output: 5143
@rp0927, verification is inconclusive for the stated stack change. The checked-out revision has no provider-account-workspace-scope.ts file and no assertProviderAccountRefForWorkspace reference. It still contains two inline validation blocks in ensureAgentSession and createAgentSession.
Please update this PR revision or provide the commit that contains the extraction. The finding remains open.
You are interacting with an AI system.
There was a problem hiding this comment.
The extraction is on a later stack commit, not on this PR's head. assertProviderAccountRefForWorkspace lives in src/main/runtime/provider-account-workspace-scope.ts from 5615a1999, and both ensureAgentSession and createAgentSession call it on tip 82763dc2f (#13276). This PR's branch stops before that commit.
There was a problem hiding this comment.
@rp0927, thanks for the clarification.
The extraction is outside #13273. The duplication remains in this PR revision, so this thread cannot be marked addressed here. Commit 5615a1999 and #13276 track the extraction on the later stack tip.
You are interacting with an AI system.
7422fa0 to
899d6ab
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/tab-bar/CodexLaunchAccountMenu.tsx (1)
135-135: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse renderer typography tokens.
Replace
text-[12px]andtext-[10px]with typography tokens fromsrc/renderer/src/assets/main.css.As per coding guidelines: “use tokens from
src/renderer/src/assets/main.css” and “do not invent documented colors, font sizes, or shadow tiers.”Also applies to: 196-196
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 02469244-c4a4-4875-8513-974856932948
📥 Commits
Reviewing files that changed from the base of the PR and between cb42b60 and 899d6ab75dbc920089f44d69fc1e79383bdf64cd.
📒 Files selected for processing (94)
src/cli/handlers/account.test.tssrc/cli/handlers/account.tssrc/cli/handlers/terminal.test.tssrc/cli/handlers/terminal.tssrc/cli/help.tssrc/cli/specs/core.tssrc/main/agent-hooks/server.test.tssrc/main/agent-hooks/server.tssrc/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex-usage/codex-usage-provider.tssrc/main/codex-usage/scanner-paths.test.tssrc/main/codex-usage/scanner.tssrc/main/codex-usage/store-snapshot.benchmark.test.tssrc/main/codex-usage/store.test.tssrc/main/codex-usage/store.tssrc/main/codex-usage/types.tssrc/main/codex/codex-session-account-attribution.test.tssrc/main/codex/codex-session-account-attribution.tssrc/main/codex/codex-session-account-registry.test.tssrc/main/codex/codex-session-account-registry.tssrc/main/index.tssrc/main/ipc/filesystem.test.tssrc/main/ipc/filesystem.tssrc/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/ipc/usage-provider-handlers.test.tssrc/main/ipc/usage-provider-handlers.tssrc/main/runtime/orca-runtime-agent-session-operation.test.tssrc/main/runtime/orca-runtime-git.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/agent-session.test.tssrc/main/runtime/rpc/methods/agent-session.tssrc/main/runtime/rpc/methods/git-params.tssrc/main/runtime/rpc/methods/git.test.tssrc/main/runtime/rpc/methods/git.tssrc/main/text-generation/commit-message-agent-environment.test.tssrc/main/text-generation/commit-message-agent-environment.tssrc/main/usage/usage-event-aggregation.tssrc/main/usage/usage-provider-contract.tssrc/main/usage/usage-rollup-merge.tssrc/main/usage/usage-rollup-records.tssrc/preload/api/agent-usage-api.tssrc/preload/api/git-inspection-api.tssrc/preload/api/pty-api.tssrc/preload/index.tssrc/preload/usage-provider-api.tssrc/renderer/src/components/native-chat/native-chat-session-option-discovery.tssrc/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.tssrc/renderer/src/components/native-chat/native-chat-session-option-enrichment.tssrc/renderer/src/components/native-chat/use-native-chat-session-options.tssrc/renderer/src/components/stats/CodexUsagePane.tsxsrc/renderer/src/components/stats/codex-usage-account-filter.test.tssrc/renderer/src/components/stats/codex-usage-account-filter.tssrc/renderer/src/components/tab-bar/CodexLaunchAccountMenu.test.tsxsrc/renderer/src/components/tab-bar/CodexLaunchAccountMenu.tsxsrc/renderer/src/components/tab-bar/QuickLaunchButton.test.tssrc/renderer/src/components/tab-bar/QuickLaunchButton.tsxsrc/renderer/src/components/tab-bar/codex-launch-account-options.test.tssrc/renderer/src/components/tab-bar/codex-launch-account-options.tssrc/renderer/src/components/terminal-pane/pty-connection-types.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/pty-transport.test.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/launch-agent-in-new-tab.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-agent-web-host-tab.tssrc/renderer/src/lib/runtime-agent-background-create.tssrc/renderer/src/runtime/remote-agent-session-launch.test.tssrc/renderer/src/runtime/remote-agent-session-launch.tssrc/renderer/src/runtime/runtime-git-client.test.tssrc/renderer/src/runtime/runtime-git-client.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/usage-provider-slices.tssrc/renderer/src/store/slices/usage-snapshot-refresh.benchmark.test.tssrc/shared/agent-session-host-authority.tssrc/shared/agent-session-option-catalog-claude-codex.tssrc/shared/agent-session-option-catalog.test.tssrc/shared/agent-session-option-catalog.tssrc/shared/codex-model-list-probe.test.tssrc/shared/codex-model-list-probe.tssrc/shared/codex-usage-account-filter-contract.test.tssrc/shared/codex-usage-account-filter-contract.tssrc/shared/codex-usage-types.tssrc/shared/commit-message-agent-spec.tssrc/shared/protocol-version.tssrc/shared/provider-account-ref.test.tssrc/shared/provider-account-ref.tssrc/shared/worktree/launch-types.ts
🚧 Files skipped from review as they are similar to previous changes (87)
- src/renderer/src/components/terminal-pane/pty-transport.ts
- src/main/codex/codex-session-account-attribution.test.ts
- src/main/ipc/filesystem.ts
- src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts
- src/main/agent-hooks/server.ts
- src/renderer/src/components/terminal-pane/pty-transport.test.ts
- src/renderer/src/components/terminal-pane/pty-connection-types.ts
- src/main/runtime/orca-runtime-agent-session-operation.test.ts
- src/main/runtime/rpc/methods/agent-session.test.ts
- src/main/codex-usage/store-snapshot.benchmark.test.ts
- src/shared/provider-account-ref.test.ts
- src/cli/help.ts
- src/cli/handlers/account.test.ts
- src/cli/specs/core.ts
- src/shared/codex-model-list-probe.test.ts
- src/main/codex/codex-session-account-registry.test.ts
- src/renderer/src/lib/launch-agent-in-new-tab.test.ts
- src/shared/codex-usage-account-filter-contract.test.ts
- src/shared/codex-usage-account-filter-contract.ts
- src/main/codex-usage/scanner.ts
- src/renderer/src/store/slices/usage-snapshot-refresh.benchmark.test.ts
- src/renderer/src/components/stats/codex-usage-account-filter.ts
- src/main/codex-usage/codex-usage-provider.ts
- src/main/codex-usage/types.ts
- src/main/codex/codex-session-account-attribution.ts
- src/main/usage/usage-provider-contract.ts
- src/shared/protocol-version.ts
- src/renderer/src/runtime/remote-agent-session-launch.ts
- src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
- src/main/codex/codex-session-account-registry.ts
- src/main/runtime/rpc/methods/git-params.ts
- src/main/runtime/rpc/methods/agent-session.ts
- src/renderer/src/runtime/runtime-git-client.test.ts
- src/preload/index.ts
- src/renderer/src/store/slices/terminals.ts
- src/main/ipc/usage-provider-handlers.test.ts
- src/main/codex-usage/store.test.ts
- src/main/agent-hooks/server.test.ts
- src/renderer/src/components/tab-bar/QuickLaunchButton.test.ts
- src/cli/handlers/terminal.test.ts
- src/shared/codex-model-list-probe.ts
- src/main/ipc/filesystem.test.ts
- src/renderer/src/runtime/remote-agent-session-launch.test.ts
- src/shared/agent-session-option-catalog.test.ts
- src/renderer/src/components/tab-bar/CodexLaunchAccountMenu.test.tsx
- src/shared/agent-session-option-catalog.ts
- src/main/runtime/rpc/methods/git.ts
- src/renderer/src/components/terminal-pane/pty-transport-types.ts
- src/main/usage/usage-rollup-merge.ts
- src/shared/codex-usage-types.ts
- src/shared/commit-message-agent-spec.ts
- src/main/usage/usage-event-aggregation.ts
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/components/terminal-pane/pty-connection.ts
- src/main/runtime/orca-runtime-git.ts
- src/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.ts
- src/main/text-generation/commit-message-agent-environment.test.ts
- src/main/codex-usage/scanner-paths.test.ts
- src/main/ipc/usage-provider-handlers.ts
- src/renderer/src/lib/launch-agent-web-host-tab.ts
- src/main/codex-accounts/runtime-home-service.test.ts
- src/main/text-generation/commit-message-agent-environment.ts
- src/renderer/src/lib/runtime-agent-background-create.ts
- src/renderer/src/components/tab-bar/codex-launch-account-options.ts
- src/shared/agent-session-host-authority.ts
- src/renderer/src/components/tab-bar/codex-launch-account-options.test.ts
- src/renderer/src/lib/launch-agent-in-new-tab.ts
- src/renderer/src/runtime/web-runtime-session.ts
- src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
- src/preload/usage-provider-api.ts
- src/main/codex-usage/store.ts
- src/cli/handlers/terminal.ts
- src/main/runtime/orca-runtime.ts
- src/main/codex-accounts/runtime-home-service.ts
- src/renderer/src/components/stats/CodexUsagePane.tsx
- src/renderer/src/runtime/runtime-git-client.ts
- src/shared/provider-account-ref.ts
- src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
- src/main/usage/usage-rollup-records.ts
- src/main/index.ts
- src/renderer/src/components/stats/codex-usage-account-filter.test.ts
- src/main/ipc/pty.test.ts
- src/renderer/src/store/slices/usage-provider-slices.ts
- src/main/runtime/rpc/methods/git.test.ts
- src/renderer/src/components/native-chat/use-native-chat-session-options.ts
- src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts
- src/main/ipc/pty.ts
955b58c to
c9fdc96
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
c9fdc96 to
eea9a71
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: aafd7c52-b85c-4d88-aa0e-dfc14ab472b4
📥 Commits
Reviewing files that changed from the base of the PR and between 5b7f442 and eea9a710844b8a1dd963b845580b1462855a6e53.
📒 Files selected for processing (87)
src/cli/handlers/account.test.tssrc/cli/handlers/account.tssrc/cli/handlers/terminal.test.tssrc/cli/handlers/terminal.tssrc/cli/help.tssrc/cli/specs/core.tssrc/main/agent-hooks/server.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex-usage/codex-usage-provider.tssrc/main/codex-usage/scanner-paths.test.tssrc/main/codex-usage/scanner.tssrc/main/codex-usage/store-snapshot.benchmark.test.tssrc/main/codex-usage/store.tssrc/main/codex-usage/types.tssrc/main/codex/codex-session-account-attribution.test.tssrc/main/codex/codex-session-account-attribution.tssrc/main/codex/codex-session-account-registry.test.tssrc/main/codex/codex-session-account-registry.tssrc/main/index.tssrc/main/ipc/filesystem.tssrc/main/ipc/pty.tssrc/main/ipc/usage-provider-handlers.test.tssrc/main/ipc/usage-provider-handlers.tssrc/main/runtime/orca-runtime-agent-session-operation.test.tssrc/main/runtime/orca-runtime-git.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/agent-session.test.tssrc/main/runtime/rpc/methods/agent-session.tssrc/main/runtime/rpc/methods/git-params.tssrc/main/runtime/rpc/methods/git.test.tssrc/main/runtime/rpc/methods/git.tssrc/main/text-generation/commit-message-agent-environment.test.tssrc/main/text-generation/commit-message-agent-environment.tssrc/main/usage/usage-event-aggregation.tssrc/main/usage/usage-provider-contract.tssrc/main/usage/usage-rollup-merge.tssrc/main/usage/usage-rollup-records.tssrc/preload/api/agent-usage-api.tssrc/preload/api/git-inspection-api.tssrc/preload/api/pty-api.tssrc/preload/index.tssrc/preload/usage-provider-api.tssrc/renderer/src/components/native-chat/native-chat-session-option-discovery.tssrc/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.tssrc/renderer/src/components/native-chat/native-chat-session-option-enrichment.tssrc/renderer/src/components/native-chat/use-native-chat-session-options.tssrc/renderer/src/components/stats/CodexUsagePane.tsxsrc/renderer/src/components/stats/codex-usage-account-filter.test.tssrc/renderer/src/components/stats/codex-usage-account-filter.tssrc/renderer/src/components/tab-bar/CodexLaunchAccountMenu.test.tsxsrc/renderer/src/components/tab-bar/CodexLaunchAccountMenu.tsxsrc/renderer/src/components/tab-bar/QuickLaunchButton.test.tssrc/renderer/src/components/tab-bar/QuickLaunchButton.tsxsrc/renderer/src/components/tab-bar/codex-launch-account-options.test.tssrc/renderer/src/components/tab-bar/codex-launch-account-options.tssrc/renderer/src/components/terminal-pane/pty-connection-types.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/launch-agent-in-new-tab.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-agent-web-host-tab.tssrc/renderer/src/lib/runtime-agent-background-create.tssrc/renderer/src/runtime/remote-agent-session-launch.test.tssrc/renderer/src/runtime/remote-agent-session-launch.tssrc/renderer/src/runtime/runtime-git-client.test.tssrc/renderer/src/runtime/runtime-git-client.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/usage-provider-slices.tssrc/renderer/src/store/slices/usage-snapshot-refresh.benchmark.test.tssrc/shared/agent-session-host-authority.tssrc/shared/agent-session-option-catalog-claude-codex.tssrc/shared/agent-session-option-catalog.test.tssrc/shared/agent-session-option-catalog.tssrc/shared/codex-model-list-probe.test.tssrc/shared/codex-model-list-probe.tssrc/shared/codex-usage-account-filter-contract.test.tssrc/shared/codex-usage-account-filter-contract.tssrc/shared/codex-usage-types.tssrc/shared/commit-message-agent-spec.tssrc/shared/protocol-version.tssrc/shared/provider-account-ref.test.tssrc/shared/provider-account-ref.tssrc/shared/worktree/launch-types.ts
🚧 Files skipped from review as they are similar to previous changes (84)
- src/renderer/src/store/slices/usage-snapshot-refresh.benchmark.test.ts
- src/main/codex-usage/store-snapshot.benchmark.test.ts
- src/main/runtime/rpc/methods/git.test.ts
- src/renderer/src/runtime/remote-agent-session-launch.test.ts
- src/renderer/src/components/tab-bar/QuickLaunchButton.test.ts
- src/cli/help.ts
- src/main/runtime/orca-runtime-agent-session-operation.test.ts
- src/renderer/src/components/stats/codex-usage-account-filter.test.ts
- src/main/codex/codex-session-account-attribution.test.ts
- src/main/usage/usage-event-aggregation.ts
- src/shared/agent-session-option-catalog.ts
- src/shared/codex-usage-account-filter-contract.ts
- src/preload/usage-provider-api.ts
- src/shared/codex-usage-account-filter-contract.test.ts
- src/main/codex-usage/codex-usage-provider.ts
- src/shared/codex-model-list-probe.test.ts
- src/shared/codex-usage-types.ts
- src/preload/api/agent-usage-api.ts
- src/main/runtime/rpc/methods/git-params.ts
- src/main/agent-hooks/server.ts
- src/main/codex-usage/scanner.ts
- src/renderer/src/runtime/runtime-git-client.ts
- src/shared/provider-account-ref.test.ts
- src/main/ipc/usage-provider-handlers.test.ts
- src/main/runtime/rpc/methods/agent-session.ts
- src/main/codex-usage/types.ts
- src/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.ts
- src/main/runtime/orca-runtime-git.ts
- src/preload/api/git-inspection-api.ts
- src/renderer/src/runtime/runtime-git-client.test.ts
- src/renderer/src/lib/launch-agent-in-new-tab.test.ts
- src/shared/agent-session-option-catalog-claude-codex.ts
- src/main/runtime/rpc/methods/git.ts
- src/shared/provider-account-ref.ts
- src/renderer/src/components/terminal-pane/pty-transport.ts
- src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
- src/main/codex-usage/scanner-paths.test.ts
- src/main/usage/usage-provider-contract.ts
- src/renderer/src/components/terminal-pane/pty-connection-types.ts
- src/renderer/src/components/stats/CodexUsagePane.tsx
- src/renderer/src/lib/launch-agent-in-new-tab.ts
- src/renderer/src/runtime/remote-agent-session-launch.ts
- src/shared/worktree/launch-types.ts
- src/shared/agent-session-option-catalog.test.ts
- src/cli/specs/core.ts
- src/main/codex/codex-session-account-registry.test.ts
- src/main/codex/codex-session-account-attribution.ts
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/lib/launch-agent-web-host-tab.ts
- src/shared/protocol-version.ts
- src/preload/api/pty-api.ts
- src/renderer/src/components/tab-bar/codex-launch-account-options.test.ts
- src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
- src/renderer/src/components/native-chat/use-native-chat-session-options.ts
- src/renderer/src/components/tab-bar/CodexLaunchAccountMenu.test.tsx
- src/shared/codex-model-list-probe.ts
- src/main/text-generation/commit-message-agent-environment.test.ts
- src/main/runtime/rpc/methods/agent-session.test.ts
- src/main/codex/codex-session-account-registry.ts
- src/cli/handlers/account.test.ts
- src/shared/commit-message-agent-spec.ts
- src/renderer/src/components/stats/codex-usage-account-filter.ts
- src/renderer/src/components/tab-bar/codex-launch-account-options.ts
- src/main/usage/usage-rollup-merge.ts
- src/renderer/src/store/slices/usage-provider-slices.ts
- src/cli/handlers/terminal.ts
- src/main/runtime/orca-runtime.ts
- src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
- src/main/codex-usage/store.ts
- src/preload/index.ts
- src/main/ipc/usage-provider-handlers.ts
- src/main/index.ts
- src/main/text-generation/commit-message-agent-environment.ts
- src/main/ipc/filesystem.ts
- src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts
- src/renderer/src/store/slices/terminals.ts
- src/renderer/src/lib/runtime-agent-background-create.ts
- src/shared/agent-session-host-authority.ts
- src/renderer/src/components/terminal-pane/pty-transport-types.ts
- src/renderer/src/runtime/web-runtime-session.ts
- src/cli/handlers/terminal.test.ts
- src/renderer/src/components/terminal-pane/pty-connection.ts
- src/main/usage/usage-rollup-records.ts
- src/main/ipc/pty.ts
9ab76d5 to
4050575
Compare
|
Restacked onto current The stack was also restructured so each PR is green on its own head — previously every follow-up fix landed on the tip (#13276), which meant ancestor heads failed This head was verified standalone: Added here: |
launch-agent-in-new-tab.test.ts grew past the 800-line budget once the account-scoped cases landed; move those cases to their own file. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KvdKNvkWoiVSxqbw7DKmgm
main dropped the shared/types barrel, so the CLI terminal handler and the launch account options resolved neither import. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KvdKNvkWoiVSxqbw7DKmgm
`unknown` for accountFilter broke parameter contravariance against each provider store, and the slice file passed its max-lines budget once the account-scoped state landed; split the factory out. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KvdKNvkWoiVSxqbw7DKmgm
4050575 to
90ba2a3
Compare
Summary
Codex usage events and rollups can now retain an optional launch-account attribution. The scanner combines managed-home roots with bounded session-launch evidence, keeps same-day usage from different accounts in separate rollups, and preserves cached attribution after transient launch evidence expires.
The Stats pane adds account filtering for managed, system, unattributed, and removed accounts. Older persisted usage caches that predate account attribution are rejected and rebuilt instead of being interpreted under the new schema.
This PR is stacked on #13272, #13271, #13270, and #13183. Please review it after those PRs land; their changes will disappear from this diff as the stack advances.
Screenshots
Not attached yet because this is a dependency-gated draft. Before marking it ready, I will capture the Codex Stats account filter against the rebased branch.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildFocused validation:
pnpm run build:desktop— passed.git diff --check— passed.Local environment note: the repository requests Node 24, while this workstation currently exposes Node 25.8.1. The desktop build completed; its development CLI install step reported the expected permission warning for
/usr/local/bin/orca-devwithout failing the build.AI Review Report
The review traced account attribution from live Codex launches and managed-home scan roots into usage events, persisted snapshots, aggregate rollups, IPC filters, renderer state, and Stats display. It checked legacy schema invalidation, same-day account separation, deleted-account labels, and loss of transient launch evidence.
Regression tests cover managed/system attribution, first-evidence retention, malformed persisted registry rows, rescanning after late attribution, cached attribution retention, separate account rollups, owned-root boundaries, old-schema invalidation, combined workspace/account filters, and removed account options.
Cross-platform review:
Security Audit
Notes
@rp0927