chore: remove key not needed

Kujtim Hoxha created

Change summary

internal/agent/tools/mcp/init.go       |  4 ++--
internal/agent/tools/multiedit_test.go |  2 +-
internal/app/app.go                    | 16 ++++++++--------
internal/app/lsp_events.go             |  4 ++--
internal/permission/permission.go      |  6 +++---
internal/permission/permission_test.go |  6 +++---
internal/pubsub/broker.go              |  4 ++--
internal/pubsub/events.go              |  2 +-
8 files changed, 22 insertions(+), 22 deletions(-)

Detailed changes

internal/agent/tools/mcp/init.go 🔗

@@ -93,8 +93,8 @@ type ClientInfo struct {
 }
 
 // AddEventListener registers a callback for MCP events.
-func AddEventListener(key string, fn func(pubsub.Event[Event])) {
-	broker.AddListener(key, fn)
+func AddEventListener(fn func(pubsub.Event[Event])) {
+	broker.AddListener(fn)
 }
 
 // GetStates returns the current state of all MCP clients

internal/agent/tools/multiedit_test.go 🔗

@@ -38,7 +38,7 @@ func (m *mockPermissionService) SkipRequests() bool {
 	return false
 }
 
-func (m *mockPermissionService) AddNotificationListener(key string, fn func(pubsub.Event[permission.PermissionNotification])) {
+func (m *mockPermissionService) AddNotificationListener(fn func(pubsub.Event[permission.PermissionNotification])) {
 }
 
 type mockHistoryService struct {

internal/app/app.go 🔗

@@ -221,7 +221,7 @@ func (app *App) RunNonInteractive(ctx context.Context, output io.Writer, prompt
 	)
 
 	// Register callback to process messages directly.
-	app.Messages.AddListener("non-interactive", func(event pubsub.Event[message.Message]) {
+	app.Messages.AddListener(func(event pubsub.Event[message.Message]) {
 		msg := event.Payload
 		if msg.SessionID != sess.ID || msg.Role != message.Assistant || len(msg.Parts) == 0 {
 			return
@@ -321,25 +321,25 @@ func (app *App) Subscribe(program *tea.Program) {
 	app.program = program
 
 	// Register listeners that send directly to the program.
-	app.Sessions.AddListener("tui-sessions", func(event pubsub.Event[session.Session]) {
+	app.Sessions.AddListener(func(event pubsub.Event[session.Session]) {
 		program.Send(event)
 	})
-	app.Messages.AddListener("tui-messages", func(event pubsub.Event[message.Message]) {
+	app.Messages.AddListener(func(event pubsub.Event[message.Message]) {
 		program.Send(event)
 	})
-	app.Permissions.AddListener("tui-permissions", func(event pubsub.Event[permission.PermissionRequest]) {
+	app.Permissions.AddListener(func(event pubsub.Event[permission.PermissionRequest]) {
 		program.Send(event)
 	})
-	app.Permissions.AddNotificationListener("tui-permissions-notifications", func(event pubsub.Event[permission.PermissionNotification]) {
+	app.Permissions.AddNotificationListener(func(event pubsub.Event[permission.PermissionNotification]) {
 		program.Send(event)
 	})
-	app.History.AddListener("tui-history", func(event pubsub.Event[history.File]) {
+	app.History.AddListener(func(event pubsub.Event[history.File]) {
 		program.Send(event)
 	})
-	mcp.AddEventListener("tui-mcp", func(event pubsub.Event[mcp.Event]) {
+	mcp.AddEventListener(func(event pubsub.Event[mcp.Event]) {
 		program.Send(event)
 	})
-	AddLSPEventListener("tui-lsp", func(event pubsub.Event[LSPEvent]) {
+	AddLSPEventListener(func(event pubsub.Event[LSPEvent]) {
 		program.Send(event)
 	})
 }

internal/app/lsp_events.go 🔗

@@ -42,8 +42,8 @@ var (
 )
 
 // AddLSPEventListener registers a callback for LSP events.
-func AddLSPEventListener(key string, fn func(pubsub.Event[LSPEvent])) {
-	lspBroker.AddListener(key, fn)
+func AddLSPEventListener(fn func(pubsub.Event[LSPEvent])) {
+	lspBroker.AddListener(fn)
 }
 
 // GetLSPStates returns the current state of all LSP clients

internal/permission/permission.go 🔗

@@ -51,7 +51,7 @@ type Service interface {
 	AutoApproveSession(sessionID string)
 	SetSkipRequests(skip bool)
 	SkipRequests() bool
-	AddNotificationListener(key string, fn func(pubsub.Event[PermissionNotification]))
+	AddNotificationListener(fn func(pubsub.Event[PermissionNotification]))
 }
 
 type permissionService struct {
@@ -222,8 +222,8 @@ func (s *permissionService) AutoApproveSession(sessionID string) {
 	s.autoApproveSessionsMu.Unlock()
 }
 
-func (s *permissionService) AddNotificationListener(key string, fn func(pubsub.Event[PermissionNotification])) {
-	s.notificationBroker.AddListener(key, fn)
+func (s *permissionService) AddNotificationListener(fn func(pubsub.Event[PermissionNotification])) {
+	s.notificationBroker.AddListener(fn)
 }
 
 func (s *permissionService) SetSkipRequests(skip bool) {

internal/permission/permission_test.go 🔗

@@ -116,7 +116,7 @@ func TestPermissionService_SequentialProperties(t *testing.T) {
 		wg.Add(1)
 
 		events := make(chan pubsub.Event[PermissionRequest], 10)
-		service.AddListener("test", func(event pubsub.Event[PermissionRequest]) {
+		service.AddListener(func(event pubsub.Event[PermissionRequest]) {
 			events <- event
 		})
 
@@ -160,7 +160,7 @@ func TestPermissionService_SequentialProperties(t *testing.T) {
 		}
 
 		events := make(chan pubsub.Event[PermissionRequest], 10)
-		service.AddListener("test", func(event pubsub.Event[PermissionRequest]) {
+		service.AddListener(func(event pubsub.Event[PermissionRequest]) {
 			events <- event
 		})
 		var result1 bool
@@ -194,7 +194,7 @@ func TestPermissionService_SequentialProperties(t *testing.T) {
 		service := NewPermissionService("/tmp", false, []string{})
 
 		events := make(chan pubsub.Event[PermissionRequest], 10)
-		service.AddListener("test", func(event pubsub.Event[PermissionRequest]) {
+		service.AddListener(func(event pubsub.Event[PermissionRequest]) {
 			events <- event
 		})
 

internal/pubsub/broker.go 🔗

@@ -19,10 +19,10 @@ func NewBroker[T any]() *Broker[T] {
 }
 
 // AddListener registers a callback for events.
-func (b *Broker[T]) AddListener(key string, fn func(Event[T])) {
+func (b *Broker[T]) AddListener(fn func(Event[T])) {
 	b.signal.AddListener(func(_ context.Context, event Event[T]) {
 		fn(event)
-	}, key)
+	})
 }
 
 // Publish emits an event to all listeners without blocking.

internal/pubsub/events.go 🔗

@@ -9,7 +9,7 @@ const (
 )
 
 type Subscriber[T any] interface {
-	AddListener(key string, fn func(Event[T]))
+	AddListener(fn func(Event[T]))
 }
 
 type (