Skip to content

Commit 630695f

Browse files
Merge pull request #94 from microsoft/colbylwilliams/fix-ios-sample-build
swift sample: track MessageAttachment.uri and optional SessionInputRequest.message
1 parent 392051d commit 630695f

5 files changed

Lines changed: 49 additions & 13 deletions

File tree

clients/swift/AHPClient/AHPClient/Views/ChatView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ private struct InputBarPreviewWrapper: View {
721721
</userRequest>
722722
""",
723723
attachments: [
724-
MessageAttachment(type: .file, path: "src/auth.swift", displayName: "auth.swift")
724+
MessageAttachment(type: .file, uri: "src/auth.swift", displayName: "auth.swift")
725725
]
726726
)
727727
ReasoningPartView(part: ReasoningResponsePart(

clients/swift/AHPClient/AHPClient/Views/InputRequestView.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ struct InputRequestView: View {
1313
var body: some View {
1414
VStack(alignment: .leading, spacing: 12) {
1515
// Header
16-
HStack(spacing: 8) {
17-
Image(systemName: "questionmark.bubble")
18-
.foregroundStyle(.blue)
19-
Text(request.message)
20-
.font(.subheadline.weight(.semibold))
21-
.frame(maxWidth: .infinity, alignment: .leading)
16+
if let message = request.message, !message.isEmpty {
17+
HStack(spacing: 8) {
18+
Image(systemName: "questionmark.bubble")
19+
.foregroundStyle(.blue)
20+
Text(message)
21+
.font(.subheadline.weight(.semibold))
22+
.frame(maxWidth: .infinity, alignment: .leading)
23+
}
2224
}
2325

2426
// URL elicitation

clients/swift/AHPClient/AHPClient/Views/RequestPartView.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ struct UserBubble: View {
2121
if let attachments, !attachments.isEmpty {
2222
for (i, a) in attachments.enumerated() {
2323
let icon = attachmentIcon(a.type)
24-
let label = a.displayName ?? a.path
25-
result.append(ContextPill(id: "attachment-\(i)", label: label, icon: icon, content: a.path))
24+
let label = a.displayName ?? a.uri
25+
result.append(ContextPill(id: "attachment-\(i)", label: label, icon: icon, content: a.uri))
2626
}
2727
}
2828
return result
@@ -374,9 +374,9 @@ private struct InputBarPreviewWrapper: View {
374374
UserBubble(
375375
text: "Please review these files",
376376
attachments: [
377-
MessageAttachment(type: .file, path: "src/auth/login.swift", displayName: "login.swift"),
378-
MessageAttachment(type: .directory, path: "src/models/", displayName: "models"),
379-
MessageAttachment(type: .selection, path: "src/app.swift", displayName: "app.swift (selection)")
377+
MessageAttachment(type: .file, uri: "src/auth/login.swift", displayName: "login.swift"),
378+
MessageAttachment(type: .directory, uri: "src/models/", displayName: "models"),
379+
MessageAttachment(type: .selection, uri: "src/app.swift", displayName: "app.swift (selection)")
380380
]
381381
)
382382

@@ -397,7 +397,7 @@ private struct InputBarPreviewWrapper: View {
397397
</userRequest>
398398
""",
399399
attachments: [
400-
MessageAttachment(type: .file, path: "AGENTS.md", displayName: "AGENTS.md")
400+
MessageAttachment(type: .file, uri: "AGENTS.md", displayName: "AGENTS.md")
401401
]
402402
)
403403

clients/swift/AHPClient/AHPClient/Views/ResponsePartView.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,43 @@ struct ResponsePartView: View {
1616
ToolCallPartView(toolCall: tc.toolCall)
1717
case .contentRef(let ref):
1818
ContentRefView(ref: ref)
19+
case .systemNotification(let note):
20+
SystemNotificationPartView(part: note)
1921
}
2022
}
2123
}
2224

25+
// MARK: - SystemNotificationPartView
26+
27+
struct SystemNotificationPartView: View {
28+
let part: SystemNotificationResponsePart
29+
30+
private var text: String {
31+
switch part.content {
32+
case .string(let s): return s
33+
case .markdown(let m): return m
34+
}
35+
}
36+
37+
var body: some View {
38+
Label {
39+
Text(text)
40+
.font(.footnote)
41+
.foregroundStyle(.secondary)
42+
.textSelection(.enabled)
43+
.frame(maxWidth: .infinity, alignment: .leading)
44+
} icon: {
45+
Image(systemName: "info.circle")
46+
.foregroundStyle(.secondary)
47+
}
48+
.padding(10)
49+
.background(
50+
Color.secondary.opacity(0.08),
51+
in: RoundedRectangle(cornerRadius: 10, style: .continuous)
52+
)
53+
}
54+
}
55+
2356
// MARK: - MarkdownPartView
2457

2558
struct MarkdownPartView: View {

clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/ToolCallStateExtensions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ extension ResponsePart {
6969
case .reasoning(let r): return r.id
7070
case .toolCall(let t): return t.toolCall.toolCallId
7171
case .contentRef: return nil
72+
case .systemNotification: return nil
7273
}
7374
}
7475
}

0 commit comments

Comments
 (0)