on main help sign in
chore: rename active dialog id method
cef196fKujtim Hoxha
internal/tui/components/dialogs/dialogs.go+2−2
@@ -38,7 +38,7 @@ type DialogCmp interface {
38 HasDialogs() bool
38 HasDialogs() bool
39 GetLayers() []*lipgloss.Layer
39 GetLayers() []*lipgloss.Layer
40 ActiveView() *tea.View
40 ActiveView() *tea.View
41− ActiveDialogId() DialogID
41+ ActiveDialogID() DialogID
42}
42}
43
43
44type dialogCmp struct {
44type dialogCmp struct {
@@ -140,7 +140,7 @@ func (d dialogCmp) ActiveView() *tea.View {
140 return &view
140 return &view
141}
141}
142
142
143−func (d dialogCmp) ActiveDialogId() DialogID {
143+func (d dialogCmp) ActiveDialogID() DialogID {
144 if len(d.dialogs) == 0 {
144 if len(d.dialogs) == 0 {
145 return ""
145 return ""
146 }
146 }
internal/tui/tui.go+7−7
@@ -14,6 +14,7 @@ import (
14 "github.com/charmbracelet/crush/internal/pubsub"
14 "github.com/charmbracelet/crush/internal/pubsub"
15 cmpChat "github.com/charmbracelet/crush/internal/tui/components/chat"
15 cmpChat "github.com/charmbracelet/crush/internal/tui/components/chat"
16 "github.com/charmbracelet/crush/internal/tui/components/completions"
16 "github.com/charmbracelet/crush/internal/tui/components/completions"
17+ "github.com/charmbracelet/crush/internal/tui/components/core/layout"
17 "github.com/charmbracelet/crush/internal/tui/components/core/status"
18 "github.com/charmbracelet/crush/internal/tui/components/core/status"
18 "github.com/charmbracelet/crush/internal/tui/components/dialogs"
19 "github.com/charmbracelet/crush/internal/tui/components/dialogs"
19 "github.com/charmbracelet/crush/internal/tui/components/dialogs/commands"
20 "github.com/charmbracelet/crush/internal/tui/components/dialogs/commands"
@@ -24,7 +25,6 @@ import (
24 "github.com/charmbracelet/crush/internal/tui/components/dialogs/permissions"
25 "github.com/charmbracelet/crush/internal/tui/components/dialogs/permissions"
25 "github.com/charmbracelet/crush/internal/tui/components/dialogs/quit"
26 "github.com/charmbracelet/crush/internal/tui/components/dialogs/quit"
26 "github.com/charmbracelet/crush/internal/tui/components/dialogs/sessions"
27 "github.com/charmbracelet/crush/internal/tui/components/dialogs/sessions"
27− "github.com/charmbracelet/crush/internal/tui/components/core/layout"
28 "github.com/charmbracelet/crush/internal/tui/page"
28 "github.com/charmbracelet/crush/internal/tui/page"
29 "github.com/charmbracelet/crush/internal/tui/page/chat"
29 "github.com/charmbracelet/crush/internal/tui/page/chat"
30 "github.com/charmbracelet/crush/internal/tui/page/logs"
30 "github.com/charmbracelet/crush/internal/tui/page/logs"
@@ -167,7 +167,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
167
167
168 // File Picker
168 // File Picker
169 case chat.OpenFilePickerMsg:
169 case chat.OpenFilePickerMsg:
170− if a.dialog.ActiveDialogId() == filepicker.FilePickerID {
170+ if a.dialog.ActiveDialogID() == filepicker.FilePickerID {
171 // If the commands dialog is already open, close it
171 // If the commands dialog is already open, close it
172 return a, util.CmdHandler(dialogs.CloseDialogMsg{})
172 return a, util.CmdHandler(dialogs.CloseDialogMsg{})
173 }
173 }
@@ -194,7 +194,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
194 payload := msg.Payload
194 payload := msg.Payload
195
195
196 // Forward agent events to dialogs
196 // Forward agent events to dialogs
197− if a.dialog.HasDialogs() && a.dialog.ActiveDialogId() == compact.CompactDialogID {
197+ if a.dialog.HasDialogs() && a.dialog.ActiveDialogID() == compact.CompactDialogID {
198 u, dialogCmd := a.dialog.Update(payload)
198 u, dialogCmd := a.dialog.Update(payload)
199 a.dialog = u.(dialogs.DialogCmp)
199 a.dialog = u.(dialogs.DialogCmp)
200 cmds = append(cmds, dialogCmd)
200 cmds = append(cmds, dialogCmd)
@@ -292,7 +292,7 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
292 return cmd
292 return cmd
293 // dialogs
293 // dialogs
294 case key.Matches(msg, a.keyMap.Quit):
294 case key.Matches(msg, a.keyMap.Quit):
295− if a.dialog.ActiveDialogId() == quit.QuitDialogID {
295+ if a.dialog.ActiveDialogID() == quit.QuitDialogID {
296 // if the quit dialog is already open, close the app
296 // if the quit dialog is already open, close the app
297 return tea.Quit
297 return tea.Quit
298 }
298 }
@@ -301,7 +301,7 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
301 })
301 })
302
302
303 case key.Matches(msg, a.keyMap.Commands):
303 case key.Matches(msg, a.keyMap.Commands):
304− if a.dialog.ActiveDialogId() == commands.CommandsDialogID {
304+ if a.dialog.ActiveDialogID() == commands.CommandsDialogID {
305 // If the commands dialog is already open, close it
305 // If the commands dialog is already open, close it
306 return util.CmdHandler(dialogs.CloseDialogMsg{})
306 return util.CmdHandler(dialogs.CloseDialogMsg{})
307 }
307 }
@@ -309,12 +309,12 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
309 Model: commands.NewCommandDialog(a.selectedSessionID),
309 Model: commands.NewCommandDialog(a.selectedSessionID),
310 })
310 })
311 case key.Matches(msg, a.keyMap.Sessions):
311 case key.Matches(msg, a.keyMap.Sessions):
312− if a.dialog.ActiveDialogId() == sessions.SessionsDialogID {
312+ if a.dialog.ActiveDialogID() == sessions.SessionsDialogID {
313 // If the sessions dialog is already open, close it
313 // If the sessions dialog is already open, close it
314 return util.CmdHandler(dialogs.CloseDialogMsg{})
314 return util.CmdHandler(dialogs.CloseDialogMsg{})
315 }
315 }
316 var cmds []tea.Cmd
316 var cmds []tea.Cmd
317− if a.dialog.ActiveDialogId() == commands.CommandsDialogID {
317+ if a.dialog.ActiveDialogID() == commands.CommandsDialogID {
318 // If the commands dialog is open, close it first
318 // If the commands dialog is open, close it first
319 cmds = append(cmds, util.CmdHandler(dialogs.CloseDialogMsg{}))
319 cmds = append(cmds, util.CmdHandler(dialogs.CloseDialogMsg{}))
320 }
320 }