11package sidebar
22
33import (
4+ "context"
45 "fmt"
56 "log/slog"
67 "maps"
@@ -11,6 +12,7 @@ import (
1112 tea "charm.land/bubbletea/v2"
1213 "charm.land/lipgloss/v2"
1314
15+ "github.com/docker/cagent/pkg/modelsdev"
1416 "github.com/docker/cagent/pkg/paths"
1517 "github.com/docker/cagent/pkg/runtime"
1618 "github.com/docker/cagent/pkg/session"
@@ -62,33 +64,34 @@ type ragIndexingState struct {
6264
6365// model implements Model
6466type model struct {
65- width int
66- height int
67- xPos int // absolute x position on screen
68- yPos int // absolute y position on screen
69- layoutCfg LayoutConfig // layout configuration for spacing
70- sessionUsage map [string ]* runtime.Usage // sessionID -> latest usage snapshot
71- sessionAgent map [string ]string // sessionID -> agent name
72- todoComp * todotool.SidebarComponent
73- mcpInit bool
74- ragIndexing map [string ]* ragIndexingState // strategy name -> indexing state
75- spinner spinner.Spinner
76- mode Mode
77- sessionTitle string
78- sessionStarred bool
79- sessionHasContent bool // true when session has been used (has messages)
80- currentAgent string
81- agentModel string
82- agentDescription string
83- availableAgents []runtime.AgentDetails
84- agentSwitching bool
85- availableTools int
86- toolsLoading bool // true when more tools may still be loading
87- sessionState * service.SessionState
88- workingAgent string // Name of the agent currently working (empty if none)
89- scrollbar * scrollbar.Model
90- workingDirectory string
91- queuedMessages []string // Truncated preview of queued messages
67+ width int
68+ height int
69+ xPos int // absolute x position on screen
70+ yPos int // absolute y position on screen
71+ layoutCfg LayoutConfig // layout configuration for spacing
72+ sessionUsage map [string ]* runtime.Usage // sessionID -> latest usage snapshot
73+ sessionAgent map [string ]string // sessionID -> agent name
74+ todoComp * todotool.SidebarComponent
75+ mcpInit bool
76+ ragIndexing map [string ]* ragIndexingState // strategy name -> indexing state
77+ spinner spinner.Spinner
78+ mode Mode
79+ sessionTitle string
80+ sessionStarred bool
81+ sessionHasContent bool // true when session has been used (has messages)
82+ currentAgent string
83+ agentModel string
84+ agentDescription string
85+ availableAgents []runtime.AgentDetails
86+ agentSwitching bool
87+ availableTools int
88+ toolsLoading bool // true when more tools may still be loading
89+ sessionState * service.SessionState
90+ workingAgent string // Name of the agent currently working (empty if none)
91+ scrollbar * scrollbar.Model
92+ workingDirectory string
93+ queuedMessages []string // Truncated preview of queued messages
94+ reasoningSupported bool // true if current model supports reasoning (default: true / fail-open)
9295}
9396
9497// Option is a functional option for configuring the sidebar.
@@ -101,18 +104,19 @@ func WithLayoutConfig(cfg LayoutConfig) Option {
101104
102105func New (sessionState * service.SessionState , opts ... Option ) Model {
103106 m := & model {
104- width : 20 ,
105- layoutCfg : DefaultLayoutConfig (),
106- height : 24 ,
107- sessionUsage : make (map [string ]* runtime.Usage ),
108- sessionAgent : make (map [string ]string ),
109- todoComp : todotool .NewSidebarComponent (),
110- spinner : spinner .New (spinner .ModeSpinnerOnly , styles .SpinnerDotsHighlightStyle ),
111- sessionTitle : "New session" ,
112- ragIndexing : make (map [string ]* ragIndexingState ),
113- sessionState : sessionState ,
114- scrollbar : scrollbar .New (),
115- workingDirectory : getCurrentWorkingDirectory (),
107+ width : 20 ,
108+ layoutCfg : DefaultLayoutConfig (),
109+ height : 24 ,
110+ sessionUsage : make (map [string ]* runtime.Usage ),
111+ sessionAgent : make (map [string ]string ),
112+ todoComp : todotool .NewSidebarComponent (),
113+ spinner : spinner .New (spinner .ModeSpinnerOnly , styles .SpinnerDotsHighlightStyle ),
114+ sessionTitle : "New session" ,
115+ ragIndexing : make (map [string ]* ragIndexingState ),
116+ sessionState : sessionState ,
117+ scrollbar : scrollbar .New (),
118+ workingDirectory : getCurrentWorkingDirectory (),
119+ reasoningSupported : true , // Default to true (fail-open)
116120 }
117121 for _ , opt := range opts {
118122 opt (m )
@@ -143,16 +147,19 @@ func (m *model) SetTodos(result *tools.ToolCallResult) error {
143147}
144148
145149// SetAgentInfo sets the current agent information and updates the model in availableAgents
146- func (m * model ) SetAgentInfo (agentName , model , description string ) {
150+ func (m * model ) SetAgentInfo (agentName , modelID , description string ) {
147151 m .currentAgent = agentName
148- m .agentModel = model
152+ m .agentModel = modelID
149153 m .agentDescription = description
150154
155+ // Check if the model supports reasoning (fail-open on errors)
156+ m .reasoningSupported = modelsdev .ModelSupportsReasoning (context .Background (), modelID )
157+
151158 // Update the model in availableAgents for the current agent
152159 // This is important when model routing selects a different model than configured
153160 for i := range m .availableAgents {
154- if m .availableAgents [i ].Name == agentName && model != "" {
155- m .availableAgents [i ].Model = model
161+ if m .availableAgents [i ].Name == agentName && modelID != "" {
162+ m .availableAgents [i ].Model = modelID
156163 break
157164 }
158165 }
@@ -749,13 +756,14 @@ func (m *model) toolsetInfo(contentWidth int) string {
749756 lines = append (lines , m .renderToolsStatus ())
750757
751758 // Toggle indicators with shortcuts
759+ // Only show "Thinking enabled" if the model supports reasoning
752760 toggles := []struct {
753761 enabled bool
754762 label string
755763 shortcut string
756764 }{
757765 {m .sessionState .YoloMode , "YOLO mode enabled" , "^y" },
758- {m .sessionState .Thinking , "Thinking enabled" , "/think" },
766+ {m .sessionState .Thinking && m . reasoningSupported , "Thinking enabled" , "/think" },
759767 {m .sessionState .HideToolResults , "Tool output hidden" , "^o" },
760768 {m .sessionState .SplitDiffView , "Split Diff View enabled" , "^t" },
761769 }
0 commit comments