Skip to content

Commit 57f41fe

Browse files
committed
resolve comments
1 parent 91bbe3e commit 57f41fe

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

  • com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ChatView.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -858,14 +858,14 @@ public void onChatProgress(ChatProgressValue value) {
858858

859859
// Cache conversation progress on report
860860
if (persistenceManager != null) {
861-
persistenceManager.cacheConversationProgress(this.conversationId, value);
862-
863-
// Set subagentToolCallId on subagent CopilotTurnData for restoration
864-
if (StringUtils.isNotBlank(value.getParentTurnId())
865-
&& StringUtils.isNotBlank(this.lastRunSubagentToolCallId)) {
866-
persistenceManager.setSubagentToolCallId(this.conversationId, value.getTurnId(),
867-
this.lastRunSubagentToolCallId);
868-
}
861+
// Chain setSubagentToolCallId after cacheConversationProgress to avoid race condition
862+
// where the subagent CopilotTurnData hasn't been created yet
863+
final String subagentToolCallId = this.lastRunSubagentToolCallId;
864+
persistenceManager.cacheConversationProgress(this.conversationId, value).thenRun(() -> {
865+
if (StringUtils.isNotBlank(value.getParentTurnId()) && StringUtils.isNotBlank(subagentToolCallId)) {
866+
persistenceManager.setSubagentToolCallId(this.conversationId, value.getTurnId(), subagentToolCallId);
867+
}
868+
});
869869
}
870870
break;
871871
case end:

0 commit comments

Comments
 (0)