diff --git a/src/main.tsx b/src/main.tsx index 4c956e248..048b3262f 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -55,20 +55,19 @@ function getRemoteStr(remote : RemoteType) : string { return "(no remote)"; } if (remote.remotevars.local) { - return sprintf("%s@%s", remote.remotevars.remoteuser, "local") + return sprintf("%s@%s", remote.remotevars.user, "local"); } - else if (remote.remotevars.remotehost) { - return sprintf("%s@%s", remote.remotevars.remoteuser, remote.remotevars.remotehost); + let hoststr = ""; + if (remote.remotevars.sudo) { + hoststr = sprintf("sudo@%s@%s", remote.remotevars.user, remote.remotevars.host) } else { - let host = remote.remotevars.host || "unknown"; - if (remote.remotevars.user) { - return sprintf("%s@%s", remote.remotevars.user, host) - } - else { - return host; - } + hoststr = sprintf("%s@%s", remote.remotevars.user, remote.remotevars.host) } + if (remote.remotevars.alias) { + return sprintf("(%s) %s", remote.remotevars.alias, hoststr) + } + return hoststr; } function replaceHomePath(path : string, homeDir : string) : string { @@ -450,12 +449,14 @@ class CmdInput extends React.Component<{}, {}> { if (win != null) { ri = win.getCurRemoteInstance(); } + console.log("cmd-input remote", ri); let remote : RemoteType = null; let remoteState : RemoteStateType = null; if (ri != null) { remote = GlobalModel.getRemote(ri.remoteid); remoteState = ri.state; } + console.log("lookup remote", remote); let promptStr = getRemoteStr(remote); let cwdStr = getCwdStr(remote, remoteState); let infoMsg = GlobalModel.infoMsg.get(); @@ -850,6 +851,8 @@ class MainSideBar extends React.Component<{}, {}> { let model = GlobalModel; let activeSessionId = model.activeSessionId.get(); let session : Session = null; + let remotes = model.remotes; + let remote : RemoteType = null; return (
@@ -912,11 +915,9 @@ class MainSideBar extends React.Component<{}, {}> { Remotes

diff --git a/src/model.ts b/src/model.ts index 756c6bcb7..465d0d75e 100644 --- a/src/model.ts +++ b/src/model.ts @@ -367,32 +367,68 @@ class Window { return null; } + updateCmd(cmd : CmdDataType) : void { + if (cmd.remove) { + throw new Error("cannot remove cmd with updateCmd call [" + cmd.cmdid + "]"); + } + let origCmd = this.cmds[cmd.cmdid]; + if (origCmd != null) { + origCmd.setCmd(cmd); + } + return; + } + + mergeCmd(cmd : CmdDataType) : void { + if (cmd.remove) { + delete this.cmds[cmd.cmdid]; + return; + } + let origCmd = this.cmds[cmd.cmdid]; + if (origCmd == null) { + this.cmds[cmd.cmdid] = new Cmd(cmd); + return; + } + origCmd.setCmd(cmd); + return; + } + addLineCmd(line : LineType, cmd : CmdDataType, interactive : boolean) { if (!this.loaded.get()) { return; } mobx.action(() => { if (cmd != null) { - this.cmds[cmd.cmdid] = new Cmd(cmd); + this.mergeCmd(cmd); } - let lines = this.lines; - let lineIdx = 0; - for (lineIdx=0; lineIdx line.ts || (curTs == line.ts && lineId > line.lineid)) { - break; + let lineIdx = 0; + for (lineIdx=0; lineIdx line.ts || (curTs == line.ts && lineId > line.lineid)) { + break; + } } + if (lineIdx == lines.length) { + this.lines.push(line); + return; + } + this.lines.splice(lineIdx, 0, line); } - if (lineIdx == lines.length) { - this.lines.push(line); - return; - } - this.lines.splice(lineIdx, 0, line); })(); } }; @@ -679,7 +715,7 @@ class Model { ws : WSControl; remotes : OArr = mobx.observable.array([], {deep: false}); remotesLoaded : OV = mobx.observable.box(false); - windows : OMap = mobx.observable.map({}, {deep: false}); + windows : OMap = mobx.observable.map({}, {deep: false}); // key = "sessionid/windowid" infoShow : OV = mobx.observable.box(false); infoMsg : OV = mobx.observable.box(null); infoTimeoutId : any = null; @@ -940,7 +976,12 @@ class Model { } if ("line" in update) { let lineMsg : LineCmdUpdateType = update; - this.addLineCmd(lineMsg.line, lineMsg.cmd, interactive); + if (lineMsg.line != null) { + this.addLineCmd(lineMsg.line, lineMsg.cmd, interactive); + } + if (lineMsg.line == null && lineMsg.cmd != null) { + this.updateCmd(lineMsg.cmd); + } } if ("window" in update) { let winMsg : WindowUpdateType = update; @@ -1057,6 +1098,12 @@ class Model { win.addLineCmd(line, cmd, interactive); } + updateCmd(cmd : CmdDataType) { + this.windows.forEach((win : Window) => { + win.updateCmd(cmd); + }); + } + getClientKwargs() : Record { let session = this.getActiveSession(); let win = this.getActiveWindow(); diff --git a/src/sh2.less b/src/sh2.less index 4193414f3..0c611bfca 100644 --- a/src/sh2.less +++ b/src/sh2.less @@ -246,6 +246,22 @@ html, body, #main { color: #ddd; } + .remote-status { + font-size: 8px; + margin-right: 5px; + position: relative; + top: -3px; + color: #c4a000; + + &.status-connected { + color: #4e9a06; + } + + &.status-error, &.status-disconnected { + color: #cc0000; + } + } + .status { font-size: 8px; margin-right: 5px; diff --git a/src/term.ts b/src/term.ts index 5c981d0c5..eec907313 100644 --- a/src/term.ts +++ b/src/term.ts @@ -117,10 +117,11 @@ class TermWrap { if (termYPos >= usedRows) { usedRows = termYPos + 1; } - for (let i=usedRows; i=usedRows; i--) { let line = termBuf.translateBufferLineToString(i, true); if (line != null && line.trim() != "") { usedRows = i+1; + break; } } return usedRows; diff --git a/src/types.ts b/src/types.ts index ace44d525..8015ea0c0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -176,6 +176,7 @@ type CmdDataType = { donepk : CmdDonePacketType, runout : any[], usedrows : number, + remove? : boolean, }; type PtyDataUpdateType = {