Skip to content

Commit 2d2f34d

Browse files
committed
resolve comments
1 parent 57f41fe commit 2d2f34d

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/persistence/ConversationPersistenceManager.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,14 @@ public ConversationDataFactory getDataFactory() {
556556
* @param conversationId the conversation ID
557557
* @param subagentTurnId the subagent's turn ID
558558
* @param toolCallId the run_subagent tool call ID from the parent turn
559+
* @return a future that completes when the tool call ID has been set
559560
*/
560-
public void setSubagentToolCallId(String conversationId, String subagentTurnId, String toolCallId) {
561+
public CompletableFuture<Void> setSubagentToolCallId(String conversationId, String subagentTurnId,
562+
String toolCallId) {
561563
if (toolCallId == null || subagentTurnId == null) {
562-
return;
564+
return CompletableFuture.completedFuture(null);
563565
}
564-
CompletableFuture.runAsync(() -> {
566+
return CompletableFuture.runAsync(() -> {
565567
lock.writeLock().lock();
566568
try {
567569
ConversationData conversation = getConversationFromCacheOrLoadFromDisk(conversationId);

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

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

859859
// Cache conversation progress on report
860860
if (persistenceManager != null) {
861-
// Chain setSubagentToolCallId after cacheConversationProgress to avoid race condition
862-
// where the subagent CopilotTurnData hasn't been created yet
861+
final String currentConversationId = this.conversationId;
863862
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-
});
863+
persistenceManager.cacheConversationProgress(currentConversationId, value)
864+
.thenCompose(v -> {
865+
if (StringUtils.isNotBlank(value.getParentTurnId())
866+
&& StringUtils.isNotBlank(subagentToolCallId)) {
867+
return persistenceManager.setSubagentToolCallId(
868+
currentConversationId, value.getTurnId(), subagentToolCallId);
869+
}
870+
return CompletableFuture.completedFuture(null);
871+
});
869872
}
870873
break;
871874
case end:
@@ -1173,7 +1176,7 @@ private void clearCurrentConversation() {
11731176

11741177
@Override
11751178
public void onCancel() {
1176-
// Destroy the conversation on the server to stop any in-progress processing
1179+
// Send conversation/destroy to cancel in-progress turns
11771180
if (StringUtils.isNotBlank(this.conversationId)) {
11781181
CopilotLanguageServerConnection ls = CopilotCore.getPlugin().getCopilotLanguageServer();
11791182
if (ls != null) {

0 commit comments

Comments
 (0)