@@ -65,6 +65,32 @@ function parseAnthropicStreamedToolCalls(
65
65
} ) ;
66
66
}
67
67
68
+ interface InterruptProps {
69
+ interruptValue ?: unknown ;
70
+ isLastMessage : boolean ;
71
+ hasNoAIOrToolMessages : boolean ;
72
+ }
73
+
74
+ function Interrupt ( {
75
+ interruptValue,
76
+ isLastMessage,
77
+ hasNoAIOrToolMessages,
78
+ } : InterruptProps ) {
79
+ return (
80
+ < >
81
+ { isAgentInboxInterruptSchema ( interruptValue ) &&
82
+ ( isLastMessage || hasNoAIOrToolMessages ) && (
83
+ < ThreadView interrupt = { interruptValue } />
84
+ ) }
85
+ { interruptValue &&
86
+ ! isAgentInboxInterruptSchema ( interruptValue ) &&
87
+ isLastMessage ? (
88
+ < GenericInterruptView interrupt = { interruptValue } />
89
+ ) : null }
90
+ </ >
91
+ ) ;
92
+ }
93
+
68
94
export function AssistantMessage ( {
69
95
message,
70
96
isLoading,
@@ -114,64 +140,71 @@ export function AssistantMessage({
114
140
115
141
return (
116
142
< div className = "group mr-auto flex items-start gap-2" >
117
- { isToolResult ? (
118
- < ToolResult message = { message } />
119
- ) : (
120
- < div className = "flex flex-col gap-2" >
121
- { contentString . length > 0 && (
122
- < div className = "py-1" >
123
- < MarkdownText > { contentString } </ MarkdownText >
124
- </ div >
125
- ) }
143
+ < div className = "flex flex-col gap-2" >
144
+ { isToolResult ? (
145
+ < >
146
+ < ToolResult message = { message } />
147
+ < Interrupt
148
+ interruptValue = { threadInterrupt ?. value }
149
+ isLastMessage = { isLastMessage }
150
+ hasNoAIOrToolMessages = { hasNoAIOrToolMessages }
151
+ />
152
+ </ >
153
+ ) : (
154
+ < >
155
+ { contentString . length > 0 && (
156
+ < div className = "py-1" >
157
+ < MarkdownText > { contentString } </ MarkdownText >
158
+ </ div >
159
+ ) }
126
160
127
- { ! hideToolCalls && (
128
- < >
129
- { ( hasToolCalls && toolCallsHaveContents && (
130
- < ToolCalls toolCalls = { message . tool_calls } />
131
- ) ) ||
132
- ( hasAnthropicToolCalls && (
133
- < ToolCalls toolCalls = { anthropicStreamedToolCalls } />
161
+ { ! hideToolCalls && (
162
+ < >
163
+ { ( hasToolCalls && toolCallsHaveContents && (
164
+ < ToolCalls toolCalls = { message . tool_calls } />
134
165
) ) ||
135
- ( hasToolCalls && < ToolCalls toolCalls = { message . tool_calls } /> ) }
136
- </ >
137
- ) }
138
-
139
- { message && (
140
- < CustomComponent
141
- message = { message }
142
- thread = { thread }
143
- />
144
- ) }
145
- { isAgentInboxInterruptSchema ( threadInterrupt ?. value ) &&
146
- ( isLastMessage || hasNoAIOrToolMessages ) && (
147
- < ThreadView interrupt = { threadInterrupt . value } />
166
+ ( hasAnthropicToolCalls && (
167
+ < ToolCalls toolCalls = { anthropicStreamedToolCalls } />
168
+ ) ) ||
169
+ ( hasToolCalls && (
170
+ < ToolCalls toolCalls = { message . tool_calls } />
171
+ ) ) }
172
+ </ >
148
173
) }
149
- { threadInterrupt ?. value &&
150
- ! isAgentInboxInterruptSchema ( threadInterrupt . value ) &&
151
- isLastMessage ? (
152
- < GenericInterruptView interrupt = { threadInterrupt . value } />
153
- ) : null }
154
- < div
155
- className = { cn (
156
- "mr-auto flex items-center gap-2 transition-opacity" ,
157
- "opacity-0 group-focus-within:opacity-100 group-hover:opacity-100" ,
174
+
175
+ { message && (
176
+ < CustomComponent
177
+ message = { message }
178
+ thread = { thread }
179
+ />
158
180
) }
159
- >
160
- < BranchSwitcher
161
- branch = { meta ?. branch }
162
- branchOptions = { meta ?. branchOptions }
163
- onSelect = { ( branch ) => thread . setBranch ( branch ) }
164
- isLoading = { isLoading }
181
+ < Interrupt
182
+ interruptValue = { threadInterrupt ?. value }
183
+ isLastMessage = { isLastMessage }
184
+ hasNoAIOrToolMessages = { hasNoAIOrToolMessages }
165
185
/>
166
- < CommandBar
167
- content = { contentString }
168
- isLoading = { isLoading }
169
- isAiMessage = { true }
170
- handleRegenerate = { ( ) => handleRegenerate ( parentCheckpoint ) }
171
- />
172
- </ div >
173
- </ div >
174
- ) }
186
+ < div
187
+ className = { cn (
188
+ "mr-auto flex items-center gap-2 transition-opacity" ,
189
+ "opacity-0 group-focus-within:opacity-100 group-hover:opacity-100" ,
190
+ ) }
191
+ >
192
+ < BranchSwitcher
193
+ branch = { meta ?. branch }
194
+ branchOptions = { meta ?. branchOptions }
195
+ onSelect = { ( branch ) => thread . setBranch ( branch ) }
196
+ isLoading = { isLoading }
197
+ />
198
+ < CommandBar
199
+ content = { contentString }
200
+ isLoading = { isLoading }
201
+ isAiMessage = { true }
202
+ handleRegenerate = { ( ) => handleRegenerate ( parentCheckpoint ) }
203
+ />
204
+ </ div >
205
+ </ >
206
+ ) }
207
+ </ div >
175
208
</ div >
176
209
) ;
177
210
}
0 commit comments