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.
This commit is contained in:
Levi Neely 2026-07-29 11:03:55 +02:00
parent 6941c372d8
commit 38db3db4f2
3 changed files with 4 additions and 0 deletions

View File

@ -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))
}

View File

@ -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 ""
}

View File

@ -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).