Skip to content

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

Keep the chat view at its size limit: Regenerate's target lives in turn-tail

Bugfixer 2ae4502ee30f9
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index e7c565eeb6..d3e81f7857 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -54,7 +54,7 @@ import { showToolCallsEnabled } from "@/lib/feature-flags";
import { stateForBot } from "@/lib/mascot";
import { flatPreview, peerLine, peerPreview, peerRequest } from "@/lib/peer-message"; import { PeerCompactRow, PeerLabel, PeerMessagesContext, PeerOpenedActions } from "./PeerExchange"; import { earlierAnswers } from "@/lib/check-rounds";
import { lastRequests } from "@/lib/automation-note"; import { automationNoteRow } from "./AutomationNoteRow"; import { teammateNamed } from "./RoomClusterLabel";
-import { showWorkingDots } from "@/lib/turn-tail";
+import { regenerateTarget, showWorkingDots } from "@/lib/turn-tail";
import { lastNonReceipt } from "@/lib/receipts";
import { useTurnLive } from "@/state/turn-status"; import { isLiveReply, StreamingReplyContext, streamedReply, useHasLiveReply, useLiveRow, useLiveTranscriptLayout } from "@/state/live-reply"; import { useTurnNow } from "./NowCard"; import { useThreadRoutineRun } from "@/state/older-routine-runs";
import { ChatMarkdown } from "./ChatMarkdown";
@@ -781,18 +781,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
});
const lastBotTextId = useMemo(
- () => {
- // A teammate's tagged answer is not this bot's reply: Regenerate stays on this bot's answer to the same request, or none.
- let skippedTeammate = false;
- for (let i = messages.length - 1; i >= 0; i--) {
- const m = messages[i]!;
- if (skippedTeammate && m.role === "user") return undefined;
- if (m.role !== "bot" || m.kind !== "text") continue;
- if (!m.from || m.from.botId === bot.id) return m.id;
- skippedTeammate = true;
- }
- return undefined;
- },
+ () => regenerateTarget(messages, bot.id),
[messages, bot.id],
); const unreadDivider = useUnreadDivider({ threadId: bot.threadId, messages: chatMessages, following });
diff --git a/src/lib/turn-tail.ts b/src/lib/turn-tail.ts
index a691a54ba6..0f015ecdea 100644
--- a/src/lib/turn-tail.ts
+++ b/src/lib/turn-tail.ts
@@ -27,3 +27,17 @@ export function awaitedMemberId(
if (lastMessage?.kind !== "activity" || !lastMessage.tool || lastMessage.tool.ok !== undefined) return undefined;
return lastMessage.from?.botId;
}
+
+/** The reply Regenerate sits on: this bot's last text answer. A tagged teammate's answer in the chat (#8096) is not this
+ * bot's reply, so it is skipped, but never past the person's line it answered: that request then has no reply of its own. */
+export function regenerateTarget(messages: readonly Message[], botId: string): string | undefined {
+ let skippedTeammate = false;
+ for (let i = messages.length - 1; i >= 0; i--) {
+ const m = messages[i]!;
+ if (skippedTeammate && m.role === "user") return undefined;
+ if (m.role !== "bot" || m.kind !== "text") continue;
+ if (!m.from || m.from.botId === botId) return m.id;
+ skippedTeammate = true;
+ }
+ return undefined;
+}