Skip to content

Commit 474da6a

Browse files
committed
Fix a bug where stale plans persisted forever in the chat
1 parent 4aad4e4 commit 474da6a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

apps/array/src/renderer/features/sessions/components/SessionView.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Box, ContextMenu, Flex } from "@radix-ui/themes";
55
import {
66
type AcpMessage,
77
isJsonRpcNotification,
8+
isJsonRpcRequest,
89
} from "@shared/types/session-events";
910
import { useCallback, useMemo, useState } from "react";
1011
import { useHotkeys } from "react-hotkeys-hook";
@@ -57,7 +58,18 @@ export function SessionView({
5758
]);
5859

5960
const latestPlan = useMemo((): Plan | null => {
61+
// Find the index of the last user prompt - only show plans after that
62+
let lastPromptIndex = -1;
6063
for (let i = events.length - 1; i >= 0; i--) {
64+
const msg = events[i].message;
65+
if (isJsonRpcRequest(msg) && msg.method === "session/prompt") {
66+
lastPromptIndex = i;
67+
break;
68+
}
69+
}
70+
71+
// Search for plans only after the last user prompt
72+
for (let i = events.length - 1; i > lastPromptIndex; i--) {
6173
const msg = events[i].message;
6274
if (isJsonRpcNotification(msg) && msg.method === "session/update") {
6375
const update = (msg.params as { update?: { sessionUpdate?: string } })

0 commit comments

Comments
 (0)