Skip to content

🤖 fix: iPhone Duo folds keep the sidebar drawer closed, and phone sheets clear side safe areas - #7431

Merged
ibetitsmike merged 12 commits into
mainfrom
mike/iphone-duo-pwa-fixes
Oct 24, 2026
Merged

ibetitsmike merged 12 commits into
mainfrom
mike/iphone-duo-pwa-fixes

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • New useLeftSidebarState owns the sidebar state for every toggle path in App. Wide widths keep the saved LEFT_SIDEBAR_COLLAPSED_KEY and its old default. The narrow drawer state lives in memory, starts closed on every return to narrow, and never touches the saved flag.
  • That state is keyed to useNarrowViewportSession(), a new number per narrow period. A reset during the wide render failed: next to useSyncExternalStore, React 18.3 skipped App's re-render on the next fold.
  • LeftSidebar uses useNarrowViewport() instead of its own copy of the query.
  • The static phone workspace view no longer bails out on a saved expanded sidebar, and the first-run view always draws the collapsed sidebar at narrow widths, as the app now does.
  • Settings and Analytics phone sheets pad by the side safe-area insets, with close buttons clear of the right one. The toast's right offset is 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's App.tsx fails cases 1, 2 and 4; case 3 catches a drawer open that writes the wide flag.
  • firstRunView.test.ts checks computed styles at 382 and 951 px per saved state; workspaceViewPage.test.ts covers a saved expanded sidebar.
  • The Storybook test-runner's assertClearsRightInset emulates an 84 px right inset at 466x700 for both sheets and a new toast story; all three fail with main's classes.
  • Remote dogfood UAT in Chromium, with main as the control: PASS on 07f3f1e and a smoke PASS on 6db15df. The head only extends the repro.

After a fold with the wide sidebar open, 382 px

This PR main
Drawer closed, chat visible Drawer open over the chat

Settings at 466 px with an 84 px right safe-area inset

This PR main
Controls end before the inset Close button and controls under the inset

Notes

  • Pixel changes: app-mcp-identity--workspace-modal-phone is intended. It shows the chat page behind the modal, not a drawer the old play helper left open. Phone plays now open the drawer with openLeftSidebar(). 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.
  • No new dependencies. Cleanup and the test audit stayed inside this diff.
  • Out of scope: a color band for the side column, hover-only controls on wide touch layouts (follow-up), and the Device Posture and Viewport Segments APIs (behind Safari flags).

Review record

  • Cleanup (simplify, deslop) on 07f3f1e: 3 findings, fixed in 6db15df. Test audit on 6db15df: 1 gap (closing the drawer must keep the wide sidebar open), fixed in 63f383b.
  • Pixel attribution with Pixel's own diff pipeline, main against this branch: the laptop app-chatloading--replay snapshots changed because a story helper let a saved collapse reach the next workspace switch. Fixed in 021b5a7.
  • Test audit on 021b5a7: pass, no production change. Its two comment-precision gaps are fixed in c65a05d.
  • Codex: code and security reviews clean on c65a05d.

… 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).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T20:53:47.531880Z c65a05d Manual request
🔒 Security Review ✅ Completed 2026-10-24T20:53:41.609198Z c65a05d Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

27 agent steps · 7 replayed from cache · 31 model calls · 218.4k tokens (70% cached)
Spend: $0.10 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 2 steps · 4 calls 21.9s
🟢 a chat survives a restart of the server 2 steps · 4 calls 21.9s
🟢 compaction.e2e.ts · 1 passed 3 steps · 7 calls 43.4s
🟢 /compact replaces the old chat with a summary 3 steps · 7 calls 43.4s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 9.2s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 9.2s
🟢 settingsRoundTrip.e2e.ts · 1 passed 3 steps · 5 calls 29.5s
🟢 a chat survives trips through Settings 3 steps · 5 calls 29.5s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 7.7s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 7.7s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 2.7s
🟢 the agent opens the playground workspace 2 steps · 1 call 2.7s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 7.0s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 7.0s
🟢 todoNudge.e2e.ts · 1 passed 2 steps · 4 calls 22.3s
🟢 the agent finishes open TODO items after the turn-end nudge 2 steps · 4 calls 22.3s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 22.1s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 4.1s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 4.8s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 4.4s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 3.2s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 2.9s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 2.8s

e2e 0.20.0 · 2m 49s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 8.1k tokens (21% cached)
Spend: $0.02 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 5.7s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 5.7s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 5.6s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 5.6s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 8.7s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 8.7s

e2e 0.20.0 · 22.0s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 5.3s · 2 targets (web, phone) · run artifacts

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 63f383b02e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

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.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: c65a05d33d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: c65a05d33d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@ibetitsmike
ibetitsmike added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit e62702f Oct 24, 2026
71 of 74 checks passed
@ibetitsmike
ibetitsmike deleted the mike/iphone-duo-pwa-fixes branch October 24, 2026 21:22
azaj01 pushed a commit to azaj01/mux that referenced this pull request Oct 25, 2026
…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.
yermakoffivan pushed a commit to yermakoffivan/mux that referenced this pull request Oct 26, 2026
> 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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant