Skip to content

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

fix(routines): no run banner on a run that worked in its own results thread (#4266)

wlals08747d7e7a1c1e40
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index 501f537977..d54cf2a066 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -999,7 +999,9 @@ export function ChatView({ bot: profile }: { bot: Bot }) {
? { link: currentLink, assign: (link: string | null) => dispatch({ type: "updateTask", botId: bot.id, threadId: bot.threadId, patch: { link } }) }
: null, [canWrite, currentLink, bot.id, bot.threadId, dispatch]);
- const routineExecution = useThreadRoutineRun(bot.id, bot.threadId);
+ const routineRun = useThreadRoutineRun(bot.id, bot.threadId);
+ // A run inside its own results conversation (a wait finishing in this chat) is no execution thread: no banner.
+ const routineExecution = routineRun && (routineRun.resultsThreadId ?? routineRun.sourceThreadId) !== bot.threadId ? routineRun : undefined;
const resultsThreadId = routineExecution?.resultsThreadId ?? routineExecution?.sourceThreadId;
const canOpenResults = resultsThreadId && [...state.bots, ...state.groups].some((owner) => owner.threadId === resultsThreadId || owner.tasks?.some((task) => task.threadId === resultsThreadId));
diff --git a/src/components/RoutineResultsNavigation.test.ts b/src/components/RoutineResultsNavigation.test.ts
index 3eb2eab904..a15f4cc912 100644
--- a/src/components/RoutineResultsNavigation.test.ts
+++ b/src/components/RoutineResultsNavigation.test.ts
@@ -163,4 +163,11 @@ describe("routine results navigation", () => {
fixture.state!.routineRuns = [{ ...run, resultsThreadId: "deleted-destination" }];
expect(buttonsFrom(() => ChatView({ bot })).has("Back to results")).toBe(false);
});
+
+ it("shows no run banner when the run worked inside the conversation its results go to", () => {
+ fixture.state!.routineRuns = [{ ...run, resultsThreadId: "execution", sourceThreadId: "execution" }];
+ const buttons = buttonsFrom(() => ChatView({ bot }));
+ expect(buttons.has("Back to results")).toBe(false);
+ expect(buttons.has("Run logs")).toBe(false);
+ });
});