Skip to content

Commit f734a2e

Browse files
committed
Clarify running-turn stop messaging
1 parent 9e29c9d commit f734a2e

3 files changed

Lines changed: 54 additions & 16 deletions

File tree

‎apps/web/src/components/ChatView.logic.test.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { ThreadId } from "@t3tools/contracts";
22
import { describe, expect, it } from "vitest";
33

4-
import { buildExpiredTerminalContextToastCopy, deriveComposerSendState } from "./ChatView.logic";
4+
import {
5+
buildExpiredTerminalContextToastCopy,
6+
buildRunningTurnBlockedMessage,
7+
deriveComposerSendState,
8+
} from "./ChatView.logic";
59

610
describe("deriveComposerSendState", () => {
711
it("treats expired terminal pills as non-sendable content", () => {
@@ -67,3 +71,17 @@ describe("buildExpiredTerminalContextToastCopy", () => {
6771
});
6872
});
6973
});
74+
75+
describe("buildRunningTurnBlockedMessage", () => {
76+
it("explains when a turn is still running", () => {
77+
expect(buildRunningTurnBlockedMessage(false)).toBe(
78+
"A turn is still running. Stop it before sending another prompt.",
79+
);
80+
});
81+
82+
it("explains when a long-running command is keeping the turn active", () => {
83+
expect(buildRunningTurnBlockedMessage(true)).toBe(
84+
"A long-running command is still active. Stop the current turn before sending another prompt.",
85+
);
86+
});
87+
});

‎apps/web/src/components/ChatView.logic.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,9 @@ export function buildExpiredTerminalContextToastCopy(
160160
description: "Re-add it if you want that terminal output included.",
161161
};
162162
}
163+
164+
export function buildRunningTurnBlockedMessage(hasRunningSubprocess: boolean): string {
165+
return hasRunningSubprocess
166+
? "A long-running command is still active. Stop the current turn before sending another prompt."
167+
: "A turn is still running. Stop it before sending another prompt.";
168+
}

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ import { ProviderHealthBanner } from "./chat/ProviderHealthBanner";
164164
import { ThreadErrorBanner } from "./chat/ThreadErrorBanner";
165165
import {
166166
buildExpiredTerminalContextToastCopy,
167+
buildRunningTurnBlockedMessage,
167168
buildLocalDraftThread,
168169
buildTemporaryWorktreeBranchName,
169170
cloneComposerImageForRetry,
@@ -661,6 +662,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
661662
const isSendBusy = sendPhase !== "idle";
662663
const isPreparingWorktree = sendPhase === "preparing-worktree";
663664
const isWorking = phase === "running" || isSendBusy || isConnecting || isRevertingCheckpoint;
665+
const hasRunningTerminalSubprocess = terminalState.runningTerminalIds.length > 0;
666+
const runningTurnBlockedMessage = buildRunningTurnBlockedMessage(hasRunningTerminalSubprocess);
664667
const nowIso = new Date(nowTick).toISOString();
665668
const activeWorkStartedAt = deriveActiveWorkStartedAt(
666669
activeLatestTurn,
@@ -2346,6 +2349,10 @@ export default function ChatView({ threadId }: ChatViewProps) {
23462349
e?.preventDefault();
23472350
const api = readNativeApi();
23482351
if (!api || !activeThread || isSendBusy || isConnecting || sendInFlightRef.current) return;
2352+
if (phase === "running") {
2353+
setThreadError(activeThread.id, runningTurnBlockedMessage);
2354+
return;
2355+
}
23492356
if (activePendingProgress) {
23502357
onAdvanceActivePendingUserInput();
23512358
return;
@@ -3931,22 +3938,29 @@ export default function ChatView({ threadId }: ChatViewProps) {
39313938
</Button>
39323939
</div>
39333940
) : phase === "running" ? (
3934-
<button
3935-
type="button"
3936-
className="flex size-8 cursor-pointer items-center justify-center rounded-full bg-rose-500/90 text-white transition-all duration-150 hover:bg-rose-500 hover:scale-105 sm:h-8 sm:w-8"
3937-
onClick={() => void onInterrupt()}
3938-
aria-label="Stop generation"
3939-
>
3940-
<svg
3941-
width="12"
3942-
height="12"
3943-
viewBox="0 0 12 12"
3944-
fill="currentColor"
3945-
aria-hidden="true"
3941+
<div className="flex items-center gap-2">
3942+
<span className="hidden max-w-52 text-right text-xs text-muted-foreground/70 sm:inline">
3943+
{runningTurnBlockedMessage}
3944+
</span>
3945+
<button
3946+
type="button"
3947+
className="flex h-9 cursor-pointer items-center justify-center gap-2 rounded-full bg-rose-500/90 px-3 text-white transition-all duration-150 hover:bg-rose-500 hover:scale-105 sm:h-8"
3948+
onClick={() => void onInterrupt()}
3949+
aria-label="Stop generation"
3950+
title={runningTurnBlockedMessage}
39463951
>
3947-
<rect x="2" y="2" width="8" height="8" rx="1.5" />
3948-
</svg>
3949-
</button>
3952+
<svg
3953+
width="12"
3954+
height="12"
3955+
viewBox="0 0 12 12"
3956+
fill="currentColor"
3957+
aria-hidden="true"
3958+
>
3959+
<rect x="2" y="2" width="8" height="8" rx="1.5" />
3960+
</svg>
3961+
<span className="hidden sm:inline">Stop</span>
3962+
</button>
3963+
</div>
39503964
) : pendingUserInputs.length === 0 ? (
39513965
showPlanFollowUpPrompt ? (
39523966
prompt.trim().length > 0 ? (

0 commit comments

Comments
 (0)