@@ -39,6 +39,7 @@ import { explicitPromptTarget } from "./explicit-prompt";
3939import { escapeClosesPanel } from "./panel-escape" ;
4040import { markChatListRead , unreadWorkCount } from "./unread-counts" ;
4141import { AgentPanelColumn } from "./panel-layout" ;
42+ import { markerAfterActiveChat , markerAfterActivity } from "./thinking-marker" ;
4243import { concurrencyPath } from "~/utils/pathBuilder" ;
4344
4445function serializePageContext ( pageContext : AgentPageContext ) : string | undefined {
@@ -138,9 +139,7 @@ export function DashboardAgentPanel({
138139 const [ thinkingChatId , setThinkingChatId ] = useState < string | null > ( null ) ;
139140 const handleActivityChange = useCallback (
140141 ( chatId : string , activity : TurnActivity | null ) => {
141- setThinkingChatId ( ( previous ) =>
142- activity !== null ? chatId : previous === chatId ? null : previous
143- ) ;
142+ setThinkingChatId ( ( previous ) => markerAfterActivity ( previous , chatId , activity ) ) ;
144143 onTurnActivityChange ?.( chatId , activity !== null ) ;
145144 } ,
146145 [ onTurnActivityChange ]
@@ -149,6 +148,11 @@ export function DashboardAgentPanel({
149148 // The read POST and its reload can land out of order, so mask the next list.
150149 const justRead = useRef < Set < string > > ( new Set ( ) ) ;
151150
151+ // Ordering-safe: if the new chat has not reported yet, its own report re-sets the marker.
152+ useEffect ( ( ) => {
153+ setThinkingChatId ( ( previous ) => markerAfterActiveChat ( previous , active ?. chatId ) ) ;
154+ } , [ active ?. chatId ] ) ;
155+
152156 const loadHistory = useMemo (
153157 ( ) =>
154158 createCoalescedReload ( async ( ) => {
0 commit comments