@@ -12,6 +12,7 @@ import (
1212 "github.com/docker/cagent/pkg/evaluation"
1313 "github.com/docker/cagent/pkg/runtime"
1414 "github.com/docker/cagent/pkg/tui/components/messages"
15+ "github.com/docker/cagent/pkg/tui/components/notification"
1516 "github.com/docker/cagent/pkg/tui/components/statusbar"
1617 "github.com/docker/cagent/pkg/tui/core"
1718 "github.com/docker/cagent/pkg/tui/dialog"
@@ -41,8 +42,9 @@ type appModel struct {
4142 width , height int
4243 keyMap KeyMap
4344
44- chatPage chatpage.Page
45- statusBar statusbar.StatusBar
45+ chatPage chatpage.Page
46+ statusBar statusbar.StatusBar
47+ notification notification.Notification
4648
4749 // Dialog system
4850 dialog dialog.Manager
@@ -75,10 +77,11 @@ func DefaultKeyMap() KeyMap {
7577// New creates and initializes a new TUI application model
7678func New (a * app.App ) tea.Model {
7779 t := & appModel {
78- chatPage : chatpage .New (a ),
79- keyMap : DefaultKeyMap (),
80- dialog : dialog .New (),
81- application : a ,
80+ chatPage : chatpage .New (a ),
81+ keyMap : DefaultKeyMap (),
82+ dialog : dialog .New (),
83+ notification : notification .New (),
84+ application : a ,
8285 }
8386
8487 t .statusBar = statusbar .New (t )
@@ -120,6 +123,11 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
120123 cmd := a .handleWindowResize (msg .Width , msg .Height )
121124 return a , cmd
122125
126+ case notification.ShowMsg , notification.HideMsg :
127+ updated , cmd := a .notification .Update (msg )
128+ a .notification = updated
129+ return a , cmd
130+
123131 case tea.KeyPressMsg :
124132 cmd := a .handleKeyPressMsg (msg )
125133 return a , cmd
@@ -197,6 +205,9 @@ func (a *appModel) handleWindowResize(width, height int) tea.Cmd {
197205 // Update status bar width
198206 a .statusBar .SetWidth (a .width )
199207
208+ // Update notification size
209+ a .notification .SetSize (a .width , a .height )
210+
200211 return tea .Batch (cmds ... )
201212}
202213
@@ -271,12 +282,27 @@ func (a *appModel) View() tea.View {
271282
272283 baseView := lipgloss .JoinVertical (lipgloss .Top , components ... )
273284
274- if a .dialog .HasDialog () {
285+ // Check if we need to render any overlays (dialogs or notifications)
286+ hasOverlays := a .dialog .HasDialog () || a .notification .IsVisible ()
287+
288+ if hasOverlays {
275289 baseLayer := lipgloss .NewLayer (baseView )
276- dialogLayers := a .dialog .GetLayers ()
290+ var allLayers []* lipgloss.Layer
291+ allLayers = append (allLayers , baseLayer )
277292
278- allLayers := []* lipgloss.Layer {baseLayer }
279- allLayers = append (allLayers , dialogLayers ... )
293+ // Add dialog layers
294+ if a .dialog .HasDialog () {
295+ dialogLayers := a .dialog .GetLayers ()
296+ allLayers = append (allLayers , dialogLayers ... )
297+ }
298+
299+ // Add notification layer (should be on top)
300+ if a .notification .IsVisible () {
301+ notificationLayer := a .notification .GetLayer ()
302+ if notificationLayer != nil {
303+ allLayers = append (allLayers , notificationLayer )
304+ }
305+ }
280306
281307 canvas := lipgloss .NewCanvas (allLayers ... )
282308 return toFullscreenView (canvas .Render ())
0 commit comments