-
Notifications
You must be signed in to change notification settings - Fork 0
fix(settings): report external Codex ownership #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
f700c56
0fe44e4
6321d1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import type { OcxConfig } from "../types"; | ||
| import { shouldSyncCodexOnStart } from "./desired-state"; | ||
| import { tomlString } from "./paths"; | ||
| import { | ||
| isEffectiveCodexClientCompaction, | ||
| isEffectiveCodexDesktopAuthless, | ||
|
|
@@ -11,14 +12,15 @@ export type CodexDesktopSwitchInertReason = | |
|
|
||
| export interface CodexDesktopSwitchState { | ||
| stored: boolean; | ||
| effective: boolean; | ||
| effective: boolean | null; | ||
| inertReason?: CodexDesktopSwitchInertReason; | ||
| } | ||
|
|
||
| export type CodexDesktopSwitchApplyReason = | ||
| | "not_requested" | ||
| | "proxy_not_running" | ||
| | "integration_disabled" | ||
| | "external_provider" | ||
| | "write_lock_busy" | ||
| | "injection_refused"; | ||
|
|
||
|
|
@@ -35,7 +37,7 @@ export interface CodexDesktopSwitchReport { | |
| codexDesktopAuthless: CodexDesktopSwitchState; | ||
| codexClientCompaction: CodexDesktopSwitchState; | ||
| apply: CodexDesktopSwitchApply; | ||
| authSource: { presentsCodexAccount: boolean; summary: string }; | ||
| authSource: { presentsCodexAccount: boolean | null; summary: string }; | ||
| } | ||
|
|
||
| type DesktopSwitchConfig = Pick< | ||
|
|
@@ -50,9 +52,10 @@ type DesktopSwitchConfig = Pick< | |
|
|
||
| function describeSwitch( | ||
| stored: boolean, | ||
| effective: boolean, | ||
| effective: boolean | null, | ||
| config: Pick<OcxConfig, "runtimeRole">, | ||
| ): CodexDesktopSwitchState { | ||
| if (effective === null) return { stored, effective }; | ||
| if (!stored || effective) return { stored, effective }; | ||
| return { | ||
| stored, | ||
|
|
@@ -68,15 +71,21 @@ export function describeCodexDesktopSwitches( | |
| apply: CodexDesktopSwitchApply, | ||
| ): CodexDesktopSwitchReport { | ||
| const authlessStored = config.codexDesktopAuthless === true; | ||
| const authlessEffective = isEffectiveCodexDesktopAuthless(config); | ||
| const externallyOwned = !apply.applied && apply.reason === "external_provider"; | ||
| const authlessEffective = externallyOwned ? null : isEffectiveCodexDesktopAuthless(config); | ||
| const compactionStored = config.codexClientCompaction === true; | ||
| const compactionEffective = isEffectiveCodexClientCompaction(config); | ||
| const compactionEffective = externallyOwned ? null : isEffectiveCodexClientCompaction(config); | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
|
||
|
|
||
| return { | ||
| codexDesktopAuthless: describeSwitch(authlessStored, authlessEffective, config), | ||
| codexClientCompaction: describeSwitch(compactionStored, compactionEffective, config), | ||
| apply, | ||
| authSource: authlessEffective | ||
| authSource: externallyOwned | ||
| ? { | ||
| presentsCodexAccount: null, | ||
| summary: "An external model provider owns Codex sign-in behavior; its account requirement was not changed.", | ||
| } | ||
| : authlessEffective | ||
| ? { | ||
| presentsCodexAccount: false, | ||
| summary: "The Codex app will not require its own account sign-in.", | ||
|
|
@@ -88,6 +97,26 @@ export function describeCodexDesktopSwitches( | |
| }; | ||
| } | ||
|
|
||
| /** | ||
| * The apply record for a report that attempted no rewrite. `not_requested` alone would have | ||
| * the report claiming OpenCodex's stored-versus-effective state as live, so the read path | ||
| * consults the same ownership predicate the injector does and reports external ownership | ||
| * instead — a settings GET and a switch-free PUT then agree with an attempted apply. | ||
| */ | ||
| export async function observedCodexDesktopSwitchApply(): Promise<CodexDesktopSwitchApply> { | ||
| // Same lazy boundary as applyCodexDesktopSwitches: the ownership predicate lives in the | ||
| // injection graph, which the settings read path must not pull in at module scope. | ||
| const { currentExternalCodexModelProvider } = await import("./inject/config-toml"); | ||
| const provider = currentExternalCodexModelProvider(); | ||
|
Comment on lines
+109
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Unreadable Codex configuration breaks all settings requests When Learn moreThis new read runs outside the error handling used by Example: An external provider manager temporarily replaces Recommended fix: Catch import/read failures inside Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| if (!provider) return { applied: false, reason: "not_requested", retryable: false }; | ||
| return { | ||
| applied: false, | ||
| reason: "external_provider", | ||
| retryable: false, | ||
| detail: `config.toml selects the external model_provider ${tomlString(provider)}.`, | ||
| }; | ||
| } | ||
|
|
||
| export async function applyCodexDesktopSwitches( | ||
| config: OcxConfig, | ||
| ): Promise<CodexDesktopSwitchApply> { | ||
|
|
@@ -115,6 +144,14 @@ export async function applyCodexDesktopSwitches( | |
| detail: result.message, | ||
| }; | ||
| } | ||
| if (result.success && result.configApplied === false) { | ||
| return { | ||
| applied: false, | ||
| reason: "external_provider", | ||
| retryable: false, | ||
| detail: result.message, | ||
| }; | ||
| } | ||
| if (result.success) { | ||
| // history_paginated_requires_native_writer stands down only the legacy relabel; | ||
| // apply still writes the routing and catalog half for paginated Codex homes. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.