| 1 | import { createSelector } from "@reduxjs/toolkit"; |
| 2 | import { RootState } from "../store"; |
| 3 | import { findCurrentToolCall } from "../util"; |
| 4 | |
| 5 | export const selectCurrentToolCall = createSelector( |
| 6 | (store: RootState) => store.session.history, |
| 7 | (history) => { |
| 8 | return findCurrentToolCall(history); |
| 9 | }, |
| 10 | ); |
| 11 | |
| 12 | export const selectCurrentToolCallApplyState = createSelector( |
| 13 | [ |
| 14 | (store: RootState) => store.session.history, |
| 15 | (store: RootState) => store.session.codeBlockApplyStates, |
| 16 | ], |
| 17 | (history, applyStates) => { |
| 18 | const currentToolCall = findCurrentToolCall(history); |
| 19 | if (!currentToolCall) { |
| 20 | return undefined; |
| 21 | } |
| 22 | return applyStates.states.find( |
| 23 | (state) => |
| 24 | state.toolCallId && state.toolCallId === currentToolCall.toolCallId, |
| 25 | ); |
| 26 | }, |
| 27 | ); |