fix(command): add missing command handler wiring and lint fixes

Wire SetCommandHandler into ChannelInboundProcessor so slash commands
are intercepted before reaching the LLM. Also apply lint fixes across
command package (strconv.Itoa, comment formatting, unused code removal)
and remove obsolete tool-call-browser.vue component.
This commit is contained in:
Acbox
2026-03-11 19:05:55 +08:00
parent ab82a72639
commit bb26d18757
10 changed files with 64 additions and 52 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
package command
import (
"fmt"
"strings"
)
@@ -91,5 +90,5 @@ func buildPermString(read, write, del bool) string {
if len(parts) == 0 {
return "none"
}
return fmt.Sprintf("%s", strings.Join(parts, ", "))
return strings.Join(parts, ", ")
}
+8 -8
View File
@@ -11,13 +11,13 @@ import (
//
// Example output:
//
// - mybot
// Description: A helpful assistant
// ID: abc123
// - mybot
// Description: A helpful assistant
// ID: abc123
//
// - another
// Description: Something else
// ID: def456
// - another
// Description: Something else
// ID: def456
func formatItems(items [][]kv) string {
if len(items) == 0 {
return ""
@@ -42,8 +42,8 @@ func formatItems(items [][]kv) string {
//
// Example output:
//
// - ID: abc123
// - Name: mybot
// - ID: abc123
// - Name: mybot
func formatKV(pairs []kv) string {
var b strings.Builder
for _, p := range pairs {
+10 -10
View File
@@ -49,17 +49,17 @@ type Handler struct {
mcpConnService *mcp.ConnectionService
inboxService *inbox.Service
modelsService *models.Service
providersService *providers.Service
memProvService *memprovider.Service
searchProvService *searchproviders.Service
browserCtxService *browsercontexts.Service
emailService *emailpkg.Service
modelsService *models.Service
providersService *providers.Service
memProvService *memprovider.Service
searchProvService *searchproviders.Service
browserCtxService *browsercontexts.Service
emailService *emailpkg.Service
emailOutboxService *emailpkg.OutboxService
heartbeatService *heartbeat.Service
queries *dbsqlc.Queries
skillLoader SkillLoader
containerFS ContainerFS
heartbeatService *heartbeat.Service
queries *dbsqlc.Queries
skillLoader SkillLoader
containerFS ContainerFS
logger *slog.Logger
}
+1 -5
View File
@@ -29,10 +29,6 @@ type fakeSubagentService struct {
items []subagent.Subagent
}
func (f *fakeSubagentService) list() []subagent.Subagent {
return f.items
}
type fakeScheduleService struct {
items []schedule.Schedule
}
@@ -325,7 +321,7 @@ func TestNewCommands_NilServices(t *testing.T) {
}
}
// suppress unused warnings
// suppress unused warnings.
var (
_ = fakeSubagentService{items: []subagent.Subagent{{ID: "1", Name: "test", CreatedAt: time.Now(), UpdatedAt: time.Now()}}}
_ = fakeScheduleService{items: []schedule.Schedule{{ID: "1", Name: "test"}}}
+1 -1
View File
@@ -13,7 +13,7 @@ type ParsedCommand struct {
}
// Parse parses a raw command string into its components.
// Expected format: /resource [action] [args...]
// Expected format: /resource [action] [args...].
func Parse(text string) (ParsedCommand, error) {
text = strings.TrimSpace(text)
if !strings.HasPrefix(text, "/") {
+3 -2
View File
@@ -2,6 +2,7 @@ package command
import (
"fmt"
"strconv"
"strings"
"github.com/memohai/memoh/internal/schedule"
@@ -45,7 +46,7 @@ func (h *Handler) buildScheduleGroup() *CommandGroup {
}
maxCalls := "unlimited"
if item.MaxCalls != nil {
maxCalls = fmt.Sprintf("%d", *item.MaxCalls)
maxCalls = strconv.Itoa(*item.MaxCalls)
}
return formatKV([]kv{
{"Name", item.Name},
@@ -54,7 +55,7 @@ func (h *Handler) buildScheduleGroup() *CommandGroup {
{"Command", item.Command},
{"Enabled", boolStr(item.Enabled)},
{"Max Calls", maxCalls},
{"Current Calls", fmt.Sprintf("%d", item.CurrentCalls)},
{"Current Calls", strconv.Itoa(item.CurrentCalls)},
{"Created", item.CreatedAt.Format("2006-01-02 15:04:05")},
{"Updated", item.UpdatedAt.Format("2006-01-02 15:04:05")},
}), nil
+2 -9
View File
@@ -23,8 +23,8 @@ func (h *Handler) buildSettingsGroup() *CommandGroup {
{"Language", s.Language},
{"Allow Guest", boolStr(s.AllowGuest)},
{"Max Context Load Time", fmt.Sprintf("%d min", s.MaxContextLoadTime)},
{"Max Context Tokens", fmt.Sprintf("%d", s.MaxContextTokens)},
{"Max Inbox Items", fmt.Sprintf("%d", s.MaxInboxItems)},
{"Max Context Tokens", strconv.Itoa(s.MaxContextTokens)},
{"Max Inbox Items", strconv.Itoa(s.MaxInboxItems)},
{"Reasoning Enabled", boolStr(s.ReasoningEnabled)},
{"Reasoning Effort", s.ReasoningEffort},
{"Heartbeat Enabled", boolStr(s.HeartbeatEnabled)},
@@ -126,13 +126,6 @@ func settingsUpdateUsage() string {
"- --heartbeat_model_id <id>"
}
func valueOrNone(s string) string {
if s == "" {
return "(none)"
}
return s
}
// resolveModelName resolves a model UUID to "model_name (provider_name)".
func (h *Handler) resolveModelName(cc CommandContext, modelID string) string {
if modelID == "" {