on main help sign in
chore(ui): add command palette entry for toggling notifications (#2402)
commitca32607dc23f2b3f93204dcad32c89ef6ebb7e7a authorChristian Rocha <christian@rocha.is> dateThu 12 Mar 2026, 11:20 (7 months ago) parentd3b4ab2
3 files changed+41−12
internal/ui/dialog/actions.go+8−7 internal/ui/dialog/commands.go+14−2 internal/ui/model/ui.go+19−3
internal/ui/dialog/actions.go+8−7
@@ -44,13 +44,14 @@ type ActionSelectModel struct {
4444
4545// Messages for commands
4646type (
47− ActionNewSession struct{}
48− ActionToggleHelp struct{}
49− ActionToggleCompactMode struct{}
50− ActionToggleThinking struct{}
51− ActionTogglePills struct{}
52− ActionExternalEditor struct{}
53− ActionToggleYoloMode struct{}
47+ ActionNewSession struct{}
48+ ActionToggleHelp struct{}
49+ ActionToggleCompactMode struct{}
50+ ActionToggleThinking struct{}
51+ ActionTogglePills struct{}
52+ ActionExternalEditor struct{}
53+ ActionToggleYoloMode struct{}
54+ ActionToggleNotifications struct{}
5455 // ActionInitializeProject is a message to initialize a project.
5556 ActionInitializeProject struct{}
5657 ActionSummarize struct {
internal/ui/dialog/commands.go+14−2
@@ -437,8 +437,11 @@ func (c *Commands) defaultCommands() []*CommandItem {
437437 }
438438 }
439439
440− // Add external editor command if $EDITOR is available
441− // TODO: Use [tea.EnvMsg] to get environment variable instead of os.Getenv
440+ // Add external editor command if $EDITOR is available.
441+ //
442+ // TODO: Use [tea.EnvMsg] to get environment variable instead of os.Getenv;
443+ // because os.Getenv does IO is breaks the TEA paradigm and is generally an
444+ // antipattern.
442445 if os.Getenv("EDITOR") != "" {
443446 commands = append(commands, NewCommandItem(c.com.Styles, "open_external_editor", "Open External Editor", "ctrl+o", ActionExternalEditor{}))
444447 }
@@ -456,6 +459,15 @@ func (c *Commands) defaultCommands() []*CommandItem {
456459 commands = append(commands, NewCommandItem(c.com.Styles, "toggle_pills", label, "ctrl+t", ActionTogglePills{}))
457460 }
458461
462+ // Add a command for toggling notifications.
463+ cfg = c.com.Config()
464+ notificationsDisabled := cfg != nil && cfg.Options != nil && cfg.Options.DisableNotifications
465+ notificationLabel := "Disable Notifications"
466+ if notificationsDisabled {
467+ notificationLabel = "Enable Notifications"
468+ }
469+ commands = append(commands, NewCommandItem(c.com.Styles, "toggle_notifications", notificationLabel, "", ActionToggleNotifications{}))
470+
459471 commands = append(commands,
460472 NewCommandItem(c.com.Styles, "toggle_yolo", "Toggle Yolo Mode", "", ActionToggleYoloMode{}),
461473 NewCommandItem(c.com.Styles, "toggle_help", "Toggle Help", "ctrl+g", ActionToggleHelp{}),
internal/ui/model/ui.go+19−3
@@ -1229,24 +1229,40 @@ func (m *UI) handleDialogMsg(msg tea.Msg) tea.Cmd {
12291229 cmds = append(cmds, msg.Cmd)
12301230 }
12311231
1232− // Session dialog messages
1232+ // Session dialog messages.
12331233 case dialog.ActionSelectSession:
12341234 m.dialog.CloseDialog(dialog.SessionsID)
12351235 cmds = append(cmds, m.loadSession(msg.Session.ID))
12361236
1237− // Open dialog message
1237+ // Open dialog message.
12381238 case dialog.ActionOpenDialog:
12391239 m.dialog.CloseDialog(dialog.CommandsID)
12401240 if cmd := m.openDialog(msg.DialogID); cmd != nil {
12411241 cmds = append(cmds, cmd)
12421242 }
12431243
1244− // Command dialog messages
1244+ // Command dialog messages.
12451245 case dialog.ActionToggleYoloMode:
12461246 yolo := !m.com.App.Permissions.SkipRequests()
12471247 m.com.App.Permissions.SetSkipRequests(yolo)
12481248 m.setEditorPrompt(yolo)
12491249 m.dialog.CloseDialog(dialog.CommandsID)
1250+ case dialog.ActionToggleNotifications:
1251+ cfg := m.com.Config()
1252+ if cfg != nil && cfg.Options != nil {
1253+ disabled := !cfg.Options.DisableNotifications
1254+ cfg.Options.DisableNotifications = disabled
1255+ if err := m.com.Store().SetConfigField(config.ScopeGlobal, "options.disable_notifications", disabled); err != nil {
1256+ cmds = append(cmds, util.ReportError(err))
1257+ } else {
1258+ status := "enabled"
1259+ if disabled {
1260+ status = "disabled"
1261+ }
1262+ cmds = append(cmds, util.CmdHandler(util.NewInfoMsg("Notifications "+status)))
1263+ }
1264+ }
1265+ m.dialog.CloseDialog(dialog.CommandsID)
12501266 case dialog.ActionNewSession:
12511267 if m.isAgentBusy() {
12521268 cmds = append(cmds, util.ReportWarn("Agent is busy, please wait before starting a new session..."))