Skip to content

feat(mobile): the page owns its safe area, like a native screen (OTA phase C follow-up) - #22570

Merged
Jinwoo-H merged 3 commits into
mainfrom
ota-fu-page-owns-safe-area
Sep 24, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
ota-fu-page-owns-safe-area

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​552 $\color{#cf222e}{\Huge{\mathbf{−}}}$​214 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​338
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​615 $\color{#cf222e}{\Huge{\mathbf{−}}}$​96 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​519

Why

Native screens draw edge-to-edge and each header's SafeAreaView paints its own colour under the status bar; sheets dim the whole screen; the command dock sits over the gesture bar. The hybrid-shell page could not: the shell reserved both bar strips outside the WebView and painted them a flat bgBase, so every page screen showed a band above its header, sheet scrims stopped at the band, and the dock floated above the gesture bar. Jinwoo's call: make the page look like native.

What

  • Shell: the WebView goes edge-to-edge; only the keyboard strip stays off the view (paddingBottom: keyboardInset), and the status-bar strip only while the update banner shows.
  • Bridge init carries an optional safeAreaInsets (the shell's insets; bottom 0 while the keyboard is up, top 0 under the banner), re-sent through the existing route-update init when they change. No BRIDGE_PROTOCOL_VERSION bump: a new optional field.
  • Page root layout app/_layout.web.tsx feeds those insets into react-native-safe-area-context's insets and frame contexts and replaces expo-router's injected DefaultNavigator (an all-edges SafeAreaView the page got because its route tree had no root layout). Every existing SafeAreaView in the page then pads once, like native.
  • Wire compatibility both ways: the page's ready report now carries accepts beside reports; the shell goes edge-to-edge only for a page that declared safe-area-insets (older pages keep the strips), tracked in the existing per-document page state like the Back claim. A new page under an old shell reads the missing field as zeros and the old shell still pads. Inset re-sends go only to pages that accept them.
  • Pins re-measured: session closure 4216 → 4218 (bridge-safe-area-insets.ts, app/_layout.web.tsx), asset-ceiling crossing 31 → 32 routes, script sweep unchanged at 69; web-overrides.json allowlists the root layout.

Relies on #22549 (native inset zeroing) on WebView 144+ so env() does not add on top.

Proof

  • Red first: bridge contract test 5/6; screen test with ownership forced off ({paddingTop:44,paddingBottom:8} vs {paddingBottom:0}); real-browser render with a CDP env inset (header 34 px low without the root layout); route-manifest test; "older page gets no re-init" (3 inits vs 1) before the accept gate.
  • Opus design review, two rounds: ownership moved into page-document state, re-init gate corrected, banner wrapper and a mutating predicate removed, provider folded; the second round confirmed nothing else must change, wire compat verified in both directions.
  • Emulator (Pixel_9_Pro_API_36, fresh OTA APK from this branch, page vs native, device px): WebView full display; host status strip #111111 / title 189 vs native #111111 / 186; session strip #1a1a1a / 171 vs #1a1a1a / 168; sheet scrim #080808 in the strip on both; dock bottom 2783 both; keyboard up: input row / dock / IME top 1830 / 1847 / 1848 on both; landscape clean; 0 page faults.
  • Lead gate on 4624fc9: every lint/typecheck line 0; config/scripts 260 files / 2400 tests; mobile 871 files / 9492 tests.

Needs a new native build to take effect.

The shell reserved both system-bar strips outside the WebView and painted
them bgBase, so every page screen showed a flat band above its header,
sheet scrims stopped short of the status bar, and the dock floated above
the gesture bar.

For a page that declares `safe-area-insets` in `ready.accepts`, the shell
now draws the WebView edge-to-edge and keeps only the keyboard strip off
it. `init` carries the insets the view sits under (bottom 0 while the
keyboard ends the view, top 0 under the update banner), and a move is
re-sent over the existing route-update `init`. An older page keeps the
reserved strips, since it has no reader for the insets.

On the page, a root layout (`app/_layout.web.tsx`) feeds those insets to
react-native-safe-area-context below ExpoRoot's env()-measuring provider.
It also replaces expo-router's DefaultNavigator, an all-edges SafeAreaView
that padded a second time.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The page's route tree gained `./_layout.tsx` (its web sibling of the
native root), so every pin that counts the tree moved:

- Script sweep re-measured by building `routes.slice(0, n)` for each n.
  It reads 69 scripts at 16 routes, which matches the real build. The
  asset-ceiling crossing moves from 31 routes to 32.
- Route closures now enter through both layouts. `entryNames` gains
  `[dir]` because `app/_layout` and `app/h/_layout` share a name.
- Session closure pin 4216 -> 4219. The added modules are
  bridge-safe-area-insets, page-safe-area-provider and _layout.web.
- The web-overrides allowlist names `app/_layout.web.tsx`.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Review fixes on the page-owns-safe-area change.

- Ownership is page-document state now. `page-ready` carries `accepts`
  beside `reports`, the patch sets `pageOwnsSafeArea` from
  `safe-area-insets`, and the session hook projects it like
  `backClaimed`. The screen's own per-session copy is gone.
- Insets moves re-send `init` only to a page that declared
  `safe-area-insets`. A page that took route updates but not insets was
  sent a useless `init` on every keyboard show and hide.
- The banner wrapper is gone. The root pads the status bar strip while
  the banner shows.
- The shell session defaults the insets inline, with no predicate that
  mutated its argument.
- The provider is folded into its single caller, `app/_layout.web.tsx`.
  The session closure pin reads 4218 (local 1032).
- The screen tests share their module mocks, and the safe-area cases
  move to a suite of their own: owned page, banner, iOS and Android
  keyboard, and an older page that gets no re-init.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the whole PR (3 commits, 42 files) at 4624fc9b5a.

  • Optional safeAreaInsets on init — bridge-safe-area-insets.ts bounds each edge 0..4096, absent reads as zeros, and all-zero is omitted; the page's host-message reader is non-strict, so an old page strips the new key rather than refusing the frame.
  • Page declares the accept — createPageReadyFrame() adds safe-area-insets to ready.accepts, the only element added to an existing array, so an old shell ignores it.
  • Ownership lives in per-document state — page-ready carries {reports, accepts}; pageDocumentStatePatch records pageOwnsSafeArea, gated on state.kind === 'ready' and cleared with CLEAR_PAGE_DOCUMENT_STATE, so a declaration never outlives its document.
  • Edge-to-edge layout — the shell keeps the keyboard strip and reserves the status-bar strip only while the banner shows; pageSafeAreaInsets zeroes top under the banner and bottom while the keyboard ends the view, so the page pads each edge exactly once.
  • Inset re-send — publishSafeAreaInsets moves the held value and re-inits only for a deliverable page that declared the accept; the client fires onSafeAreaInsetsUpdate only on a real move and preserves object identity otherwise.
  • Page root layout — app/_layout.web.tsx replaces expo-router's DefaultNavigator, feeding the shell insets into the safe-area contexts with no padding of its own.
  • Build pins re-measured — route manifest/closure gain app/_layout (with [dir]/[name] output), script sweep 67→69, ceiling crossing 31→32, session modules 4216→4218.

I checked the four shell/page combinations: the accepts gate keeps an older page on the reserved strips, and a new page under an old shell reads zeros and sits inside those strips, so the rollout is safe in both directions.

ℹ️ Nitpicks

  • config/scripts/verify-mobile-web-app-bundle.mjs still describes "the subtree's one layout, h/_layout.tsx", but this PR makes it two (app/_layout.web.tsx joins h/_layout.tsx). Doc-only, not blocking.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The mobile web shell bridge now carries validated safe-area insets in init frames and reports page acceptance in ready declarations. The shell adjusts padding for pages that handle insets, keyboard state, and update notices, while the web root layout provides shell insets to safe-area context. Route discovery and bundle closure include the web root layout, with directory-qualified multi-entry outputs and updated sweep measurements. Tests cover bridge updates, shell rendering, route discovery, and bundle limits.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 4624f

Pages that draw edge-to-edge can stop receiving safe-area updates after the shell rebuilds its bridge connection. Their content can then sit under the status bar, navigation bar, or keyboard with stale padding until the page reloads. Carry the page's declared capabilities across host replacement before merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the motivation, implementation, compatibility behavior, testing results, and native-build requirement. However, it omits several required template sections, including ELI5, Li… Add the required template sections. Include a Linked Issue entry such as Fixes #22549`` if applicable, attach before-and-after visual proof or state N/A with a reason, document testing steps and platforms, complete the AI Disclosure and R…
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 41 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: page-owned safe-area handling for mobile screens. The extra phase qualifier does not obscure the change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the motivation, implementation, compatibility behavior, testing results, and native-build requirement. However, it omits several required template sections, including ELI5, Linked Issue, Visual Proof, Testing, Review, Notes, and Checklist details.

Resolution

Add the required template sections. Include a Linked Issue entry such as Fixes #22549`` if applicable, attach before-and-after visual proof or state N/A with a reason, document testing steps and platforms, complete the AI Disclosure and Review sections, address the Agent skill upstream boundary, Notes, and Checklist items.

Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 41 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 7981570e-92db-4370-9621-649cab49c58f

📥 Commits

Reviewing files that changed from the base of the PR and between 069dc8a and 4624fc9.

📒 Files selected for processing (42)
  • config/scripts/build-mobile-web-app-bundle.mjs
  • config/scripts/build-mobile-web-app-bundle.test.mjs
  • config/scripts/mobile-web-app-render-harness.mjs
  • config/scripts/mobile-web-app-route-manifest.mjs
  • config/scripts/mobile-web-app-route-manifest.test.mjs
  • config/scripts/mobile-web-app-safe-area-render.test.mjs
  • config/scripts/mobile-web-app-session-terminal-closure.test.mjs
  • config/scripts/verify-mobile-web-app-bundle.mjs
  • mobile/app/_layout.web.tsx
  • mobile/src/mobile-web-shell/MobileWebShellScreen.test.tsx
  • mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
  • mobile/src/mobile-web-shell/bridge-host-contract.ts
  • mobile/src/mobile-web-shell/bridge-host-route.ts
  • mobile/src/mobile-web-shell/bridge-host-test-harness.ts
  • mobile/src/mobile-web-shell/bridge-host.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-init-handshake.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-session.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-shell-session.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.ts
  • mobile/src/mobile-web-shell/bridge/bridge-init-frame.ts
  • mobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client-frames.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client.ts
  • mobile/src/mobile-web-shell/bridge/bridge-safe-area-insets.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-safe-area-insets.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-back-claim-state.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-safe-area-screen.test.tsx
  • mobile/src/mobile-web-shell/mobile-web-shell-safe-area-state.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-screen-test-harness.tsx
  • mobile/src/mobile-web-shell/mobile-web-shell-screen-test-mocks.tsx
  • mobile/src/mobile-web-shell/mobile-web-shell-session-contract.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session.ts
  • mobile/src/mobile-web-shell/page-document-state.ts
  • mobile/src/mobile-web-shell/page-safe-area-insets.test.ts
  • mobile/src/mobile-web-shell/page-safe-area-insets.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.test.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-session.test.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-session.ts
  • mobile/web-entry/web-overrides.json

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

}
insets = next
// Only to a page that reads them: a re-init to one that does not is a wasted frame per move.
if (deliverable && accepts.includes(BRIDGE_SAFE_AREA_ACCEPT)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Preserve inset delivery when a host is rebuilt under a live page.

A replacement host can inherit an established session without receiving another ready. Its route handler starts with an empty accepts list, so this check blocks later inset updates. If the inset value changed during the rebuild, the new handler already holds that value and also rejects the subsequent publish as unchanged. The page then keeps its old padding while the shell keeps the WebView edge-to-edge. Carry the document's acceptance into the replacement host and synchronize its current insets with the page when the host takes over.

@Jinwoo-H
Jinwoo-H merged commit 37820f9 into main Sep 24, 2026
59 of 61 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-fu-page-owns-safe-area branch September 24, 2026 00:08
Jinwoo-H added a commit that referenced this pull request Sep 24, 2026
…22576)

#22570 pinned its own branch commit, which the squash left off main; the corpus now pins main at 37820f9, the tree its fenced paths match. Every golden changes only its baseline line.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
nwparker added a commit that referenced this pull request Sep 24, 2026
Measured, not derived: 4220 without the DSH icon entry, 4221 with it. Two of the three
modules above main's 4218 pin are not this change's — they arrived with the mobile work
after #22570 and were never repinned; the changelog records that split explicitly.
nwparker added a commit that referenced this pull request Sep 28, 2026
* feat(agents): add first-class DeepSeek Harness (dsh) support

Register DSH as a supervised Orca agent: catalog entry and detection for its
dsh-tui profile, status/question hooks through DeepSeek's own Claude-Code hook
bridge, composer-ready prompt delivery, session resume, headless Source Control
AI, and title identity that no longer collides with Gemini's.

* fix(dsh): reach Orca through DSH's credential scrub and stop reading its title as Gemini

DSH runs command hooks through its own shell executor, which drops every env var whose
name contains KEY, TOKEN, SECRET or PASSWORD — taking ORCA_PANE_KEY and
ORCA_AGENT_LAUNCH_TOKEN with it, so every hook exited without posting. Mirror both onto
scrub-safe aliases at spawn and restore them at the top of the DSH hook script.

Its title collided too: DSH rests on the same glyph Gemini works on, so a resting DSH
pane was relabelled Gemini CLI and reported working forever. Defer both the Gemini
classifier and the title status detector on DSH's whale, in the base module both copies
of that classifier read.

* test(mobile): repin the session-route closure for the DSH agent icon

* fix(dsh): address review — never splice user rows, cover remote panes, keep the diff off argv

- findManagedDshPatchRegion paired an orphan start marker with a later block's end, so a
  truncated write made install/remove delete the user's own rows. Pair each end with the
  nearest preceding start; regression test fails without the fix.
- The relay PTY env builder never applied the scrub-safe aliases, so remote DSH status
  silently never appeared even with the remote hook installed.
- Source Control AI sent the whole diff on argv; send it over stdin with DSH's '-' marker.
- dsh-tui/dst already chose the interactive profile, so a workspace folder named 'web' or
  'plugin' no longer marks a live agent pane non-interactive.
- Isolate USERPROFILE as well as HOME so a Windows run cannot edit the real home.
- Drop the duplicate README badge and revert an incidental doc reformat.

* refactor(dsh): share the managed-hooks reader and tighten the new modules

Reuse before reimplementing: readManagedDshHookEvents was a near-verbatim copy of Muse's,
with byte-identical private helpers. Both now call one readManagedHookEventsFromJson.

Also: one readTextOrAbsent instead of two spellings of the same read (dropping an
existsSync TOCTOU), one status() builder instead of four inline literals, rmSync(force)
instead of exists-then-unlink, and a redundant empty-string guard before JSON.parse.
The patch-file transforms lose their index juggling for a predicate plus a filter.

* fix(dsh): refuse a flow-style patch file, keep its mode, and stop the relay inheriting a pane

- applyManagedDshPatch matched only an exact `[]`, so `[] # keep empty` or a non-empty
  flow sequence got a block entry appended after it — invalid YAML that would leave DSH
  unable to load the user's own patch layer either. It now strips the token from an empty
  sequence (keeping a trailing comment) and returns null for a non-empty one; install
  reports that and changes nothing.
- The patch rewrite dropped an owner-only file to the umask default (CWE-732); pass
  preserveMode.
- The relay PTY env never dropped inherited pane identity the way the local and daemon
  builders do, so a spawn that specified none could inherit the relay's own and every
  agent's hook would report against that pane.

* fix(dsh): keep the flow-style refusal in every status read, and scope the mode test to POSIX

A refused patch file carries no managed region, so getStatus() fell through to a bare
not_installed with detail null — the actionable 'rewrite it as a block sequence' message
only ever reached the one-shot install() return. Export the predicate and check it first,
behind one shared message constant.

The owner-only mode assertion cannot hold on Windows, where chmod only toggles the
read-only attribute and mode & 0o777 reads 0o666 for any writable file.

* docs(readme): restore the DeepSeek Harness badge lost in the rebase

* test(mobile): repin the session-route closure to the measured 4221

Measured, not derived: 4220 without the DSH icon entry, 4221 with it. Two of the three
modules above main's 4218 pin are not this change's — they arrived with the mobile work
after #22570 and were never repinned; the changelog records that split explicitly.

* fix(dsh): settle tui-idle on the agent's own hook, so supervised workers see it ready

Reported by a tester on the adhoc build: `terminal wait --for tui-idle` ran to its 90s
timeout against an already-ready DSH composer, so a supervised worker never sees the agent
as ready.

Every existing tier reads the title, and DSH deliberately carries no title status: its rest
prefix is Gemini's working glyph, so the detector reports none. A fresh first-party `done`
is better evidence than any title anyway — it is the agent's own account of its own turn,
and normalizeDshEvent drops subagent events, so it is the lead's. Scoped to DSH: for agents
whose hooks report child turns, a mid-turn `done` is the #6011 class this file prevents.

* test(daemon): record the DSH transcript's true-colour I2 divergences

Adding the dsh-tui capture to __fixtures__ enrolled it in the serialize replay sweep, where
it reports 10 I2 divergences and failed the unlisted-transcript default of 0.

Every one is the same shape — visible-grid row=0, a 24-bit background the round trip does
not restore to default — which is DSH's whale intro painting whole rows of true colour.
Verified as an upstream limitation rather than a regression by replaying against the
previous build (build-serialize-addon-at-ref.mjs --ref origin/main): I1 and I3 both hold.

* fix(dsh): return the new tui-idle verdict from the first-party done lane

Main refactored isTuiIdleSatisfied into evaluateTuiIdle, which returns a verdict rather
than a boolean. The DSH lane still returned `true`; it is tier-1 positive evidence, so it
returns READY_STRONG like the title/body lane above it. Re-verified the regression test
still fails without the lane.

* test(relay): pin the scrub-safe pane-identity aliases on the relay spawn path

The relay builds a remote pane's env itself, so the alias mirroring there had no
test: removing the call left every suite green while remote DSH status silently
vanished. Both cases fail without it.

* docs(dsh): point the hook service at the integration reference

The reference doc had no inbound link from anywhere in the repo.
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