OGAM icon indicating copy to clipboard operation
OGAM copied to clipboard

Add selectable text in chat responses

Open frankvalenziano opened this issue 8 months ago • 1 comments

Summary

Update the chat output to handle selecting and copying individual parts of the text.

Problem / Motivation

Right now the only option is to long press the AI's output and copy the entire response. It would be beneficial to be able to select targeted lines or words for copying.

Proposed Solution

Implement UITextView using the below method suggested by the LLM:

import SwiftUI import UIKit

struct SelectableTextView: UIViewRepresentable { let text: String

func makeUIView(context: Context) -> UITextView {
    let textView = UITextView()
    textView.backgroundColor = .clear
    textView.isEditable = false
    textView.isSelectable = true
    textView.isScrollEnabled = false // Allows the bubble to resize naturally
    textView.textContainerInset = .zero
    textView.textContainer.lineFragmentPadding = 0
    textView.font = UIFont.preferredFont(forTextStyle: .body)
    
    // Ensure the view doesn't hog space in a List/VStack
    textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
    return textView
}

func updateUIView(_ uiView: UITextView, context: Context) {
    uiView.text = text
}

}

Platform

  • [ ] Android
  • [X] iOS
  • [ ] Both

frankvalenziano avatar Mar 27 '26 12:03 frankvalenziano

Reasonable, putting this to my backlog.

Ganeshship avatar Apr 10 '26 04:04 Ganeshship