(tabId string, widgetId string, rpcData wshrpc.CommandTermGetScrollbackLinesData)
| 82 | } |
| 83 | |
| 84 | func getTermScrollbackOutput(tabId string, widgetId string, rpcData wshrpc.CommandTermGetScrollbackLinesData) (*TermGetScrollbackToolOutput, error) { |
| 85 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
| 86 | defer cancelFn() |
| 87 | |
| 88 | fullBlockId, err := wcore.ResolveBlockIdFromPrefix(ctx, tabId, widgetId) |
| 89 | if err != nil { |
| 90 | return nil, err |
| 91 | } |
| 92 | |
| 93 | rpcClient := wshclient.GetBareRpcClient() |
| 94 | result, err := wshclient.TermGetScrollbackLinesCommand( |
| 95 | rpcClient, |
| 96 | rpcData, |
| 97 | &wshrpc.RpcOpts{Route: wshutil.MakeFeBlockRouteId(fullBlockId)}, |
| 98 | ) |
| 99 | if err != nil { |
| 100 | return nil, err |
| 101 | } |
| 102 | |
| 103 | content := strings.Join(result.Lines, "\n") |
| 104 | var effectiveLineEnd int |
| 105 | if rpcData.LastCommand { |
| 106 | effectiveLineEnd = result.LineStart + len(result.Lines) |
| 107 | } else { |
| 108 | effectiveLineEnd = min(rpcData.LineEnd, result.TotalLines) |
| 109 | } |
| 110 | hasMore := effectiveLineEnd < result.TotalLines |
| 111 | |
| 112 | var sinceLastOutputSec *int |
| 113 | if result.LastUpdated > 0 { |
| 114 | sec := max(0, int((time.Now().UnixMilli()-result.LastUpdated)/1000)) |
| 115 | sinceLastOutputSec = &sec |
| 116 | } |
| 117 | |
| 118 | var nextStart *int |
| 119 | if hasMore { |
| 120 | nextStart = &effectiveLineEnd |
| 121 | } |
| 122 | |
| 123 | blockORef := waveobj.MakeORef(waveobj.OType_Block, fullBlockId) |
| 124 | rtInfo := wstore.GetRTInfo(blockORef) |
| 125 | |
| 126 | var lastCommand *CommandInfo |
| 127 | if rtInfo != nil && rtInfo.ShellIntegration && rtInfo.ShellLastCmd != "" { |
| 128 | cmdInfo := &CommandInfo{ |
| 129 | Command: rtInfo.ShellLastCmd, |
| 130 | } |
| 131 | if rtInfo.ShellState == "running-command" { |
| 132 | cmdInfo.Status = "running" |
| 133 | } else if rtInfo.ShellState == "ready" { |
| 134 | cmdInfo.Status = "completed" |
| 135 | exitCode := rtInfo.ShellLastCmdExitCode |
| 136 | cmdInfo.ExitCode = &exitCode |
| 137 | } |
| 138 | lastCommand = cmdInfo |
| 139 | } |
| 140 | |
| 141 | return &TermGetScrollbackToolOutput{ |
no test coverage detected