mirror of
https://github.com/Gitlawb/openclaude.git
synced 2026-11-06 12:50:54 -04:00
* feat(ctx): add --save to /set-context-window to persist overrides `/set-context-window [model] <tokens> --save` applies the session override and also writes modelLimits["<model>"].contextWindow to user settings.json through the existing settings writer, keeping unrelated settings and the entry's maxOutputTokens. The output distinguishes session-only changes, successful saves, and failed saves (the session override still applies). After saving, the command resolves the window a restarted session would use and reports when an env override, the route catalog, or another modelLimits entry will take precedence over the saved value. Precedence is unchanged. Closes #2298 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ctx): check --save values against the settings schema before writing The session override accepts any finite integer of at least 33000 tokens, but the settings schema only accepts safe integers for modelLimits.*.contextWindow. Saving a larger value reported success and wrote an entry that made the whole user settings file fail to load on the next read. Validate the modelLimits patch with SettingsSchema before writing it. A rejected value now prints "Not saved: <path>: <reason>", leaves the file unchanged, and keeps the session override. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ctx): report when invalid settings keep a saved window from loading The settings writer keeps fields the schema rejects that are already in the file, and the loader then ignores the whole file. --save still printed "Saved" and blamed whichever source won without the file, for example "fallback for unknown model ... instead of the saved value". After writing, check whether the user settings file loads. If it does not, say that the saved value will not apply after a restart and list the invalid settings. Update the help text and setup docs to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ctx): report env settings that a --save repair makes loadable Startup ignores an invalid user settings file, including its env block, and the settings watcher skips --save's own write. When --save repaired such a file, the restart check still read this session's environment and printed a plain "Saved", although after a restart the file's env (for example CLAUDE_CODE_OPENAI_CONTEXT_WINDOWS) applies and can take precedence over the saved value. Read the file's state before writing. If it did not load before and loads now, name its env settings that this session did not load and say the restart check does not account for them. Qualify the resolver comment and update the help text and setup docs to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ctx): report a failed save for a model name settings cannot store The settings schema drops a "__proto__" record key without an error, and the writer's merge and the loader drop it the same way. --save checked only that the patch validated, then printed "Saved to modelLimits["__proto__"]" while the file kept no entry, and the restart check reported "[object Object] tokens". Check that the validated patch still holds the model's entry before writing. If it does not, report "Not saved" and keep the session override, as other failed saves do. Cover both command forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ctx): report a failed save when the window does not reach settings --save printed "Saved to modelLimits[...]" whenever the settings writer returned no error. For an invalid settings file the writer merges into the raw JSON, and when modelLimits or the model's entry is an array the merge keeps the array and sets the new field as a named array property, which JSON drops. The file then held no contextWindow for the model. Read the file back after writing and report a save only when it holds the requested contextWindow. Otherwise report "Not saved", naming the array that blocked it, and keep the session override, as other failed saves do. Cover both array levels in both command forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>