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:
parent
6941c372d8
commit
38db3db4f2
|
|
@ -199,6 +199,7 @@ func (s *agent) handleCommand(ctx context.Context, input string) bool {
|
||||||
s.agentName = name
|
s.agentName = name
|
||||||
s.session = nil
|
s.session = nil
|
||||||
s.pushSessionEnv()
|
s.pushSessionEnv()
|
||||||
|
s.notifyChange()
|
||||||
for _, msg := range rt.Messages {
|
for _, msg := range rt.Messages {
|
||||||
s.emit(infoEvent(msg))
|
s.emit(infoEvent(msg))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -752,6 +752,8 @@ func (s *agent) WaitChange(ctx context.Context, field, current string) (string,
|
||||||
return s.CtxSz()
|
return s.CtxSz()
|
||||||
case WatchCWD:
|
case WatchCWD:
|
||||||
return s.CWD()
|
return s.CWD()
|
||||||
|
case WatchAgent:
|
||||||
|
return s.AgentName()
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ const (
|
||||||
WatchUsage = "usage"
|
WatchUsage = "usage"
|
||||||
WatchCtxSz = "ctxsz"
|
WatchCtxSz = "ctxsz"
|
||||||
WatchCWD = "cwd"
|
WatchCWD = "cwd"
|
||||||
|
WatchAgent = "agent"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrInterrupted is returned when the user cancels an agent turn (Ctrl-C).
|
// ErrInterrupted is returned when the user cancels an agent turn (Ctrl-C).
|
||||||
|
|
|
||||||
Reference in New Issue