Your home as a live 3D model in the Mac menu bar and on iPhone — lights and ACs via Smart Life, Home Assistant, Philips Hue and Apple Home.
iPhone Duo: the open screen, split at the fold (1.2.0, build 11)
0xProbability0998fffa2e39
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex eaa0870..17c26d4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,19 @@What changed in each release of House Control. The Mac app is on[Releases](https://github.com/0xProbabillity/house-control/releases); the iPhone app is on the App Store and TestFlight.+## 1.2.0 — in TestFlight++### iPhone++- **iPhone Duo.** Open, the app fills the inner display (not a phone-sized column in the middle of it): the home in 3D on one half, scenes, rooms and+ devices on the other. Half-folded like a book it breaks exactly at the fold; standing like a laptop, the model+ is on the upper half and the controls on the lower one. Held upright and flat, tiles go three to a row. Opening+ the phone plays the camera sweep and the lights coming on. See [iPhone Duo](README.md#iphone-duo).+- **The floor plan editor on a wide screen** keeps the plan on the left and the details of what is picked on the+ right; **Add** and **Items** open as cards in the middle.+- **Settings, connections and the welcome screen** keep a readable width on a wide screen. On a short screen (the+ Duo's outer one) the welcome screen tightens up, and scrolls where even that does not fit.+## 1.1.0 — 2026-10-22### iPhonediff --git a/README.md b/README.mdindex dc6c035..37b5d7a 100644--- a/README.md+++ b/README.md@@ -230,6 +230,37 @@ apps, so it stays out of the App Store edition entirely: its code lives in its othat only the Smart Life edition and the Mac app link, and `build-ios.sh` refuses an App Store archive that contains it.The two editions are separate apps (bundle id and App Group), so both can sit on one phone.+### iPhone Duo++Closed, the Duo runs the app like any iPhone. Open it and the app spreads across the inner display, one half each,+so the 3D model and the controls are never on top of each other:++- **Open flat, held sideways:** the home in 3D on the left half, scenes, rooms and devices on the right. A lamp or+ AC opens its controls on the right half while the model turns to it on the left.+- **Half-folded like a book:** the same, broken exactly at the fold. Nothing sits across the crease.+- **Half-folded like a laptop on a table:** the model stands on the upper half, facing you, and the controls lie on+ the lower half, under your thumb — a small home hub for the desk or the bedside.+- **Open flat, held upright:** the model above the crease, the controls below it, tiles three to a row.+- **Opening the phone** plays the camera sweep and the lights coming on, as when the app starts.+- **The floor plan editor** keeps the plan on the left half and the details of what you picked on the right,+ instead of in a sheet over the plan. Settings and the connection screens stay at a readable width.+- **Beside another app** the app can be resized, so it takes the shape it is given; narrower than 720 points, it+ stacks as on any iPhone.++To try it, run the app on the iPhone Duo simulator (Xcode 27.1 or newer) and fold it with the **Closed**,+**Partially Open** and **Open** buttons under the device in Device Hub:++```bash+DEVICE="iPhone Duo" ./scripts/ios-sim.sh+```++In a browser, `?platform=ios&fold=455,0,41,669` at 951×669 stands in for a Duo half-folded like a book, and+`fold=0,455,669,41` at 669×951 for one standing like a laptop.++The fold comes from the system's division region (`reservedRegions(kind: .division)`). The iPhone Duo simulator in+Xcode 27.1 reports none, so where there is none at all and the hinge says half open, the app takes the fold to run+down the middle of the screen ([FoldWebView.swift](ios/Sources/FoldWebView.swift)).+### Sync with a Mac or PCOptional. Pair a Mac or a Windows PC and your floor plan — rooms, furniture, lamps, scenes and the links to realdiff --git a/ios/Config/Base.xcconfig b/ios/Config/Base.xcconfigindex 39c3c15..b4c0e9e 100644--- a/ios/Config/Base.xcconfig+++ b/ios/Config/Base.xcconfig@@ -1,6 +1,6 @@// Version of the iPhone app. CURRENT_PROJECT_VERSION is the build number TestFlight sees.-MARKETING_VERSION = 1.1.0-CURRENT_PROJECT_VERSION = 10+MARKETING_VERSION = 1.2.0+CURRENT_PROJECT_VERSION = 11CODE_SIGN_STYLE = Automaticdiff --git a/ios/Sources/ConnectionViews.swift b/ios/Sources/ConnectionViews.swiftindex ec81093..2f8d2b2 100644--- a/ios/Sources/ConnectionViews.swift+++ b/ios/Sources/ConnectionViews.swift@@ -30,6 +30,7 @@ struct HomeAssistantView: View {.padding(.horizontal, 18).padding(.top, 8).padding(.bottom, 32)+ .readableWidth().animation(.spring(response: 0.45, dampingFraction: 0.85), value: model.homeAssistantName)}.scrollDismissesKeyboard(.interactively)@@ -236,6 +237,7 @@ struct HueView: View {.padding(.horizontal, 18).padding(.top, 8).padding(.bottom, 32)+ .readableWidth().animation(.spring(response: 0.45, dampingFraction: 0.85), value: model.hueName).animation(.spring(response: 0.45, dampingFraction: 0.85), value: pairing != nil)}diff --git a/ios/Sources/DevicesView.swift b/ios/Sources/DevicesView.swiftindex b47ff5a..6fe791f 100644--- a/ios/Sources/DevicesView.swift+++ b/ios/Sources/DevicesView.swift@@ -86,6 +86,7 @@ struct DevicesView: View {.padding(.horizontal, 18).padding(.top, 8).padding(.bottom, 32)+ .readableWidth()}.background(Theme.background).navigationTitle("Devices")diff --git a/ios/Sources/FoldWebView.swift b/ios/Sources/FoldWebView.swiftnew file mode 100644index 0000000..a62c0db--- /dev/null+++ b/ios/Sources/FoldWebView.swift@@ -0,0 +1,67 @@+import UIKit+import WebKit++/// The web view, telling the page where a folding screen (iPhone Duo) breaks in two, so the+/// 3D home and the controls each keep to one half instead of sitting across the crease+/// (web/src/ui/layout.js). The fold is the screen's active division region: there only while+/// the device is half folded. UIKit lays the view out again when the regions change, so they+/// are read on every layout, and on every hinge update for good measure.+final class FoldWebView: WKWebView {+ /// The active fold in the view's coordinates (page px), or nil while the screen is flat.+ var onFold: ((CGRect?) -> Void)?+ private(set) var fold: CGRect?+ private var hinge: UIInteraction?+ private var halfOpen = false++ /// How wide the crease is taken to be where the system names none (below).+ private static let crease: CGFloat = 24++ override func layoutSubviews() {+ super.layoutSubviews()+ readFold()+ }++ override func didMoveToWindow() {+ super.didMoveToWindow()+ #if compiler(>=6.4)+ if #available(iOS 27.1, *), window != nil, hinge == nil {+ let interaction = UIHingeInteraction { [weak self] _, update in+ self?.halfOpen = update.hinge?.status == .partiallyOpen+ self?.readFold()+ }+ addInteraction(interaction)+ hinge = interaction+ }+ #endif+ readFold()+ }++ private func readFold() {+ var next: CGRect?+ #if compiler(>=6.4)+ if #available(iOS 27.1, *) {+ let regions = reservedRegions(kind: .division, options: .includeInactive)+ next = regions.filter(\.isActive).map(\.frame).map { $0.intersection(bounds) }+ .first { !$0.isNull && !$0.isEmpty }+ .map(\.integral)+ // A system that names no division at all, active or not, while the hinge says half+ // open (the iPhone Duo simulator does this): the crease is down the screen's middle.+ if regions.isEmpty, halfOpen { next = middleOfScreen() }+ }+ #endif+ guard next != fold else { return }+ fold = next+ onFold?(next)+ }++ private func middleOfScreen() -> CGRect? {+ guard let screen = window?.windowScene?.screen else { return nil }+ let size = screen.bounds.size+ let centre = convert(CGPoint(x: size.width / 2, y: size.height / 2), from: screen.coordinateSpace)+ guard bounds.insetBy(dx: Self.crease, dy: Self.crease).contains(centre) else { return nil }+ let half = Self.crease / 2+ return size.width > size.height+ ? CGRect(x: centre.x - half, y: 0, width: Self.crease, height: bounds.height).integral+ : CGRect(x: 0, y: centre.y - half, width: bounds.width, height: Self.crease).integral+ }+}diff --git a/ios/Sources/HomeWeb.swift b/ios/Sources/HomeWeb.swiftindex 06f3545..2ddcc90 100644--- a/ios/Sources/HomeWeb.swift+++ b/ios/Sources/HomeWeb.swift@@ -40,7 +40,8 @@ final class HomeWeb: NSObject, WKScriptMessageHandler, WKNavigationDelegate {/// ("Invalid parameter not satisfying: targetNode").var webView: WKWebView {if let view { return view }- let webView = WKWebView(frame: .zero, configuration: configuration)+ let webView = FoldWebView(frame: .zero, configuration: configuration)+ webView.onFold = { [weak self] _ in self?.sendFold() }webView.navigationDelegate = selfwebView.isOpaque = falsewebView.backgroundColor = UIColor(Theme.background)@@ -110,6 +111,16 @@ final class HomeWeb: NSObject, WKScriptMessageHandler, WKNavigationDelegate {view?.evaluateJavaScript(WebJSON.call(function, args), completionHandler: nil)}+ /// Where an iPhone Duo's screen folds, for the page to lay itself out around (FoldWebView).+ private func sendFold() {+ guard ready, mode == "panel" else { return }+ if let fold = (view as? FoldWebView)?.fold {+ call("setFold", ["x": fold.minX, "y": fold.minY, "width": fold.width, "height": fold.height])+ } else {+ call("setFold", NSNull())+ }+ }+func reply(to message: [String: Any], _ result: Any) {guard let id = message["callId"] as? Int else { return }call("reply", id, result)@@ -125,6 +136,7 @@ final class HomeWeb: NSObject, WKScriptMessageHandler, WKNavigationDelegate {if body["type"] as? String == "ready" {ready = trueretries = 0+ if (view as? FoldWebView)?.fold != nil { sendFold() }}onMessage?(body)}diff --git a/ios/Sources/NewHomeView.swift b/ios/Sources/NewHomeView.swiftindex b37bba1..dbd8baa 100644--- a/ios/Sources/NewHomeView.swift+++ b/ios/Sources/NewHomeView.swift@@ -73,6 +73,7 @@ struct NewHomeView: View {.padding(.horizontal, 18).padding(.top, 8).padding(.bottom, 32)+ .readableWidth()}.scrollDismissesKeyboard(.interactively).background(Theme.background)diff --git a/ios/Sources/PairingView.swift b/ios/Sources/PairingView.swiftindex a4762f7..d9aff7d 100644--- a/ios/Sources/PairingView.swift+++ b/ios/Sources/PairingView.swift@@ -34,6 +34,7 @@ struct PairingView: View {.padding(.horizontal, 18).padding(.top, 8).padding(.bottom, 32)+ .readableWidth().animation(.spring(response: 0.5, dampingFraction: 0.85), value: paired).animation(.easeOut(duration: 0.2), value: rejected)}diff --git a/ios/Sources/RootView.swift b/ios/Sources/RootView.swiftindex 4ba79ae..b038ce3 100644--- a/ios/Sources/RootView.swift+++ b/ios/Sources/RootView.swift@@ -55,6 +55,7 @@ private struct BannerView: View {.background(.ultraThinMaterial, in: Capsule()).overlay(Capsule().strokeBorder(Theme.line)).shadow(color: .black.opacity(0.45), radius: 18, y: 8)+ .frame(maxWidth: 520).padding(.horizontal, 20).accessibilityElement(children: .combine).accessibilityAddTraits(.isStaticText)diff --git a/ios/Sources/SettingsView.swift b/ios/Sources/SettingsView.swiftindex 6f8fab1..ee70448 100644--- a/ios/Sources/SettingsView.swift+++ b/ios/Sources/SettingsView.swift@@ -29,6 +29,7 @@ struct SettingsView: View {.padding(.horizontal, 18).padding(.top, 8).padding(.bottom, 32)+ .readableWidth()}.background(Theme.background).navigationTitle("Settings")diff --git a/ios/Sources/SmartLifeView.swift b/ios/Sources/SmartLifeView.swiftindex 7b58cfc..d2e1d97 100644--- a/ios/Sources/SmartLifeView.swift+++ b/ios/Sources/SmartLifeView.swift@@ -36,6 +36,7 @@ struct SmartLifeView: View {.padding(.horizontal, 18).padding(.top, 8).padding(.bottom, 32)+ .readableWidth().animation(.spring(response: 0.5, dampingFraction: 0.85), value: login).animation(.spring(response: 0.5, dampingFraction: 0.85), value: model.smartLifeConnected)}diff --git a/ios/Sources/Theme.swift b/ios/Sources/Theme.swiftindex 6850978..94fc86b 100644--- a/ios/Sources/Theme.swift+++ b/ios/Sources/Theme.swift@@ -16,6 +16,14 @@ enum Theme {static let red = Color(red: 1, green: 0.47, blue: 0.43)}+extension View {+ /// Keeps a screen's content at a hand's width, centred, where the screen is wider than a+ /// phone's (iPhone Duo open): settings rows stretched across 900 points read badly.+ func readableWidth(_ width: CGFloat = 620) -> some View {+ frame(maxWidth: width).frame(maxWidth: .infinity)+ }+}+/// A rounded glass panel: the container of every settings group.struct Card<Content: View>: View {var padding: CGFloat = 0diff --git a/ios/Sources/WelcomeView.swift b/ios/Sources/WelcomeView.swiftindex 2222426..d234fc9 100644--- a/ios/Sources/WelcomeView.swift+++ b/ios/Sources/WelcomeView.swift@@ -5,31 +5,49 @@ struct WelcomeView: View {@Environment(AppModel.self) private var modelvar body: some View {+ // A short screen (iPhone Duo closed) drops the icon and tightens up; one shorter still+ // (iPhone Duo open in landscape) scrolls what does not fit.+ ViewThatFits(in: .vertical) {+ content(compact: false)+ content(compact: true)+ ScrollView { content(compact: true) }+ }+ .presentationDetents([.large])+ .presentationBackground(Theme.background)+ .presentationDragIndicator(.visible)+ .preferredColorScheme(.dark)+ .interactiveDismissDisabled(false)+ .onDisappear { UserDefaults.standard.set(true, forKey: "welcomed") }+ }++ private func content(compact: Bool) -> some View {VStack(spacing: 0) {- Image(systemName: "house.fill")- .font(.system(size: 34, weight: .semibold))- .foregroundStyle(Color(red: 1, green: 0.95, blue: 0.86))- .frame(width: 76, height: 76)- .background(- LinearGradient(colors: [Color(red: 0.36, green: 0.24, blue: 0.52), Color(red: 0.13, green: 0.16, blue: 0.36), Color(red: 0.05, green: 0.07, blue: 0.16)],- startPoint: .top, endPoint: .bottom),- in: RoundedRectangle(cornerRadius: 20, style: .continuous))- .shadow(color: Theme.warm.opacity(0.45), radius: 22)- .padding(.top, 44)- .accessibilityHidden(true)+ if !compact {+ Image(systemName: "house.fill")+ .font(.system(size: 34, weight: .semibold))+ .foregroundStyle(Color(red: 1, green: 0.95, blue: 0.86))+ .frame(width: 76, height: 76)+ .background(+ LinearGradient(colors: [Color(red: 0.36, green: 0.24, blue: 0.52), Color(red: 0.13, green: 0.16, blue: 0.36), Color(red: 0.05, green: 0.07, blue: 0.16)],+ startPoint: .top, endPoint: .bottom),+ in: RoundedRectangle(cornerRadius: 20, style: .continuous))+ .shadow(color: Theme.warm.opacity(0.45), radius: 22)+ .padding(.top, 44)+ .accessibilityHidden(true)+ }Text("Welcome to House Control").font(.system(size: 27, weight: .bold)).foregroundStyle(Theme.text).multilineTextAlignment(.center)- .padding(.top, 20)+ .padding(.top, compact ? 34 : 20)Text("Your home as a live 3D model, in your pocket.").font(.system(size: 16)).foregroundStyle(Theme.muted).multilineTextAlignment(.center).padding(.top, 6)- VStack(alignment: .leading, spacing: 26) {+ VStack(alignment: .leading, spacing: compact ? 20 : 26) {feature("hand.tap.fill", Theme.warm, "Tap a lamp, drag to dim","Lights, colours, air conditioners and scenes, right on the floor plan.")feature("pencil.and.ruler.fill", Theme.accent, "Draw it here or on your computer",@@ -40,6 +58,7 @@ struct WelcomeView: View {: "Home Assistant, Philips Hue and Apple Home. Until you connect one, everything is simulated.")}.padding(.horizontal, 6)+ .padding(.vertical, compact ? 20 : 28).frame(maxHeight: .infinity)Button { model.finishWelcome(.setUpHere) } label: { Label("Set up my home", systemImage: "house.fill") }@@ -55,12 +74,7 @@ struct WelcomeView: View {}.padding(.horizontal, 24).padding(.bottom, 10)- .presentationDetents([.large])- .presentationBackground(Theme.background)- .presentationDragIndicator(.visible)- .preferredColorScheme(.dark)- .interactiveDismissDisabled(false)- .onDisappear { UserDefaults.standard.set(true, forKey: "welcomed") }+ .readableWidth(520)}private func feature(_ symbol: String, _ tint: Color, _ title: String, _ detail: String) -> some View {diff --git a/ios/project.yml b/ios/project.ymlindex 4264c83..9e58dc1 100644--- a/ios/project.yml+++ b/ios/project.yml@@ -48,8 +48,10 @@ targets:LSApplicationCategoryType: public.app-category.lifestyleUILaunchScreen:UIColorName: LaunchBackground+ # Portrait on an iPhone. iPhone Duo's inner screen takes any shape regardless, and only+ # an app that can be resized gets all of it (and a place beside another app) rather+ # than a phone-sized column in the middle.UISupportedInterfaceOrientations: [UIInterfaceOrientationPortrait]- UIRequiresFullScreen: trueUIUserInterfaceStyle: DarkITSAppUsesNonExemptEncryption: falseNSLocalNetworkUsageDescription: House Control finds your Home Assistant and Hue Bridge on this Wi-Fi network, and your Mac or PC, to keep your floor plan the same on both.diff --git a/web/src/editor/editor.css b/web/src/editor/editor.cssindex 37c0ff2..6e29e62 100644--- a/web/src/editor/editor.css+++ b/web/src/editor/editor.css@@ -422,6 +422,40 @@ html.ios.mode-editor body { background: var(--bg); }.editor.phone .toast { bottom: calc(var(--tools-h) + 14px); font-size: 14px; max-width: calc(100% - 40px); text-align: center; z-index: 9; }.editor.phone[data-sheet='peek'] .toast { bottom: calc(var(--peek-h) + var(--tools-h)); }+/* iPhone Duo open, or any wide window: the details dock on the trailing half, beside the+ plan instead of over it, and the item lists open as cards in the middle. */+@media (min-width: 720px) and (min-aspect-ratio: 23/20) {+ .editor.phone {+ --side-w: min(480px, max(360px, calc(50% - 20px)));+ --safe-left: env(safe-area-inset-left, 0px);+ --safe-right: env(safe-area-inset-right, 0px);+ }+ .p-bar { padding-left: max(10px, var(--safe-left)); padding-right: max(10px, var(--safe-right)); }+ .editor.phone .canvas { transition: right 320ms var(--ease); }+ .editor.phone[data-sheet='peek'] .canvas, .editor.phone[data-sheet='full'] .canvas { bottom: var(--tools-h); right: var(--side-w); }+ .p-sheet, .p-sheet[data-state='peek'], .p-sheet[data-state='full'] {+ left: auto; right: 0; top: var(--bar-h); bottom: var(--tools-h); z-index: 5; width: var(--side-w); height: auto;+ border-radius: 0; border-top: 0; border-left: 1px solid var(--line); box-shadow: none;+ }+ .p-sheet[data-state='closed'] { transform: translateX(105%); }+ .p-sheet .inspector { padding-top: 14px; padding-right: max(18px, var(--safe-right)); }+ .p-grip { display: none; }+ /* The status bar sits in the top trailing corner of iPhone Duo's open screen, a little+ wider than its safe area: the header's buttons keep clear of it. */+ .editor.phone .insp-head { padding-top: 4px; padding-right: 30px; touch-action: auto; }+ .p-tools { padding-left: max(8px, var(--safe-left)); padding-right: max(8px, var(--safe-right)); }+ .p-tools .p-tool { max-width: 160px; justify-self: center; width: 100%; }+ .p-modal {+ left: 50%; right: auto; bottom: auto; top: 50%; width: min(520px, calc(100% - 40px)); max-height: calc(100% - var(--bar-h) - 40px);+ padding-bottom: 6px; border-radius: 22px; border: 1px solid rgba(255, 255, 255, 0.12);+ box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);+ opacity: 0; pointer-events: none; transform: translate(-50%, -46%) scale(0.97);+ transition: transform 300ms var(--ease), opacity 200ms ease;+ }+ .p-modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }+ .editor.phone[data-sheet='peek'] .toast, .editor.phone[data-sheet='full'] .toast { bottom: calc(var(--tools-h) + 14px); left: calc((100% - var(--side-w)) / 2); }+}+@media (prefers-reduced-motion: reduce) {.p-sheet, .p-modal, .editor.phone .canvas, .p-scrim { transition-duration: 1ms; }}diff --git a/web/src/editor/editor.js b/web/src/editor/editor.jsindex ae7a0ea..dc52514 100644--- a/web/src/editor/editor.js+++ b/web/src/editor/editor.js@@ -959,8 +959,10 @@ export async function bootEditor(root) {document.activeElement?.blur?.();}let gripDrag = null;+ // Docked beside the plan on a wide screen (editor.css), the details have no height to drag.+ const docked = matchMedia('(min-width: 720px) and (min-aspect-ratio: 23/20)');const startGrip = (ev) => {- if (ev.target.closest('button, input, select, textarea, a')) return;+ if (docked.matches || ev.target.closest('button, input, select, textarea, a')) return;gripDrag = { y: ev.clientY, h: sheet.getBoundingClientRect().height, id: ev.pointerId, moved: false };};grip.addEventListener('pointerdown', startGrip);diff --git a/web/src/main.js b/web/src/main.jsindex a0eeee6..2767279 100644--- a/web/src/main.js+++ b/web/src/main.js@@ -4,6 +4,7 @@ import { createWorld } from './three/world.js';import { createPanel } from './ui/panel.js';import { createAgent } from './agent/tools.js';import { h, openMenu } from './ui/dom.js';+import { phoneLayout, sameLayout } from './ui/layout.js';import { icon } from './ui/icons.js';import { isNative, isPhone, post, incoming, haptic } from './bridge.js';import { publishWidgets, runWidgetAction } from './widgets.js';@@ -88,8 +89,44 @@ async function boot() {}panel.attach(world);- // On a phone the header sits lower (status bar) but is closer to the model.- const applyInsets = () => (isPhone ? world.setInsets(50 + safeAreaTop(), 36) : world.setInsets(...STAGE_INSETS));++ // A phone stacks the stage over the controls; a wide or folded one (iPhone Duo) may put+ // them side by side or break them at the fold (ui/layout.js). The native app reports+ // the fold whenever the hinge moves.+ const root = document.documentElement;+ // ?fold=455,0,40,669 stands in for a half-folded iPhone Duo's fold (x,y,width,height) in a browser.+ const [fx, fy, fw, fh] = (new URLSearchParams(location.search).get('fold') || '').split(',').map(Number);+ let fold = window.__HOUSE_BOOT__?.fold || (fh ? { x: fx, y: fy, width: fw, height: fh } : null);+ let layout = null;+ let wasWide = innerWidth >= 600;+ function applyLayout() {+ if (!isPhone) return;+ const next = phoneLayout(innerWidth, innerHeight, fold);+ const wide = innerWidth >= 600;+ // Opening a Duo replays the sweep the panel plays when it appears.+ if (layout && wide && !wasWide) world.intro();+ wasWide = wide;+ if (sameLayout(layout, next)) return;+ const moved = layout && layout.kind !== next.kind;+ layout = next;+ root.classList.toggle('split', next.kind === 'split');+ root.classList.toggle('table', next.kind === 'table');+ for (const [name, px] of [['--split-start', next.start], ['--split-end', next.end]]) {+ if (px == null) root.style.removeProperty(name);+ else root.style.setProperty(name, `${Math.round(px)}px`);+ }+ if (moved) { panel.relayout(); applyInsets(); }+ }+ incoming.setFold = (rect) => { fold = rect || null; applyLayout(); };+ window.addEventListener('resize', applyLayout);+ applyLayout();++ // On a phone the header sits lower (status bar) but is closer to the model; with the+ // stage to itself (beside the controls, or above the fold) nothing covers its foot.+ function applyInsets() {+ if (isPhone) world.setInsets(50 + safeAreaTop(), layout?.kind === 'stack' ? 36 : 0);+ else world.setInsets(...STAGE_INSETS);+ }applyInsets();new ResizeObserver(() => (isPhone ? applyInsets() : world.resize())).observe(panel.canvas);@@ -99,9 +136,13 @@ async function boot() {incoming.hidden = () => { hide(); panel.closeSheet(); if (panel.room !== 'all') panel.selectRoom('all'); };incoming.setNotch = (x) => panel.setNotch(x);if (isPhone) {- // Swiping in from the left edge goes back from a device sheet, as it does everywhere on iOS.+ // Swiping in from the left edge goes back from a device sheet, as it does everywhere on iOS+ // (beside the 3D stage, from the sheet's own left edge).let edge = null;- window.addEventListener('pointerdown', (ev) => { edge = ev.clientX < 28 ? { x: ev.clientX, y: ev.clientY } : null; }, true);+ window.addEventListener('pointerdown', (ev) => {+ const left = layout?.kind === 'split' ? layout.end : 0;+ edge = ev.clientX >= left && ev.clientX - left < 28 ? { x: ev.clientX, y: ev.clientY } : null;+ }, true);window.addEventListener('pointerup', (ev) => {const swiped = edge && ev.clientX - edge.x > 56 && Math.abs(ev.clientY - edge.y) < 80;edge = null;diff --git a/web/src/style.css b/web/src/style.cssindex 018bee5..cd24596 100644--- a/web/src/style.css+++ b/web/src/style.css@@ -316,7 +316,7 @@ html.native .card { width: auto; height: auto; box-shadow:color: var(--muted);flex: none;}-.list-head .title { flex: 1; }+.list-head .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.list-head b { color: var(--text); font-weight: 600; }.pill {height: 26px; padding: 0 11px; border-radius: 999px;@@ -701,7 +701,7 @@ html.ios, html.ios body { background: var(--bg); }html.ios * { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }html.ios #app { padding: 0; place-items: stretch; }html.ios .card {- --stage-h: min(470px, 52%);+ --stage-h: var(--split-start, min(470px, 52%));--safe-top: var(--safe-top-preview, env(safe-area-inset-top, 0px));--safe-bottom: var(--safe-bottom-preview, env(safe-area-inset-bottom, 0px));width: auto;@@ -775,6 +775,54 @@ html.ios .panel-toast { bottom: calc(var(--safe-bottom) + 14px); font-size: 13.5html.ios .tooltip { display: none; }html.ios .fatal { margin: calc(env(safe-area-inset-top, 0px) + 20px) 16px 0; width: auto; }+/* ---------- iPhone Duo and other wide screens ---------- */+/* ui/layout.js picks the layout. 'split': the 3D stage on the leading side, the controls on+ the trailing one, broken on the fold when the Duo is half-folded like a book. 'table':+ half-folded like a laptop, the stage above the fold and the controls below it. A flat+ Duo held upright stacks them on its crease (--split-start is then the stage's height). */++html.ios .card {+ --safe-left: env(safe-area-inset-left, 0px);+ --safe-right: env(safe-area-inset-right, 0px);+}+html.ios .top { padding-left: max(20px, calc(var(--safe-left) + 8px)); padding-right: max(18px, calc(var(--safe-right) + 8px)); }+html.ios .panel { container-type: inline-size; }++html.ios.split .stage { inset: 0 auto 0 0; width: var(--split-start); height: auto; }+html.ios.split .stage canvas {+ -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 90%, transparent 100%);+ mask-image: linear-gradient(90deg, #000 0%, #000 90%, transparent 100%);+}+html.ios.split .panel, html.ios.split .sheet {+ inset: calc(var(--safe-top) + 64px) 0 0 var(--split-end);+ padding-right: max(16px, calc(var(--safe-right) + 6px));+}+html.ios.split .sheet { padding-left: 20px; padding-right: max(20px, calc(var(--safe-right) + 8px)); }+html.ios.split .devices { margin-right: min(-16px, calc(-6px - var(--safe-right))); padding-right: max(16px, calc(var(--safe-right) + 6px)); }+html.ios.split .panel-toast { left: calc(var(--split-end) + 16px); right: max(16px, var(--safe-right)); }++html.ios.table .stage canvas {+ -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 92%, transparent 100%);+ mask-image: linear-gradient(180deg, #000 0%, #000 92%, transparent 100%);+}+html.ios.table .panel, html.ios.table .sheet { top: calc(var(--split-end) + 12px); }++/* Room for a third column of tiles, and scenes that need not squeeze. */+@container (min-width: 560px) {+ html.ios .grid { grid-template-columns: repeat(3, 1fr); }+ html.ios .scene { height: 74px; font-size: 13px; }+}+/* A wide sheet keeps its controls at a hand's width, centred. */+@media (min-width: 600px) {+ html.ios:not(.split) .sheet > * { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }+}++/* Folding or opening moves the controls; they settle where they now are. */+html.ios .card.relayout .panel:not(.hidden), html.ios .card.relayout .sheet:not(.hidden) {+ animation: relayout-in 460ms var(--ease) both;+}+@keyframes relayout-in { from { opacity: 0; transform: translateY(10px); } }+/* ---------- boot / error ---------- */.fatal {diff --git a/web/src/ui/layout.js b/web/src/ui/layout.jsnew file mode 100644index 0000000..2ec1346--- /dev/null+++ b/web/src/ui/layout.js@@ -0,0 +1,35 @@+// Where the 3D stage ends and the controls begin on a phone's screen. Every iPhone stacks+// them; a wide screen (iPhone Duo open, or the app given a wide window) puts them side by+// side, one on each half; and a half-folded iPhone Duo breaks the two exactly at its fold,+// so nothing ever sits across the crease:+// 'stack' 3D above, controls below. `start` is the stage's height when the screen asks+// for one (the flat Duo held upright: its crease), else the CSS decides.+// 'split' 3D on the leading side up to `start`, controls on the trailing side from `end`.+// 'table' half-folded like a laptop on a table: 3D on the upper half up to `start`,+// controls on the lower half from `end`.+// `fold` is the active fold as the native app reports it (a rect in page px), or null when+// the screen is flat or has none.++const SPLIT_MIN_WIDTH = 720; // narrower than this, a landscape screen still stacks+const PANEL_MIN = 360;+const PANEL_MAX = 480;+const TALL_WIDE = 600; // an upright screen this wide is a Duo's inner one: stack on its crease++export function phoneLayout(width, height, fold) {+ if (fold && fold.width > 0 && fold.height > fold.width) {+ return { kind: 'split', start: fold.x, end: fold.x + fold.width };+ }+ if (fold && fold.height > 0) {+ return { kind: 'table', start: fold.y, end: fold.y + fold.height };+ }+ if (width >= SPLIT_MIN_WIDTH && width > height * 1.15) {+ const panel = Math.min(PANEL_MAX, Math.max(PANEL_MIN, width / 2));+ return { kind: 'split', start: width - panel, end: width - panel };+ }+ if (width >= TALL_WIDE && height > width) {+ return { kind: 'stack', start: Math.round(height / 2) };+ }+ return { kind: 'stack', start: null };+}++export const sameLayout = (a, b) => a && b && a.kind === b.kind && a.start === b.start && a.end === b.end;diff --git a/web/src/ui/panel.js b/web/src/ui/panel.jsindex 2ad3605..7211e8b 100644--- a/web/src/ui/panel.js+++ b/web/src/ui/panel.js@@ -566,6 +566,14 @@ export function createPanel(root, config, store, { onFocus, onMenu }) {get room() { return ui.room; },setNotch(x) { card.style.setProperty('--notch-x', `${x}px`); },setAgentLive(live) { aiBadge.hidden = !live; },+ /** The stage and the controls moved (a Duo folded or opened): the controls settle in place. */+ relayout() {+ card.classList.remove('relayout');+ void card.offsetWidth; // restarts the animation+ card.classList.add('relayout');+ clearTimeout(card.relayoutTimer);+ card.relayoutTimer = setTimeout(() => card.classList.remove('relayout'), 600);+ },/** `ai`: something an AI assistant did (who, what), instead of an error. */toast(text, ai = null) {toastEl.replaceChildren(...(ai ? [h('span.toast-ai', icon('sparkles', 13, 2.2), ai), h('span', text)] : [text]));