fix(swift-ios): select across response blocks and copy as Markdown #11297
Closedmackinleysmith(GitHub profile, opens in a new tab)wants to merge 250+ commits into
t3code/rebuild-mobile-app-swift fromrefs/pull/11297/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/swift-ios/Features/Chat/MarkdownMessageView.swift line 282Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -239,18 +240,11 @@239240 let blocks: [MarkdownRenderedBlock]241+ var continuousSelection = false240242 let selectionContext: MarkdownSelectionContext241243 let imageContext: MarkdownImageContext?242244 var spacing: CGFloat = 12243245 var textColor: MarkdownTextColor = .primary244246245247 var body: some View {246248 VStack(alignment: .leading, spacing: spacing) {247- ForEach(blocks.indices, id: \.self) { index in248- // Unchanged blocks share inline runs by reference across249- // streaming revisions, so equatable comparison skips their250- // body and layout entirely; only the changed tail re-renders.251- MarkdownBlockView(252- block: blocks[index],253- selectionContext: selectionContext,254- imageContext: imageContext,255- textColor: textColor256- )249+ ForEach(selectionGroups, id: \.lowerBound) { range in250+ if continuousSelection, MarkdownContinuousSelection.supports(blocks[range.lowerBound]) {apps/swift-ios/Features/Chat/MarkdownMessageView.swift line 1251OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1063,0 +1231,21 @@1231+ skills: [FeatureProviderSkill] = [],1232+ traits: UITraitCollection = .current1233+ ) -> NSAttributedString {1234+ let result = NSMutableAttributedString()1235+ for paragraph in paragraphs(blocks) {1236+ let text = NSMutableAttributedString(attributedString: MarkdownSelectableTextAttributes.make(1237+ from: paragraph.inline,1238+ lineSpacing: paragraph.lineSpacing,1239+ foregroundColor: foregroundColor,1240+ dynamicTypeSize: dynamicTypeSize,1241+ skills: skills,1242+ traits: traits1243+ ))1244+ if !paragraph.prefix.isEmpty {1245+ text.insert(NSAttributedString(string: paragraph.prefix, attributes: [1246+ .font: MarkdownInlineStyle.body.uiFont(dynamicTypeSize: dynamicTypeSize),1247+ .foregroundColor: foregroundColor,1248+ .markdownCopyDecoration: true,1249+ ]), at: 0)1250+ }1251+ guard text.length > 0 else { continue }
- @@ -836,6 +871,20 @@871+ }872+873+ init(874+ prose: [MarkdownRenderedBlock],875+ selectionContext: MarkdownSelectionContext,876+ textColor: MarkdownTextColor877+ ) {878+ self.content = .prose(prose)879+ self.selectionContext = selectionContext880+ self.lineSpacing = 4881+ self.textColor = textColor882+ self.wrapsLines = true883+ }884+836885 func makeCoordinator() -> Coordinator {837886 Coordinator()838887 }839888840889 func makeUIView(context: Context) -> UITextView {841- let textView = FeatureInlineSkillTextView()890+ let textView = MarkdownSelectionTextView(frame: .zero, textContainer: nil)
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed