Repository Public MIT
1{2 "accessibility" : [3 "The role is written above the bubble and read with the text (\"Assistant, …\"): it never depends on colour or side.",4 "The text is selectable (`textSelection(.enabled)`); copy is also in the context menu.",5 "While streaming the element has the \"updates frequently\" trait and the indicator has a text label; its symbol animation stops with Reduce Motion.",6 "Failure is a symbol plus text. The copy button is labelled \"Copy\" / \"Copied\" and has a 44-point target on iOS.",7 "Alignment uses leading and trailing, so the layout mirrors in right-to-left languages; right-to-left text inside a bubble keeps its natural direction."8 ],9 "category" : "ai",10 "changelog" : [11 {12 "changes" : [13 "Release 1.1.0: see the project changelog."14 ],15 "date" : "2026-12-03",16 "version" : "1.1.0"17 },18 {19 "changes" : [20 "Initial release."21 ],22 "date" : "2026-12-02",23 "version" : "1.0.0"24 }25 ],26 "dependencies" : [27 {28 "id" : "glass-foundation",29 "version" : "1.1.0"30 }31 ],32 "description" : "Message bubble with role, streaming state, text selection and copy.",33 "examples" : [34 {35 "code" : "import SwiftUI\nimport SPGlassKit\n\npublic struct GlassChatBubbleExample: GlassExample {\n public static let componentID = \"glass-chat-bubble\"\n\n /// Fictitious conversation: no model produced these messages.\n @State private var messages = [\n GlassChatMessage(id: \"1\", role: .system, text: \"Sample data — this conversation is fictitious.\"),\n GlassChatMessage(id: \"2\", role: .user, text: \"Can you summarise the sample quarterly note in two sentences? 🙂\"),\n GlassChatMessage(id: \"3\", role: .assistant, text: \"Certainly. The sample note reports steady demand and a slightly lower margin. It expects the next quarter to look similar, with one new product line.\"),\n GlassChatMessage(id: \"4\", role: .tool, text: \"{\\n \\\"tool\\\": \\\"sample_lookup\\\",\\n \\\"rows\\\": 3,\\n \\\"a_very_long_key_without_any_space_to_test_wrapping_inside_the_bubble\\\": true\\n}\"),\n GlassChatMessage(id: \"4b\", role: .assistant, text: \"The note says:\\n> Demand stayed steady over the quarter.\\nAs a filter:\\n```swift\\nlet steady = notes.filter { $0.demand == .steady }\\n```\"),\n GlassChatMessage(id: \"5\", role: .user, text: \"هل يمكنك كتابة الخلاصة بالعربية؟\"),\n GlassChatMessage(id: \"6\", role: .assistant, text: \"The sample answer is still being writ\", state: .streaming),\n GlassChatMessage(id: \"7\", role: .assistant, text: \"\", state: .streaming),\n GlassChatMessage(id: \"8\", role: .assistant, text: \"A partial sample answer that stopped.\", state: .failed(reason: \"Sample failure: the connection was interrupted.\")),\n ]\n @State private var lastCopied = \"Nothing copied yet\"\n @State private var retryCount = 0\n\n public init() {}\n\n public var body: some View {\n ScrollView {\n LazyVStack(spacing: 12) {\n ForEach(messages) { message in\n GlassChatBubble(\n message,\n usesMonospacedFont: message.role == .tool,\n onCopy: { text in lastCopied = \"Copied \\(text.count) characters (kept inside the example)\" },\n onRetry: { retryCount += 1 }\n )\n }\n Text(\"\\(lastCopied) · retried \\(retryCount) times\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n .padding()\n }\n }\n}\n\n#Preview(\"GlassChatBubble\") { GlassChatBubbleExample().glassTheme(.aurora) }\n",36 "title" : "GlassChatBubble example"37 }38 ],39 "files" : [40 {41 "bytes" : 18557,42 "path" : "AI/AI/GlassChatBubble.swift",43 "sha256" : "e3843a61610b922c9fba6bdfa06257893cb8295a335b388c140d57a3f13dd98c"44 }45 ],46 "frameworks" : [4748 ],49 "id" : "glass-chat-bubble",50 "kind" : "content-component",51 "license" : "MIT",52 "minimumOS" : {53 "iOS" : "26.0",54 "iPadOS" : "26.0",55 "macOS" : "26.0"56 },57 "name" : "GlassChatBubble",58 "platforms" : [59 "iOS",60 "iPadOS",61 "macOS"62 ],63 "schemaVersion" : 1,64 "sha256" : "fe5aee4fd9804381128477eff44126bf3ee3702820146be5ddb417af778ee647",65 "symbols" : [66 "GlassChatRole",67 "GlassChatMessageState",68 "GlassChatMessage",69 "GlassChatBubbleMetrics",70 "GlassChatBlock",71 "GlassChatBlocks",72 "GlassChatBubble"73 ],74 "version" : "1.1.0"75}76