From 304a14de7d6f0b9977c8ecc4bced5b5f359ce02e Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Mon, 9 Mar 2026 04:01:23 -0700 Subject: [PATCH 01/61] Fix users who installed intel builds on arm macs (#641) --- apps/desktop/src/main.ts | 19 ++++++- apps/desktop/src/runtimeArch.test.ts | 49 +++++++++++++++++++ apps/desktop/src/runtimeArch.ts | 40 +++++++++++++++ apps/desktop/src/updateMachine.test.ts | 18 ++++--- apps/desktop/src/updateMachine.ts | 11 +++-- apps/desktop/src/updateState.test.ts | 3 ++ apps/web/src/components/Sidebar.tsx | 34 +++++++++++++ .../components/desktopUpdate.logic.test.ts | 31 ++++++++++++ .../web/src/components/desktopUpdate.logic.ts | 19 +++++++ packages/contracts/src/ipc.ts | 11 +++++ 10 files changed, 224 insertions(+), 11 deletions(-) create mode 100644 apps/desktop/src/runtimeArch.test.ts create mode 100644 apps/desktop/src/runtimeArch.ts diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index 2abce92ba9..03cf67cd6d 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -31,6 +31,7 @@ import { reduceDesktopUpdateStateOnNoUpdate, reduceDesktopUpdateStateOnUpdateAvailable, } from "./updateMachine"; +import { isArm64HostRunningIntelBuild, resolveDesktopRuntimeInfo } from "./runtimeArch"; fixPath(); @@ -80,7 +81,13 @@ let backendLogSink: RotatingFileSink | null = null; let restoreStdIoCapture: (() => void) | null = null; let destructiveMenuIconCache: Electron.NativeImage | null | undefined; -const initialUpdateState = (): DesktopUpdateState => createInitialDesktopUpdateState(app.getVersion()); +const desktopRuntimeInfo = resolveDesktopRuntimeInfo({ + platform: process.platform, + processArch: process.arch, + runningUnderArm64Translation: app.runningUnderARM64Translation === true, +}); +const initialUpdateState = (): DesktopUpdateState => + createInitialDesktopUpdateState(app.getVersion(), desktopRuntimeInfo); function logTimestamp(): string { return new Date().toISOString(); @@ -708,6 +715,7 @@ async function downloadAvailableUpdate(): Promise<{ accepted: boolean; completed } updateDownloadInFlight = true; setUpdateState(reduceDesktopUpdateStateOnDownloadStart(updateState)); + autoUpdater.disableDifferentialDownload = isArm64HostRunningIntelBuild(desktopRuntimeInfo); console.info("[desktop-updater] Downloading update..."); try { @@ -746,7 +754,7 @@ async function installDownloadedUpdate(): Promise<{ accepted: boolean; completed function configureAutoUpdater(): void { const enabled = shouldEnableAutoUpdates(); setUpdateState({ - ...createInitialDesktopUpdateState(app.getVersion()), + ...createInitialDesktopUpdateState(app.getVersion(), desktopRuntimeInfo), enabled, status: enabled ? "idle" : "disabled", }); @@ -780,8 +788,15 @@ function configureAutoUpdater(): void { autoUpdater.channel = DESKTOP_UPDATE_CHANNEL; autoUpdater.allowPrerelease = DESKTOP_UPDATE_ALLOW_PRERELEASE; autoUpdater.allowDowngrade = false; + autoUpdater.disableDifferentialDownload = isArm64HostRunningIntelBuild(desktopRuntimeInfo); let lastLoggedDownloadMilestone = -1; + if (isArm64HostRunningIntelBuild(desktopRuntimeInfo)) { + console.info( + "[desktop-updater] Apple Silicon host detected while running Intel build; updates will switch to arm64 packages.", + ); + } + autoUpdater.on("checking-for-update", () => { console.info("[desktop-updater] Looking for updates..."); }); diff --git a/apps/desktop/src/runtimeArch.test.ts b/apps/desktop/src/runtimeArch.test.ts new file mode 100644 index 0000000000..258a8fb215 --- /dev/null +++ b/apps/desktop/src/runtimeArch.test.ts @@ -0,0 +1,49 @@ +import { describe, expect, it } from "vitest"; + +import { isArm64HostRunningIntelBuild, resolveDesktopRuntimeInfo } from "./runtimeArch"; + +describe("resolveDesktopRuntimeInfo", () => { + it("detects Rosetta-translated Intel builds on Apple Silicon", () => { + const runtimeInfo = resolveDesktopRuntimeInfo({ + platform: "darwin", + processArch: "x64", + runningUnderArm64Translation: true, + }); + + expect(runtimeInfo).toEqual({ + hostArch: "arm64", + appArch: "x64", + runningUnderArm64Translation: true, + }); + expect(isArm64HostRunningIntelBuild(runtimeInfo)).toBe(true); + }); + + it("detects native Apple Silicon builds", () => { + const runtimeInfo = resolveDesktopRuntimeInfo({ + platform: "darwin", + processArch: "arm64", + runningUnderArm64Translation: false, + }); + + expect(runtimeInfo).toEqual({ + hostArch: "arm64", + appArch: "arm64", + runningUnderArm64Translation: false, + }); + expect(isArm64HostRunningIntelBuild(runtimeInfo)).toBe(false); + }); + + it("passes through non-mac builds without translation", () => { + const runtimeInfo = resolveDesktopRuntimeInfo({ + platform: "linux", + processArch: "x64", + runningUnderArm64Translation: true, + }); + + expect(runtimeInfo).toEqual({ + hostArch: "x64", + appArch: "x64", + runningUnderArm64Translation: false, + }); + }); +}); diff --git a/apps/desktop/src/runtimeArch.ts b/apps/desktop/src/runtimeArch.ts new file mode 100644 index 0000000000..7e4265afb0 --- /dev/null +++ b/apps/desktop/src/runtimeArch.ts @@ -0,0 +1,40 @@ +import type { DesktopRuntimeArch, DesktopRuntimeInfo } from "@t3tools/contracts"; + +interface ResolveDesktopRuntimeInfoInput { + readonly platform: NodeJS.Platform; + readonly processArch: string; + readonly runningUnderArm64Translation: boolean; +} + +function normalizeDesktopArch(arch: string): DesktopRuntimeArch { + if (arch === "arm64") return "arm64"; + if (arch === "x64") return "x64"; + return "other"; +} + +export function resolveDesktopRuntimeInfo( + input: ResolveDesktopRuntimeInfoInput, +): DesktopRuntimeInfo { + const appArch = normalizeDesktopArch(input.processArch); + + if (input.platform !== "darwin") { + return { + hostArch: appArch, + appArch, + runningUnderArm64Translation: false, + }; + } + + const hostArch = + appArch === "arm64" || input.runningUnderArm64Translation ? "arm64" : appArch; + + return { + hostArch, + appArch, + runningUnderArm64Translation: input.runningUnderArm64Translation, + }; +} + +export function isArm64HostRunningIntelBuild(runtimeInfo: DesktopRuntimeInfo): boolean { + return runtimeInfo.hostArch === "arm64" && runtimeInfo.appArch === "x64"; +} diff --git a/apps/desktop/src/updateMachine.test.ts b/apps/desktop/src/updateMachine.test.ts index 045bfaf8f4..620c683b82 100644 --- a/apps/desktop/src/updateMachine.test.ts +++ b/apps/desktop/src/updateMachine.test.ts @@ -13,11 +13,17 @@ import { reduceDesktopUpdateStateOnUpdateAvailable, } from "./updateMachine"; +const runtimeInfo = { + hostArch: "x64", + appArch: "x64", + runningUnderArm64Translation: false, +} as const; + describe("updateMachine", () => { it("clears transient errors when a check starts", () => { const state = reduceDesktopUpdateStateOnCheckStart( { - ...createInitialDesktopUpdateState("1.0.0"), + ...createInitialDesktopUpdateState("1.0.0", runtimeInfo), enabled: true, status: "error", message: "network", @@ -36,7 +42,7 @@ describe("updateMachine", () => { it("records a check failure without exposing an action", () => { const state = reduceDesktopUpdateStateOnCheckFailure( { - ...createInitialDesktopUpdateState("1.0.0"), + ...createInitialDesktopUpdateState("1.0.0", runtimeInfo), enabled: true, status: "checking", }, @@ -52,7 +58,7 @@ describe("updateMachine", () => { it("preserves available version on download failure for retry", () => { const state = reduceDesktopUpdateStateOnDownloadFailure( { - ...createInitialDesktopUpdateState("1.0.0"), + ...createInitialDesktopUpdateState("1.0.0", runtimeInfo), enabled: true, status: "downloading", availableVersion: "1.1.0", @@ -70,7 +76,7 @@ describe("updateMachine", () => { it("transitions to downloaded and then preserves install retry state", () => { const downloaded = reduceDesktopUpdateStateOnDownloadComplete( { - ...createInitialDesktopUpdateState("1.0.0"), + ...createInitialDesktopUpdateState("1.0.0", runtimeInfo), enabled: true, status: "downloading", availableVersion: "1.1.0", @@ -89,7 +95,7 @@ describe("updateMachine", () => { it("clears stale download state when no update is available", () => { const state = reduceDesktopUpdateStateOnNoUpdate( { - ...createInitialDesktopUpdateState("1.0.0"), + ...createInitialDesktopUpdateState("1.0.0", runtimeInfo), enabled: true, status: "error", availableVersion: "1.1.0", @@ -111,7 +117,7 @@ describe("updateMachine", () => { it("tracks available, download start, and progress cleanly", () => { const available = reduceDesktopUpdateStateOnUpdateAvailable( { - ...createInitialDesktopUpdateState("1.0.0"), + ...createInitialDesktopUpdateState("1.0.0", runtimeInfo), enabled: true, status: "checking", }, diff --git a/apps/desktop/src/updateMachine.ts b/apps/desktop/src/updateMachine.ts index 9c4e212657..f13b420281 100644 --- a/apps/desktop/src/updateMachine.ts +++ b/apps/desktop/src/updateMachine.ts @@ -1,12 +1,18 @@ -import type { DesktopUpdateState } from "@t3tools/contracts"; +import type { DesktopRuntimeInfo, DesktopUpdateState } from "@t3tools/contracts"; import { getCanRetryAfterDownloadFailure, nextStatusAfterDownloadFailure } from "./updateState"; -export function createInitialDesktopUpdateState(currentVersion: string): DesktopUpdateState { +export function createInitialDesktopUpdateState( + currentVersion: string, + runtimeInfo: DesktopRuntimeInfo, +): DesktopUpdateState { return { enabled: false, status: "disabled", currentVersion, + hostArch: runtimeInfo.hostArch, + appArch: runtimeInfo.appArch, + runningUnderArm64Translation: runtimeInfo.runningUnderArm64Translation, availableVersion: null, downloadedVersion: null, downloadPercent: null, @@ -152,4 +158,3 @@ export function reduceDesktopUpdateStateOnInstallFailure( canRetry: true, }; } - diff --git a/apps/desktop/src/updateState.test.ts b/apps/desktop/src/updateState.test.ts index e2bc9c6257..43b718bd00 100644 --- a/apps/desktop/src/updateState.test.ts +++ b/apps/desktop/src/updateState.test.ts @@ -12,6 +12,9 @@ const baseState: DesktopUpdateState = { enabled: true, status: "idle", currentVersion: "1.0.0", + hostArch: "x64", + appArch: "x64", + runningUnderArm64Translation: false, availableVersion: null, downloadedVersion: null, downloadPercent: null, diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index ecfd526acb..894fde25e9 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -8,6 +8,7 @@ import { SettingsIcon, SquarePenIcon, TerminalIcon, + TriangleAlertIcon, } from "lucide-react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { @@ -36,14 +37,18 @@ import { type DraftThreadEnvMode, useComposerDraftStore } from "../composerDraft import { selectThreadTerminalState, useTerminalStateStore } from "../terminalStateStore"; import { toastManager } from "./ui/toast"; import { + getArm64IntelBuildWarningDescription, getDesktopUpdateActionError, getDesktopUpdateButtonTooltip, isDesktopUpdateButtonDisabled, resolveDesktopUpdateButtonAction, + shouldShowArm64IntelBuildWarning, shouldHighlightDesktopUpdateError, shouldShowDesktopUpdateButton, shouldToastDesktopUpdateActionResult, } from "./desktopUpdate.logic"; +import { Alert, AlertAction, AlertDescription, AlertTitle } from "./ui/alert"; +import { Button } from "./ui/button"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible"; import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; import { @@ -887,6 +892,12 @@ export default function Sidebar() { const desktopUpdateButtonAction = desktopUpdateState ? resolveDesktopUpdateButtonAction(desktopUpdateState) : "none"; + const showArm64IntelBuildWarning = + isElectron && shouldShowArm64IntelBuildWarning(desktopUpdateState); + const arm64IntelBuildWarningDescription = + desktopUpdateState && showArm64IntelBuildWarning + ? getArm64IntelBuildWarningDescription(desktopUpdateState) + : null; const desktopUpdateButtonInteractivityClasses = desktopUpdateButtonDisabled ? "cursor-not-allowed opacity-60" : "hover:bg-accent hover:text-foreground"; @@ -1030,6 +1041,29 @@ export default function Sidebar() { )} + {showArm64IntelBuildWarning && arm64IntelBuildWarningDescription ? ( + + + + Intel build on Apple Silicon + {arm64IntelBuildWarningDescription} + {desktopUpdateButtonAction !== "none" ? ( + + + + ) : null} + + + ) : null}
diff --git a/apps/web/src/components/desktopUpdate.logic.test.ts b/apps/web/src/components/desktopUpdate.logic.test.ts index f80c1f3e46..7fd362bf1d 100644 --- a/apps/web/src/components/desktopUpdate.logic.test.ts +++ b/apps/web/src/components/desktopUpdate.logic.test.ts @@ -2,11 +2,13 @@ import { describe, expect, it } from "vitest"; import type { DesktopUpdateActionResult, DesktopUpdateState } from "@t3tools/contracts"; import { + getArm64IntelBuildWarningDescription, getDesktopUpdateActionError, getDesktopUpdateButtonTooltip, isDesktopUpdateButtonDisabled, resolveDesktopUpdateButtonAction, shouldHighlightDesktopUpdateError, + shouldShowArm64IntelBuildWarning, shouldShowDesktopUpdateButton, shouldToastDesktopUpdateActionResult, } from "./desktopUpdate.logic"; @@ -15,6 +17,9 @@ const baseState: DesktopUpdateState = { enabled: true, status: "idle", currentVersion: "1.0.0", + hostArch: "x64", + appArch: "x64", + runningUnderArm64Translation: false, availableVersion: null, downloadedVersion: null, downloadPercent: null, @@ -171,4 +176,30 @@ describe("desktop update UI helpers", () => { }), ).toBe(false); }); + + it("shows an Apple Silicon warning for Intel builds under Rosetta", () => { + const state: DesktopUpdateState = { + ...baseState, + hostArch: "arm64", + appArch: "x64", + runningUnderArm64Translation: true, + }; + + expect(shouldShowArm64IntelBuildWarning(state)).toBe(true); + expect(getArm64IntelBuildWarningDescription(state)).toContain("Apple Silicon"); + expect(getArm64IntelBuildWarningDescription(state)).toContain("Intel build"); + }); + + it("changes the warning copy when a native build update is ready to download", () => { + const state: DesktopUpdateState = { + ...baseState, + hostArch: "arm64", + appArch: "x64", + runningUnderArm64Translation: true, + status: "available", + availableVersion: "1.1.0", + }; + + expect(getArm64IntelBuildWarningDescription(state)).toContain("Download the available update"); + }); }); diff --git a/apps/web/src/components/desktopUpdate.logic.ts b/apps/web/src/components/desktopUpdate.logic.ts index ab7b7cdc41..faf30883cc 100644 --- a/apps/web/src/components/desktopUpdate.logic.ts +++ b/apps/web/src/components/desktopUpdate.logic.ts @@ -32,10 +32,29 @@ export function shouldShowDesktopUpdateButton(state: DesktopUpdateState | null): return resolveDesktopUpdateButtonAction(state) !== "none"; } +export function shouldShowArm64IntelBuildWarning(state: DesktopUpdateState | null): boolean { + return state?.hostArch === "arm64" && state.appArch === "x64"; +} + export function isDesktopUpdateButtonDisabled(state: DesktopUpdateState | null): boolean { return state?.status === "downloading"; } +export function getArm64IntelBuildWarningDescription(state: DesktopUpdateState): string { + if (!shouldShowArm64IntelBuildWarning(state)) { + return "This install is using the correct architecture."; + } + + const action = resolveDesktopUpdateButtonAction(state); + if (action === "download") { + return "This Mac has Apple Silicon, but T3 Code is still running the Intel build under Rosetta. Download the available update to switch to the native Apple Silicon build."; + } + if (action === "install") { + return "This Mac has Apple Silicon, but T3 Code is still running the Intel build under Rosetta. Restart to install the downloaded Apple Silicon build."; + } + return "This Mac has Apple Silicon, but T3 Code is still running the Intel build under Rosetta. The next app update will replace it with the native Apple Silicon build."; +} + export function getDesktopUpdateButtonTooltip(state: DesktopUpdateState): string { if (state.status === "available") { return `Update ${state.availableVersion ?? "available"} ready to download`; diff --git a/packages/contracts/src/ipc.ts b/packages/contracts/src/ipc.ts index 92f5b502c9..db9bab415e 100644 --- a/packages/contracts/src/ipc.ts +++ b/packages/contracts/src/ipc.ts @@ -58,10 +58,21 @@ export type DesktopUpdateStatus = | "downloaded" | "error"; +export type DesktopRuntimeArch = "arm64" | "x64" | "other"; + +export interface DesktopRuntimeInfo { + hostArch: DesktopRuntimeArch; + appArch: DesktopRuntimeArch; + runningUnderArm64Translation: boolean; +} + export interface DesktopUpdateState { enabled: boolean; status: DesktopUpdateStatus; currentVersion: string; + hostArch: DesktopRuntimeArch; + appArch: DesktopRuntimeArch; + runningUnderArm64Translation: boolean; availableVersion: string | null; downloadedVersion: string | null; downloadPercent: number | null; From 4b6a0c433cb808a0ebdd30ec48e799b6543d2cc9 Mon Sep 17 00:00:00 2001 From: Sai Shankar Date: Mon, 9 Mar 2026 16:33:13 +0530 Subject: [PATCH 02/61] fix(web): fix native scrollbar being intercepted by sidebar rail on windows and linux (#618) the rail's 16px hit area at z-20 sits right where the native os scrollbar lives when the sidebar is in offcanvas mode and collapsed. this causes clicks and drags on the scrollbar to toggle the sidebar instead on windows and linux. scoping pointer-events-none to [data-collapsible=offcanvas][data-state=collapsed] fixes the interception without affecting icon mode where the rail needs to stay clickable. --- apps/web/src/components/ui/sidebar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/ui/sidebar.tsx b/apps/web/src/components/ui/sidebar.tsx index 77826aeced..ba77bddc27 100644 --- a/apps/web/src/components/ui/sidebar.tsx +++ b/apps/web/src/components/ui/sidebar.tsx @@ -566,7 +566,8 @@ function SidebarRail({
- {addingProject && ( + {shouldShowProjectPathEntry && (
{isElectron && (
{canCollapse ? (
-
diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts new file mode 100644 index 0000000000..8a5e11e1af --- /dev/null +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -0,0 +1,92 @@ +import { describe, expect, it } from "vitest"; + +import { hasUnseenCompletion, resolveThreadStatusPill } from "./Sidebar.logic"; + +function makeLatestTurn(overrides?: { + completedAt?: string | null; + startedAt?: string | null; +}): Parameters[0]["latestTurn"] { + return { + turnId: "turn-1" as never, + state: "completed", + assistantMessageId: null, + requestedAt: "2026-03-09T10:00:00.000Z", + startedAt: overrides?.startedAt ?? "2026-03-09T10:00:00.000Z", + completedAt: overrides?.completedAt ?? "2026-03-09T10:05:00.000Z", + }; +} + +describe("hasUnseenCompletion", () => { + it("returns true when a thread completed after its last visit", () => { + expect( + hasUnseenCompletion({ + latestTurn: makeLatestTurn(), + lastVisitedAt: "2026-03-09T10:04:00.000Z", + session: null, + }), + ).toBe(true); + }); +}); + +describe("resolveThreadStatusPill", () => { + const baseThread = { + latestTurn: null, + lastVisitedAt: undefined, + session: { + provider: "codex" as const, + status: "running" as const, + createdAt: "2026-03-09T10:00:00.000Z", + updatedAt: "2026-03-09T10:00:00.000Z", + orchestrationStatus: "running" as const, + }, + }; + + it("shows pending approval before all other statuses", () => { + expect( + resolveThreadStatusPill({ + thread: baseThread, + hasPendingApprovals: true, + hasPendingUserInput: true, + }), + ).toMatchObject({ label: "Pending Approval", pulse: false }); + }); + + it("shows awaiting input when plan mode is blocked on user answers", () => { + expect( + resolveThreadStatusPill({ + thread: baseThread, + hasPendingApprovals: false, + hasPendingUserInput: true, + }), + ).toMatchObject({ label: "Awaiting Input", pulse: false }); + }); + + it("falls back to working when the thread is actively running without blockers", () => { + expect( + resolveThreadStatusPill({ + thread: baseThread, + hasPendingApprovals: false, + hasPendingUserInput: false, + }), + ).toMatchObject({ label: "Working", pulse: true }); + }); + + it("shows completed when there is an unseen completion and no active blocker", () => { + expect( + resolveThreadStatusPill({ + thread: { + ...baseThread, + latestTurn: makeLatestTurn(), + lastVisitedAt: "2026-03-09T10:04:00.000Z", + session: { + ...baseThread.session, + status: "ready", + orchestrationStatus: "ready", + }, + }, + hasPendingApprovals: false, + hasPendingUserInput: false, + }), + ).toMatchObject({ label: "Completed", pulse: false }); + }); +}); diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts new file mode 100644 index 0000000000..44626cf147 --- /dev/null +++ b/apps/web/src/components/Sidebar.logic.ts @@ -0,0 +1,76 @@ +import type { Thread } from "../types"; + +export interface ThreadStatusPill { + label: "Working" | "Connecting" | "Completed" | "Pending Approval" | "Awaiting Input"; + colorClass: string; + dotClass: string; + pulse: boolean; +} + +type ThreadStatusInput = Pick; + +export function hasUnseenCompletion(thread: ThreadStatusInput): boolean { + if (!thread.latestTurn?.completedAt) return false; + const completedAt = Date.parse(thread.latestTurn.completedAt); + if (Number.isNaN(completedAt)) return false; + if (!thread.lastVisitedAt) return true; + + const lastVisitedAt = Date.parse(thread.lastVisitedAt); + if (Number.isNaN(lastVisitedAt)) return true; + return completedAt > lastVisitedAt; +} + +export function resolveThreadStatusPill(input: { + thread: ThreadStatusInput; + hasPendingApprovals: boolean; + hasPendingUserInput: boolean; +}): ThreadStatusPill | null { + const { hasPendingApprovals, hasPendingUserInput, thread } = input; + + if (hasPendingApprovals) { + return { + label: "Pending Approval", + colorClass: "text-amber-600 dark:text-amber-300/90", + dotClass: "bg-amber-500 dark:bg-amber-300/90", + pulse: false, + }; + } + + if (hasPendingUserInput) { + return { + label: "Awaiting Input", + colorClass: "text-indigo-600 dark:text-indigo-300/90", + dotClass: "bg-indigo-500 dark:bg-indigo-300/90", + pulse: false, + }; + } + + if (thread.session?.status === "running") { + return { + label: "Working", + colorClass: "text-sky-600 dark:text-sky-300/80", + dotClass: "bg-sky-500 dark:bg-sky-300/80", + pulse: true, + }; + } + + if (thread.session?.status === "connecting") { + return { + label: "Connecting", + colorClass: "text-sky-600 dark:text-sky-300/80", + dotClass: "bg-sky-500 dark:bg-sky-300/80", + pulse: true, + }; + } + + if (hasUnseenCompletion(thread)) { + return { + label: "Completed", + colorClass: "text-emerald-600 dark:text-emerald-300/90", + dotClass: "bg-emerald-500 dark:bg-emerald-300/90", + pulse: false, + }; + } + + return null; +} diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 0e700369eb..fb2ccb2fec 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -28,8 +28,7 @@ import { APP_STAGE_LABEL } from "../branding"; import { newCommandId, newProjectId, newThreadId } from "../lib/utils"; import { useStore } from "../store"; import { isChatNewLocalShortcut, isChatNewShortcut, shortcutLabelForCommand } from "../keybindings"; -import { type Thread } from "../types"; -import { derivePendingApprovals } from "../session-logic"; +import { derivePendingApprovals, derivePendingUserInputs } from "../session-logic"; import { gitRemoveWorktreeMutationOptions, gitStatusQueryOptions } from "../lib/gitReactQuery"; import { serverConfigQueryOptions } from "../lib/serverReactQuery"; import { readNativeApi } from "../nativeApi"; @@ -68,6 +67,7 @@ import { } from "./ui/sidebar"; import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "../worktreeCleanup"; import { isNonEmpty as isNonEmptyString } from "effect/String"; +import { resolveThreadStatusPill } from "./Sidebar.logic"; const EMPTY_KEYBINDINGS: ResolvedKeybindingsConfig = []; const THREAD_PREVIEW_LIMIT = 6; @@ -89,13 +89,6 @@ function formatRelativeTime(iso: string): string { return `${Math.floor(hours / 24)}d ago`; } -interface ThreadStatusPill { - label: "Working" | "Connecting" | "Completed" | "Pending Approval"; - colorClass: string; - dotClass: string; - pulse: boolean; -} - interface TerminalStatusIndicator { label: "Terminal process running"; colorClass: string; @@ -111,57 +104,6 @@ interface PrStatusIndicator { type ThreadPr = GitStatusResult["pr"]; -function hasUnseenCompletion(thread: Thread): boolean { - if (!thread.latestTurn?.completedAt) return false; - const completedAt = Date.parse(thread.latestTurn.completedAt); - if (Number.isNaN(completedAt)) return false; - if (!thread.lastVisitedAt) return true; - - const lastVisitedAt = Date.parse(thread.lastVisitedAt); - if (Number.isNaN(lastVisitedAt)) return true; - return completedAt > lastVisitedAt; -} - -function threadStatusPill(thread: Thread, hasPendingApprovals: boolean): ThreadStatusPill | null { - if (hasPendingApprovals) { - return { - label: "Pending Approval", - colorClass: "text-amber-600 dark:text-amber-300/90", - dotClass: "bg-amber-500 dark:bg-amber-300/90", - pulse: false, - }; - } - - if (thread.session?.status === "running") { - return { - label: "Working", - colorClass: "text-sky-600 dark:text-sky-300/80", - dotClass: "bg-sky-500 dark:bg-sky-300/80", - pulse: true, - }; - } - - if (thread.session?.status === "connecting") { - return { - label: "Connecting", - colorClass: "text-sky-600 dark:text-sky-300/80", - dotClass: "bg-sky-500 dark:bg-sky-300/80", - pulse: true, - }; - } - - if (hasUnseenCompletion(thread)) { - return { - label: "Completed", - colorClass: "text-emerald-600 dark:text-emerald-300/90", - dotClass: "bg-emerald-500 dark:bg-emerald-300/90", - pulse: false, - }; - } - - return null; -} - function terminalStatusFromRunningIds( runningTerminalIds: string[], ): TerminalStatusIndicator | null { @@ -321,6 +263,13 @@ export default function Sidebar() { } return map; }, [threads]); + const pendingUserInputByThreadId = useMemo(() => { + const map = new Map(); + for (const thread of threads) { + map.set(thread.id, derivePendingUserInputs(thread.activities).length > 0); + } + return map; + }, [threads]); const projectCwdById = useMemo( () => new Map(projects.map((project) => [project.id, project.cwd] as const)), [projects], @@ -1268,10 +1217,11 @@ export default function Sidebar() { {visibleThreads.map((thread) => { const isActive = routeThreadId === thread.id; - const threadStatus = threadStatusPill( + const threadStatus = resolveThreadStatusPill({ thread, - pendingApprovalByThreadId.get(thread.id) === true, - ); + hasPendingApprovals: pendingApprovalByThreadId.get(thread.id) === true, + hasPendingUserInput: pendingUserInputByThreadId.get(thread.id) === true, + }); const prStatus = prStatusIndicator(prByThreadId.get(thread.id) ?? null); const terminalStatus = terminalStatusFromRunningIds( selectThreadTerminalState(terminalStateByThreadId, thread.id) From b946f00f1a31f16a51f9bd1f579baf40c8eaed83 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 9 Mar 2026 09:42:19 -0700 Subject: [PATCH 10/61] Show Plan Ready status pill for settled plan threads - add "Plan Ready" sidebar status when a plan-mode turn is settled with a proposed plan - update sidebar logic tests to cover the new status and expanded thread inputs --- apps/web/src/components/Sidebar.logic.test.ts | 32 +++++++++++++++++++ apps/web/src/components/Sidebar.logic.ts | 28 ++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts index 8a5e11e1af..d0216d0e40 100644 --- a/apps/web/src/components/Sidebar.logic.test.ts +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -20,8 +20,10 @@ describe("hasUnseenCompletion", () => { it("returns true when a thread completed after its last visit", () => { expect( hasUnseenCompletion({ + interactionMode: "default", latestTurn: makeLatestTurn(), lastVisitedAt: "2026-03-09T10:04:00.000Z", + proposedPlans: [], session: null, }), ).toBe(true); @@ -30,8 +32,10 @@ describe("hasUnseenCompletion", () => { describe("resolveThreadStatusPill", () => { const baseThread = { + interactionMode: "plan" as const, latestTurn: null, lastVisitedAt: undefined, + proposedPlans: [], session: { provider: "codex" as const, status: "running" as const, @@ -71,11 +75,39 @@ describe("resolveThreadStatusPill", () => { ).toMatchObject({ label: "Working", pulse: true }); }); + it("shows plan ready when a settled plan turn has a proposed plan ready for follow-up", () => { + expect( + resolveThreadStatusPill({ + thread: { + ...baseThread, + latestTurn: makeLatestTurn(), + proposedPlans: [ + { + id: "plan-1" as never, + turnId: "turn-1" as never, + createdAt: "2026-03-09T10:00:00.000Z", + updatedAt: "2026-03-09T10:05:00.000Z", + planMarkdown: "# Plan", + }, + ], + session: { + ...baseThread.session, + status: "ready", + orchestrationStatus: "ready", + }, + }, + hasPendingApprovals: false, + hasPendingUserInput: false, + }), + ).toMatchObject({ label: "Plan Ready", pulse: false }); + }); + it("shows completed when there is an unseen completion and no active blocker", () => { expect( resolveThreadStatusPill({ thread: { ...baseThread, + interactionMode: "default", latestTurn: makeLatestTurn(), lastVisitedAt: "2026-03-09T10:04:00.000Z", session: { diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index 44626cf147..e950d8de6e 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -1,13 +1,23 @@ import type { Thread } from "../types"; +import { findLatestProposedPlan, isLatestTurnSettled } from "../session-logic"; export interface ThreadStatusPill { - label: "Working" | "Connecting" | "Completed" | "Pending Approval" | "Awaiting Input"; + label: + | "Working" + | "Connecting" + | "Completed" + | "Pending Approval" + | "Awaiting Input" + | "Plan Ready"; colorClass: string; dotClass: string; pulse: boolean; } -type ThreadStatusInput = Pick; +type ThreadStatusInput = Pick< + Thread, + "interactionMode" | "latestTurn" | "lastVisitedAt" | "proposedPlans" | "session" +>; export function hasUnseenCompletion(thread: ThreadStatusInput): boolean { if (!thread.latestTurn?.completedAt) return false; @@ -63,6 +73,20 @@ export function resolveThreadStatusPill(input: { }; } + const hasPlanReadyPrompt = + !hasPendingUserInput && + thread.interactionMode === "plan" && + isLatestTurnSettled(thread.latestTurn, thread.session) && + findLatestProposedPlan(thread.proposedPlans, thread.latestTurn?.turnId ?? null) !== null; + if (hasPlanReadyPrompt) { + return { + label: "Plan Ready", + colorClass: "text-violet-600 dark:text-violet-300/90", + dotClass: "bg-violet-500 dark:bg-violet-300/90", + pulse: false, + }; + } + if (hasUnseenCompletion(thread)) { return { label: "Completed", From 9fdb45be1efb0e0b542a0dd78d868de6f71d7d4a Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 9 Mar 2026 09:13:52 -0700 Subject: [PATCH 11/61] Remove service tier setting from Codex flow and contracts - Drop `serviceTier` from orchestration/provider contracts and server dispatch paths - Remove service-tier app setting/UI and related resolver logic - Keep fast badge behavior tied to explicit fast-mode boolean --- .../Layers/ProviderCommandReactor.ts | 17 +++--- apps/server/src/orchestration/decider.ts | 1 - .../src/provider/Layers/CodexAdapter.ts | 1 - apps/web/src/appSettings.test.ts | 20 ++----- apps/web/src/appSettings.ts | 30 +--------- apps/web/src/components/ChatView.tsx | 19 +++--- apps/web/src/routes/_chat.settings.tsx | 58 ++----------------- packages/contracts/src/orchestration.ts | 5 -- packages/contracts/src/provider.ts | 3 - 9 files changed, 25 insertions(+), 129 deletions(-) diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts index 2a72d59027..39f1376431 100644 --- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts +++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts @@ -5,7 +5,6 @@ import { type OrchestrationEvent, type ProviderModelOptions, type ProviderKind, - type ProviderServiceTier, type ProviderStartOptions, type OrchestrationSession, ThreadId, @@ -205,7 +204,6 @@ const make = Effect.gen(function* () { readonly provider?: ProviderKind; readonly model?: string; readonly modelOptions?: ProviderModelOptions; - readonly serviceTier?: ProviderServiceTier | null; readonly providerOptions?: ProviderStartOptions; }, ) { @@ -241,7 +239,6 @@ const make = Effect.gen(function* () { : {}), ...(effectiveCwd ? { cwd: effectiveCwd } : {}), ...(desiredModel ? { model: desiredModel } : {}), - ...(options?.serviceTier !== undefined ? { serviceTier: options.serviceTier } : {}), ...(options?.modelOptions !== undefined ? { modelOptions: options.modelOptions } : {}), ...(options?.providerOptions !== undefined ? { providerOptions: options.providerOptions } : {}), ...(input?.resumeCursor !== undefined ? { resumeCursor: input.resumeCursor } : {}), @@ -328,7 +325,6 @@ const make = Effect.gen(function* () { readonly attachments?: ReadonlyArray; readonly provider?: ProviderKind; readonly model?: string; - readonly serviceTier?: ProviderServiceTier | null; readonly modelOptions?: ProviderModelOptions; readonly providerOptions?: ProviderStartOptions; readonly interactionMode?: "default" | "plan"; @@ -344,7 +340,6 @@ const make = Effect.gen(function* () { yield* ensureSessionForThread(input.threadId, input.createdAt, { ...(input.provider !== undefined ? { provider: input.provider } : {}), ...(input.model !== undefined ? { model: input.model } : {}), - ...(input.serviceTier !== undefined ? { serviceTier: input.serviceTier } : {}), ...(input.modelOptions !== undefined ? { modelOptions: input.modelOptions } : {}), ...(input.providerOptions !== undefined ? { providerOptions: input.providerOptions } : {}), }); @@ -365,7 +360,6 @@ const make = Effect.gen(function* () { ...(normalizedInput ? { input: normalizedInput } : {}), ...(normalizedAttachments.length > 0 ? { attachments: normalizedAttachments } : {}), ...(modelForTurn !== undefined ? { model: modelForTurn } : {}), - ...(input.serviceTier !== undefined ? { serviceTier: input.serviceTier } : {}), ...(input.modelOptions !== undefined ? { modelOptions: input.modelOptions } : {}), ...(input.interactionMode !== undefined ? { interactionMode: input.interactionMode } : {}), }); @@ -480,7 +474,6 @@ const make = Effect.gen(function* () { ...(message.attachments !== undefined ? { attachments: message.attachments } : {}), ...(event.payload.provider !== undefined ? { provider: event.payload.provider } : {}), ...(event.payload.model !== undefined ? { model: event.payload.model } : {}), - ...(event.payload.serviceTier !== undefined ? { serviceTier: event.payload.serviceTier } : {}), ...(event.payload.modelOptions !== undefined ? { modelOptions: event.payload.modelOptions } : {}), ...(event.payload.providerOptions !== undefined ? { providerOptions: event.payload.providerOptions } : {}), interactionMode: event.payload.interactionMode, @@ -639,9 +632,13 @@ const make = Effect.gen(function* () { return; } const cachedProviderOptions = threadProviderOptions.get(event.payload.threadId); - yield* ensureSessionForThread(event.payload.threadId, event.occurredAt, { - ...(cachedProviderOptions !== undefined ? { providerOptions: cachedProviderOptions } : {}), - }); + yield* ensureSessionForThread( + event.payload.threadId, + event.occurredAt, + cachedProviderOptions !== undefined + ? { providerOptions: cachedProviderOptions } + : undefined, + ); return; } case "thread.turn-start-requested": diff --git a/apps/server/src/orchestration/decider.ts b/apps/server/src/orchestration/decider.ts index 1c1ca4dd79..2218f88cf5 100644 --- a/apps/server/src/orchestration/decider.ts +++ b/apps/server/src/orchestration/decider.ts @@ -301,7 +301,6 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand" messageId: command.message.messageId, ...(command.provider !== undefined ? { provider: command.provider } : {}), ...(command.model !== undefined ? { model: command.model } : {}), - ...(command.serviceTier !== undefined ? { serviceTier: command.serviceTier } : {}), ...(command.modelOptions !== undefined ? { modelOptions: command.modelOptions } : {}), ...(command.providerOptions !== undefined ? { providerOptions: command.providerOptions } : {}), assistantDeliveryMode: command.assistantDeliveryMode ?? DEFAULT_ASSISTANT_DELIVERY_MODE, diff --git a/apps/server/src/provider/Layers/CodexAdapter.ts b/apps/server/src/provider/Layers/CodexAdapter.ts index 9a6271b792..a31ba2907e 100644 --- a/apps/server/src/provider/Layers/CodexAdapter.ts +++ b/apps/server/src/provider/Layers/CodexAdapter.ts @@ -1354,7 +1354,6 @@ const makeCodexAdapter = (options?: CodexAdapterLiveOptions) => threadId: input.threadId, ...(input.input !== undefined ? { input: input.input } : {}), ...(input.model !== undefined ? { model: input.model } : {}), - ...(input.serviceTier !== undefined ? { serviceTier: input.serviceTier } : {}), ...(input.modelOptions?.codex?.reasoningEffort !== undefined ? { effort: input.modelOptions.codex.reasoningEffort } : {}), diff --git a/apps/web/src/appSettings.test.ts b/apps/web/src/appSettings.test.ts index 5ab5d3c90a..e07e116af7 100644 --- a/apps/web/src/appSettings.test.ts +++ b/apps/web/src/appSettings.test.ts @@ -4,7 +4,6 @@ import { getAppModelOptions, getSlashModelOptions, normalizeCustomModelSlugs, - resolveAppServiceTier, shouldShowFastTierIcon, resolveAppModelSelection, } from "./appSettings"; @@ -85,21 +84,10 @@ describe("getSlashModelOptions", () => { }); }); -describe("resolveAppServiceTier", () => { - it("maps automatic to no override", () => { - expect(resolveAppServiceTier("auto")).toBeNull(); - }); - - it("preserves explicit service tier overrides", () => { - expect(resolveAppServiceTier("fast")).toBe("fast"); - expect(resolveAppServiceTier("flex")).toBe("flex"); - }); -}); - describe("shouldShowFastTierIcon", () => { - it("shows the fast-tier icon only for gpt-5.4 on fast tier", () => { - expect(shouldShowFastTierIcon("gpt-5.4", "fast")).toBe(true); - expect(shouldShowFastTierIcon("gpt-5.4", "auto")).toBe(false); - expect(shouldShowFastTierIcon("gpt-5.3-codex", "fast")).toBe(false); + it("shows the fast-tier icon only for gpt-5.4 when fast mode is enabled", () => { + expect(shouldShowFastTierIcon("gpt-5.4", true)).toBe(true); + expect(shouldShowFastTierIcon("gpt-5.4", false)).toBe(false); + expect(shouldShowFastTierIcon("gpt-5.3-codex", true)).toBe(false); }); }); diff --git a/apps/web/src/appSettings.ts b/apps/web/src/appSettings.ts index e58f7af4a6..53177312cf 100644 --- a/apps/web/src/appSettings.ts +++ b/apps/web/src/appSettings.ts @@ -1,30 +1,11 @@ import { useCallback, useSyncExternalStore } from "react"; import { Option, Schema } from "effect"; -import { type ProviderKind, type ProviderServiceTier } from "@t3tools/contracts"; +import { type ProviderKind } from "@t3tools/contracts"; import { getDefaultModel, getModelOptions, normalizeModelSlug } from "@t3tools/shared/model"; const APP_SETTINGS_STORAGE_KEY = "t3code:app-settings:v1"; const MAX_CUSTOM_MODEL_COUNT = 32; export const MAX_CUSTOM_MODEL_LENGTH = 256; -export const APP_SERVICE_TIER_OPTIONS = [ - { - value: "auto", - label: "Automatic", - description: "Use Codex defaults without forcing a service tier.", - }, - { - value: "fast", - label: "Fast", - description: "Request the fast service tier when the model supports it.", - }, - { - value: "flex", - label: "Flex", - description: "Request the flex service tier when the model supports it.", - }, -] as const; -export type AppServiceTier = (typeof APP_SERVICE_TIER_OPTIONS)[number]["value"]; -const AppServiceTierSchema = Schema.Literals(["auto", "fast", "flex"]); const MODELS_WITH_FAST_SUPPORT = new Set(["gpt-5.4"]); const BUILT_IN_MODEL_SLUGS_BY_PROVIDER: Record> = { codex: new Set(getModelOptions("codex").map((option) => option.slug)), @@ -41,7 +22,6 @@ const AppSettingsSchema = Schema.Struct({ enableAssistantStreaming: Schema.Boolean.pipe( Schema.withConstructorDefault(() => Option.some(false)), ), - codexServiceTier: AppServiceTierSchema.pipe(Schema.withConstructorDefault(() => Option.some("auto"))), customCodexModels: Schema.Array(Schema.String).pipe( Schema.withConstructorDefault(() => Option.some([])), ), @@ -53,17 +33,13 @@ export interface AppModelOption { isCustom: boolean; } -export function resolveAppServiceTier(serviceTier: AppServiceTier): ProviderServiceTier | null { - return serviceTier === "auto" ? null : serviceTier; -} - export function shouldShowFastTierIcon( model: string | null | undefined, - serviceTier: AppServiceTier, + fastModeEnabled: boolean, ): boolean { const normalizedModel = normalizeModelSlug(model); return ( - resolveAppServiceTier(serviceTier) === "fast" && + fastModeEnabled && normalizedModel !== null && MODELS_WITH_FAST_SUPPORT.has(normalizedModel) ); diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 196dfebacc..eafabbb36b 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -205,9 +205,7 @@ import { readNativeApi } from "~/nativeApi"; import { getAppModelOptions, resolveAppModelSelection, - resolveAppServiceTier, shouldShowFastTierIcon, - type AppServiceTier, useAppSettings, } from "../appSettings"; import { @@ -785,8 +783,6 @@ export default function ChatView({ threadId }: ChatViewProps) { activeThread.messages.length > 0 || activeThread.session !== null), ); - const selectedServiceTierSetting = settings.codexServiceTier; - const selectedServiceTier = resolveAppServiceTier(selectedServiceTierSetting); const lockedProvider: ProviderKind | null = hasThreadStarted ? (sessionProvider ?? selectedProviderByThreadId ?? null) : null; @@ -1255,9 +1251,9 @@ export default function ChatView({ threadId }: ChatViewProps) { label: name, description: `${providerLabel} · ${slug}`, showFastBadge: - provider === "codex" && shouldShowFastTierIcon(slug, selectedServiceTierSetting), + provider === "codex" && shouldShowFastTierIcon(slug, selectedCodexFastModeEnabled), })); - }, [composerTrigger, searchableModelOptions, selectedServiceTierSetting, workspaceEntries]); + }, [composerTrigger, searchableModelOptions, selectedCodexFastModeEnabled, workspaceEntries]); const composerMenuOpen = Boolean(composerTrigger); const activeComposerMenuItem = useMemo( () => @@ -2665,7 +2661,6 @@ export default function ChatView({ threadId }: ChatViewProps) { attachments: turnAttachments, }, model: selectedModel || undefined, - serviceTier: selectedServiceTier, ...(selectedModelOptionsForDispatch ? { modelOptions: selectedModelOptionsForDispatch } : {}), @@ -3700,7 +3695,7 @@ export default function ChatView({ threadId }: ChatViewProps) { model={selectedModelForPickerWithCustomFallback} lockedProvider={lockedProvider} modelOptionsByProvider={modelOptionsByProvider} - serviceTierSetting={selectedServiceTierSetting} + fastModeEnabled={selectedCodexFastModeEnabled} onProviderModelChange={onProviderModelSelect} /> @@ -5548,7 +5543,7 @@ const ProviderModelPicker = memo(function ProviderModelPicker(props: { model: ModelSlug; lockedProvider: ProviderKind | null; modelOptionsByProvider: Record>; - serviceTierSetting: AppServiceTier; + fastModeEnabled: boolean; disabled?: boolean; onProviderModelChange: (provider: ProviderKind, model: ModelSlug) => void; }) { @@ -5578,10 +5573,10 @@ const ProviderModelPicker = memo(function ProviderModelPicker(props: { disabled={props.disabled} /> } - > + >