feat(mobile): iPhone Duo key rail with D-pad, split terminal panes and half-fold layout (#35177)

Carries over #33221 and #33210. Replaces our #34484 Duo support with the community design, on top of main's rebuilt terminal key bar (#36166).

Fixes #33200

Co-authored-by: Takeshi Matsumoto <zytakeshi520@gmail.com>
Co-authored-by: Lars Keggenhoff <lars@kghf.io>
This commit is contained in:
Kelvin Amoaba
2026-10-30 16:35:12 +00:00
committed by GitHub
co-authored by Takeshi Matsumoto Lars Keggenhoff
parent 0eaa1f9049
commit a803cbead8
213 changed files with 10043 additions and 1899 deletions
@@ -169,6 +169,15 @@ describe('the page routes a manifest declares', () => {
expect(withRoutes([{ pathname: '/h', grants: ['browser.screencast'] }])).toBe(false)
})
it('accepts explicit cross-layout host ownership without changing legacy route declarations', () => {
const legacy = { pathname: '/h/[hostId]', grants: ['navigate'], canOwnHostArea: true }
expect(withRoutes([legacy])).toBe(true)
expect(withRoutes([{ ...legacy, canOwnHostAreaAcrossLayouts: true }])).toBe(true)
for (const invalid of [false, 'true', 1, null]) {
expect(withRoutes([{ ...legacy, canOwnHostAreaAcrossLayouts: invalid }])).toBe(false)
}
})
it('refuses a route carrying a field the contract does not declare', () => {
expect(withRoutes([{ pathname: '/h', grants: [], screen: 'x' }])).toBe(false)
})
@@ -191,30 +200,16 @@ describe('the page routes a manifest declares', () => {
expect(withRoutes([{ pathname: '/h', grants: [], optionalGrants: [''] }])).toBe(false)
})
it('bounds the two lists together, not one at a time', () => {
it('bounds each list on its own, as released shells read them', () => {
const names = (count, prefix) =>
Array.from({ length: count }, (_value, index) => `${prefix}${String(index)}`)
const half = MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS / 2
// At the ceiling exactly, split across the lanes.
const cap = MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS
expect(
withRoutes([
{ pathname: '/h', grants: names(half, 'req'), optionalGrants: names(half, 'opt') }
])
withRoutes([{ pathname: '/h', grants: names(cap, 'req'), optionalGrants: names(cap, 'opt') }])
).toBe(true)
// Individually valid arrays can exceed the combined session grant cap.
expect(withRoutes([{ pathname: '/h', grants: names(cap + 1, 'req') }])).toBe(false)
expect(
withRoutes([
{ pathname: '/h', grants: names(half + 1, 'req'), optionalGrants: names(half, 'opt') }
])
).toBe(false)
expect(
withRoutes([
{
pathname: '/h',
grants: [],
optionalGrants: names(MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS + 1, 'opt')
}
])
withRoutes([{ pathname: '/h', grants: [], optionalGrants: names(cap + 1, 'opt') }])
).toBe(false)
})
@@ -16,6 +16,8 @@ export const MOBILE_WEB_BUNDLE_MAX_TOTAL_BYTES = 32 * 1024 * 1024
export const MOBILE_WEB_BUNDLE_MAX_ASSET_BYTES = 10 * 1024 * 1024
export const MOBILE_WEB_BUNDLE_MAX_ROUTES = 64
export const MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS = 16
// What a route's two lists can grant together; released shells cap each list alone, never the pair.
export const MOBILE_WEB_BUNDLE_MAX_GRANTED_ROUTE_GRANTS = 2 * MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS
export const SHA256_PATTERN = /^[a-f0-9]{64}$/
const ASSET_PATH_PATTERN = /^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/
@@ -108,22 +110,11 @@ export const MobileWebBundleRouteSchema = z
.max(MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS)
.optional(),
/** The page can draw the wide host area, sidebar included, when `init` says it owns it. */
canOwnHostArea: z.literal(true).optional()
canOwnHostArea: z.literal(true).optional(),
/** This page also renders the narrow host area; legacy ownership remains wide-only. */
canOwnHostAreaAcrossLayouts: z.literal(true).optional()
})
.strict()
// Cap the combined session grant set as well as each input array; separate caps would allow twice the limit.
.superRefine((route, context) => {
if (
route.grants.length + (route.optionalGrants?.length ?? 0) >
MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS
) {
context.addIssue({
code: 'custom',
path: ['optionalGrants'],
message: 'grants and optionalGrants together must not exceed the route grant ceiling'
})
}
})
export type MobileWebBundleRoute = z.infer<typeof MobileWebBundleRouteSchema>