Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
[codex] Revert stale send spinner fix (#1704)
Julius Marmingee8f5b4ad5b28
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex fd2f37100..1580c8f60 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -52,7 +52,6 @@ import {deriveWorkLogEntries,hasActionableProposedPlan,hasToolActivityForTurn,- isSessionActivelyRunningTurn,isLatestTurnSettled,formatElapsed,} from "../session-logic";@@ -1121,11 +1120,7 @@ export default function ChatView({ threadId }: ChatViewProps) {activePendingUserInput: activePendingUserInput?.requestId ?? null,threadError: activeThread?.error,});- const isTurnRunning = isSessionActivelyRunningTurn(- activeLatestTurn,- activeThread?.session ?? null,- );- const isWorking = isTurnRunning || isSendBusy || isConnecting || isRevertingCheckpoint;+ const isWorking = phase === "running" || isSendBusy || isConnecting || isRevertingCheckpoint;const nowIso = new Date(nowTick).toISOString();const activeWorkStartedAt = deriveActiveWorkStartedAt(activeLatestTurn,@@ -1142,7 +1137,7 @@ export default function ChatView({ threadId }: ChatViewProps) {if (activePendingProgress) {return `pending:${activePendingProgress.questionIndex}:${activePendingProgress.isLastQuestion}:${activePendingIsResponding}`;}- if (isTurnRunning) {+ if (phase === "running") {return "running";}if (showPlanFollowUpPrompt) {@@ -1156,7 +1151,7 @@ export default function ChatView({ threadId }: ChatViewProps) {isConnecting,isPreparingWorktree,isSendBusy,- isTurnRunning,+ phase,prompt,showPlanFollowUpPrompt,]);@@ -2316,10 +2311,10 @@ export default function ChatView({ threadId }: ChatViewProps) {scheduleStickToBottom();}, [messageCount, scheduleStickToBottom]);useEffect(() => {- if (!isTurnRunning) return;+ if (phase !== "running") return;if (!shouldAutoScrollRef.current) return;scheduleStickToBottom();- }, [isTurnRunning, scheduleStickToBottom, timelineEntries]);+ }, [phase, scheduleStickToBottom, timelineEntries]);useEffect(() => {setExpandedWorkGroups({});@@ -2538,14 +2533,14 @@ export default function ChatView({ threadId }: ChatViewProps) {: "local";useEffect(() => {- if (!isTurnRunning) return;+ if (phase !== "running") return;const timer = window.setInterval(() => {setNowTick(Date.now());}, 1000);return () => {window.clearInterval(timer);};- }, [isTurnRunning]);+ }, [phase]);useEffect(() => {if (!activeThreadId) return;@@ -2765,7 +2760,7 @@ export default function ChatView({ threadId }: ChatViewProps) {const api = readNativeApi();if (!api || !activeThread || isRevertingCheckpoint) return;- if (isTurnRunning || isSendBusy || isConnecting) {+ if (phase === "running" || isSendBusy || isConnecting) {setThreadError(activeThread.id, "Interrupt the current turn before reverting checkpoints.");return;}@@ -2798,7 +2793,7 @@ export default function ChatView({ threadId }: ChatViewProps) {}setIsRevertingCheckpoint(false);},- [activeThread, isConnecting, isRevertingCheckpoint, isSendBusy, isTurnRunning, setThreadError],+ [activeThread, isConnecting, isRevertingCheckpoint, isSendBusy, phase, setThreadError],);const onSend = async (e?: { preventDefault: () => void }) => {@@ -4387,7 +4382,7 @@ export default function ChatView({ threadId }: ChatViewProps) {}: null}- isRunning={isTurnRunning}+ isRunning={phase === "running"}showPlanFollowUpPrompt={pendingUserInputs.length === 0 && showPlanFollowUpPrompt}diff --git a/apps/web/src/session-logic.test.ts b/apps/web/src/session-logic.test.tsindex bc1b69841..e05c3b5e9 100644--- a/apps/web/src/session-logic.test.ts+++ b/apps/web/src/session-logic.test.ts@@ -20,7 +20,6 @@ import {findSidebarProposedPlan,hasActionableProposedPlan,hasToolActivityForTurn,- isSessionActivelyRunningTurn,isLatestTurnSettled,} from "./session-logic";@@ -1073,30 +1072,15 @@ describe("isLatestTurnSettled", () => {} as const;it("returns false while the same turn is still active in a running session", () => {- expect(- isLatestTurnSettled(- {- ...latestTurn,- completedAt: null,- },- {- orchestrationStatus: "running",- activeTurnId: TurnId.makeUnsafe("turn-1"),- },- ),- ).toBe(false);- });-- it("returns true when the turn completed but the session status stayed stale-running", () => {expect(isLatestTurnSettled(latestTurn, {orchestrationStatus: "running",activeTurnId: TurnId.makeUnsafe("turn-1"),}),- ).toBe(true);+ ).toBe(false);});- it("returns false while a different turn is still running", () => {+ it("returns false while any turn is running to avoid stale latest-turn banners", () => {expect(isLatestTurnSettled(latestTurn, {orchestrationStatus: "running",@@ -1128,56 +1112,6 @@ describe("isLatestTurnSettled", () => {});});-describe("isSessionActivelyRunningTurn", () => {- const completedTurn = {- turnId: TurnId.makeUnsafe("turn-1"),- startedAt: "2026-02-27T21:10:00.000Z",- completedAt: "2026-02-27T21:10:06.000Z",- } as const;-- it("returns true when the current turn has not completed yet", () => {- expect(- isSessionActivelyRunningTurn(- {- ...completedTurn,- completedAt: null,- },- {- orchestrationStatus: "running",- activeTurnId: TurnId.makeUnsafe("turn-1"),- },- ),- ).toBe(true);- });-- it("returns false when the same turn already completed and only the session is stale", () => {- expect(- isSessionActivelyRunningTurn(completedTurn, {- orchestrationStatus: "running",- activeTurnId: TurnId.makeUnsafe("turn-1"),- }),- ).toBe(false);- });-- it("returns true when a different turn is still active", () => {- expect(- isSessionActivelyRunningTurn(completedTurn, {- orchestrationStatus: "running",- activeTurnId: TurnId.makeUnsafe("turn-2"),- }),- ).toBe(true);- });-- it("returns false when the session is not running", () => {- expect(- isSessionActivelyRunningTurn(completedTurn, {- orchestrationStatus: "ready",- activeTurnId: undefined,- }),- ).toBe(false);- });-});-describe("deriveActiveWorkStartedAt", () => {const latestTurn = {turnId: TurnId.makeUnsafe("turn-1"),@@ -1186,22 +1120,6 @@ describe("deriveActiveWorkStartedAt", () => {} as const;it("prefers the in-flight turn start when the latest turn is not settled", () => {- expect(- deriveActiveWorkStartedAt(- {- ...latestTurn,- completedAt: null,- },- {- orchestrationStatus: "running",- activeTurnId: TurnId.makeUnsafe("turn-1"),- },- "2026-02-27T21:11:00.000Z",- ),- ).toBe("2026-02-27T21:10:00.000Z");- });-- it("falls back to sendStartedAt when only the session status is stale-running", () => {expect(deriveActiveWorkStartedAt(latestTurn,@@ -1211,7 +1129,7 @@ describe("deriveActiveWorkStartedAt", () => {},"2026-02-27T21:11:00.000Z",),- ).toBe("2026-02-27T21:11:00.000Z");+ ).toBe("2026-02-27T21:10:00.000Z");});it("falls back to sendStartedAt once the latest turn is settled", () => {diff --git a/apps/web/src/session-logic.ts b/apps/web/src/session-logic.tsindex 90d8da820..fc3382701 100644--- a/apps/web/src/session-logic.ts+++ b/apps/web/src/session-logic.ts@@ -128,30 +128,15 @@ export function formatElapsed(startIso: string, endIso: string | undefined): strtype LatestTurnTiming = Pick<OrchestrationLatestTurn, "turnId" | "startedAt" | "completedAt">;type SessionActivityState = Pick<ThreadSession, "orchestrationStatus" | "activeTurnId">;-export function isSessionActivelyRunningTurn(- latestTurn: LatestTurnTiming | null,- session: SessionActivityState | null,-): boolean {- if (!session || session.orchestrationStatus !== "running") return false;- if (!latestTurn) return true;-- const activeTurnId = session.activeTurnId;- if (activeTurnId === undefined) {- return latestTurn.completedAt === null;- }- if (latestTurn.turnId !== activeTurnId) {- return true;- }- return latestTurn.completedAt === null;-}-export function isLatestTurnSettled(latestTurn: LatestTurnTiming | null,session: SessionActivityState | null,): boolean {if (!latestTurn?.startedAt) return false;if (!latestTurn.completedAt) return false;- return !isSessionActivelyRunningTurn(latestTurn, session);+ if (!session) return true;+ if (session.orchestrationStatus === "running") return false;+ return true;}export function deriveActiveWorkStartedAt(