Skip to content

Commit 0331321

Browse files
Copilotdgageot
andcommitted
Address code review feedback
- Extract error message as a constant for maintainability - Fix unreachable code in processMessage by restructuring if-else - Improve code clarity and reduce duplication Co-authored-by: dgageot <153495+dgageot@users.noreply.github.com>
1 parent ea6542a commit 0331321

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

pkg/tui/page/chat/chat.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const (
3636
sidebarWidth = 40
3737
// Hide sidebar if window width is less than this
3838
minWindowWidth = 120
39+
40+
// Error message shown when bang commands are disabled
41+
bangCommandsDisabledMsg = "Bang commands are not enabled for this agent. Set 'enable_bang_commands: true' in your agent configuration."
3942
)
4043

4144
// Page represents the main chat page
@@ -493,12 +496,11 @@ func (p *chatPage) processMessage(content string) tea.Cmd {
493496
if strings.HasPrefix(content, "!") {
494497
if p.app.IsBangCommandsEnabled() {
495498
p.app.RunBangCommand(ctx, content[1:])
496-
} else {
497-
// Add an error message if bang commands are not enabled
498-
cmd := p.messages.AddErrorMessage("Bang commands are not enabled for this agent. Set 'enable_bang_commands: true' in your agent configuration.")
499-
return tea.Batch(cmd, p.messages.ScrollToBottom())
499+
return p.messages.ScrollToBottom()
500500
}
501-
return p.messages.ScrollToBottom()
501+
// Add an error message if bang commands are not enabled
502+
cmd := p.messages.AddErrorMessage(bangCommandsDisabledMsg)
503+
return tea.Batch(cmd, p.messages.ScrollToBottom())
502504
}
503505

504506
// Persist to history

0 commit comments

Comments
 (0)