Skip to content

Commit 421ea38

Browse files
fix(mobile): stop crashing on launch before the shell snapshot arrives
Build 56 still died on every cold open. The device's expo-error.log names it: "TypeError: Cannot read property 'defaultModelSelection' of null" in NewTaskFlowProvider. resolveProjectSettings reads the project aggregate's legacy fields when projectSettingsFolded is false, and the mobile flow passes its selected project through as-is, which is null until the shell snapshot lands. tsc did not catch it: apps/mobile extends Expo's tsconfig without noUncheckedIndexedAccess, so `projects[0] ?? null` types as non-null there. Accept null in resolveProjectSettings and treat it like an absent project. Co-Authored-By: Claude Code <[email protected]>
1 parent d7c71f9 commit 421ea38

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎packages/shared/src/projectSettings.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ describe("resolveProjectSettings", () => {
2929
);
3030
});
3131

32+
it("treats a null project like an absent one before the shell snapshot arrives", () => {
33+
// The mobile new-task flow resolves settings while its selected project is
34+
// still null; reading the aggregate's legacy fields off null crashed launch.
35+
expect(resolveProjectSettings(DEFAULT_SERVER_SETTINGS, null, null).settings).toBe(
36+
DEFAULT_SERVER_SETTINGS,
37+
);
38+
});
39+
3240
it("applies overrides per key and reports their source", () => {
3341
const settings = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, {
3442
defaultAutoPull: true,

‎packages/shared/src/projectSettings.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ export interface LegacyProjectSettingsFields {
5959
export function resolveProjectSettings(
6060
settings: ServerSettings,
6161
projectId: ProjectId | null,
62-
project?: LegacyProjectSettingsFields,
62+
// Nullable, not just optional: the mobile new-task flow passes its selected
63+
// project straight through, and that is null until the shell snapshot lands.
64+
project?: LegacyProjectSettingsFields | null,
6365
): ResolvedProjectSettings {
6466
const stored = projectId === null ? undefined : settings.projectSettingsOverrides[projectId];
6567
const overrides: ProjectSettingsOverrides =
66-
project === undefined || settings.projectSettingsFolded
68+
project == null || settings.projectSettingsFolded
6769
? (stored ?? EMPTY_OVERRIDES)
6870
: {
6971
...(project.defaultModelSelection != null

0 commit comments

Comments
 (0)