Skip to content

Commit 26bc765

Browse files
Merge remote-tracking branch 'origin/main' into factory/issue-33853
2 parents f1907f9 + d313b2a commit 26bc765

18 files changed

Lines changed: 599 additions & 80 deletions

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ function AdaptiveWorkspaceLayoutContent(
362362
floatingTabs.row,
363363
floatingTabsEnabled,
364364
]);
365-
// A floating sidebar brings the rail with it.
366-
const width = viewportWidth - (sidebarFloats ? 0 : navigationRailWidth);
365+
// The rail keeps its room even while the sidebar floats; only the list pane overlays the page.
366+
const width = viewportWidth - navigationRailWidth;
367367
// The sidebar stays mounted under a workspace page, so its list is ready on the way back.
368368
const shouldRenderPrimarySidebar = layout.usesSplitView;
369369
const fileInspector = useMemo(
@@ -721,7 +721,7 @@ function AdaptiveWorkspaceLayoutContent(
721721
// panes land. A sliding sidebar uncovers the strip it is about to fill, or covers the content
722722
// until it is gone.
723723
const contentLeftTarget = sidebarFloats
724-
? 0
724+
? navigationRailWidth
725725
: navigationRailWidth +
726726
(shouldRenderPrimarySidebar && !workspacePage && panes.primarySidebarVisible
727727
? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
@@ -794,7 +794,9 @@ function AdaptiveWorkspaceLayoutContent(
794794
workspacePage,
795795
]);
796796
const railAnimatedStyle = useAnimatedStyle(() => ({ width: renderedRailWidth.value }));
797-
const floatingSidebarAnimatedStyle = useAnimatedStyle(() => ({ left: renderedRailWidth.value }));
797+
const floatingSidebarAnimatedStyle = useAnimatedStyle(() => ({
798+
left: sidebarFloats ? renderedRailWidth.value : 0,
799+
}));
798800
const floatingSidebarOpen = sidebarFloats && panes.primarySidebarVisible;
799801
// Its own value, so a sidebar that was beside a list doesn't dim the page as it leaves.
800802
const scrimOpacity = useSharedValue(0);
@@ -850,7 +852,7 @@ function AdaptiveWorkspaceLayoutContent(
850852
Math.max(
851853
0,
852854
viewportWidth -
853-
(sidebarFloats ? 0 : renderedRailWidth.value) -
855+
renderedRailWidth.value -
854856
(workspacePage || sidebarFloats ? 0 : renderedSidebarWidth.value) -
855857
renderedInspectorWidth.value,
856858
),
@@ -974,10 +976,7 @@ function AdaptiveWorkspaceLayoutContent(
974976
>
975977
<AndroidHingeObserver onChange={handleHingeChange} />
976978
{shouldRenderNavigationRail ? (
977-
<Animated.View
978-
className={sidebarFloats ? "absolute inset-y-0 left-0" : "shrink self-stretch"}
979-
style={railAnimatedStyle}
980-
/>
979+
<Animated.View className="shrink self-stretch" style={railAnimatedStyle} />
981980
) : null}
982981
{shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (
983982
<Animated.View
@@ -994,11 +993,9 @@ function AdaptiveWorkspaceLayoutContent(
994993
style={[
995994
workspacePage ? { position: "absolute", top: 0, bottom: 0, left: 0 } : null,
996995
sidebarFloats
997-
? [
998-
{ position: "absolute", top: 0, bottom: 0, zIndex: 2, elevation: 8 },
999-
floatingSidebarAnimatedStyle,
1000-
]
996+
? { position: "absolute", top: 0, bottom: 0, zIndex: 2, elevation: 8 }
1001997
: null,
998+
floatingSidebarAnimatedStyle,
1002999
sidebarAnimatedStyle,
10031000
]}
10041001
>

‎apps/server/src/device/DeviceHost.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ export interface DeviceHostReady {
162162
readonly run: (
163163
command: string,
164164
args: ReadonlyArray<string>,
165-
options?: { readonly timeoutMs?: number; readonly stdin?: string },
165+
options?: {
166+
readonly timeoutMs?: number;
167+
readonly stdin?: string;
168+
/** Local output cap; SSH output is not capped. */
169+
readonly maxOutputBytes?: number;
170+
},
166171
) => Effect.Effect<{ readonly stdout: string; readonly stderr: string; readonly code: number }>;
167172
readonly helpers: {
168173
readonly serveSimAxSettings: string | null;

‎apps/server/src/device/DeviceHubOperations.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const LIST_TIMEOUT_SECONDS = 40;
1919
// expo-device-hub 0.19.1 reports a failed simulator listing only as text; its error ids are hashes.
2020
const SIMULATOR_LIST_FAILED =
2121
/^\[apple-utils\] (?:Failed to (?:run `xcrun simctl list devices|parse JSON output:|list devices:)|`xcrun simctl list devices --json` did not respond within )/;
22+
// The hub passes numeric display IDs that Xcode 26 rejects; iOS 27 needs them for multiple displays.
23+
const runsOnXcode26Runtime = (version: string) => Number(/^iOS (\d+)/.exec(version)?.[1]) <= 26;
24+
const DEFAULT_DISPLAY_SCREENSHOT = `f=$(mktemp -t t3-screenshot) || exit 1
25+
trap 'rm -f "$f"' 0
26+
xcrun simctl io "$1" screenshot --type=png "$f" >/dev/null && base64 -i "$f"`;
2227

2328
const HubDevice = Schema.Struct({
2429
id: Schema.String,
@@ -265,6 +270,24 @@ export const makeDeviceHubOperations = (options: {
265270
},
266271
);
267272

273+
const defaultDisplayScreenshot = Effect.fn("DeviceHubOperations.defaultDisplayScreenshot")(
274+
function* (udid: string) {
275+
const capture = yield* run("sh", ["-c", DEFAULT_DISPLAY_SCREENSHOT, "sh", udid], {
276+
timeoutMs: Duration.toMillis(SCREENSHOT_TIMEOUT),
277+
maxOutputBytes: 64 * 1024 * 1024,
278+
});
279+
if (capture.code !== 0) {
280+
return yield* new DeviceOperationError({
281+
operation: "screenshot",
282+
reason: "command_failed",
283+
exitCode: capture.code,
284+
cause: capture.stderr.trim(),
285+
});
286+
}
287+
return new Uint8Array(Buffer.from(capture.stdout, "base64"));
288+
},
289+
);
290+
268291
const screenshot: DeviceOperations["screenshot"] = (device) =>
269292
httpClient
270293
.execute(
@@ -289,6 +312,13 @@ export const makeDeviceHubOperations = (options: {
289312
cause,
290313
}),
291314
),
315+
Effect.catchIf(
316+
(error) =>
317+
device.platform === "ios" &&
318+
runsOnXcode26Runtime(device.version) &&
319+
error.reason === "hub_rejected",
320+
() => defaultDisplayScreenshot(device.id),
321+
),
292322
Effect.withSpan("DeviceHubOperations.screenshot"),
293323
);
294324

‎apps/server/src/device/DeviceHubProxy.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ const handler = Effect.gen(function* () {
213213
upstreamSearch.delete("wsTicket");
214214
upstreamSearch.delete("hostId");
215215
const search = upstreamSearch.size > 0 ? `?${upstreamSearch.toString()}` : "";
216+
const screenshotDevice = upstreamSearch.get("device");
217+
if (!ready.upstream && hubPath === "/vendor/serve-sim/api/screenshot" && screenshotDevice) {
218+
const { png } = yield* devices.screenshot({ hostId: ready.hostId, deviceId: screenshotDevice });
219+
return HttpServerResponse.uint8Array(png, {
220+
contentType: "image/png",
221+
headers: { "cache-control": "no-store, no-transform" },
222+
});
223+
}
216224
// Hosts with several upstreams (one per cloud session) route and authenticate requests themselves.
217225
const routed = ready.upstream ? yield* ready.upstream(hubPath, upstreamSearch) : undefined;
218226
if (routed === null) {

‎apps/server/src/device/DeviceService.test.ts‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const decodeBootError = Schema.decodeUnknownSync(Schema.fromJsonString(DeviceBoo
4848
const encodeBootError = Schema.encodeSync(Schema.fromJsonString(DeviceBootError));
4949

5050
it.effect.each([400, 500])(
51-
"distinguishes screenshot HTTP rejection (%s) from transport failure",
51+
"retries a hub-rejected (%s) screenshot with simctl only on iOS 26 and older",
5252
(status) =>
5353
Effect.gen(function* () {
5454
const operations = makeDeviceHubOperations({
@@ -59,22 +59,26 @@ it.effect.each([400, 500])(
5959
HttpClientResponse.fromWeb(request, new Response("private hub output", { status })),
6060
),
6161
),
62-
run: () => Effect.die("Screenshot does not run a command"),
62+
run: () => Effect.succeed({ code: 0, stdout: "iVBORw==", stderr: "" }),
6363
platformAvailable: () => Effect.succeed(false),
6464
});
65-
const result = yield* operations
66-
.screenshot({
67-
id: "phone",
68-
name: "Phone",
69-
version: "iOS 26.3",
70-
platform: "ios",
71-
booted: true,
72-
physical: false,
73-
})
74-
.pipe(Effect.result);
75-
expect(result).toMatchObject({
65+
const screenshot = (version: string) =>
66+
operations
67+
.screenshot({
68+
id: "phone",
69+
name: "Phone",
70+
version,
71+
platform: "ios",
72+
booted: true,
73+
physical: false,
74+
})
75+
.pipe(Effect.result);
76+
expect(yield* screenshot("iOS 27.0")).toMatchObject({
7677
failure: { _tag: "DeviceOperationError", reason: "hub_rejected" },
7778
});
79+
expect(yield* screenshot("iOS 26.3")).toMatchObject({
80+
success: new Uint8Array([137, 80, 78, 71]),
81+
});
7882
}),
7983
);
8084

‎apps/server/src/device/LocalDeviceHost.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ export const make = Effect.fn("LocalDeviceHost.make")(function* () {
806806
timeout: Duration.millis(options?.timeoutMs ?? 20_000),
807807
timeoutBehavior: "timedOutResult",
808808
...(options?.stdin === undefined ? {} : { stdin: options.stdin }),
809+
...(options?.maxOutputBytes === undefined
810+
? {}
811+
: { maxOutputBytes: options.maxOutputBytes }),
809812
})
810813
.pipe(
811814
Effect.map((result) => ({

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5774,8 +5774,15 @@ describe("CodexAdapterV2 post-settle continuation", () => {
57745774
);
57755775

57765776
it.effect.each([
5777+
// regression: #27773 a first-request 429 only notifies the reset-less premium limit
57775778
{
5778-
name: "usage",
5779+
name: "first-request-reset",
5780+
code: "usageLimitExceeded",
5781+
notification: false,
5782+
expectedClass: "usage_limit",
5783+
},
5784+
{
5785+
name: "newer-reset-during-read",
57795786
code: "usageLimitExceeded",
57805787
notification: false,
57815788
expectedClass: "usage_limit",
@@ -5891,6 +5898,37 @@ describe("CodexAdapterV2 post-settle continuation", () => {
58915898
},
58925899
},
58935900
};
5901+
const readsReset =
5902+
scenario.name === "first-request-reset" || scenario.name === "newer-reset-during-read";
5903+
// Usage limits with no known reset read the account before publishing their terminal.
5904+
const readsAccount =
5905+
scenario.expectedClass === "usage_limit" &&
5906+
!("expectedCode" in scenario) &&
5907+
scenario.name !== "deferred-reset";
5908+
const premium = {
5909+
...snapshot,
5910+
frame: {
5911+
method: "account/rateLimits/updated",
5912+
params: { rateLimits: { limitId: "premium", primary: null, secondary: null } },
5913+
},
5914+
};
5915+
const newerSnapshot = {
5916+
...snapshot,
5917+
frame: {
5918+
method: "account/rateLimits/updated",
5919+
params: {
5920+
rateLimits: {
5921+
limitId: "codex",
5922+
primary: { usedPercent: 100, resetsAt: 2000200000, windowDurationMins: 300 },
5923+
},
5924+
},
5925+
},
5926+
};
5927+
const readRequest = {
5928+
type: "expect_outbound" as const,
5929+
label: "account/rateLimits/read",
5930+
frame: { id: 4, method: "account/rateLimits/read", params: null },
5931+
};
58945932
const transcript = makeCodexReplayTranscript({
58955933
scenario: `codex-limit-${scenario.name}`,
58965934
entries: [
@@ -5915,6 +5953,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
59155953
},
59165954
]
59175955
: []),
5956+
...(readsReset ? [premium] : []),
59185957
...(scenario.name === "deferred-reset" ? [snapshot] : []),
59195958
...(scenario.name === "deferred-reset"
59205959
? [
@@ -5999,7 +6038,36 @@ describe("CodexAdapterV2 post-settle continuation", () => {
59996038
},
60006039
},
60016040
},
6002-
...(scenario.name === "late-reset" || "resetAfter" in scenario ? [snapshot] : []),
6041+
...(readsAccount ? [readRequest] : []),
6042+
...(scenario.name === "newer-reset-during-read" ? [newerSnapshot] : []),
6043+
...(readsReset
6044+
? [
6045+
{
6046+
type: "emit_inbound" as const,
6047+
label: "account/rateLimits/read",
6048+
frame: {
6049+
id: 4,
6050+
result: {
6051+
...premium.frame.params,
6052+
rateLimitsByLimitId: { codex: snapshot.frame.params.rateLimits },
6053+
},
6054+
},
6055+
},
6056+
]
6057+
: []),
6058+
...(readsAccount && !readsReset
6059+
? [
6060+
{
6061+
type: "emit_inbound" as const,
6062+
label: "account/rateLimits/read",
6063+
frame: { id: 4, error: { code: -32600, message: "Not signed in." } },
6064+
},
6065+
]
6066+
: []),
6067+
...(scenario.name === "late-reset"
6068+
? [{ ...snapshot, label: "account/rateLimits/updated/late" }]
6069+
: []),
6070+
...("resetAfter" in scenario ? [snapshot] : []),
60036071
...(scenario.name === "deferred-reset"
60046072
? [
60056073
{
@@ -6038,17 +6106,24 @@ describe("CodexAdapterV2 post-settle continuation", () => {
60386106
});
60396107
const resetReceipt = yield* Deferred.make<void>();
60406108
const snapshotReceipt = yield* Deferred.make<void>();
6109+
const terminalReceipt = yield* Deferred.make<void>();
60416110
const harness = yield* makeCodexReplayHarness(
60426111
transcript,
60436112
(event) =>
6044-
event.type === "turn_item.updated" &&
6045-
event.turnItem.type === "error" &&
6046-
event.turnItem.failure.resetAt === resetAt
6047-
? Deferred.succeed(resetReceipt, undefined)
6048-
: Effect.void,
6049-
undefined,
6113+
event.type === "turn.terminal"
6114+
? Deferred.succeed(terminalReceipt, undefined)
6115+
: event.type === "turn_item.updated" &&
6116+
event.turnItem.type === "error" &&
6117+
event.turnItem.failure.resetAt === resetAt
6118+
? Deferred.succeed(resetReceipt, undefined)
6119+
: Effect.void,
60506120
undefined,
60516121
undefined,
6122+
// The late reset must land after the terminal its failed read released.
6123+
(entry) =>
6124+
entry.label === "account/rateLimits/updated/late"
6125+
? Deferred.await(terminalReceipt)
6126+
: Effect.void,
60526127
() => Deferred.succeed(snapshotReceipt, undefined),
60536128
);
60546129
yield* harness.runtime.startTurn(
@@ -6066,7 +6141,10 @@ describe("CodexAdapterV2 post-settle continuation", () => {
60666141
if (terminal?.status !== "failed") return;
60676142
assert.equal(terminal.failure.class, scenario.expectedClass);
60686143
assert.equal(terminal.threadDisposition, "reusable");
6069-
if (scenario.name === "deferred-reset") assert.equal(terminal.failure.resetAt, resetAt);
6144+
if (scenario.name === "deferred-reset" || scenario.name === "first-request-reset")
6145+
assert.equal(terminal.failure.resetAt, resetAt);
6146+
if (scenario.name === "newer-reset-during-read")
6147+
assert.equal(terminal.failure.resetAt, "2033-05-20T11:06:40.000Z");
60706148
if (scenario.name === "matching-details")
60716149
assert.equal(terminal.failure.message, "Detailed provider allowance explanation.");
60726150
if ("resetAfter" in scenario) {

0 commit comments

Comments
 (0)