Gateway: keep whole T3 history pages, and show a command's first line as its activity
This commit is contained in:
1 parent
52210d0223
commit
abd2fd0e13
3 files changed
+13
-7
No files matched your search
@@ -93,7 +93,10 @@ function windowCursor(start: number, bounded: BoundedThread): string | null {
|
||||
return bounded.hasMoreHistory && bounded.historyCursor ? `h${bounded.historyCursor}` : null;
|
||||
}
|
||||
|
||||
/** Up to 20 messages before `cursor`. T3 pages without messages are skipped, three at most. */
|
||||
/**
|
||||
* The messages before `cursor`: 20 from the bounded window, or one T3 page, which can hold more.
|
||||
* T3 pages without messages are skipped, three at most.
|
||||
*/
|
||||
export async function loadHistory(host: T3Host, thread: ThreadShell, cursor: string): Promise<HistoryResponse> {
|
||||
if (cursor.startsWith("w")) {
|
||||
const end = Number(cursor.slice(1));
|
||||
@@ -120,7 +123,7 @@ export async function loadHistory(host: T3Host, thread: ThreadShell, cursor: str
|
||||
createdAt: item.startedAt ?? item.updatedAt ?? "",
|
||||
}),
|
||||
);
|
||||
if (messages.length > 0) return { messages: messages.slice(-MESSAGES_PER_THREAD), earlierCursor: next && `h${next}` };
|
||||
if (messages.length > 0) return { messages, earlierCursor: next && `h${next}` };
|
||||
}
|
||||
return { messages: [], earlierCursor: next && `h${next}` };
|
||||
}
|
||||
@@ -139,7 +142,9 @@ export function currentActivity(turnItems: TurnItem[]): Activity | null {
|
||||
function describeStep(item: TurnItem): Omit<Activity, "startedAt"> | null {
|
||||
switch (item.type) {
|
||||
case "command_execution":
|
||||
return item.monitor || typeof item.input !== "string" ? null : { kind: "command", text: item.input };
|
||||
return item.monitor || typeof item.input !== "string"
|
||||
? null
|
||||
: { kind: "command", text: item.input.split("\n").find((line) => line.trim()) ?? item.input };
|
||||
case "file_change":
|
||||
return item.fileName ? { kind: "edit", text: item.fileName.split("/").pop()! } : null;
|
||||
case "file_search":
|
||||
|
||||
Reference in new issue
Block a user