From 38db3db4f2f253e02d0c69bdee566e6c59c3decc Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Wed, 29 Jul 2026 11:03:55 +0200 Subject: [PATCH] agent: add WatchAgent support and notify on /agent change - Add WatchAgent constant to WaitChange fields - Add WatchAgent case in WaitChange read() function - Call notifyChange() in /agent command after setting agentName This enables the D-Bus adapter to detect agent changes and emit ConfigChanged signals so the GUI can refresh the session list. --- pkg/agent/commands.go | 1 + pkg/agent/core.go | 2 ++ pkg/agent/types.go | 1 + 3 files changed, 4 insertions(+) diff --git a/pkg/agent/commands.go b/pkg/agent/commands.go index 1310ceb..ae920f1 100644 --- a/pkg/agent/commands.go +++ b/pkg/agent/commands.go @@ -199,6 +199,7 @@ func (s *agent) handleCommand(ctx context.Context, input string) bool { s.agentName = name s.session = nil s.pushSessionEnv() + s.notifyChange() for _, msg := range rt.Messages { s.emit(infoEvent(msg)) } diff --git a/pkg/agent/core.go b/pkg/agent/core.go index 465adaa..3de52f4 100644 --- a/pkg/agent/core.go +++ b/pkg/agent/core.go @@ -752,6 +752,8 @@ func (s *agent) WaitChange(ctx context.Context, field, current string) (string, return s.CtxSz() case WatchCWD: return s.CWD() + case WatchAgent: + return s.AgentName() } return "" } diff --git a/pkg/agent/types.go b/pkg/agent/types.go index 4dfff4e..2534bdd 100644 --- a/pkg/agent/types.go +++ b/pkg/agent/types.go @@ -15,6 +15,7 @@ const ( WatchUsage = "usage" WatchCtxSz = "ctxsz" WatchCWD = "cwd" + WatchAgent = "agent" ) // ErrInterrupted is returned when the user cancels an agent turn (Ctrl-C).