refactor(agent): unified transcript block finalization logic
- Replaced commit-based stability checks with a unified `isTranscriptBlockFinalized` tracking mechanism. - Removed deprecated provisional rendering configuration and flags across tool and renderer interfaces. - Standardized native scrollback boundary logic to pin at the first unfinalized block using settled row verification. - Updated and refactored test suites to validate block finalization and settled row boundaries instead of deprecated commit stability methods.
This commit is contained in:
@@ -4,8 +4,11 @@ import type { Component } from "@oh-my-pi/pi-tui";
|
||||
|
||||
class MutableLiveBlock implements Component {
|
||||
#lines: string[];
|
||||
constructor(lines: string[]) {
|
||||
#settledRows: number;
|
||||
|
||||
constructor(lines: string[], settledRows: number) {
|
||||
this.#lines = [...lines];
|
||||
this.#settledRows = settledRows;
|
||||
}
|
||||
render(width: number): string[] {
|
||||
return this.#lines.map(line => line.slice(0, width));
|
||||
@@ -16,22 +19,26 @@ class MutableLiveBlock implements Component {
|
||||
isTranscriptBlockFinalized(): boolean {
|
||||
return false;
|
||||
}
|
||||
getTranscriptBlockSettledRows(): number {
|
||||
return this.#settledRows;
|
||||
}
|
||||
}
|
||||
|
||||
describe("transcript streaming commit (assistant text)", () => {
|
||||
it("treats in-place growth of the trailing line as append-only", () => {
|
||||
it("commits only the declared settled head while the trailing line grows", () => {
|
||||
const chat = new TranscriptContainer();
|
||||
// Models a streaming assistant reply: stable head rows plus a current
|
||||
// line that grows token-by-token without adding a new row.
|
||||
const block = new MutableLiveBlock(["para one", "para two", "the quick brown"]);
|
||||
// line that grows token-by-token without adding a new row. The head is
|
||||
// committable only because the block explicitly declares those rows settled.
|
||||
const block = new MutableLiveBlock(["para one", "para two", "the quick brown"], 2);
|
||||
chat.addChild(block);
|
||||
|
||||
chat.render(80);
|
||||
expect(chat.getNativeScrollbackLiveRegionStart()).toBe(2);
|
||||
|
||||
block.setLines(["para one", "para two", "the quick brown fox"]);
|
||||
chat.render(80);
|
||||
// The head rows never changed; only the trailing line grew. Its scrolled-
|
||||
// off head must be committable to native scrollback (tmux pane history).
|
||||
expect(chat.getNativeScrollbackCommitSafeEnd()).toBe(3);
|
||||
|
||||
expect(chat.getNativeScrollbackLiveRegionStart()).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user