@@ -164,7 +164,7 @@ export const Chat = ({
164164 setSlashSelectedIndex,
165165 agentSelectedIndex,
166166 setAgentSelectedIndex,
167- streamingAgents,
167+ streamingAgents : rawStreamingAgents ,
168168 focusedAgentId,
169169 setFocusedAgentId,
170170 messages,
@@ -200,6 +200,16 @@ export const Chat = ({
200200 isRetrying : store . isRetrying ,
201201 } ) ) ,
202202 )
203+
204+ // Stabilize streamingAgents reference - only create new Set when content changes
205+ const streamingAgentsKey = useMemo (
206+ ( ) => Array . from ( rawStreamingAgents ) . sort ( ) . join ( ',' ) ,
207+ [ rawStreamingAgents ] ,
208+ )
209+ const streamingAgents = useMemo (
210+ ( ) => rawStreamingAgents ,
211+ [ streamingAgentsKey ] ,
212+ )
203213 const pendingBashMessages = useChatStore ( ( state ) => state . pendingBashMessages )
204214
205215 // Refs for tracking state across renders
@@ -889,7 +899,7 @@ export const Chat = ({
889899 useEffect ( ( ) => {
890900 inputValueRef . current = inputValue
891901 } , [ inputValue ] )
892-
902+
893903 // Report activity on input changes for ad rotation (debounced via separate effect)
894904 const lastReportedActivityRef = useRef < number > ( 0 )
895905 useEffect ( ( ) => {
@@ -976,7 +986,13 @@ export const Chat = ({
976986 reportActivity ( )
977987 const result = await onSubmitPrompt ( inputValue , agentMode )
978988 handleCommandResult ( result )
979- } , [ onSubmitPrompt , inputValue , agentMode , handleCommandResult , reportActivity ] )
989+ } , [
990+ onSubmitPrompt ,
991+ inputValue ,
992+ agentMode ,
993+ handleCommandResult ,
994+ reportActivity ,
995+ ] )
980996
981997 const totalMentionMatches = agentMatches . length + fileMatches . length
982998 const historyNavUpEnabled =
0 commit comments