fix(mobile): stop crashing on launch before the shell snapshot arrives (#11537)
This commit is contained in:
1 parent
d7c71f91d6
commit
8b3ddf51c5
2 files changed
+12
-2
No files matched your search
@@ -29,6 +29,14 @@ describe("resolveProjectSettings", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("treats a null project like an absent one before the shell snapshot arrives", () => {
|
||||
// The mobile new-task flow resolves settings while its selected project is
|
||||
// still null; reading the aggregate's legacy fields off null crashed launch.
|
||||
expect(resolveProjectSettings(DEFAULT_SERVER_SETTINGS, null, null).settings).toBe(
|
||||
DEFAULT_SERVER_SETTINGS,
|
||||
);
|
||||
});
|
||||
|
||||
it("applies overrides per key and reports their source", () => {
|
||||
const settings = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, {
|
||||
defaultAutoPull: true,
|
||||
|
||||
@@ -59,11 +59,13 @@ export interface LegacyProjectSettingsFields {
|
||||
export function resolveProjectSettings(
|
||||
settings: ServerSettings,
|
||||
projectId: ProjectId | null,
|
||||
project?: LegacyProjectSettingsFields,
|
||||
// Nullable, not just optional: the mobile new-task flow passes its selected
|
||||
// project straight through, and that is null until the shell snapshot lands.
|
||||
project?: LegacyProjectSettingsFields | null,
|
||||
): ResolvedProjectSettings {
|
||||
const stored = projectId === null ? undefined : settings.projectSettingsOverrides[projectId];
|
||||
const overrides: ProjectSettingsOverrides =
|
||||
project === undefined || settings.projectSettingsFolded
|
||||
project == null || settings.projectSettingsFolded
|
||||
? (stored ?? EMPTY_OVERRIDES)
|
||||
: {
|
||||
...(project.defaultModelSelection != null
|
||||
|
||||
Reference in new issue
Block a user