Skip to content

Commit b46c805

Browse files
ochafikclaude
andcommitted
feat(swift-host): Add visual feedback during teardown
- Show spinner with "Closing..." text when tearing down - Dim card to 50% opacity during teardown - Hide close button while teardown is in progress 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 5277436 commit b46c805

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

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

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ struct ToolCallCard: View {
183183
let onRemove: () -> Void
184184

185185
@State private var isInputExpanded = false
186+
@State private var isTearingDown = false
186187

187188
var body: some View {
188189
VStack(alignment: .leading, spacing: 8) {
@@ -199,24 +200,36 @@ struct ToolCallCard: View {
199200

200201
Spacer()
201202

202-
Text(toolCallInfo.state.description)
203-
.font(.caption2)
204-
.padding(.horizontal, 6)
205-
.padding(.vertical, 2)
206-
.background(stateColor.opacity(0.15))
207-
.foregroundColor(stateColor)
208-
.cornerRadius(4)
203+
if isTearingDown {
204+
HStack(spacing: 4) {
205+
ProgressView().scaleEffect(0.6)
206+
Text("Closing...")
207+
.font(.caption2)
208+
}
209+
.foregroundColor(.secondary)
210+
} else {
211+
Text(toolCallInfo.state.description)
212+
.font(.caption2)
213+
.padding(.horizontal, 6)
214+
.padding(.vertical, 2)
215+
.background(stateColor.opacity(0.15))
216+
.foregroundColor(stateColor)
217+
.cornerRadius(4)
209218

210-
Button { withAnimation { isInputExpanded.toggle() } } label: {
211-
Image(systemName: isInputExpanded ? "chevron.up" : "chevron.down")
212-
.font(.caption)
213-
.foregroundColor(.secondary)
214-
}
219+
Button { withAnimation { isInputExpanded.toggle() } } label: {
220+
Image(systemName: isInputExpanded ? "chevron.up" : "chevron.down")
221+
.font(.caption)
222+
.foregroundColor(.secondary)
223+
}
215224

216-
Button(action: onRemove) {
217-
Image(systemName: "xmark")
218-
.font(.caption)
219-
.foregroundColor(.secondary)
225+
Button {
226+
isTearingDown = true
227+
onRemove()
228+
} label: {
229+
Image(systemName: "xmark")
230+
.font(.caption)
231+
.foregroundColor(.secondary)
232+
}
220233
}
221234
}
222235

@@ -277,6 +290,8 @@ struct ToolCallCard: View {
277290
.padding(10)
278291
.background(Color(UIColor.secondarySystemBackground))
279292
.cornerRadius(10)
293+
.opacity(isTearingDown ? 0.5 : 1.0)
294+
.animation(.easeInOut(duration: 0.2), value: isTearingDown)
280295
}
281296

282297
private var stateColor: Color {

0 commit comments

Comments
 (0)