Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(codex): connect ChatGPT accounts with managed authentication #14290

Mergedjuliusmarmingemerged 7 commits intomain fromrefs/pull/14290/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Users can connect their ChatGPT plan directly in T3 Code without managing a Codex CLI login. Each account has its own provider instance, so personal and work accounts stay separate in onboarding, settings, and the model picker.

Sign-in runs through OpenAI OAuth. For remote environments, the primary environment completes sign-in and transfers the credentials to the selected environment. T3 handles reconnecting, changing accounts, disconnecting, token refresh, and managed Codex installation. Existing CLI providers remain available.

The first successful connection explains ChatGPT plan usage. Provider settings, the model picker, and Usage link to ChatGPT usage management. Account emails are redacted by default. PostHog records anonymous connection and turn outcomes, account counts, and distinct cancellation versus expiration outcomes.

Validation: focused OAuth, callback, remote handoff, installation, runtime, model catalog, usage, and onboarding tests; server/web typechecks; Apple Silicon DMG tested by the maintainer. OpenAI Responses feature restrictions still apply.

Model: quasar-alpha. Harness: Codex in T3 Code.


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. @@ -0,0 +31,21 @@
      31+ const settings = yield* ServerSettingsService;
      32+ const runtime = yield* makeCodexManagedRuntime({
      33+ instanceId,
      34+ enabled,
      35+ config,
      36+ environment: mergeProviderInstanceEnvironment(input.environment),
      37+ });
      38+ const continuationIdentity = codexContinuationIdentity(runtime.homeLayout);
      39+ const stamp = withInstanceIdentity({
      40+ instanceId,
      41+ driverKind: DRIVER,
      42+ displayName,
      43+ accentColor,
      44+ continuationGroupKey: continuationIdentity.continuationKey,
      45+ });
      46+ const setup = { canAuthenticate: true, canInstall: true };
      47+ const runtimePaths = {
      48+ homePath: runtime.homeLayout.sharedHomePath,
      49+ shadowHomePath: runtime.homeLayout.mode === "authOverlay" ? runtime.homePath : null,
      50+ };
      51+ const pending = makePendingCodexProvider({ ...config, customModels: [] }).pipe(
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Drivers/CodexManagedProvider.ts:51

      A disabled managed instance still produces an enabled, pending provider snapshot when input.enabled is false but config.enabled remains true. pending receives only config, so the !enabled branch returns a base built with the stale config status; pass the instance-level enabled value when constructing the pending provider.

      Suggested change
      51- const pending = makePendingCodexProvider({ ...config, customModels: [] }).pipe(
      51+ const pending = makePendingCodexProvider({ ...config, enabled, customModels: [] }).pipe(
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/server/src/provider/Drivers/CodexManagedProvider.ts around line 51:
      
      A disabled managed instance still produces an enabled, pending provider snapshot when `input.enabled` is `false` but `config.enabled` remains `true`. `pending` receives only `config`, so the `!enabled` branch returns a `base` built with the stale config status; pass the instance-level `enabled` value when constructing the pending provider.
      @@ -19,3 +24,7 @@
      1924 function WelcomeRouteView() {
      2025 const { authGateState } = Route.useRouteContext();
      2126 const navigate = useNavigate();
      27+ const hash = useLocation({ select: (location) => location.hash });
      28+ const resumeEnvironmentId = hash.startsWith("agents:")
      29+ ? Option.getOrUndefined(decodeEnvironmentId(hash.slice("agents:".length)))
      30+ : undefined;
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium routes/welcome.tsx:28

      The wizard never resumes remote-one for /welcome#agents:remote-one; it starts at the normal connection step instead. useLocation(...).hash includes the leading #, so startsWith("agents:") is always false for this return URL. Strip the # before checking or include it in the prefix.

      Suggested change
      28- const resumeEnvironmentId = hash.startsWith("agents:")
      29- ? Option.getOrUndefined(decodeEnvironmentId(hash.slice("agents:".length)))
      30- : undefined;
      28+ const resumeEnvironmentId = hash.startsWith("#agents:")
      29+ ? Option.getOrUndefined(decodeEnvironmentId(hash.slice("#agents:".length)))
      30+ : undefined;
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/web/src/routes/welcome.tsx around lines 28-30:
      
      The wizard never resumes `remote-one` for `/welcome#agents:remote-one`; it starts at the normal connection step instead. `useLocation(...).hash` includes the leading `#`, so `startsWith("agents:")` is always false for this return URL. Strip the `#` before checking or include it in the prefix.
      @@ -0,0 +637,21 @@
      637+ }
      638+ return yield* SubscriptionRef.get(state);
      639+ }),
      640+ );
      641+ });
      642+
      643+ const remove = Effect.fn("CodexInstallation.remove")(
      644+ function* (protectedBinaryPaths: ReadonlyArray<string> = []) {
      645+ yield* gate.withPermit(
      646+ Effect.gen(function* () {
      647+ if (isRunning(yield* SubscriptionRef.get(state)) || leases > 0) {
      648+ return yield* installationError(
      649+ "remove",
      650+ "Stop Codex sessions and sign-in flows before removing its managed runtime.",
      651+ );
      652+ }
      653+ const realManaged = yield* fs.realPath(managedDirectory).pipe(Effect.option);
      654+ if (Option.isSome(realManaged)) {
      655+ for (const binary of protectedBinaryPaths) {
      656+ const resolved = yield* fs.realPath(binary).pipe(Effect.option);
      657+ const candidate = Option.getOrElse(resolved, () => path.resolve(binary));
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium provider/CodexInstallation.ts:657

      remove deletes a managed Codex executable referenced by a provider configured with a home-relative path such as ~/.t3/tools/codex/0.156.1/bin/codex, leaving that provider broken instead of returning the protection error. The launch path expands binaryPath, but this check passes the unexpanded value to realPath and path.resolve, so it does not match the managed-directory prefix; expand the path before resolving it here.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/server/src/provider/CodexInstallation.ts around line 657:
      
      `remove` deletes a managed Codex executable referenced by a provider configured with a home-relative path such as `~/.t3/tools/codex/0.156.1/bin/codex`, leaving that provider broken instead of returning the protection error. The launch path expands `binaryPath`, but this check passes the unexpanded value to `realPath` and `path.resolve`, so it does not match the managed-directory prefix; expand the path before resolving it here.
      @@ -0,0 +885,21 @@
      885+ );
      886+ }
      887+
      888+ return (
      889+ <section aria-label="Codex setup" className="divide-y divide-border/50">
      890+ {accountPicker}
      891+ <SettingsRow
      892+ title="ChatGPT account"
      893+ description={accountDescription}
      894+ control={
      895+ <div className="flex flex-wrap items-center justify-end gap-2">
      896+ {authActive ? (
      897+ <>
      898+ {waitingControl}
      899+ {!finishingSignIn && (
      900+ <Button
      901+ size="sm"
      902+ variant="ghost"
      903+ disabled={pending || readOnly}
      904+ onClick={() => {
      905+ if (!handoff && !auth?.flowId) return;
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium settings/CodexSetupSection.tsx:905

      Clicking Cancel while run(startInstall) is still pending does not stop the managed installation because installation.operationId is not available yet, so both handlers skip cancelInstall. In the settings path, continueWithSignIn.current also remains set, allowing sign-in to start after cancellation. Track the pending start request and cancel it or defer cancellation until its operationId is available, while clearing continueWithSignIn.current in both paths.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/web/src/components/settings/CodexSetupSection.tsx around line 905:
      
      Clicking Cancel while `run(startInstall)` is still pending does not stop the managed installation because `installation.operationId` is not available yet, so both handlers skip `cancelInstall`. In the settings path, `continueWithSignIn.current` also remains set, allowing sign-in to start after cancellation. Track the pending start request and cancel it or defer cancellation until its `operationId` is available, while clearing `continueWithSignIn.current` in both paths.
      @@ -53,3 +53,21 @@
      5353 if (search.machine) next.machine = search.machine;
      5454 return next;
      5555 }
      56+
      57+/** Provider configuration always belongs to one environment, including project scopes. */
      58+export function selectSingleEnvironmentScope(
      59+ search: SettingsScopeSearch,
      60+ scope: ResolvedSettingsScope,
      61+ environments: readonly {
      62+ readonly environmentId: EnvironmentPresentation["environmentId"];
      63+ readonly connection: Pick<EnvironmentPresentation["connection"], "phase">;
      64+ }[],
      65+ primaryEnvironmentId: string | null,
      66+): SettingsScopeSearch {
      67+ if (search.machine || scope.kind === "unavailable") return search;
      68+ const selectedIds = new Set(scope.environmentIds);
      69+ const candidates = environments.filter((environment) =>
      70+ selectedIds.has(environment.environmentId),
      71+ );
      72+ const selected =
      73+ candidates.find((environment) => environment.environmentId === primaryEnvironmentId) ??
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium settings/settingsScopeAxis.ts:73

      When no machine is specified, an offline primaryEnvironmentId is selected even if another candidate is connected, so the provider-settings route targets an unusable environment instead of the available connected one. The primary lookup must require connection.phase === "connected" before falling back to another connected candidate; explicit offline selections remain preserved by the early return.

      -    candidates.find((environment) => environment.environmentId === primaryEnvironmentId) ??
      +    candidates.find(
      +      (environment) =>
      +        environment.environmentId === primaryEnvironmentId &&
      +        environment.connection.phase === "connected",
      +    ) ??
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/web/src/components/settings/settingsScopeAxis.ts around line 73:
      
      When no `machine` is specified, an offline `primaryEnvironmentId` is selected even if another candidate is connected, so the provider-settings route targets an unusable environment instead of the available connected one. The primary lookup must require `connection.phase === "connected"` before falling back to another connected candidate; explicit offline selections remain preserved by the early return.
      @@ -139,0 +170,21 @@
      170+ };
      171+ const resumeProviderAuth = (value: string | undefined) => {
      172+ const destination = providerAuthReturnUrl(value);
      173+ const expectedOrigin = `${ElectronProtocol.getDesktopScheme(environment.isDevelopment)}://app`;
      174+ if (!destination?.startsWith(`${expectedOrigin}/`)) return false;
      175+ void runPromise(
      176+ Effect.gen(function* () {
      177+ const mainWindow = yield* electronWindow.currentMainOrFirst;
      178+ if (Option.isNone(mainWindow)) return;
      179+ yield* Effect.promise(() => mainWindow.value.loadURL(destination));
      180+ yield* electronWindow.reveal(mainWindow.value);
      181+ }).pipe(
      182+ Effect.catchCause((cause) =>
      183+ Effect.logWarning("Could not return to provider setup", cause),
      184+ ),
      185+ ),
      186+ );
      187+ return true;
      188+ };
      189+ const args = yield* HostProcessArguments;
      190+ args.some((value) => startProviderAuthHandoff(value));
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High app/DesktopClerk.ts:190

      A cold-launched t3code://app/settings/providers?... callback never resumes provider setup: HostProcessArguments only invokes startProviderAuthHandoff, so providerAuthReturnUrl is not loaded and no window is revealed until the app is already running. Apply the same resumeProviderAuth handling used by second-instance when processing startup arguments.

      Suggested change
      190- args.some((value) => startProviderAuthHandoff(value));
      190+ args.some((value) => startProviderAuthHandoff(value) || resumeProviderAuth(value));
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/desktop/src/app/DesktopClerk.ts around line 190:
      
      A cold-launched `t3code://app/settings/providers?...` callback never resumes provider setup: `HostProcessArguments` only invokes `startProviderAuthHandoff`, so `providerAuthReturnUrl` is not loaded and no window is revealed until the app is already running. Apply the same `resumeProviderAuth` handling used by `second-instance` when processing startup arguments.
      @@ -2508,3 +2510,4 @@
      25082510 providerAuth.complete(input, currentSessionId),
      25092511 { "rpc.aggregate": "provider" },
      25102512 ),
      2513+ [WS_METHODS.chatGptReconnectProfile]: (input) => providerAuth.reconnectProfile(input),
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🔴 Critical src/ws.ts:2513

      These three handlers bypass authorization, so an unscoped session can reconnect or import ChatGPT credentials and start the OAuth handoff despite AuthOrchestrationOperateScope being required. They return the provider effects/stream directly instead of using observeRpcEffect and observeRpcStream, which are the paths that invoke authorizeEffect/authorizeStream.

      Also found in 1 other location(s)

      apps/server/src/auth/RpcAuthorization.ts:40

      The new scope entries do not actually protect chatGptReconnectProfile, chatGptImportProfile, or chatGptHandoffSubscribe: their WsRpcGroup handlers return providerAuth.reconnectProfile, providerAuth.importProfile, and subscribeChatGptHandoff directly rather than passing them through observeRpcEffect/observeRpcStream. Consequently requiredScopeForRpcMethod is never consulted for these methods, so a session without AuthOrchestrationOperateScope can initiate reconnection, import credentials (overwriting provider credentials), or start the OAuth handoff despite these declarations.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/server/src/ws.ts around line 2513:
      
      These three handlers bypass authorization, so an unscoped session can reconnect or import ChatGPT credentials and start the OAuth handoff despite `AuthOrchestrationOperateScope` being required. They return the provider effects/stream directly instead of using `observeRpcEffect` and `observeRpcStream`, which are the paths that invoke `authorizeEffect`/`authorizeStream`.
      
      Also found in 1 other location(s):
      - apps/server/src/auth/RpcAuthorization.ts:40 -- The new scope entries do not actually protect `chatGptReconnectProfile`, `chatGptImportProfile`, or `chatGptHandoffSubscribe`: their `WsRpcGroup` handlers return `providerAuth.reconnectProfile`, `providerAuth.importProfile`, and `subscribeChatGptHandoff` directly rather than passing them through `observeRpcEffect`/`observeRpcStream`. Consequently `requiredScopeForRpcMethod` is never consulted for these methods, so a session without `AuthOrchestrationOperateScope` can initiate reconnection, import credentials (overwriting provider credentials), or start the OAuth handoff despite these declarations.
      
      @@ -717,12 +736,9 @@
      717- serverConfig.settings,
      718- serverConfig.environment.platform.os,
      719- )
      720- : resolveOnboardingProviderInstallCommand(
      721- driver,
      722- serverConfig.environment.platform.os,
      723- ),
      724- keybindings: serverConfig.keybindings,
      725- });
      726- }}
      727- />
      728- ))}
      736+ {primaryAgents.map(({ driver, provider, instanceId }) =>
      737+ driver === "codex" && serverConfig !== null ? (
      738+ <OnboardingCodexSetup
      739+ key={instanceId ?? driver}
      740+ environmentId={environmentId}
      741+ provider={provider}
      742+ serverConfig={serverConfig}
      743+ createdAccount={instanceId === createdAccount?.instanceId ? createdAccount : null}
      744+ onAutoStartConsumed={() =>
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium onboarding/WelcomeWizard.tsx:744

      onAutoStartConsumed clears account A's autoStart flag when any Codex row invokes it, so starting managed setup on existing account B can consume A's pending auto-start before A's provider snapshot arrives. Account A then never opens its sign-in/install flow automatically; scope the callback to the created account (for example, pass and check its instanceId).

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/web/src/components/onboarding/WelcomeWizard.tsx around line 744:
      
      `onAutoStartConsumed` clears account A's `autoStart` flag when any Codex row invokes it, so starting managed setup on existing account B can consume A's pending auto-start before A's provider snapshot arrives. Account A then never opens its sign-in/install flow automatically; scope the callback to the created account (for example, pass and check its `instanceId`).
      @@ -0,0 +489,21 @@
      489+ )
      490+ return;
      491+ setAutoStartHandled(true);
      492+ onAutoStartConsumed();
      493+ void setup();
      494+ }, [
      495+ autoStart,
      496+ autoStartHandled,
      497+ unavailable,
      498+ busy,
      499+ installation,
      500+ provider?.setup?.canInstall,
      501+ onAutoStartConsumed,
      502+ setup,
      503+ ]);
      504+
      505+ useEffect(() => {
      506+ if (!continueWithSignIn.current || pending || installActive) return;
      507+ if (installation?.phase === "failed" || installation?.phase === "cancelled") {
      508+ continueWithSignIn.current = null;
      509+ } else if (installed) {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium settings/CodexSetupSection.tsx:509

      When updating an already installed runtime, this effect starts signIn as soon as pending clears, while installed is still true and the install subscription has not yet entered an active phase. Because startInstall resolves before that subscription update, authentication can overlap replacement of the executable and bypass the required update-before-sign-in flow. Gate this continuation on the specific install operation reaching a completed state (or otherwise wait for the install-state update) instead of using the stale installed snapshot at line 509.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/web/src/components/settings/CodexSetupSection.tsx around line 509:
      
      When updating an already installed runtime, this effect starts `signIn` as soon as `pending` clears, while `installed` is still `true` and the install subscription has not yet entered an active phase. Because `startInstall` resolves before that subscription update, authentication can overlap replacement of the executable and bypass the required update-before-sign-in flow. Gate this continuation on the specific install operation reaching a completed state (or otherwise wait for the install-state update) instead of using the stale `installed` snapshot at line 509.
      @@ -0,0 +885,21 @@
      885+ );
      886+ }
      887+
      888+ return (
      889+ <section aria-label="Codex setup" className="divide-y divide-border/50">
      890+ {accountPicker}
      891+ <SettingsRow
      892+ title="ChatGPT account"
      893+ description={accountDescription}
      894+ control={
      895+ <div className="flex flex-wrap items-center justify-end gap-2">
      896+ {authActive ? (
      897+ <>
      898+ {waitingControl}
      899+ {!finishingSignIn && (
      900+ <Button
      901+ size="sm"
      902+ variant="ghost"
      903+ disabled={pending || readOnly}
      904+ onClick={() => {
      905+ if (!handoff && !auth?.flowId) return;
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium settings/CodexSetupSection.tsx:905

      Clicking the enabled Cancel button during waitingForAuthState does not cancel the accepted sign-in request, so the delayed OAuth flow continues after cancellation. At this point auth has no flowId and there is no install operation, causing both branches to be skipped; preserve a cancellation intent and apply it when the flow ID arrives, or disable Cancel until cancellation is possible. Apply the same handling to the onboarding Cancel control.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/web/src/components/settings/CodexSetupSection.tsx around line 905:
      
      Clicking the enabled `Cancel` button during `waitingForAuthState` does not cancel the accepted sign-in request, so the delayed OAuth flow continues after cancellation. At this point `auth` has no `flowId` and there is no install operation, causing both branches to be skipped; preserve a cancellation intent and apply it when the flow ID arrives, or disable Cancel until cancellation is possible. Apply the same handling to the onboarding Cancel control.
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/5105f3180e3dc7a801b2c0fb46828be2e4a6c19d/apps/server/src/textGeneration/CodexTextGeneration.ts#L223

      When resolveRuntime is present, a stale persisted serviceTier is still passed to managed Codex commands, causing them to use a disallowed or unsupported tier instead of the managed account default. Gate this config argument on !resolved, matching the chat adapter.

      ✅ Resolved in a2c28a240687d5a495ebf88f083aa25cd1686d0e

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This XXL change introduces managed ChatGPT OAuth, credential transfer and refresh, Codex runtime installation, and new cross-platform setup flows, including authentication-sensitive code and product-default changes. An unresolved critical finding also reports that credential and OAuth WebSocket operations bypass their declared authorization scope, requiring human review.

      Not approved because:

      • 10 blocking correctness issues found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. @@ -0,0 +1040,21 @@
      1040+ />
      1041+ </div>
      1042+ }
      1043+ />
      1044+ <SettingsRow
      1045+ title="CODEX_HOME path"
      1046+ description="Shared Codex config, sessions, and state."
      1047+ control={
      1048+ <div className="w-full sm:w-80">
      1049+ <Input
      1050+ aria-label="Codex home path"
      1051+ value={provider?.runtimePaths?.homePath ?? ""}
      1052+ title={provider?.runtimePaths?.homePath}
      1053+ placeholder="Unavailable"
      1054+ disabled
      1055+ />
      1056+ </div>
      1057+ }
      1058+ />
      1059+ <SettingsRow
      1060+ title="Shadow home path"
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Shared primitives: use Button from ui/button for this styled disclosure control instead of a raw <button>.

      Posted via Macroscope — UI Consistency
    5. @@ -0,0 +106,21 @@
      106+ operation: Schema.String,
      107+ detail: Schema.String,
      108+ cause: Schema.optional(Schema.Defect()),
      109+ },
      110+) {
      111+ override get message() {
      112+ return this.detail;
      113+ }
      114+}
      115+const isInstallationError = Schema.is(CodexInstallationError);
      116+const installationError = (operation: string, detail: string, cause?: unknown) =>
      117+ new CodexInstallationError({ operation, detail, ...(cause === undefined ? {} : { cause }) });
      118+const wrapFailure = (operation: string, detail: string) => (cause: unknown) =>
      119+ isInstallationError(cause) ? cause : installationError(operation, detail, cause);
      120+export interface CodexExecutable {
      121+ readonly executablePath: string;
      122+ readonly source: "managed" | "local";
      123+ readonly version: string;
      124+ readonly managedVersionDirectory: string | null;
      125+}
      126+interface CodexInstallationService {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      The new service declares a separate CodexInstallationService interface instead of inlining its shape in Context.Service. Please move the interface members into the tag's type argument and use CodexInstallation["Service"] for references to its service type. This requires changes in both the interface and tag, so there is no single-hunk suggestion.

      Posted via Macroscope — Effect Service Conventions
      @@ -0,0 +56,21 @@
      56+ const resolve = Effect.gen(function* () {
      57+ const executable = yield* installation.acquire().pipe(
      58+ Effect.mapError(
      59+ () =>
      60+ new ProviderSetupError({
      61+ instanceId: options.instanceId,
      62+ operation: "install",
      63+ detail: "Set up managed Codex before starting a session.",
      64+ }),
      65+ ),
      66+ );
      67+ const credentials = yield* auth.access;
      68+ yield* materializeCodexShadowHome(homeLayout).pipe(
      69+ Effect.provideService(FileSystem.FileSystem, fs),
      70+ Effect.provideService(Path.Path, path),
      71+ Effect.mapError(
      72+ (cause) =>
      73+ new ProviderSetupError({
      74+ instanceId: options.instanceId,
      75+ operation: "runtime",
      76+ detail: cause.message,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This new runtime error exposes cause.message directly to clients; filesystem errors can contain local paths and arbitrary OS text. Please use a fixed, safe runtime message and retain the underlying error as cause rather than copying its message into detail. This also needs a change to the error schema, so there is no single-hunk suggestion.

      Posted via Macroscope — Effect Service Conventions
      @@ -0,0 +1,17 @@
      1+import { ProviderSetupError, type CodexAuthCallbackInput } from "@t3tools/contracts";
      2+import { receiveCodexAuthCallback } from "@t3tools/shared/codexAuthCallback";
      3+import { codexAuthorizationRequest } from "@t3tools/shared/codexAuthHandoff";
      4+import { providerAuthReturnUrl } from "@t3tools/shared/providerAuthReturnUrl";
      5+import { isLoopbackHost } from "@t3tools/shared/preview";
      6+import * as Deferred from "effect/Deferred";
      7+import * as Effect from "effect/Effect";
      8+import * as Fiber from "effect/Fiber";
      9+import * as Stream from "effect/Stream";
      10+
      11+/** A connected local environment receives the callback; only the remote environment owns tokens. */
      12+export function subscribeCodexAuthCallback(input: CodexAuthCallbackInput) {
      13+ const failure = (error: unknown) =>
      14+ new ProviderSetupError({
      15+ instanceId: input.instanceId,
      16+ operation: "callback",
      17+ detail:
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This mapper copies an arbitrary underlying error message into a caller-visible ProviderSetupError.detail, potentially exposing unbounded or sensitive failure text from the callback listener. Please use a fixed, safe callback message and preserve the original error as cause in the structured error channel. The error schema and this mapper both need changes, so there is no single-hunk suggestion.

      Posted via Macroscope — Effect Service Conventions
    6. Review in Change Stack →

      Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

      ✨ Finishing Touches 💡 1
      🛠️ Fix failing CI checks 💡
      • Commit to this branch
      • Create a new PR
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    7. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.5 KiB13.5 KiB+10 B (+0.1%)15.1 KiB✅
      CodexThread snapshot wire7.1 KiB7.1 KiB+5 B (+0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.5 KiB6.5 KiB+5 B (+0.1%)7.8 KiB✅
      CodexLive turn WebSocket decoded56.3 KiB56.3 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages10100 (0.0%)21✅
      ClaudeTotal thread wire13.5 KiB13.5 KiB+10 B (+0.1%)15.1 KiB✅
      ClaudeThread snapshot wire7.1 KiB7.1 KiB+1 B (+0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.4 KiB6.4 KiB+9 B (+0.1%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.0 KiB57.0 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages990 (0.0%)21✅

      Baseline: d2c9281 · PR result: 6f14834 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 114.0 KiB
      • Claude decoded thread snapshot: 114.6 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    8. @@ -180,3 +185,7 @@
      180185 const outputPath = yield* writeTempFile(operation, "codex-output", "");
      181186
      182187 const runCodexCommand = Effect.fn("runCodexJson.runCodexCommand")(function* () {
      188+ const resolved = resolveRuntime
      189+ ? yield* resolveRuntime.pipe(
      190+ Effect.mapError(
      191+ (cause) => new TextGenerationError({ operation, detail: cause.detail }),
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      The runtime-resolution failure is wrapped without its underlying error, losing the cause chain, and cause.detail can contain raw filesystem error text. Please use a fixed, safe detail and retain the structured failure as cause.

      Suggested change
      191- (cause) => new TextGenerationError({ operation, detail: cause.detail }),
      191+ (cause) =>
      192+ new TextGenerationError({
      193+ operation,
      194+ detail: "Failed to resolve managed Codex runtime.",
      195+ cause,
      196+ }),
      Posted via Macroscope — Effect Service Conventions
    9. juliusmarminge merged this27bdf1a

    10. juliusmarminge closed this

Sign in to join this conversation.