authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-12 23:33:09-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-12 23:33:09-07:00
log8b3ddf51c59a54411cd02b321cb07f39c927df09
tree4659d34c0c96f8a022e16215b5dfc23c050e3faf
parentd7c71f91d61e68ae35fcc0032847cb42324a8b51
signature Signed by PGP key B5690EEEBB952194

fix(mobile): stop crashing on launch before the shell snapshot arrives (#11537)


2 files changed, 12 insertions(+), 2 deletions(-)

packages/shared/src/projectSettings.test.ts+8
......@@ -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+4-2
......@@ -59,11 +59,13 @@ export interface LegacyProjectSettingsFields {
5959export 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