Skip to content

Commit 0d9c5cd

Browse files
authored
Merge pull request #248 from OpenKnots/okcode/remove-queued-code
Allow removing queued chat messages
2 parents 8fe48e1 + e7821cf commit 0d9c5cd

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

apps/web/src/components/ChatView.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,6 +3597,15 @@ export default function ChatView({ threadId }: ChatViewProps) {
35973597
setQueuedMessages([]);
35983598
}, []);
35993599

3600+
const onRemoveQueuedMessage = useCallback((messageId: MessageId) => {
3601+
setOptimisticUserMessages((existing) => {
3602+
const target = existing.find((msg) => msg.id === messageId && msg.queued);
3603+
if (target) revokeUserMessagePreviewUrls(target);
3604+
return existing.filter((msg) => msg.id !== messageId);
3605+
});
3606+
setQueuedMessages((existing) => existing.filter((msg) => msg.id !== messageId));
3607+
}, []);
3608+
36003609
const onRespondToApproval = useCallback(
36013610
async (requestId: ApprovalRequestId, decision: ProviderApprovalDecision) => {
36023611
const api = readNativeApi();
@@ -4737,6 +4746,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
47374746
timestampFormat={timestampFormat}
47384747
workspaceRoot={activeProject?.cwd ?? undefined}
47394748
shortcutGuides={chatShortcutGuides}
4749+
onRemoveQueuedMessage={onRemoveQueuedMessage}
47404750
onOpenSettings={() => void navigate({ to: "/settings" })}
47414751
/>
47424752
</div>

apps/web/src/components/chat/MessagesTimeline.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ describe("MessagesTimeline", () => {
102102
resolvedTheme="light"
103103
timestampFormat="locale"
104104
workspaceRoot={undefined}
105+
onRemoveQueuedMessage={() => {}}
105106
shortcutGuides={EMPTY_SHORTCUT_GUIDES}
106107
onOpenSettings={() => {}}
107108
/>,
@@ -149,6 +150,7 @@ describe("MessagesTimeline", () => {
149150
resolvedTheme="light"
150151
timestampFormat="locale"
151152
workspaceRoot={undefined}
153+
onRemoveQueuedMessage={() => {}}
152154
shortcutGuides={EMPTY_SHORTCUT_GUIDES}
153155
onOpenSettings={() => {}}
154156
/>,
@@ -183,6 +185,7 @@ describe("MessagesTimeline", () => {
183185
resolvedTheme="light"
184186
timestampFormat="locale"
185187
workspaceRoot={undefined}
188+
onRemoveQueuedMessage={() => {}}
186189
shortcutGuides={EMPTY_SHORTCUT_GUIDES}
187190
onOpenSettings={() => {}}
188191
/>,

apps/web/src/components/chat/MessagesTimeline.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
TerminalIcon,
3434
Undo2Icon,
3535
WrenchIcon,
36+
XIcon,
3637
ZapIcon,
3738
} from "lucide-react";
3839
import { Button } from "../ui/button";
@@ -87,6 +88,7 @@ interface MessagesTimelineProps {
8788
resolvedTheme: "light" | "dark";
8889
timestampFormat: TimestampFormat;
8990
workspaceRoot: string | undefined;
91+
onRemoveQueuedMessage: (messageId: MessageId) => void;
9092
shortcutGuides: ChatShortcutGuide[];
9193
onOpenSettings: () => void;
9294
}
@@ -113,6 +115,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
113115
resolvedTheme,
114116
timestampFormat,
115117
workspaceRoot,
118+
onRemoveQueuedMessage,
116119
shortcutGuides,
117120
onOpenSettings,
118121
}: MessagesTimelineProps) {
@@ -508,9 +511,16 @@ export const MessagesTimeline = memo(function MessagesTimeline({
508511
</div>
509512
<div className="flex items-center gap-1.5">
510513
{isQueued && (
511-
<span className="inline-flex items-center rounded-full bg-amber-500/10 px-1.5 py-0.5 text-[9px] font-medium text-amber-600 dark:text-amber-400">
514+
<button
515+
type="button"
516+
className="inline-flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-[9px] font-medium text-amber-600 transition-colors hover:bg-destructive/15 hover:text-destructive dark:text-amber-400 dark:hover:text-destructive"
517+
title="Remove queued message"
518+
aria-label="Remove queued message"
519+
onClick={() => onRemoveQueuedMessage(row.message.id)}
520+
>
512521
Queued
513-
</span>
522+
<XIcon className="size-2.5" />
523+
</button>
514524
)}
515525
<p className="text-right text-[10px] text-muted-foreground/30">
516526
{formatTimestamp(row.message.createdAt, timestampFormat, resolvedLocale)}

0 commit comments

Comments
 (0)