| 1 | package config |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | // SessionExperience is the single user-facing desktop presentation preference. |
| 9 | // It intentionally combines the old transcript density, reasoning display, and |
| 10 | // process-fold controls into two complete reading strategies. |
| 11 | type SessionExperience string |
| 12 | |
| 13 | const ( |
| 14 | SessionExperienceStandard SessionExperience = "standard" |
| 15 | SessionExperienceDeep SessionExperience = "deep" |
| 16 | ) |
| 17 | |
| 18 | // DesktopSessionExperience returns the canonical desktop preference. Missing |
| 19 | // and legacy-only configurations deliberately migrate to standard: the new |
| 20 | // setting must not inherit a surprising combination of old independent flags. |
| 21 | func (c *Config) DesktopSessionExperience() string { |
| 22 | if c == nil { |
| 23 | return string(SessionExperienceStandard) |
| 24 | } |
| 25 | switch strings.ToLower(strings.TrimSpace(c.Desktop.SessionExperience)) { |
| 26 | case string(SessionExperienceDeep): |
| 27 | return string(SessionExperienceDeep) |
| 28 | case string(SessionExperienceStandard): |
| 29 | return string(SessionExperienceStandard) |
| 30 | default: |
| 31 | return string(SessionExperienceStandard) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // DesktopDisplayMode keeps the old density snapshot coherent for one release. |
| 36 | func (c *Config) DesktopDisplayMode() string { |
| 37 | if c != nil && strings.TrimSpace(c.Desktop.SessionExperience) != "" { |
| 38 | return "standard" |
| 39 | } |
| 40 | switch strings.ToLower(strings.TrimSpace(c.Desktop.DisplayMode)) { |
| 41 | case "compact", "minimal": |
| 42 | return "compact" |
| 43 | default: |
| 44 | return "standard" |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // SetDesktopSessionExperience persists the canonical desktop presentation |
| 49 | // preference and keeps the deprecated fields coherent for older clients. |
| 50 | func (c *Config) SetDesktopSessionExperience(mode string) error { |
| 51 | switch strings.ToLower(strings.TrimSpace(mode)) { |
| 52 | case string(SessionExperienceStandard): |
| 53 | c.Desktop.SessionExperience = string(SessionExperienceStandard) |
| 54 | c.Desktop.DisplayMode = string(SessionExperienceStandard) |
| 55 | c.Desktop.ReasoningDisplayMode = "auto" |
| 56 | c.Desktop.ExpandThinking = true |
| 57 | return nil |
| 58 | case string(SessionExperienceDeep): |
| 59 | c.Desktop.SessionExperience = string(SessionExperienceDeep) |
| 60 | c.Desktop.DisplayMode = string(SessionExperienceStandard) |
| 61 | c.Desktop.ReasoningDisplayMode = "expanded" |
| 62 | c.Desktop.ExpandThinking = true |
| 63 | return nil |
| 64 | default: |
| 65 | return fmt.Errorf("session experience %q: must be standard|deep", mode) |
| 66 | } |
| 67 | } |
| 68 |