Elffuss BraidHub

kikocis/continue public

28132f96f4d3 · 606 BRawPermalink
1import { createSelector } from "@reduxjs/toolkit";
2import { ToolCallState } from "core";
3import { RootState } from "../store";
4
5export const selectLastToolCall = createSelector(
6 [(store: RootState) => store.session.history],
7 (history): ToolCallState | null => {
8 let lastToolCallHistoryItem = null;
9 for (let i = history.length - 1; i >= 0; i--) {
10 const item = history[i];
11 if (item.message.role === "assistant" && item.message.toolCalls?.length) {
12 lastToolCallHistoryItem = item;
13 break;
14 }
15 }
16 return lastToolCallHistoryItem?.toolCallState ?? null;
17 },
18);