diff --git a/src/app/line/linecomps.tsx b/src/app/line/linecomps.tsx index 1b75962b6..8a46619b8 100644 --- a/src/app/line/linecomps.tsx +++ b/src/app/line/linecomps.tsx @@ -113,9 +113,6 @@ class LineCmd extends React.Component< isOverflow: OV = mobx.observable.box(false, { name: "line-overflow", }); - isMinimized: OV = mobx.observable.box(false, { - name: "line-minimised", - }); isCmdExpanded: OV = mobx.observable.box(false, { name: "cmd-expanded", }); @@ -351,9 +348,9 @@ class LineCmd extends React.Component< @boundMethod clickMinimize() { - mobx.action(() => { - this.isMinimized.set(!this.isMinimized.get()); - })(); + const { line } = this.props; + const isMinimized = line.linestate["wave:min"]; + GlobalCommandRunner.lineMinimize(line.lineid, !isMinimized, true); } @boundMethod @@ -566,6 +563,7 @@ class LineCmd extends React.Component< render() { const { screen, line, width, staticRender, visible } = this.props; + const isMinimized = line.linestate["wave:min"]; const isVisible = visible.get(); if (staticRender || !isVisible) { return this.renderSimple(); @@ -678,19 +676,19 @@ class LineCmd extends React.Component<
- + - +
@@ -717,7 +715,7 @@ class LineCmd extends React.Component<   showing in sidebar =>
- + { + let minimizeStr = minimize ? "1" : "0"; + return GlobalModel.submitCommand("line", "minimize", [lineId, minimizeStr], { nohist: "1" }, interactive); + } + lineRestart(lineArg: string, interactive: boolean): Promise { return GlobalModel.submitCommand("line", "restart", [lineArg], { nohist: "1" }, interactive); } diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index 6f2da605e..5189942db 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -217,6 +217,7 @@ func init() { registerCmdFn("line:view", LineViewCommand) registerCmdFn("line:set", LineSetCommand) registerCmdFn("line:restart", LineRestartCommand) + registerCmdFn("line:minimize", LineMinimizeCommand) registerCmdFn("client", ClientCommand) registerCmdFn("client:show", ClientShowCommand) @@ -4325,6 +4326,51 @@ func LineArchiveCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) ( return update, nil } +func LineMinimizeCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) { + ids, err := resolveUiIds(ctx, pk, R_Session|R_Screen) + if err != nil { + return nil, err + } + if len(pk.Args) == 0 { + return nil, fmt.Errorf("/line:minimize requires arguments (line number or id and min value)") + } + if len(pk.Args) > 2 { + return nil, fmt.Errorf("/line:minimize only takes up to 2 argument (line number or id and min value)") + } + lineArg1 := pk.Args[0] + lineId, err := sstore.FindLineIdByArg(ctx, ids.ScreenId, lineArg1) + if err != nil { + return nil, fmt.Errorf("error looking up lineid: %v", err) + } + if lineId == "" { + return nil, fmt.Errorf("line %q not found", lineArg1) + } + lineArg2 := pk.Args[1] + minVal := resolveBool(lineArg2, true) + lineState := make(map[string]any) + if minVal { + lineState[sstore.LineState_Min] = minVal + } else { + // Remove sstore.LineState_Min from lineState if it exists + delete(lineState, sstore.LineState_Min) + } + err = sstore.UpdateLineState(ctx, ids.ScreenId, lineId, lineState) + if err != nil { + return nil, fmt.Errorf("cannot update linestate: %v", err) + } + lineObj, err := sstore.GetLineById(ctx, ids.ScreenId, lineId) + if err != nil { + return nil, fmt.Errorf("/line:minimize cannot retrieve updated line: %v", err) + } + if lineObj == nil { + // no line (which is strange given we checked for it above). just return a nop. + return nil, nil + } + update := scbus.MakeUpdatePacket() + sstore.AddLineUpdate(update, lineObj, nil) + return update, nil +} + func LineDeleteCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) { ids, err := resolveUiIds(ctx, pk, R_Session|R_Screen) if err != nil { diff --git a/wavesrv/pkg/sstore/sstore.go b/wavesrv/pkg/sstore/sstore.go index 04292453c..df8e72e5d 100644 --- a/wavesrv/pkg/sstore/sstore.go +++ b/wavesrv/pkg/sstore/sstore.go @@ -63,6 +63,7 @@ const ( const ( LineState_Source = "prompt:source" LineState_File = "prompt:file" + LineState_Min = "wave:min" LineState_Template = "template" LineState_Mode = "mode" LineState_Lang = "lang"