fix: handle web console segment rotation
This commit is contained in:
@@ -818,3 +818,42 @@ Deno.test("projectConsole renders snapshot entries and in-flight output", () =>
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("projectConsole reseeds visible rows from segment rotation", () => {
|
||||
const projection = projectConsole([
|
||||
{
|
||||
eventId: "rotation-before",
|
||||
event: {
|
||||
event: "user_message",
|
||||
data: { segments: [{ kind: "text", content: "before rotation" }] },
|
||||
} satisfies Event,
|
||||
},
|
||||
{
|
||||
eventId: "rotation-event",
|
||||
event: {
|
||||
event: "segment_rotated",
|
||||
data: {
|
||||
entry: {
|
||||
kind: "segment_start",
|
||||
ts: 10,
|
||||
session_id: "00000000-0000-0000-0000-000000000001",
|
||||
system_prompt: null,
|
||||
config: {},
|
||||
history: [
|
||||
{
|
||||
kind: "message",
|
||||
role: "user",
|
||||
content: [{ kind: "text", text: "after rotation seed" }],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
} satisfies Event,
|
||||
},
|
||||
]);
|
||||
|
||||
assertEquals(
|
||||
projection.lines.map((line) => `${line.kind}:${line.body}`),
|
||||
["user:after rotation seed"],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -259,6 +259,9 @@ export function applyProtocolEvent(
|
||||
case "status":
|
||||
next.status = event.data.status;
|
||||
break;
|
||||
case "segment_rotated":
|
||||
next.lines = snapshotLinesFromEntries(envelope.eventId, [event.data.entry]);
|
||||
break;
|
||||
case "invoke_start":
|
||||
case "turn_start":
|
||||
case "turn_end":
|
||||
@@ -272,7 +275,6 @@ export function applyProtocolEvent(
|
||||
appendAlertLine(next, envelope.eventId, event.data);
|
||||
break;
|
||||
case "memory_worker":
|
||||
case "segment_rotated":
|
||||
case "completions":
|
||||
case "rewind_targets":
|
||||
case "rewind_applied":
|
||||
|
||||
+3
-1
@@ -324,6 +324,8 @@
|
||||
if (token.kind === "command") {
|
||||
return localCommandCompletions(token.prefix);
|
||||
}
|
||||
const completionKind = token.kind;
|
||||
const completionPrefix = token.prefix;
|
||||
return new Promise((resolve, reject) => {
|
||||
if (pendingCompletionRequest) {
|
||||
rejectPendingCompletion(
|
||||
@@ -339,7 +341,7 @@
|
||||
try {
|
||||
sendProtocolMethod({
|
||||
method: "list_completions",
|
||||
params: { kind: token.kind, prefix: token.prefix },
|
||||
params: { kind: completionKind, prefix: completionPrefix },
|
||||
});
|
||||
} catch (error) {
|
||||
rejectPendingCompletion(
|
||||
|
||||
Reference in New Issue
Block a user