Skip to content

Commit bb0e144

Browse files
Merge remote-tracking branch 'origin/t3code/rebuild-mobile-app-swift' into fix/issue-14691
2 parents 6b0ce9b + f021c92 commit bb0e144

61 files changed

Lines changed: 4504 additions & 991 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/swift-ios/App/NativeFeatureClient.swift‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7406,7 +7406,10 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging,
74067406
wireID: requestID
74077407
)
74087408
case "approval.resolved":
7409-
cache.closedApprovalRequestIDs.insert(requestID)
7409+
// A V2 row re-renders from current state, and Codex sends the item
7410+
// before its runtime request. Latching that first render would hide
7411+
// the request once it turns pending.
7412+
if activity.v2Timeline == nil { cache.closedApprovalRequestIDs.insert(requestID) }
74107413
cache.approvals.removeAll { $0.id == uiRequestID }
74117414
approvalRoutes[uiRequestID] = nil
74127415
case "provider.approval.respond.failed":
@@ -7455,7 +7458,8 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging,
74557458
wireID: requestID
74567459
)
74577460
case "user-input.resolved":
7458-
cache.closedUserInputRequestIDs.insert(requestID)
7461+
// V2 rows are current state, not a log; see applyApprovalActivity.
7462+
if activity.v2Timeline == nil { cache.closedUserInputRequestIDs.insert(requestID) }
74597463
cache.userInputs.removeAll { $0.id == uiRequestID }
74607464
inputRoutes[uiRequestID] = nil
74617465
case "provider.user-input.respond.failed":

‎apps/swift-ios/App/Platform/PlatformNotifications.swift‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,13 @@ final class PlatformNotificationService: NSObject, UNUserNotificationCenterDeleg
304304

