Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions internal/tui/conversation_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,15 @@ func (s *ConversationScene) handleSlashCommand(m *Model) (Scene, tea.Cmd, bool)
if !strings.HasPrefix(input, "/") {
return s, nil, false
}
name := strings.ToLower(strings.TrimPrefix(input, "/"))
raw := strings.TrimPrefix(input, "/")
name, args, _ := strings.Cut(raw, " ")
name = strings.ToLower(name)
args = strings.TrimSpace(args)
slashCmds, _ := commandMap()
if cmd, ok := slashCmds[name]; ok {
logger.Info("[user] slash command: /%s", name)
s.input.Reset()
return cmd.Run(s, m)
return cmd.Run(s, m, args)
}

// Check if it matches a skill name — send as a chat message asking to activate the skill.
Expand All @@ -168,7 +171,7 @@ func (s *ConversationScene) handleCommandKey(key string, m *Model) (Scene, tea.C
_, keyCmds := commandMap()
if cmd, ok := keyCmds[key]; ok {
logger.Info("[user] key command: %s → %s", key, cmd.Name)
return cmd.Run(s, m)
return cmd.Run(s, m, "")
}
return s, nil, false
}
Expand Down
21 changes: 17 additions & 4 deletions internal/tui/handlers_chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tui

import (
"context"
"fmt"

tea "github.com/charmbracelet/bubbletea"

Expand Down Expand Up @@ -104,10 +105,22 @@ func (m *Model) handleCommentSubmitted(msg commentSubmittedMsg) (Model, tea.Cmd)
}
}
if card := m.currentCard(); card != nil && card.Ctx.Repo == msg.repo && card.PR.Number == msg.prNumber {
if msg.err == nil {
m.diffView.ConfirmComment(msg.pendingItem)
} else {
m.diffView.RemoveComment(msg.pendingItem)
if msg.pendingItem != nil {
if msg.err == nil {
m.diffView.ConfirmComment(msg.pendingItem)
} else {
m.diffView.RemoveComment(msg.pendingItem)
}
}
// Update action status for slash-command comments (no pending item).
if cs, ok := m.scene.(*ConversationScene); ok && msg.pendingItem == nil {
cs.actionDone = true
if msg.err != nil {
cs.actionStatus = fmt.Sprintf("Comment failed: %s", msg.err)
} else {
cs.actionStatus = fmt.Sprintf("Comment posted on PR #%d", msg.prNumber)
}
cs.BuildScrollback(m)
}
}
return *m, nil
Expand Down
36 changes: 21 additions & 15 deletions internal/tui/slashcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Command struct {
Description string // shown in help/autocomplete
KeyBinding string // optional ctrl combo (e.g. "ctrl+d"), empty = no binding
Scope CommandScope // controls autocomplete visibility
Run func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool)
Run func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool)
}

// commands returns all registered commands.
Expand All @@ -32,7 +32,7 @@ func commands() []Command {
Description: "Go to next PR",
KeyBinding: "ctrl+n",
Scope: ScopeGlobal,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
m.navigatePR(1, s)
return s, nil, true
},
Expand All @@ -42,7 +42,7 @@ func commands() []Command {
Description: "Go to previous PR",
KeyBinding: "ctrl+p",
Scope: ScopeGlobal,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
m.navigatePR(-1, s)
return s, nil, true
},
Expand All @@ -52,7 +52,7 @@ func commands() []Command {
Description: "Toggle diff overlay",
KeyBinding: "ctrl+d",
Scope: ScopePR,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
s.input.Blur()
m.diffView.Focused = true
ds := newDiffOverlayScene(s, m.width, m.height)
Expand All @@ -70,7 +70,7 @@ func commands() []Command {
Name: "approve",
Description: "Approve current PR",
Scope: ScopePR,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
card := m.currentCard()
if card == nil || card.Scoring || m.isOwnPR(card) {
return s, nil, true
Expand All @@ -96,7 +96,7 @@ func commands() []Command {
Name: "flag",
Description: "Flag a merged PR (thumbs down)",
Scope: ScopePR,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
card := m.currentCard()
if card == nil || !card.PostMerge {
return s, nil, true
Expand All @@ -115,7 +115,7 @@ func commands() []Command {
Description: "Toggle showing all merged PRs",
KeyBinding: "ctrl+a",
Scope: ScopeGlobal,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
m.showAllMerged = !m.showAllMerged
if m.showAllMerged {
s.actionStatus = "Showing all merged PRs"
Expand All @@ -136,7 +136,7 @@ func commands() []Command {
Name: "merge",
Description: "Merge current PR",
Scope: ScopePR,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
card := m.currentCard()
if card == nil || card.Scoring || !m.isOwnPR(card) {
return s, nil, true
Expand Down Expand Up @@ -164,7 +164,7 @@ func commands() []Command {
Name: "reject",
Description: "Request changes on current PR",
Scope: ScopePR,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
card := m.currentCard()
if card == nil || card.Scoring || card.Assessment == nil || m.isOwnPR(card) {
return s, nil, true
Expand All @@ -182,12 +182,18 @@ func commands() []Command {
Name: "comment",
Description: "Post a comment on current PR",
Scope: ScopePR,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
card := m.currentCard()
if card == nil {
return s, nil, true
}
// Enter diff overlay with comment modal open
// If args provided, post the comment directly
if args != "" {
repo, num := card.Ctx.Repo, card.PR.Number
s.actionStatus = "Posting comment…"
return s, postGlobalCommentCmd(repo, num, args, nil), true
}
// No args — enter diff overlay with comment modal open
s.input.Blur()
m.diffView.Focused = true
ds := newDiffOverlayScene(s, m.width, m.height)
Expand All @@ -200,7 +206,7 @@ func commands() []Command {
Description: "Open bulk approve view",
KeyBinding: "ctrl+b",
Scope: ScopeGlobal,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
m.tryEnterBulkApprove()
return m.scene, nil, true
},
Expand All @@ -210,7 +216,7 @@ func commands() []Command {
Description: "Refresh current PR and check for new PRs",
KeyBinding: "ctrl+r",
Scope: ScopeGlobal,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
card := m.currentCard()
if card == nil {
return s, nil, true
Expand All @@ -229,15 +235,15 @@ func commands() []Command {
Description: "Quit prx",
KeyBinding: "ctrl+q",
Scope: ScopeGlobal,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
return s, m.cleanupWorktrees(), true
},
},
{
Name: "exit",
Description: "Quit prx",
Scope: ScopeGlobal,
Run: func(s *ConversationScene, m *Model) (Scene, tea.Cmd, bool) {
Run: func(s *ConversationScene, m *Model, args string) (Scene, tea.Cmd, bool) {
return s, m.cleanupWorktrees(), true
},
},
Expand Down