feat(web): show native context compaction activity in chat
This commit is contained in:
+17
-5
@@ -158,6 +158,7 @@ import {
|
||||
threadPhase,
|
||||
threadToolElapsedMillis,
|
||||
TURN_PHASE_WAITING,
|
||||
TURN_PHASE_COMPACTING,
|
||||
toolCallCount,
|
||||
toolCallRow,
|
||||
toolCallsAnnouncement,
|
||||
@@ -1017,12 +1018,12 @@ function shellOutputFailed(sessionId, shellId, message) {
|
||||
async function resyncOpenChat() {
|
||||
const id = state.chatActiveId;
|
||||
if (!id || state.connection.kind !== "connected") return;
|
||||
await subscribeChatSession(id);
|
||||
const previous = state.chatThreads.get(id) ?? newChatThread(id);
|
||||
state.chatThreads.set(id, resumedThread(previous));
|
||||
await subscribeChatSession(id);
|
||||
try {
|
||||
const page = await repo.chatHistory(id);
|
||||
state.chatThreads.set(id, historyResync(previous, page));
|
||||
state.chatThreads.set(id, historyResync(state.chatThreads.get(id), page, { preserveActivity: true }));
|
||||
} catch {
|
||||
// The history refresh failed; the settled thread stands and the badge is honest.
|
||||
}
|
||||
@@ -3400,6 +3401,8 @@ function renderChatActivity(turn, streaming = false, elapsedMillis = () => 0, th
|
||||
class: `chat-reasoning chat-activity${streaming ? " chat-reasoning-live" : ""}`,
|
||||
});
|
||||
const head = h("div", { class: "chat-activity-head" });
|
||||
const compacting = streaming && threadPhase(thread, Date.now()) === TURN_PHASE_COMPACTING;
|
||||
if (compacting) head.classList.add("chat-activity-compacting");
|
||||
if (streaming) {
|
||||
const spinner = h("span", {
|
||||
class: "spinner chat-activity-spinner",
|
||||
@@ -3409,9 +3412,18 @@ function renderChatActivity(turn, streaming = false, elapsedMillis = () => 0, th
|
||||
spinner.style.animationDelay = `-${(performance.now() % 800) / 1000}s`;
|
||||
head.append(spinner);
|
||||
}
|
||||
if (compacting) {
|
||||
head.append(h("span", {
|
||||
class: "chat-activity-phase chat-compaction-status",
|
||||
role: "status",
|
||||
"aria-live": "polite",
|
||||
text: turnPhaseLabel(TURN_PHASE_COMPACTING),
|
||||
}));
|
||||
if (steps.length || parts.length) head.append(h("span", { class: "chat-compaction-break", "aria-hidden": "true" }));
|
||||
}
|
||||
if (steps.length > 0) {
|
||||
head.append(renderChatReasoningToggle(turn, streaming, steps));
|
||||
} else if (streaming) {
|
||||
head.append(renderChatReasoningToggle(turn, streaming && !compacting, steps));
|
||||
} else if (streaming && !compacting) {
|
||||
head.append(
|
||||
h("span", {
|
||||
class: "chat-activity-phase",
|
||||
@@ -3420,7 +3432,7 @@ function renderChatActivity(turn, streaming = false, elapsedMillis = () => 0, th
|
||||
);
|
||||
}
|
||||
if (parts.length > 0) {
|
||||
if (head.childElementCount > 0) head.append(h("span", { class: "chat-activity-sep", text: "\u00b7" }));
|
||||
if (steps.length > 0 || (streaming && !compacting)) head.append(h("span", { class: "chat-activity-sep", text: "\u00b7" }));
|
||||
head.append(renderChatToolChip(turn, { streaming, elapsedMillis }));
|
||||
}
|
||||
const elapsed = streaming
|
||||
|
||||
Reference in New Issue
Block a user