Merge branch 'worktree-agent-a2220433c67c864f1'
This commit is contained in:
@@ -27,6 +27,7 @@ class ChatShellRun {
|
||||
this.outputEnd = 0,
|
||||
this.outputBytes = 0,
|
||||
this.gap = false,
|
||||
this.snapshot = false,
|
||||
this.terminal = false,
|
||||
this.cols = 0,
|
||||
this.rows = 0,
|
||||
@@ -59,6 +60,11 @@ class ChatShellRun {
|
||||
/// stretch of what the command wrote.
|
||||
final bool gap;
|
||||
|
||||
/// True when [output] starts with the server's redraw of the terminal's
|
||||
/// state at [outputStart] (screens, scrollback, cursor and modes) instead
|
||||
/// of raw output: nothing earlier is missing from what it shows.
|
||||
final bool snapshot;
|
||||
|
||||
/// True when the command runs in a pseudo-terminal of [cols] x [rows]:
|
||||
/// [output] is then the raw terminal stream and it accepts typed input
|
||||
/// while it runs. Older runs (and servers without terminals) are plain.
|
||||
@@ -78,7 +84,7 @@ class ChatShellRun {
|
||||
final bool purged;
|
||||
|
||||
/// Whether earlier output is not shown here.
|
||||
bool get truncated => outputStart > 0 || gap;
|
||||
bool get truncated => !snapshot && (outputStart > 0 || gap);
|
||||
|
||||
ChatShellRunState get state => switch (status) {
|
||||
'running' => ChatShellRunState.running,
|
||||
@@ -144,6 +150,7 @@ class ChatShellRun {
|
||||
? next.outputBytes
|
||||
: outputBytes,
|
||||
gap: gap,
|
||||
snapshot: snapshot,
|
||||
terminal: next.terminal || terminal,
|
||||
cols: next.cols == 0 ? cols : next.cols,
|
||||
rows: next.rows == 0 ? rows : next.rows,
|
||||
@@ -180,6 +187,7 @@ class ChatShellRun {
|
||||
outputEnd: end,
|
||||
outputBytes: end > outputBytes ? end : outputBytes,
|
||||
gap: gap || dropped || (!contiguous && offset > 0),
|
||||
snapshot: snapshot && contiguous && !dropped,
|
||||
terminal: terminal,
|
||||
cols: cols,
|
||||
rows: rows,
|
||||
|
||||
@@ -113,8 +113,12 @@ class ChatShellTerminalSession {
|
||||
}
|
||||
|
||||
/// Draws [run]'s held output from scratch: on open, after a gap and after
|
||||
/// a readback replaced the card's copy. Answers the emulator gives to old
|
||||
/// queries in that output are not sent: the process asked them long ago.
|
||||
/// a readback replaced the card's copy. A machine terminal's read from
|
||||
/// before the server's tail is the server's snapshot
|
||||
/// ([ChatShellRun.snapshot]), which resets the emulator and restores the
|
||||
/// screens, scrollback, cursor and modes; it is drawn the same way.
|
||||
/// Answers the emulator gives to old queries in that output are not sent:
|
||||
/// the process asked them long ago.
|
||||
/// A large output is drawn in slices across turns of the event loop
|
||||
/// (ChatShellTerminalFeed), so it never stalls the UI.
|
||||
void replay(ChatShellRun run) {
|
||||
@@ -126,6 +130,9 @@ class ChatShellTerminalSession {
|
||||
terminal.useMainBuffer();
|
||||
terminal.buffer.clear();
|
||||
terminal.buffer.setCursor(0, 0);
|
||||
// A full reset (RIS): modes a program set in the output drawn before
|
||||
// (mouse reporting, bracketed paste, the alternate screen) end too.
|
||||
terminal.write('\x1bc');
|
||||
terminal.setCursorVisibleMode(true);
|
||||
terminal.write('\x1b[0m');
|
||||
if (run.truncated) {
|
||||
|
||||
Reference in New Issue
Block a user