writeRuntimeModelState records the current provider/model so a detached gateway daemon mirrors the REPL's live choice. Called only from the interactive process (switch handlers + daemon spawn); failures are best-effort and logged, never fatal — a missing file simply means "no override".
()
| 51 | // interactive process (switch handlers + daemon spawn); failures are best-effort |
| 52 | // and logged, never fatal — a missing file simply means "no override". |
| 53 | func (cli *ChatCLI) writeRuntimeModelState() { |
| 54 | if cli.Provider == "" || cli.Model == "" { |
| 55 | return |
| 56 | } |
| 57 | path := runtimeModelStatePath() |
| 58 | if err := os.MkdirAll(filepath.Dir(path), 0o750); err != nil { |
| 59 | cli.logger.Warn("gateway: could not create runtime-model state dir", zap.Error(err)) |
| 60 | return |
| 61 | } |
| 62 | data, err := json.Marshal(runtimeModelState{Provider: cli.Provider, Model: cli.Model}) |
| 63 | if err != nil { |
| 64 | cli.logger.Warn("gateway: could not marshal runtime-model state", zap.Error(err)) |
| 65 | return |
| 66 | } |
| 67 | if err := os.WriteFile(path, data, 0o600); err != nil { |
| 68 | cli.logger.Warn("gateway: could not write runtime-model state", zap.Error(err)) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // readRuntimeModelState loads the persisted snapshot. ok=false when the file is |
| 73 | // absent or malformed (no override → caller keeps its current model). |
no test coverage detected