@devries-cameron20 / t3code Mirror · read-only / commits / 9962e6986d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 21:45 UTC

fix(mobile): read display scale and width from the view's scene, not UIScreen.main (#12050)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

Julius Marminge committed Oct 1, 2026 at 10:51 UTC 9962e6986db68cd5537d23153e7898d6b3696b85
3 files changed +16 -5
apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift
+9 -1
@@ -436,6 +436,7 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
436 private var iconImages: [String: UIImage] = [:]
437 private var pendingIconUris = Set<String>()
438 private var tokensNeedRebuild = false
439 + private var chipsNeedMeasuredWidth = false
440
441 let onComposerChange = EventDispatcher()
442 let onComposerSelectionChange = EventDispatcher()
@@ -571,6 +572,10 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
572 public override func layoutSubviews() {
573 super.layoutSubviews()
574 textView.frame = bounds
575 + if chipsNeedMeasuredWidth, bounds.width > 0 {
576 + chipsNeedMeasuredWidth = false
577 + applyControlledDocument(force: true)
578 + }
579 let placeholderX = textView.textContainerInset.left + textView.textContainer.lineFragmentPadding
580 let placeholderY = textView.textContainerInset.top
581 let placeholderWidth = max(
@@ -970,7 +975,10 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
975 // `maximumWidth` does, so the chip always fits the line it sits on.
976 let availableWidth = textView.textContainer.size.width > 0
977 ? textView.textContainer.size.width - textView.textContainer.lineFragmentPadding * 2
973 - : UIScreen.main.bounds.width
978 + : (textView.window?.bounds.width ?? bounds.width)
979 + if availableWidth <= 0 {
980 + chipsNeedMeasuredWidth = true
981 + }
982 let maximumLabelWidth = max(chipFontSize * 3, availableWidth - padding * 2 - iconWidth - iconGap)
983 paragraph.lineBreakMode = .byTruncatingMiddle
984 attributedLabel.addAttribute(
apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift
+2 -2
@@ -1923,7 +1923,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
1923 theme.headerBackground.setFill()
1924 context.fill(cardRect)
1925
1926 - let hairline = 1 / UIScreen.main.scale
1926 + let hairline = 1 / traitCollection.displayScale
1927 theme.border.setFill()
1928 context.fill(CGRect(x: cardRect.minX, y: cardRect.maxY - hairline, width: cardRect.width, height: hairline))
1929
@@ -1982,7 +1982,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
1982 theme.background.setFill()
1983 context.fill(rect)
1984
1985 - let hairline = 1 / UIScreen.main.scale
1985 + let hairline = 1 / traitCollection.displayScale
1986 theme.border.withAlphaComponent(0.65).setFill()
1987 context.fill(CGRect(x: 0, y: rect.maxY - hairline, width: rect.width, height: hairline))
1988
apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift
+5 -2
@@ -315,7 +315,8 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate {
315
316 applyTheme()
317 clipsToBounds = true
318 - contentScaleFactor = UIScreen.main.scale
318 + // The real scale arrives with the window; layoutSubviews corrects it.
319 + contentScaleFactor = traitCollection.displayScale
320
321 terminalViewport.clipsToBounds = true
322 terminalViewport.contentScaleFactor = contentScaleFactor
@@ -677,7 +678,9 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate {
678 }
679
680 private func updateContentScale() {
680 - let scale = window?.screen.scale ?? UIScreen.main.scale
681 + // The trait collection follows the scene the view is in, which matters once
682 + // iPhone apps run resizable and on external displays; UIScreen.main does not.
683 + let scale = traitCollection.displayScale
684 if contentScaleFactor != scale {
685 contentScaleFactor = scale
686 }