diff --git a/db/migrations/000003_renderer.down.sql b/db/migrations/000003_renderer.down.sql new file mode 100644 index 000000000..4ef6ef5a3 --- /dev/null +++ b/db/migrations/000003_renderer.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE line DROP COLUMN renderer; + diff --git a/db/migrations/000003_renderer.up.sql b/db/migrations/000003_renderer.up.sql new file mode 100644 index 000000000..43f9de435 --- /dev/null +++ b/db/migrations/000003_renderer.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE line ADD COLUMN renderer varchar(50) NOT NULL DEFAULT ''; + diff --git a/pkg/cmdrunner/cmdrunner.go b/pkg/cmdrunner/cmdrunner.go index 13f610bd2..c75a34c9a 100644 --- a/pkg/cmdrunner/cmdrunner.go +++ b/pkg/cmdrunner/cmdrunner.go @@ -1197,7 +1197,7 @@ func makeStaticCmd(ctx context.Context, metaCmd string, ids resolvedIds, cmdStr } func addLineForCmd(ctx context.Context, metaCmd string, shouldFocus bool, ids resolvedIds, cmd *sstore.CmdType) (*sstore.ModelUpdate, error) { - rtnLine, err := sstore.AddCmdLine(ctx, ids.SessionId, ids.WindowId, DefaultUserId, cmd) + rtnLine, err := sstore.AddCmdLine(ctx, ids.SessionId, ids.WindowId, DefaultUserId, cmd, "") if err != nil { return nil, err } @@ -1885,7 +1885,7 @@ func LineSetHeightCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) if err != nil { return nil, fmt.Errorf("/line:setheight invalid height val: %v", err) } - if heightVal > 1000 { + if heightVal > 10000 { return nil, fmt.Errorf("/line:setheight invalid height val (too large): %d", heightVal) } err = sstore.UpdateLineHeight(ctx, lineId, heightVal) @@ -2051,6 +2051,14 @@ func LineShowCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sst if cmd.RtnState { buf.WriteString(fmt.Sprintf(" %-15s %s\n", "rtnstate", "true")) } + stat, _ := sstore.StatCmdPtyFile(ctx, cmd.SessionId, cmd.CmdId) + if stat == nil { + buf.WriteString(fmt.Sprintf(" %-15s %s\n", "file", "-")) + } else { + fileDataStr := fmt.Sprintf("v%d data=%d offset=%d max=%s", stat.Version, stat.DataSize, stat.FileOffset, scbase.NumFormatB2(stat.MaxSize)) + buf.WriteString(fmt.Sprintf(" %-15s %s\n", "file", stat.Location)) + buf.WriteString(fmt.Sprintf(" %-15s %s\n", "file-data", fileDataStr)) + } } update := sstore.ModelUpdate{ Info: &sstore.InfoMsgType{ diff --git a/pkg/sstore/dbops.go b/pkg/sstore/dbops.go index 7af987a0f..5bf2bee78 100644 --- a/pkg/sstore/dbops.go +++ b/pkg/sstore/dbops.go @@ -687,8 +687,8 @@ func InsertLine(ctx context.Context, line *LineType, cmd *CmdType) error { query = `SELECT nextlinenum FROM window WHERE sessionid = ? AND windowid = ?` nextLineNum := tx.GetInt(query, line.SessionId, line.WindowId) line.LineNum = int64(nextLineNum) - query = `INSERT INTO line ( sessionid, windowid, userid, lineid, ts, linenum, linenumtemp, linelocal, linetype, text, cmdid, ephemeral, contentheight, star, archived) - VALUES (:sessionid,:windowid,:userid,:lineid,:ts,:linenum,:linenumtemp,:linelocal,:linetype,:text,:cmdid,:ephemeral,:contentheight,:star,:archived)` + query = `INSERT INTO line ( sessionid, windowid, userid, lineid, ts, linenum, linenumtemp, linelocal, linetype, text, cmdid, renderer, ephemeral, contentheight, star, archived) + VALUES (:sessionid,:windowid,:userid,:lineid,:ts,:linenum,:linenumtemp,:linelocal,:linetype,:text,:cmdid,:renderer,:ephemeral,:contentheight,:star,:archived)` tx.NamedExecWrap(query, line) query = `UPDATE window SET nextlinenum = ? WHERE sessionid = ? AND windowid = ?` tx.ExecWrap(query, nextLineNum+1, line.SessionId, line.WindowId) diff --git a/pkg/sstore/fileops.go b/pkg/sstore/fileops.go index 87b91e628..bd654ee62 100644 --- a/pkg/sstore/fileops.go +++ b/pkg/sstore/fileops.go @@ -24,6 +24,14 @@ func CreateCmdPtyFile(ctx context.Context, sessionId string, cmdId string, maxSi return f.Close() } +func StatCmdPtyFile(ctx context.Context, sessionId string, cmdId string) (*cirfile.Stat, error) { + ptyOutFileName, err := scbase.PtyOutFile(sessionId, cmdId) + if err != nil { + return nil, err + } + return cirfile.StatCirFile(ctx, ptyOutFileName) +} + func AppendToCmdPtyBlob(ctx context.Context, sessionId string, cmdId string, data []byte, pos int64) (*PtyDataUpdate, error) { if pos < 0 { return nil, fmt.Errorf("invalid seek pos '%d' in AppendToCmdPtyBlob", pos) diff --git a/pkg/sstore/sstore.go b/pkg/sstore/sstore.go index d75db565a..95ccafbba 100644 --- a/pkg/sstore/sstore.go +++ b/pkg/sstore/sstore.go @@ -643,6 +643,7 @@ type LineType struct { LineNumTemp bool `json:"linenumtemp,omitempty"` LineLocal bool `json:"linelocal"` LineType string `json:"linetype"` + Renderer string `json:"renderer,omitempty"` Text string `json:"text,omitempty"` CmdId string `json:"cmdid,omitempty"` Ephemeral bool `json:"ephemeral,omitempty"` @@ -825,7 +826,7 @@ func CmdFromMap(m map[string]interface{}) *CmdType { return &cmd } -func makeNewLineCmd(sessionId string, windowId string, userId string, cmdId string) *LineType { +func makeNewLineCmd(sessionId string, windowId string, userId string, cmdId string, renderer string) *LineType { rtn := &LineType{} rtn.SessionId = sessionId rtn.WindowId = windowId @@ -836,6 +837,7 @@ func makeNewLineCmd(sessionId string, windowId string, userId string, cmdId stri rtn.LineType = LineTypeCmd rtn.CmdId = cmdId rtn.ContentHeight = LineNoHeight + rtn.Renderer = renderer return rtn } @@ -862,8 +864,8 @@ func AddCommentLine(ctx context.Context, sessionId string, windowId string, user return rtnLine, nil } -func AddCmdLine(ctx context.Context, sessionId string, windowId string, userId string, cmd *CmdType) (*LineType, error) { - rtnLine := makeNewLineCmd(sessionId, windowId, userId, cmd.CmdId) +func AddCmdLine(ctx context.Context, sessionId string, windowId string, userId string, cmd *CmdType, renderer string) (*LineType, error) { + rtnLine := makeNewLineCmd(sessionId, windowId, userId, cmd.CmdId, renderer) err := InsertLine(ctx, rtnLine, cmd) if err != nil { return nil, err