on main help sign in
refactor(ui): dialog: rename Add/Remove to Open/Close
commite24c9c387693b83baa43d4cfc7deaa274a74661b authorAyman Bagabas <ayman.bagabas@gmail.com> dateTue 16 Dec 2025, 13:01 (1 year ago) parentc74a5c4
2 files changed+14−22
internal/ui/dialog/dialog.go+6−14 internal/ui/model/ui.go+8−8
internal/ui/dialog/dialog.go+6−14
@@ -33,14 +33,6 @@ func NewOverlay(dialogs ...Dialog) *Overlay {
3333 }
3434}
3535
36−// IsFrontDialog checks if the dialog with the specified ID is at the front.
37−func (d *Overlay) IsFrontDialog(dialogID string) bool {
38− if len(d.dialogs) == 0 {
39− return false
40− }
41− return d.dialogs[len(d.dialogs)-1].ID() == dialogID
42−}
43−
4436// HasDialogs checks if there are any active dialogs.
4537func (d *Overlay) HasDialogs() bool {
4638 return len(d.dialogs) > 0
@@ -56,13 +48,13 @@ func (d *Overlay) ContainsDialog(dialogID string) bool {
5648 return false
5749}
5850
59−// AddDialog adds a new dialog to the stack.
60−func (d *Overlay) AddDialog(dialog Dialog) {
51+// OpenDialog opens a new dialog to the stack.
52+func (d *Overlay) OpenDialog(dialog Dialog) {
6153 d.dialogs = append(d.dialogs, dialog)
6254}
6355
64−// RemoveDialog removes the dialog with the specified ID from the stack.
65−func (d *Overlay) RemoveDialog(dialogID string) {
56+// CloseDialog closes the dialog with the specified ID from the stack.
57+func (d *Overlay) CloseDialog(dialogID string) {
6658 for i, dialog := range d.dialogs {
6759 if dialog.ID() == dialogID {
6860 d.removeDialog(i)
@@ -71,8 +63,8 @@ func (d *Overlay) RemoveDialog(dialogID string) {
7163 }
7264}
7365
74−// RemoveFrontDialog removes the front dialog from the stack.
75−func (d *Overlay) RemoveFrontDialog() {
66+// CloseFrontDialog closes the front dialog in the stack.
67+func (d *Overlay) CloseFrontDialog() {
7668 if len(d.dialogs) == 0 {
7769 return
7870 }
internal/ui/model/ui.go+8−8
@@ -193,7 +193,7 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
193193 sessions := dialog.NewSessions(m.com, msg.sessions...)
194194 // TODO: Get. Rid. Of. Magic numbers!
195195 sessions.SetSize(min(120, m.width-8), 30)
196− m.dialog.AddDialog(sessions)
196+ m.dialog.OpenDialog(sessions)
197197 case sessionLoadedMsg:
198198 m.state = uiChat
199199 m.session = &msg.sess
@@ -357,7 +357,7 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) (cmds []tea.Cmd) {
357357 switch {
358358 case key.Matches(msg, m.keyMap.Quit):
359359 if !m.dialog.ContainsDialog(dialog.QuitID) {
360− m.dialog.AddDialog(dialog.NewQuit(m.com))
360+ m.dialog.OpenDialog(dialog.NewQuit(m.com))
361361 return true
362362 }
363363 }
@@ -388,7 +388,7 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) (cmds []tea.Cmd) {
388388 } else {
389389 // TODO: Get. Rid. Of. Magic numbers!
390390 commands.SetSize(min(120, m.width-8), 30)
391− m.dialog.AddDialog(commands)
391+ m.dialog.OpenDialog(commands)
392392 }
393393 }
394394 case key.Matches(msg, m.keyMap.Models):
@@ -419,10 +419,10 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) (cmds []tea.Cmd) {
419419 switch msg := msg.(type) {
420420 // Generic dialog messages
421421 case dialog.CloseMsg:
422− m.dialog.RemoveFrontDialog()
422+ m.dialog.CloseFrontDialog()
423423 // Session dialog messages
424424 case dialog.SessionSelectedMsg:
425− m.dialog.RemoveDialog(dialog.SessionsID)
425+ m.dialog.CloseDialog(dialog.SessionsID)
426426 cmds = append(cmds,
427427 m.loadSession(msg.Session.ID),
428428 m.loadSessionFiles(msg.Session.ID),
@@ -430,10 +430,10 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) (cmds []tea.Cmd) {
430430 // Command dialog messages
431431 case dialog.ToggleYoloModeMsg:
432432 m.com.App.Permissions.SetSkipRequests(!m.com.App.Permissions.SkipRequests())
433− m.dialog.RemoveDialog(dialog.CommandsID)
433+ m.dialog.CloseDialog(dialog.CommandsID)
434434 case dialog.SwitchSessionsMsg:
435435 cmds = append(cmds, m.loadSessionsCmd)
436− m.dialog.RemoveDialog(dialog.CommandsID)
436+ m.dialog.CloseDialog(dialog.CommandsID)
437437 case dialog.CompactMsg:
438438 err := m.com.App.AgentCoordinator.Summarize(context.Background(), msg.SessionID)
439439 if err != nil {
@@ -441,7 +441,7 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) (cmds []tea.Cmd) {
441441 }
442442 case dialog.ToggleHelpMsg:
443443 m.help.ShowAll = !m.help.ShowAll
444− m.dialog.RemoveDialog(dialog.CommandsID)
444+ m.dialog.CloseDialog(dialog.CommandsID)
445445 case dialog.QuitMsg:
446446 cmds = append(cmds, tea.Quit)
447447 }