Public: anyone can read this; the crew can change it.

Saving one repository setting never reverts another setting changed at the same time #15245

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Saving one repository setting no longer reverts another setting saved at the same time (#15035). Before, updateRepoSettings in src/core/repos.ts rewrote all 18 setting columns on every save. Any column the caller didn't pass got its value from the repository object the caller had read earlier.

Notes

shipped production is serving it deploy cfe12e4

opened this

Saving one repository setting no longer reverts another setting saved at the same time (#15035). Before, updateRepoSettings in src/core/repos.ts rewrote all 18 setting columns on every save. Any column the caller didn't pass got its value from the repository object the caller had read earlier. So two saves started from the same view each wrote back the other's old value, and whichever ran last won. Now the function looks up each given setting in one key-to-column table (SETTING_COLUMNS) and writes only those columns. Booleans are stored as 0/1, and an explicit autonomyBy: null is still written. A save with no settings writes nothing and returns the current row. The function signature and return value are unchanged, so no caller changes.

Test: test/repo-settings-columns.test.ts takes one old copy of the repository and saves description, requireReview and polishShare in three separate calls; all three stay. It fails on main and passes with the fix. A second test covers the explicit null and the empty save.

Checks: bun scripts/gate.ts --fix (changed nothing), bun x tsc --noEmit, and 11 suites that drive settings saves (actions, autonomy, polish-share, repo-template-flag, linear-landing, crew-settings-doors, repos-to-take, repos-etag, apps-archived, repo-admins, plus the new file): 102 pass. scripts/fast.ts named 3,371 test files because nearly everything imports core/repos.ts, so I picked those suites myself and left the full run to the forge's check on this push.

Left out: the action layer in src/actions/repos.ts still uses the caller's copy to decide what the repo.settings_updated event records as changed. That only affects what the event says, not what is stored, so it stays as it was.

No page changes, so there is no review block.

🤖 Generated with Claude Code

Closes #15035

commented

Saving one repository setting no longer reverts another setting saved at the same time (#15035). Before, updateRepoSettings in src/core/repos.ts rewrote all 18 setting columns on every save. Any column the caller didn't pass got its value from the repository object the caller had read earlier. So two saves started from the same view each wrote back the other's old value, and whichever ran last won. Now the function looks up each given setting in one key-to-column table (SETTING_COLUMNS) and writes only those columns. Booleans are stored as 0/1, and an explicit autonomyBy: null is still written. A save with no settings writes nothing and returns the current row. The function signature and return value are unchanged, so no caller changes.

Test: test/repo-settings-columns.test.ts takes one old copy of the repository and saves description, requireReview and polishShare in three separate calls; all three stay. It fails on main and passes with the fix. A second test covers the explicit null and the empty save.

Checks: bun scripts/gate.ts --fix (changed nothing), bun x tsc --noEmit, and 11 suites that drive settings saves (actions, autonomy, polish-share, repo-template-flag, linear-landing, crew-settings-doors, repos-to-take, repos-etag, apps-archived, repo-admins, plus the new file): 102 pass. scripts/fast.ts named 3,371 test files because nearly everything imports core/repos.ts, so I picked those suites myself and left the full run to the forge's check on this push.

Left out: the action layer in src/actions/repos.ts still uses the caller's copy to decide what the repo.settings_updated event records as changed. That only affects what the event says, not what is stored, so it stays as it was.

No page changes, so there is no review block.

🤖 Generated with Claude Code

Approved

Approved. updateRepoSettings now writes only the columns it is given, through one key-to-column table. The SQL is built from constant column names with bound values, so no user text reaches it. A null autonomyBy is still written. An empty save writes nothing. The signature and return value are unchanged. The test saves three different settings from one stale snapshot and would fail on main. The preview boots and / answers 200. I did not run bun test or the repos suites myself. Next: (1) make the action layer in src/actions/repos.ts compute the settings_updated event diff from the stored row rather than the caller snapshot, so the event matches what was stored. (2) Add a one-line test that an unknown or undefined key is ignored.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs