Skip to content

Commit 874327b

Browse files
author
scotthuang
committed
fix(ui): remove [DEDUPE] debug logs and fix lint errors
1 parent a1229c5 commit 874327b

5 files changed

Lines changed: 8 additions & 58 deletions

File tree

‎src/agents/embedded-agent-subscribe.handlers.lifecycle.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,6 @@ export function handleAgentEnd(
256256

257257
const deliverTerminal = () => {
258258
ctx.state.deferBlockReplyDelivery = false;
259-
ctx.log.warn(
260-
`[DEDUPE] deliverTerminal runId=${ctx.params.runId} deferredEvents=${ctx.state.deferredAssistantEvents.length} hasBlockReply=${ctx.params.onBlockReply != null} hasOnPartialReply=${ctx.params.onPartialReply != null}`,
261-
);
262259
ctx.flushDeferredAssistantEvents();
263260
ctx.flushDeferredBlockReplies();
264261
const flushBlockReplyBufferResult = ctx.flushBlockReplyBuffer({ final: true });

‎src/gateway/server-chat.ts‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -675,17 +675,6 @@ export function createAgentEventHandler({
675675
controlUiVisible: opts?.controlUiVisible ?? true,
676676
dropIfSlow: true,
677677
});
678-
if (typeof payload.deltaText === "string" && payload.deltaText.length > 0) {
679-
console.warn(
680-
"[DEDUPE] emitChatDelta",
681-
JSON.stringify({
682-
runId: clientRunId,
683-
state: "delta",
684-
deltaTextLen: payload.deltaText.length,
685-
textLen: mergedText.length,
686-
}),
687-
);
688-
}
689678
};
690679

691680
const resolveBufferedChatTextState = (
@@ -827,16 +816,6 @@ export function createAgentEventHandler({
827816
: undefined,
828817
};
829818
sendChatPayload(sessionKey, payload, opts);
830-
console.warn(
831-
"[DEDUPE] emitChatFinal",
832-
JSON.stringify({
833-
runId: clientRunId,
834-
state: "final",
835-
hasMessage: payload.message != null,
836-
textLen: text?.length ?? 0,
837-
stopReason,
838-
}),
839-
);
840819
return;
841820
}
842821
const payload = {

‎ui/src/ui/app-gateway.sessions.node.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ describe("handleGatewayEvent pending transcript sync", () => {
865865
applySessionsChangedEventMock
866866
.mockReset()
867867
.mockImplementation(
868-
(state: { chatRunId: string | null; sessionKey: string }, _payload: unknown) => {
868+
(_state: { chatRunId: string | null; sessionKey: string }, _payload: unknown) => {
869869
// Session row is updated but hasActiveRun stays true — the local run
870870
// is still active and should not be reconciled by a sessions.changed event.
871871
return {

‎ui/src/ui/app-gateway.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
refreshChatAvatar,
1616
scopedAgentListParamsForRefreshTarget,
1717
retryReconnectableQueuedChatSends,
18-
scopedAgentListParamsForSession,
1918
scopedAgentParamsForSession,
2019
} from "./app-chat.ts";
2120
import type { EventLogEntry } from "./app-events.ts";
@@ -1097,7 +1096,13 @@ function handleChatGatewayEvent(host: GatewayHost, payload: ChatEventPayload | u
10971096
void loadChatHistory(host as unknown as ChatState);
10981097
return;
10991098
}
1100-
if (shouldConsumePendingTranscriptSync && !historyReloaded) {
1099+
// Only reload history for pending transcript sync when the terminal event
1100+
// doesn't already carry a complete assistant message. Normal finals carry
1101+
// the full reply in the payload; an unnecessary reload would cause a visible
1102+
// flicker (the optimistic user bubble gets replaced by the persisted copy).
1103+
// Error and aborted states always need a reload because the transcript
1104+
// contains the error details that aren't in the terminal payload.
1105+
if (shouldConsumePendingTranscriptSync && !historyReloaded && state !== "final") {
11011106
void loadChatHistory(host as unknown as ChatState);
11021107
}
11031108
}

‎ui/src/ui/chat/build-chat-items.ts‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,6 @@ function resolveHistoryStartIndex(
521521

522522
export function buildChatItems(props: BuildChatItemsProps): Array<ChatItem | MessageGroup> {
523523
let items: ChatItem[] = [];
524-
const debugItems = typeof (globalThis as any).window !== "undefined";
525-
if (debugItems) {
526-
console.warn(
527-
"[DEDUPE] buildChatItems input",
528-
JSON.stringify({
529-
msgCount: (Array.isArray(props.messages) ? props.messages : []).length,
530-
streamIsNull: props.stream === null,
531-
streamLen: typeof props.stream === "string" ? props.stream.length : 0,
532-
segCount: (props.streamSegments ?? []).length,
533-
}),
534-
);
535-
}
536524
const historyRenderLimit = resolveHistoryRenderLimit(props.historyRenderLimit);
537525
const history = (Array.isArray(props.messages) ? props.messages : []).filter(
538526
(message) => !isAssistantHeartbeatAckForDisplay(message),
@@ -706,25 +694,6 @@ export function buildChatItems(props: BuildChatItemsProps): Array<ChatItem | Mes
706694
const result = groupMessages(
707695
collapseSequentialDuplicateMessages(sortChatItemsByVisibleTime(items)),
708696
);
709-
if (debugItems) {
710-
const previews = result.map((item) => {
711-
if (item.kind === "stream") {
712-
return `stream[${item.text.slice(0, 30)}]`;
713-
}
714-
if (item.kind === "group") {
715-
const texts = item.messages.map((m) => {
716-
const msg = m.message as Record<string, unknown>;
717-
const role = typeof msg.role === "string" ? msg.role : "?";
718-
const content = Array.isArray(msg.content) ? msg.content : [];
719-
const textBlocks = content.filter((b: any) => b?.type === "text");
720-
const text = textBlocks.map((b: any) => String(b.text ?? "").slice(0, 30)).join("|");
721-
return `${role}:"${text}"`;
722-
});
723-
return `group[${texts.join("; ")}]`;
724-
}
725-
return item.kind;
726-
});
727-
}
728697
return result;
729698
}
730699

0 commit comments

Comments
 (0)