Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(activity): the Activity panel shows a finished tool run without a reload (#3699)

Aditya Umale7d31befefcaa
diff --git a/src/components/ActivityPanel.tsx b/src/components/ActivityPanel.tsx
index 762f0948fc..e4e0dac108 100644
--- a/src/components/ActivityPanel.tsx
+++ b/src/components/ActivityPanel.tsx
@@ -55,10 +55,8 @@ export function ActivityPanel({ bot }: { bot: Bot }) {
return () => loadAbort.current?.abort();
}, [load]);
- const threadIds = useMemo(
- () => new Set([bot.threadId, ...(bot.tasks ?? []).map((task) => task.threadId)]),
- [bot.threadId, bot.tasks],
- );
+ const threadKey = [bot.threadId, ...(bot.tasks ?? []).map((task) => task.threadId)].join("\n");
+ const threadIds = useMemo(() => new Set(threadKey.split("\n")), [threadKey]);
useEffect(() => {
let settle: ReturnType<typeof setTimeout> | null = null;
const stopLive = listenLiveFrames({
diff --git a/src/components/live-panels.test.ts b/src/components/live-panels.test.ts
index d78734509b..7da427cd8f 100644
--- a/src/components/live-panels.test.ts
+++ b/src/components/live-panels.test.ts
@@ -45,8 +45,10 @@ async function mount(panel: typeof InspectorPanel | typeof ActivityPanel) {
const container = document.createElement("div");
document.body.append(container);
root = createRoot(container);
- flushSync(() => root.render(createElement(BotEditorStore, { value, children: createElement(panel, { bot }) })));
+ const render = (next: Bot) => flushSync(() => root.render(createElement(BotEditorStore, { value, children: createElement(panel, { bot: next }) })));
+ render(bot);
await settle();
+ return render;
}
beforeEach(() => {
@@ -101,6 +103,15 @@ describe("Activity on the app's live stream", () => {
expect(opened).not.toHaveBeenCalled();
});
+ it("still reloads when the bot changes while a settled turn waits", async () => {
+ const render = await mount(ActivityPanel);
+ frame(runtime("e5", { type: "turn.completed", ok: true }));
+ render({ ...bot, unread: true, tasks: [...bot.tasks!] });
+ await new Promise((resolve) => setTimeout(resolve, 450));
+ await settle();
+ expect(fetched).toHaveLength(2);
+ });
+
it("reloads when the stream missed frames it could not replay", async () => {
await mount(ActivityPanel);
missed();