fix: agent rename uses SetName() not Submit(/agent ...); add SetName method to agent.Agent
This commit is contained in:
parent
d90fd1448f
commit
ff17a90bbf
|
|
@ -66,6 +66,13 @@ func (ag *Agent) Backend() backend.Backend {
|
|||
// Name returns the agent's name.
|
||||
func (ag *Agent) Name() string { return ag.agentName }
|
||||
|
||||
// SetName changes the agent's display name without reloading config.
|
||||
func (ag *Agent) SetName(name string) {
|
||||
ag.stateMu.Lock()
|
||||
ag.agentName = name
|
||||
ag.stateMu.Unlock()
|
||||
}
|
||||
|
||||
// ID returns the agent's unique identity.
|
||||
func (ag *Agent) ID() string { return ag.id }
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ func (h *agentHelper) fileSpec(name string, mode os.FileMode) FileSpec {
|
|||
if newName == "" {
|
||||
return nil
|
||||
}
|
||||
h.sess.Core.Agent().Submit(h.sess.SessionCtx, "/agent "+newName)
|
||||
h.sess.Core.Agent().SetName(newName)
|
||||
return nil
|
||||
}
|
||||
case "cwd":
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ func NewRoot(cfg Config) *Tree {
|
|||
if sess == nil {
|
||||
return fmt.Errorf("session not found: %s", sessName)
|
||||
}
|
||||
sess.Core.Agent().Submit(sess.SessionCtx, "/agent "+new)
|
||||
sess.Core.Agent().SetName(new)
|
||||
rs.cfg.Log.Info("renamed agent in session %s -> %s", sessName, new)
|
||||
broadcastEvents()
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue