| author | |
| committer | |
| log | 8b3ddf51c59a54411cd02b321cb07f39c927df09 |
| tree | 4659d34c0c96f8a022e16215b5dfc23c050e3faf |
| parent | d7c71f91d61e68ae35fcc0032847cb42324a8b51 |
| signature | Signed by PGP key B5690EEEBB952194 |
2 files changed, 12 insertions(+), 2 deletions(-)
packages/shared/src/projectSettings.test.ts+8| ... | @@ -29,6 +29,14 @@ describe("resolveProjectSettings", () => { | ... | @@ -29,6 +29,14 @@ describe("resolveProjectSettings", () => { |
| 29 | ); | 29 | ); |
| 30 | }); | 30 | }); |
| 31 | 31 | ||
| 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 | |||
| 32 | it("applies overrides per key and reports their source", () => { | 40 | it("applies overrides per key and reports their source", () => { |
| 33 | const settings = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, { | 41 | const settings = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, { |
| 34 | defaultAutoPull: true, | 42 | defaultAutoPull: true, |
packages/shared/src/projectSettings.ts+4-2| ... | @@ -59,11 +59,13 @@ export interface LegacyProjectSettingsFields { | ... | @@ -59,11 +59,13 @@ export interface LegacyProjectSettingsFields { |
| 59 | export function resolveProjectSettings( | 59 | export function resolveProjectSettings( |
| 60 | settings: ServerSettings, | 60 | settings: ServerSettings, |
| 61 | projectId: ProjectId | null, | 61 | 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, | ||
| 63 | ): ResolvedProjectSettings { | 65 | ): ResolvedProjectSettings { |
| 64 | const stored = projectId === null ? undefined : settings.projectSettingsOverrides[projectId]; | 66 | const stored = projectId === null ? undefined : settings.projectSettingsOverrides[projectId]; |
| 65 | const overrides: ProjectSettingsOverrides = | 67 | const overrides: ProjectSettingsOverrides = |
| 66 | project === undefined || settings.projectSettingsFolded | 68 | project == null || settings.projectSettingsFolded |
| 67 | ? (stored ?? EMPTY_OVERRIDES) | 69 | ? (stored ?? EMPTY_OVERRIDES) |
| 68 | : { | 70 | : { |
| 69 | ...(project.defaultModelSelection != null | 71 | ...(project.defaultModelSelection != null |