305305
@MainActor
306306
final class T3PlatformAppDelegate: NSObject, UIApplicationDelegate {
307+
func application(
308+
_ application: UIApplication,
309+
supportedInterfaceOrientationsFor window: UIWindow?
310+
) -> UIInterfaceOrientationMask {
311+
PlatformWorkspaceOrientation.supportedOrientations(in: window)
312+
}
313+
307314
func application(
308315
_ application: UIApplication,
309316
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil

‎apps/swift-ios/App/Platform/PlatformRootView.swift‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ struct PlatformRootView: View {
4747
.onOpenURL { url in
4848
handle(url: url, letOnboardingConfirmConnection: true)
4949
}
50+
#if DEBUG
51+
// Benchmarks open a thread without UI automation, which would keep
52+
// the accessibility tree busy and skew the timing.
53+
.task {
54+
guard let link = ProcessInfo.processInfo.environment["T3_DEBUG_OPEN_URL"],
55+
let url = URL(string: link) else { return }
56+
try? await Task.sleep(for: .seconds(4))
57+
handle(url: url, letOnboardingConfirmConnection: false)
58+
}
59+
#endif
5060
.task(id: subscriptionUsageKey) {
5161
guard subscriptionUsageKey.isActive else { return }
5262
await subscriptionUsage.observe(
@@ -200,8 +210,9 @@ struct PlatformRootView: View {
200210
private var presentedIncomingShare: Binding<T3IncomingShareEnvelope?> {
201211
Binding(
202212
get: {
203-
guard !incomingShareProjects.isEmpty else { return nil }
204-
return incomingShareCoordinator.pendingEnvelope
213+
guard let envelope = incomingShareCoordinator.pendingEnvelope,
214+
!DailyUXCreationContext.projects(in: model.snapshot).isEmpty else { return nil }
215+
return envelope
205216
},
206217
set: { value in
207218
guard value == nil, importedShareProjectID == nil else { return }
@@ -292,7 +303,7 @@ struct PlatformRootView: View {
292303

293304
private func refreshIncomingShares() {
294305
guard !model.isLoading else { return }
295-
let hasProjects = !incomingShareProjects.isEmpty
306+
let hasProjects = !DailyUXCreationContext.projects(in: model.snapshot).isEmpty
296307
Task { @MainActor in
297308
if await incomingShareCoordinator.refresh(hasProjects: hasProjects) {
298309
incomingShareNeedsProject = true
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import SwiftUI
2+
import UIKit
3+
4+
extension EnvironmentValues {
5+
@Entry var featureWorkspaceFoldSidebarWidth: CGFloat? = nil
6+
}
7+
8+
@MainActor
9+
enum PlatformWorkspaceOrientation {
10+
private static let hingeWindows = NSHashTable<UIWindow>.weakObjects()
11+
12+
static func allowHingeOrientations(in window: UIWindow) {
13+
guard !hingeWindows.contains(window) else { return }
14+
hingeWindows.add(window)
15+
window.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
16+
}
17+
18+
static func supportedOrientations(in window: UIWindow?) -> UIInterfaceOrientationMask {
19+
if window?.traitCollection.userInterfaceIdiom == .pad { return .all }
20+
return window.map { hingeWindows.contains($0) } == true ? .allButUpsideDown : .portrait
21+
}
22+
}
23+
24+
/// Keeps hardware capability separate from layout size, which changes on either display.
25+
struct PlatformWorkspaceGeometryObserver: UIViewRepresentable {
26+
let onFoldSidebarWidthChange: (CGFloat?) -> Void
27+
28+
func makeUIView(context: Context) -> GeometryView {
29+
GeometryView(onFoldSidebarWidthChange: onFoldSidebarWidthChange)
30+
}
31+
32+
func updateUIView(_ view: GeometryView, context: Context) {
33+
view.onFoldSidebarWidthChange = onFoldSidebarWidthChange
34+
}
35+
36+
final class GeometryView: UIView {
37+
var onFoldSidebarWidthChange: (CGFloat?) -> Void
38+
private var hasHinge = false
39+
private var lastFoldSidebarWidth: CGFloat?
40+
41+
init(onFoldSidebarWidthChange: @escaping (CGFloat?) -> Void) {
42+
self.onFoldSidebarWidthChange = onFoldSidebarWidthChange
43+
super.init(frame: .zero)
44+
isUserInteractionEnabled = false
45+
#if canImport(UIKit, _version: 9127.0.85)
46+
if #available(iOS 27.1, *) {
47+
addInteraction(UIHingeInteraction { [weak self] _, update in
48+
guard let self else { return }
49+
// Capability survives a fold and temporary window detachment.
50+
hasHinge = hasHinge || update.hinge != nil
51+
updateGeometry()
52+
})
53+
}
54+
#endif
55+
}
56+
57+
@available(*, unavailable)
58+
required init?(coder: NSCoder) { nil }
59+
60+
override func didMoveToWindow() {
61+
super.didMoveToWindow()
62+
updateGeometry()
63+
}
64+
65+
override func layoutSubviews() {
66+
super.layoutSubviews()
67+
updateGeometry()
68+
}
69+
70+
private func updateGeometry() {
71+
guard let window else { return }
72+
if hasHinge { PlatformWorkspaceOrientation.allowHingeOrientations(in: window) }
73+
var foldSidebarWidth: CGFloat?
74+
#if canImport(UIKit, _version: 9127.0.85)
75+
if #available(iOS 27.1, *) {
76+
for region in reservedRegions(kind: .division) where region.isActive {
77+
let frame = region.frame.intersection(bounds)
78+
guard !frame.isNull, frame.height >= bounds.height / 2 else { continue }
79+
let leading = effectiveUserInterfaceLayoutDirection == .rightToLeft
80+
? bounds.maxX - frame.maxX : frame.minX - bounds.minX
81+
let trailing = bounds.width - leading - frame.width
82+
let rtl = effectiveUserInterfaceLayoutDirection == .rightToLeft
83+
let leadingInset = rtl ? safeAreaInsets.right : safeAreaInsets.left
84+
let trailingInset = rtl ? safeAreaInsets.left : safeAreaInsets.right
85+
guard leading - leadingInset >= T3Metrics.minimumSidebarWidth,
86+
trailing - trailingInset >= 320 else { continue }
87+
foldSidebarWidth = leading
88+
break
89+
}
90+
}
91+
#endif
92+
guard lastFoldSidebarWidth != foldSidebarWidth else { return }
93+
lastFoldSidebarWidth = foldSidebarWidth
94+
// Layout may run during a SwiftUI update. Publish only the final reservation.
95+
DispatchQueue.main.async { [weak self] in
96+
guard let self, lastFoldSidebarWidth == foldSidebarWidth else { return }
97+
onFoldSidebarWidthChange(foldSidebarWidth)
98+
}
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)