Skip to content

Commit af07189

Browse files
ochafikclaude
andcommitted
fix(swift-host): Actually await teardown before removing card
The previous implementation spawned a Task but removed the card immediately without waiting. Now properly awaits the teardown. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b8534d4 commit af07189

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

examples/basic-host-swift/Sources/BasicHostApp/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct ContentView: View {
2424
ForEach(viewModel.activeToolCalls) { toolCall in
2525
ToolCallCard(
2626
toolCallInfo: toolCall,
27-
onRemove: { viewModel.removeToolCall(toolCall) }
27+
onRemove: { Task { await viewModel.removeToolCall(toolCall) } }
2828
)
2929
.id(toolCall.id)
3030
}

examples/basic-host-swift/Sources/BasicHostApp/McpHostViewModel.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,8 @@ class McpHostViewModel: ObservableObject {
239239
}
240240
}
241241

242-
func removeToolCall(_ toolCall: ToolCallInfo) {
243-
Task {
244-
await toolCall.teardown()
245-
}
242+
func removeToolCall(_ toolCall: ToolCallInfo) async {
243+
await toolCall.teardown()
246244
activeToolCalls.removeAll { $0.id == toolCall.id }
247245
}
248246
}

0 commit comments

Comments
 (0)