@@ -11,7 +11,7 @@ import {
11
11
useCapsForToolUse ,
12
12
useAgentUsage ,
13
13
} from "../../hooks" ;
14
- import { type Config } from "../../features/Config/configSlice" ;
14
+ // import { type Config } from "../../features/Config/configSlice";
15
15
import {
16
16
enableSend ,
17
17
selectIsStreaming ,
@@ -31,19 +31,15 @@ import { Checkpoints } from "../../features/Checkpoints";
31
31
import { SuggestNewChat } from "../ChatForm/SuggestNewChat" ;
32
32
33
33
export type ChatProps = {
34
- host : Config [ "host" ] ;
35
- tabbed : Config [ "tabbed" ] ;
36
- backFromChat : ( ) => void ;
37
- style ?: React . CSSProperties ;
38
- unCalledTools : boolean ;
39
- maybeSendToSidebar : ChatFormProps [ "onClose" ] ;
34
+ // host: Config["host"];
35
+ // tabbed: Config["tabbed"];
36
+ // backFromChat: () => void;
37
+ // style?: React.CSSProperties;
38
+ // unCalledTools: boolean;
39
+ // maybeSendToSidebar: ChatFormProps["onClose"];
40
40
} ;
41
41
42
- export const Chat : React . FC < ChatProps > = ( {
43
- style,
44
- unCalledTools,
45
- maybeSendToSidebar,
46
- } ) => {
42
+ export const Chat : React . FC < ChatProps > = ( ) => {
47
43
const dispatch = useAppDispatch ( ) ;
48
44
49
45
const [ isViewingRawJSON , setIsViewingRawJSON ] = useState ( false ) ;
@@ -58,6 +54,17 @@ export const Chat: React.FC<ChatProps> = ({
58
54
59
55
const threadNewChatSuggested = useAppSelector ( selectThreadNewChatSuggested ) ;
60
56
const messages = useAppSelector ( selectMessages ) ;
57
+
58
+ // can be a selector
59
+ const unCalledTools = React . useMemo ( ( ) => {
60
+ if ( messages . length === 0 ) return false ;
61
+ const last = messages [ messages . length - 1 ] ;
62
+ if ( last . role !== "assistant" ) return false ;
63
+ const maybeTools = last . tool_calls ;
64
+ if ( maybeTools && maybeTools . length > 0 ) return true ;
65
+ return false ;
66
+ } , [ messages ] ) ;
67
+
61
68
const capsForToolUse = useCapsForToolUse ( ) ;
62
69
const { disableInput } = useAgentUsage ( ) ;
63
70
@@ -103,22 +110,21 @@ export const Chat: React.FC<ChatProps> = ({
103
110
return (
104
111
< DropzoneProvider asChild >
105
112
< Flex
106
- style = { style }
107
113
direction = "column"
108
114
flexGrow = "1"
109
115
width = "100%"
110
116
overflowY = "auto"
111
117
justify = "between"
112
118
px = "1"
113
119
>
120
+ { " " }
121
+ { /** change messages? */ }
114
122
< ChatContent
115
123
key = { `chat-content-${ chatId } ` }
116
124
onRetry = { retryFromIndex }
117
125
onStopStreaming = { abort }
118
126
/>
119
-
120
127
{ shouldCheckpointsPopupBeShown && < Checkpoints /> }
121
-
122
128
< AgentUsage />
123
129
< SuggestNewChat
124
130
shouldBeVisible = {
@@ -138,14 +144,11 @@ export const Chat: React.FC<ChatProps> = ({
138
144
</ Card >
139
145
</ Flex >
140
146
) }
141
-
142
147
< ChatForm
143
148
key = { chatId } // TODO: think of how can we not trigger re-render on chatId change (checkboxes)
144
149
onSubmit = { handleSummit }
145
- onClose = { maybeSendToSidebar }
146
150
unCalledTools = { unCalledTools }
147
151
/>
148
-
149
152
< Flex justify = "between" pl = "1" pr = "1" pt = "1" >
150
153
{ /* Two flexboxes are left for the future UI element on the right side */ }
151
154
{ messages . length > 0 && (
0 commit comments