diff --git a/pkg/cy/api/module.go b/pkg/cy/api/module.go index 6dda37f6..2bc6b52f 100644 --- a/pkg/cy/api/module.go +++ b/pkg/cy/api/module.go @@ -32,6 +32,7 @@ type Server interface { SocketName() string ExecuteJanet(path string) error Log(level zerolog.Level, message string) + RerenderClients() } func getClient(context interface{}) (Client, error) { diff --git a/pkg/cy/api/params.go b/pkg/cy/api/params.go index 6bf38bbb..1339c2e3 100644 --- a/pkg/cy/api/params.go +++ b/pkg/cy/api/params.go @@ -7,7 +7,8 @@ import ( ) type ParamModule struct { - Tree *tree.Tree + Tree *tree.Tree + Server Server } // haha @@ -89,5 +90,14 @@ func (p *ParamModule) Set( params = node.Params() } - return params.Set(string(keyword), value) + err = params.Set(string(keyword), value) + if err != nil { + return err + } + + // Many params affect rendering; we need to cause a rerender right + // away to ensure all client screens remain accurate. + // TODO(cfoust): 10/20/24 maybe this should be under the layout engine so it's throttled? + p.Server.RerenderClients() + return nil } diff --git a/pkg/cy/janet.go b/pkg/cy/janet.go index 61f7cdb3..f5b93eab 100644 --- a/pkg/cy/janet.go +++ b/pkg/cy/janet.go @@ -41,9 +41,12 @@ func (c *Cy) initJanet(ctx context.Context) (*janet.VM, error) { TimeBinds: c.timeBinds, CopyBinds: c.copyBinds, }, - "pane": &api.PaneModule{Tree: c.tree}, - "param": &api.ParamModule{Tree: c.tree}, - "path": &api.PathModule{}, + "pane": &api.PaneModule{Tree: c.tree}, + "param": &api.ParamModule{ + Server: c, + Tree: c.tree, + }, + "path": &api.PathModule{}, "replay": &api.ReplayModule{ Lifetime: util.NewLifetime(c.Ctx()), Tree: c.tree, diff --git a/pkg/cy/module.go b/pkg/cy/module.go index 46e38c11..497d18c1 100644 --- a/pkg/cy/module.go +++ b/pkg/cy/module.go @@ -150,6 +150,17 @@ func (c *Cy) reloadConfig() error { return c.loadConfig() } +// RerenderClients triggers a rerender of all clients. +func (c *Cy) RerenderClients() { + c.RLock() + defer c.RUnlock() + + clients := c.clients + for _, client := range clients { + client.layoutEngine.Notify() + } +} + // Get the first pane that another client is attached to or return nil if there // are no other clients. func (c *Cy) getFirstClientPane(except *Client) tree.Node {