Repository navigation
fix(server): t3_project_update saves the default model where Settings reads it #42297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a424325
01c3459
bf25570
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -538,22 +538,40 @@ export const make = Effect.gen(function* () { | |
| return Option.isNone(row) ? Option.none() : Option.some(yield* hydrate(row.value)); | ||
| }); | ||
|
|
||
| // Once project settings are folded, actions resolve from Settings only, where the app's editor saves them. | ||
| const saveScripts = (projectId: ProjectId, scripts: ProjectCreateInput["scripts"]) => | ||
| scripts === undefined | ||
| // Once project settings are folded, project defaults resolve from Settings only, where the app's editor saves them. | ||
| const saveProjectSettings = ( | ||
| projectId: ProjectId, | ||
| input: Pick< | ||
| ProjectUpdateInput, | ||
| "scripts" | "defaultModelSelection" | "defaultThreadEnvMode" | "autoPull" | ||
| >, | ||
| ) => | ||
| input.scripts === undefined && | ||
| input.defaultModelSelection === undefined && | ||
| input.defaultThreadEnvMode === undefined && | ||
| input.autoPull === undefined | ||
| ? Effect.void | ||
| : serverSettings.getSettings.pipe( | ||
| // A patch replaces the project's whole entry, so its other overrides are carried over. | ||
| Effect.flatMap(({ projectSettingsOverrides }) => | ||
| serverSettings.updateSettings({ | ||
| projectSettingsOverrides: { | ||
| [projectId]: { | ||
| ...projectSettingsOverrides[projectId], | ||
| defaultProjectScripts: scripts, | ||
| }, | ||
| }, | ||
| }), | ||
| ), | ||
| Effect.flatMap(({ projectSettingsOverrides }) => { | ||
| const entry = { | ||
| ...projectSettingsOverrides[projectId], | ||
| ...(input.scripts === undefined ? {} : { defaultProjectScripts: input.scripts }), | ||
| ...(input.defaultModelSelection == null | ||
| ? {} | ||
| : { defaultModelSelection: input.defaultModelSelection }), | ||
| ...(input.defaultThreadEnvMode == null | ||
| ? {} | ||
| : { defaultThreadEnvMode: input.defaultThreadEnvMode }), | ||
| ...(input.autoPull === undefined ? {} : { defaultAutoPull: input.autoPull }), | ||
| }; | ||
| // A cleared project default inherits the machine's setting again. | ||
| if (input.defaultModelSelection === null) delete entry.defaultModelSelection; | ||
| if (input.defaultThreadEnvMode === null) delete entry.defaultThreadEnvMode; | ||
| return serverSettings.updateSettings({ | ||
| projectSettingsOverrides: { [projectId]: entry }, | ||
| }); | ||
| }), | ||
| Effect.asVoid, | ||
| Effect.mapError( | ||
| (cause) => | ||
|
|
@@ -590,7 +608,7 @@ export const make = Effect.gen(function* () { | |
| trackedFolders, | ||
| }, | ||
| undefined, | ||
| saveScripts(input.projectId, input.scripts), | ||
| saveProjectSettings(input.projectId, { scripts: input.scripts }), | ||
| ); | ||
| yield* projectEnrichment.invalidate([workspaceRoot]); | ||
| return yield* readCommitted(input.projectId); | ||
|
|
@@ -674,7 +692,7 @@ export const make = Effect.gen(function* () { | |
| ); | ||
| return { ...command, trackedFolders }; | ||
| }), | ||
| saveScripts(input.projectId, input.scripts), | ||
| saveProjectSettings(input.projectId, input), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep failed settings persistence retryable. If Persist recoverable pending settings work before treating the operation as complete. Recovery must preserve command ordering; replaying every old accepted command could overwrite newer settings.
|
||
| ); | ||
| if (workspaceRoot !== previousRoot || input.faviconPath !== undefined) { | ||
| yield* projectEnrichment.invalidate([previousRoot, workspaceRoot]); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define the settings operation with a named
Effect.fn.This reusable helper now performs settings reads and writes for multiple project defaults. Use
Effect.fn("ProjectService.saveProjectSettings")so these operations have a distinct persistence span.As per coding guidelines, “Reusable functions use
Effect.fn("Service.operation").” As per path instructions, use namedEffect.fnspans by default for reusable Effect operations.Sources: Coding guidelines, Path instructions