Repository navigation
🤖 fix: iPhone Duo folds keep the sidebar drawer closed, and phone sheets clear side safe areas - #7431
Conversation
… flag Folding devices (iPhone Duo) switch between the phone drawer and the wide inline sidebar. The drawer now keeps an in-memory open state that starts closed, so a fold never pops it over the chat and drawer use never changes the saved wide flag. The static phone view and the first-run view follow the same rule. Settings/Analytics phone sheets and the goals toast respect side safe-area insets.
…a insets expandLeftSidebar() now only expands the wide sidebar, so phone plays that need the drawer open it with the new openLeftSidebar() helper. The test-runner checks that the Settings and Analytics phone sheets and the goals toast keep clear of an 84 px right safe-area inset.
The render-phase reset of the drawer next to useSyncExternalStore made React 18 skip the app's re-render on the next fold, so the drawer showed open again. A session number that changes on each return to narrow now owns the drawer state. Adds the duoFoldDrawer bug-bash repro.
The ProjectPage and ScratchPage landmark plays click sidebar controls. At narrow widths the drawer now starts closed regardless of the persisted flag, so open it with openLeftSidebar before the click.
Drop a redundant window guard and return annotation in useLeftSidebarState, key the side-inset story checks by one Map, share the repro's drawer-open step, and fix two story comments.
…open The fold repro covered a drawer open writing the wide sidebar's saved flag but not a drawer close writing it, which was the reported symptom (closing the drawer hid the wide sidebar after the next unfold).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
🟢 e2e stories (Haiku): 14 passed27 agent steps · 7 replayed from cache · 31 model calls · 218.4k tokens (70% cached) All 14 tests in 9 files
e2e 0.20.0 · 2m 49s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 8.1k tokens (21% cached) All 3 tests in 3 files
e2e 0.20.0 · 22.0s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 5.3s · 2 targets (web, phone) · run artifacts |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
The chat-loading plays' switchWorkspace() now opens the phone drawer with openLeftSidebar(), but at desktop widths it no longer rewrote the saved sidebar flag before each switch. Its trailing collapseLeftSidebar() only writes storage, so the next switch's re-render read it and collapsed the wide sidebar, which changed the App/ChatLoading Replay desktop snapshots. Keep the live expandLeftSidebar() write before opening the drawer.
The Replay switch comment now says any later re-render reads the raw collapse write, not only the next switch's. The openLeftSidebar() doc said the phone drawer starts closed on every render; its in-memory state survives re-renders and starts closed when the story mounts.
|
@codex review |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…touch screens (coder#7473) ## Summary Three fixes for the iPad home-screen app. Taps on the blank part of a control (for example, right of a Settings nav label) needed several tries; rotating from landscape to portrait left the app at the old landscape height; and the safe-area menu padding from coder#7460 now runs only on touch screens. ## Background The touch problems were reported after coder#7460 (safe-area collision padding for Popover/Select) and coder#7431 (Duo drawer, phone sheet side insets) landed. A review of both diffs found no change to input handling: coder#7460 only changes `collisionPadding` and adds hidden `pointer-events:none` probes, and coder#7431's Settings changes are `max-md` only. A Chromium touch probe of the Settings dialog at 820x1180 with 24/20 px insets on main hit every nav button at 12 points per row, and real touch taps on the right side switched sections. The causes found are below. ## Implementation - **Taps:** `touch-action: manipulation` on `html` was gated to `(max-width: 768px) and (pointer: coarse)`. iOS ignores viewport zoom limits for gestures, so on iPads (wider than 768 px) the double-tap-to-zoom recognizer stayed armed and held or dropped taps on non-text areas. It now applies to every coarse pointer. Pinch zoom is unaffected. - **Rotation:** `installViewportHeightSync` sets `--app-viewport-height` from `innerHeight` on `resize`. After an iPad turns from landscape to portrait, that `resize` can still see the landscape height with no later event. A hidden fixed `inset:0` box is now watched by a `ResizeObserver`, which fires once the rotated layout exists, and syncs again. This runs before React mounts, so the probe setup sits in a `try`/`catch`: if it fails, it logs the error, removes the box and keeps the resize listener. - **Less aggressive safe-area padding (coder#7460):** `useSafeAreaCollisionPadding` returns the caller's padding unchanged unless `(pointer: coarse)` matches, so mouse and trackpad devices never create the probes, observe them, or re-render menus on inset changes. It subscribes to that query, so a switch to touch emulation (the test-runner's `assertMenuClearsSafeArea`) still picks up the insets. ## Validation - New unit tests, each red without its fix: `useSafeAreaCollisionPadding.test.ts` (a mouse device gets plain padding with no probes or reads, then insets after the query turns coarse) and `viewportHeight.test.ts` (a stale resize followed by the layout box resize ends at the portrait height; a probe that cannot be observed leaves no box and keeps the resize sync). - Storybook test-runner on `ProjectPage.stories.tsx` passes, including `assertMenuClearsSafeArea`. - Not device-verified: iOS tap disambiguation and the stale rotation height do not reproduce in Chromium, and Playwright WebKit models neither. ## Risks Low. The CSS change only removes double-tap zoom on touch screens wider than 768 px. The rotation sync adds one hidden element and observer on iOS standalone only. Desktop menus already got zero insets, so their positions are unchanged.
> Xum opened this PR on behalf of @ibetitsmike. ## Summary Fixes touch, keyboard and layout defects in the home-screen web app (PWA) on an iPhone Duo, found by driving the app on the iPhone Duo simulator (outer cover display and inner display) with injected touches and Web Inspector. Most fixes are gated to the iOS standalone app, to touch screens or to phone widths; the rest are noted under Risks. ## Background Prior Duo and iPad work (coder#7431, coder#7460, coder#7473) left these defects on the device: | Defect | Cause | |---|---| | Opening the keyboard hid the header; closing it could leave a blank band | iOS standalone resizes only `visualViewport` for the keyboard and scrolls the window; the shell height came from `innerHeight` | | A sidebar workspace row needed two taps | `[&:hover_button]:opacity-100` in `AgentListItem` is not hover-gated; the first tap applied `:hover`, revealed the archive button, and WebKit dropped the click | | Code block copy and run buttons stayed invisible on touch | `.code-block-wrapper:hover` reveal in ungated CSS | | The model picker scrolled the phone page sideways | The 328px panel overflowed the header's horizontal scroller | | Dialogs, Settings and Analytics ran under the Duo cover display's 84px right status column | They centered in the window, not between the side safe areas | | The workspace details popover ran past the screen | Long paths did not wrap | | Immersive review's Back button opened the drawer | It sat under the collapsed sidebar's fixed toggle bar | | The keyboard opened at launch and on every workspace switch | Composer and model search autofocus | ## Implementation - `viewportHeight.ts`: size `--app-viewport-height` from `visualViewport.height * scale`, listen to `visualViewport` resize and scroll, and undo the window scroll when not pinch zoomed. - Hover reveals: move both reveals behind `(hover: hover)`; code block buttons are always visible under `(hover: none)`. `hoverReveal.test.ts` guards new ungated reveals in classes and CSS. - `ModelSelector`: `getPanelPlacement` keeps the panel inside the nearest clipping ancestor (sideways, and below its top); placement re-runs on `visualViewport` resize; no search autofocus on phones. - `Dialog`, `SettingsPage`, `AnalyticsDashboard`: center with `calc(50% + (safe-left - safe-right) / 2)` and size from the width between the insets. Dialogs whose caller sets its own width also pass `maxWidth`, which `Dialog` caps at that width. - `firstRunView.ts`: the server's static first-run dialog copies the live Dialog's classes (`firstRunViewParity.test.ts` checks it), so it takes the same centering. - `ImmersiveReviewView`: renders the collapsed toggle bar spacer through a new `ShellOverlayToolbarSpacerContext`. - Phone autofocus: `isPhoneTouchScreen()` / `autoFocusUnlessPhone()` in `env.ts`, used by the project and scratch creation pages and the model search; the workspace switch autofocus moved into `useWorkspaceSwitchAutoFocus` so it can be tested (its focus-moved-elsewhere check is a small predicate so the hook stays under the CRAP gate). ## Validation - The defects were found on the iPhone Duo simulator (iOS 27.1, PWA installed from Safari) with a clickability audit (elementFromPoint, clipping and safe-area checks), a crawl that taps every control and checks that a click arrived, and Web Inspector. The final on-device passes are the UAT rounds in the delivery record: a separate tester agent drove the installed web app on that simulator with injected touches and Web Inspector probes, and real taps reach only the inner display there, so cover-display taps were checked with hit tests and scripted clicks. - New tests: `viewportHeight.test.ts`, `hoverReveal.test.ts`, `ModelSelector.panelPlacement.test.ts`, `ProjectPage.autofocus.test.tsx`, `useWorkspaceSwitchAutoFocus.test.tsx`, and the immersive review Back button test in `ImmersiveReviewView.test.tsx`. ## Risks - Low to medium. The viewport change runs only in the iOS standalone app, but it touches every screen there; a wrong height would show as a gap or clipping above the keyboard. - The dialog centering applies everywhere. It equals the old `left-[50%]` and `w-[90%]` (and `md:` sizes for Settings and Analytics) when both side insets are 0, which covers desktop and Electron. - Ungated changes: the workspace details popover now wraps long paths everywhere, and the immersive review header gains the toggle bar spacer wherever the left sidebar is collapsed, desktop included. ## Follow-ups (not in this PR) - With the keyboard up on the Duo cover display, the model picker has about 90px between the header and the model pill, so it keeps its search field visible and the results list shrinks to a sliver (Enter still selects). A phone layout for the picker (a sheet, or opening below) would fix it. - After the keyboard closes once, the simulator's WebKit reports a negative `visualViewport.height` until the next keyboard open, and Radix popovers and menus (workspace details, workspace actions) then open off screen. This PR's shell height ignores the bad value, and the UAT showed the popovers are unaffected by this PR's code. Not yet checked on a real device. - Pre-existing: the footer branch and "Last prompt" buttons sit in the bottom safe area, and the code block run button is partly covered by the copy button (now visible on touch). ## Delivery record | Gate | Commit | Result | |---|---|---| | Codex review | `596e93f09` | OK, no findings; security review clean (superseded by `9b043b2f0`) | | CI | `596e93f09` | `firstRunViewParity` failed (static first-run dialog drifted from the live one), fixed in `9b043b2f0`; `writeFileAtomic.fs` and a `BackgroundProcessManager` monitor test failed in CI but pass locally and are outside this diff | | Codex review | `9b043b2f0` | superseded by `230c05ab9` before a verdict | | Local DeviceHub UAT round 1 | `596e93f09` | **FAIL**: claims 1 to 7 passed; the scratch creation page still opened the keyboard at launch on a phone, fixed in `230c05ab9`. Real touches reach only the inner display in this simulator, so outer-display taps were checked by hit tests and JS clicks | | Codex review | `230c05ab9` | OK, no findings (20:42Z); security review clean | | CI | `230c05ab9` | `sessionLocks.callOptions` failed once in Unit 5/6 (a temp path from another suite in the same process); passes locally 3 of 3 and is outside this diff; failed jobs re-run | | Local DeviceHub UAT round 2 | `230c05ab9` | **PASS**: round 1 issue fixed, claims 1 to 8 hold, first-run dialog does not jump (checked in mobile Safari) | | CI rerun | `230c05ab9` | Unit 5/6 passed; `Quality / CRAP` blocked the extracted `useWorkspaceSwitchAutoFocus` at CRAP 15.0041 (max 15), fixed in `4baf78593` | | Codex review | `4baf78593` | 1 finding (P2): dialogs whose caller sets a width class lost the safe width but kept the shifted `left`. Confirmed by running `cn()`; fixed in `68fea99c6`; thread resolved | | Codex review | `68fea99c6` | OK, no findings (21:28Z); security review clean | | CI | `68fea99c6` | Required green | | Local DeviceHub UAT round 3 | `4baf78593` | **FAIL** on one item: the terminal dialog measured x -30 to 412 on the cover display (the Codex finding, fixed in `68fea99c6`). The hook refactor passed: switch autofocus on the inner display, its yield to a focused control, and no autofocus on the phone | | Local DeviceHub UAT round 4 (final) | `68fea99c6` | **PASS**: terminal dialog now x 0 to 382 on the cover display (was -30 to 412) and 0 to 867 inside, with WebKit applying the inline cap; dialogs without a caller width unchanged; claims 1 to 8 and a fold with the dialog open pass. Git divergence dialog and image lightbox are not reachable in the seeded setup (covered by the same cap by code) | --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh` • Cost: `$73.64`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh costs=73.64 -->
Summary
On a folding phone such as the iPhone Duo, every fold to the cover display (768 px or less) opened the sidebar drawer over the chat. The drawer and the wide sidebar shared one saved flag, so an open wide sidebar became an open drawer, and closing the drawer collapsed the wide sidebar after the next unfold. The cover display also reserves a right-hand safe-area column, and the Settings and Analytics phone sheets and the active-goals toast put controls under it.
Changes
useLeftSidebarStateowns the sidebar state for every toggle path inApp. Wide widths keep the savedLEFT_SIDEBAR_COLLAPSED_KEYand its old default. The narrow drawer state lives in memory, starts closed on every return to narrow, and never touches the saved flag.useNarrowViewportSession(), a new number per narrow period. A reset during the wide render failed: next touseSyncExternalStore, React 18.3 skippedApp's re-render on the next fold.LeftSidebarusesuseNarrowViewport()instead of its own copy of the query.max(1rem, inset).A first launch at the cover width with nothing saved still starts the wide sidebar collapsed (the old phone default); opening the drawer no longer changes it.
Testing
tests/bugbash/repros/duoFoldDrawer.e2e.ts(web and phone, 4 cases). Main'sApp.tsxfails cases 1, 2 and 4; case 3 catches a drawer open that writes the wide flag.firstRunView.test.tschecks computed styles at 382 and 951 px per saved state;workspaceViewPage.test.tscovers a saved expanded sidebar.assertClearsRightInsetemulates an 84 px right inset at 466x700 for both sheets and a new toast story; all three fail with main's classes.After a fold with the wide sidebar open, 382 px
Settings at 466 px with an 84 px right safe-area inset
Notes
app-mcp-identity--workspace-modal-phoneis intended. It shows the chat page behind the modal, not a drawer the old play helper left open. Phone plays now open the drawer withopenLeftSidebar().app-phoneviewports--i-phone-16-e-sidebar-with-sections(dark and light) differs by at most 8 color levels in the blurred backdrop behind the drawer, which now opens on a tap instead of at mount. The other pending snapshots are flaky: repeated local captures of main and this branch produced a matching render.Review record
app-chatloading--replaysnapshots changed because a story helper let a saved collapse reach the next workspace switch. Fixed in 021b5a7.