Skip to content

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.

fix(web): show Stop button while input is pending (#5554)

Illia Panasenko45d9aa90baab
diff --git a/apps/web/src/components/chat/ComposerPrimaryActions.test.ts b/apps/web/src/components/chat/ComposerPrimaryActions.test.ts
index b7624db0a..ba416e9fc 100644
--- a/apps/web/src/components/chat/ComposerPrimaryActions.test.ts
+++ b/apps/web/src/components/chat/ComposerPrimaryActions.test.ts
@@ -1,6 +1,64 @@
-import { describe, expect, it } from "vite-plus/test";
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { describe, expect, it, vi } from "vite-plus/test";
-import { formatPendingPrimaryActionLabel } from "./ComposerPrimaryActions";
+vi.mock("~/hooks/useSettings", () => ({
+ useEnvironmentIdentificationMode: () => "none",
+}));
+vi.mock("../SidebarStageBackdrop", () => ({
+ StageBackdropButtonArt: () => null,
+ useSidebarStageBackdropVariant: () => null,
+}));
+
+import { ComposerPrimaryActions, formatPendingPrimaryActionLabel } from "./ComposerPrimaryActions";
+
+function renderPendingActions(isRunning: boolean) {
+ return renderToStaticMarkup(
+ createElement(ComposerPrimaryActions, {
+ compact: true,
+ pendingAction: {
+ questionIndex: 0,
+ isLastQuestion: true,
+ canAdvance: true,
+ isResponding: false,
+ isComplete: true,
+ },
+ isRunning,
+ showPlanFollowUpPrompt: false,
+ promptHasText: false,
+ isSendBusy: false,
+ sendDisabledReason: null,
+ isConnecting: false,
+ isEnvironmentUnavailable: false,
+ isPreparingWorktree: false,
+ hasSendableContent: false,
+ onPreviousPendingQuestion: () => {},
+ onInterrupt: () => {},
+ onImplementPlanInNewThread: () => {},
+ }),
+ );
+}
+
+function renderStandaloneStop() {
+ return renderToStaticMarkup(
+ createElement(ComposerPrimaryActions, {
+ compact: true,
+ pendingAction: null,
+ isRunning: true,
+ showPlanFollowUpPrompt: false,
+ promptHasText: false,
+ isSendBusy: false,
+ sendDisabledReason: null,
+ isConnecting: false,
+ isEnvironmentUnavailable: false,
+ isPreparingWorktree: false,
+ hasSendableContent: false,
+ onPreviousPendingQuestion: () => {},
+ onInterrupt: () => {},
+ onImplementPlanInNewThread: () => {},
+ }),
+ );
+}
describe("formatPendingPrimaryActionLabel", () => {
it("returns 'Submitting...' while responding", () => {
@@ -91,3 +149,19 @@ describe("formatPendingPrimaryActionLabel", () => {
).toBe("Submit answers");
});
});
+
+describe("ComposerPrimaryActions", () => {
+ it("offers Stop generation while a running turn is waiting for user input", () => {
+ expect(renderPendingActions(true)).toContain('aria-label="Stop generation"');
+ });
+
+ it("does not offer Stop generation for a pending request without a running turn", () => {
+ expect(renderPendingActions(false)).not.toContain('aria-label="Stop generation"');
+ });
+
+ it("matches the small pending action size without changing the standalone size", () => {
+ expect(renderPendingActions(true)).toContain("size-8 sm:size-7");
+ expect(renderStandaloneStop()).toContain("size-8 sm:h-8 sm:w-8");
+ expect(renderStandaloneStop()).not.toContain("sm:size-7");
+ });
+});
diff --git a/apps/web/src/components/chat/ComposerPrimaryActions.tsx b/apps/web/src/components/chat/ComposerPrimaryActions.tsx
index cc211f318..52d2556bb 100644
--- a/apps/web/src/components/chat/ComposerPrimaryActions.tsx
+++ b/apps/web/src/components/chat/ComposerPrimaryActions.tsx
@@ -75,9 +75,27 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
: undefined;
const isSendDisabled = sendDisabledReason !== null;
+ const renderStopGenerationButton = (insidePendingAction: boolean) => (
+ <button
+ type="button"
+ className={cn(
+ "flex cursor-pointer items-center justify-center rounded-full bg-destructive/90 text-white shadow-xs shadow-destructive/24 inset-shadow-[0_1px_--theme(--color-white/16%)] transition-all duration-150 hover:bg-destructive hover:scale-105 active:inset-shadow-[0_1px_--theme(--color-black/8%)] active:shadow-none",
+ insidePendingAction ? "size-8 sm:size-7" : "size-8 sm:h-8 sm:w-8",
+ )}
+ {...pointerFocusProps}
+ onClick={onInterrupt}
+ aria-label="Stop generation"
+ >
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true">
+ <rect x="2" y="2" width="8" height="8" rx="1.5" />
+ </svg>
+ </button>
+ );
+
if (pendingAction) {
return (
<div className={cn("flex items-center justify-end", compact ? "gap-1.5" : "gap-2")}>
+ {isRunning ? renderStopGenerationButton(true) : null}
{pendingAction.questionIndex > 0 ? (
compact ? (
<Button
@@ -130,19 +148,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
}
if (isRunning) {
- return (
- <button
- type="button"
- className="flex size-8 cursor-pointer items-center justify-center rounded-full bg-destructive/90 text-white shadow-xs shadow-destructive/24 inset-shadow-[0_1px_--theme(--color-white/16%)] transition-all duration-150 hover:bg-destructive hover:scale-105 active:inset-shadow-[0_1px_--theme(--color-black/8%)] active:shadow-none sm:h-8 sm:w-8"
- {...pointerFocusProps}
- onClick={onInterrupt}
- aria-label="Stop generation"
- >
- <svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true">
- <rect x="2" y="2" width="8" height="8" rx="1.5" />
- </svg>
- </button>
- );
+ return renderStopGenerationButton(false);
}
if (showPlanFollowUpPrompt) {