Repository navigation
Description
What happens
Config.global() reads the three global config files like this:
export const global = lazy(async () => {
let result: Info = pipe(
{},
mergeDeep(await loadFile(path.join(Global.Path.config, "config.json"))),
mergeDeep(await loadFile(path.join(Global.Path.config, "openscience.json"))),
mergeDeep(await loadFile(path.join(Global.Path.config, "openscience.jsonc"))),
)openscience.json is merged before openscience.jsonc, and mergeDeep is later-wins, so the jsonc file has the final say.
That is the reverse of the documented and implemented order everywhere else. The filename list right at the top of the same file says:
// Config filenames, oldest first: later merges win, so the legacy names load
// as the base and openscience.json(c) overrides them.
const CONFIG_FILES = ["synsc.jsonc", "synsc.json", "openscience.jsonc", "openscience.json"]and the project-config loader iterates exactly that list, so a project already resolves openscience.json over openscience.jsonc. The global loader is the only place that disagrees.
The legacy TOML migration ~15 lines below re-reads the same list in the same wrong order:
const files = ["config.json", "openscience.json", "openscience.jsonc"].map(...)Why it is wrong
openscience.json is what the app writes when you change a setting; openscience.jsonc is the hand-maintained, comment-friendly variant. A user who keeps a commented openscience.jsonc — the whole point of the format — and lets the app manage openscience.json gets their stale jsonc value silently winning, and the setting they just changed in the UI appears not to have applied.
This is the same "global and project disagree" class as the .openscience directory precedence, and the two disagree in the same direction: the project path resolves openscience.json last, the global path resolves openscience.jsonc last.
Reproduction
Verified on this machine:
openscience.jsonc { "model": "model-from-the-jsonc-file" }
openscience.json { "model": "model-from-the-json-file" }
Config.global().model -> "model-from-the-jsonc-file" (expected "model-from-the-json-file")
A project .openscience with the same two files resolves the other way.
Suggested fix
Swap the two merges so openscience.json is read last, and reorder the migration's list to match:
mergeDeep(await loadFile(path.join(Global.Path.config, "openscience.jsonc"))),
mergeDeep(await loadFile(path.join(Global.Path.config, "openscience.json"))),The new test writes both files into the test-isolated Global.Path.config, asserts the json value wins, and cleans up after itself.
Note
global() uses mergeDeep where the rest of the loader uses mergeConfigConcatArrays (which unions plugin and instructions rather than replacing them). That inconsistency is real but is a separate behaviour change, so it is left alone here rather than folded into a precedence fix.
Activity