SetActive switches the active profile and persists. Fails on an unknown name, no silent coercion. On Save failure it reverts in-memory Active so the live model and config.yaml stay in lockstep; otherwise the switch would stick this session but vanish on the next Bootstrap.
(name string)
| 353 | // no silent coercion. On Save failure it reverts in-memory Active so the live |
| 354 | // model and config.yaml stay in lockstep; otherwise the switch would stick this |
| 355 | // session but vanish on the next Bootstrap. |
| 356 | func (c *Config) SetActive(name string) error { |
| 357 | if _, ok := c.Models[name]; !ok { |
| 358 | return fmt.Errorf("unknown model: %s", name) |
| 359 | } |
| 360 | prev := c.Active |
| 361 | c.Active = name |
| 362 | if err := c.Save(); err != nil { |
| 363 | c.Active = prev |
| 364 | return err |
| 365 | } |
| 366 | return nil |
| 367 | } |