Skip to content

Commit 1fe5167

Browse files
committed
fix(webchat): keep reply-source indexing lazy
Index persisted message identities without normalizing historical content again. Keep reply eligibility in the existing preview and navigation owners. Use the canonical attachment collector in filename tests, make its internal helpers private, and tighten the assertion baseline after removing casts. The complete attachment-reply repair remains net -1 production line. Verified with the unchanged invalidation witness, 44 focused tests, the Chromium reply flow, UI types, assertion ratchet, all three unused-export scans, and an independent Codex review of the complete 21-path change.
1 parent c2483ca commit 1fe5167

5 files changed

Lines changed: 19 additions & 12 deletions

File tree

‎config/assertion-safety-baseline.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4034,7 +4034,7 @@ ui/src/pages/chat/components/chat-sidebar-editor-menu.ts 2
40344034
ui/src/pages/chat/components/chat-sidebar-region.runtime.ts 2
40354035
ui/src/pages/chat/components/chat-swarm-progress.ts 2
40364036
ui/src/pages/chat/components/chat-task-suggestions.ts 1
4037-
ui/src/pages/chat/components/chat-thread-interactions.ts 6
4037+
ui/src/pages/chat/components/chat-thread-interactions.ts 3
40384038
ui/src/pages/chat/components/chat-voice-activity.ts 1
40394039
ui/src/pages/chat/components/session-diff-menus.ts 1
40404040
ui/src/pages/chat/components/session-diff-panel.ts 2

‎ui/src/lib/media-file-extension.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function isSameOriginMediaRoute(value: string): boolean {
1717
}
1818

1919
/** Returns the final filename after decoding one URL path-segment layer. */
20-
export function getMediaFileName(value: string): string | undefined {
20+
function getMediaFileName(value: string): string | undefined {
2121
const trimmed = value.trim();
2222
if (!trimmed) {
2323
return undefined;

‎ui/src/pages/chat/chat-history.media.test.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
readTranscriptMediaEntries,
55
} from "../../lib/chat/message-extract.ts";
66
import { buildChatItems } from "./chat-thread-build.ts";
7-
import { extractTranscriptAttachments } from "./components/chat-message-media.ts";
7+
import { extractMessageAttachments } from "./components/chat-message-media.ts";
88

99
const MANAGED_UUID = "43007e90-2ade-43f2-a781-42b843e9eca3";
1010

@@ -75,66 +75,71 @@ describe("chat history attachment card labels", () => {
7575
});
7676

7777
it("labels a managed inbound attachment with the persisted original fileName", () => {
78-
const attachments = extractTranscriptAttachments(
78+
const attachments = extractMessageAttachments(
7979
userMessageWithMedia([
8080
{
8181
path: `media://inbound/report---${MANAGED_UUID}.pdf`,
8282
fileName: "report.pdf",
8383
contentType: "application/pdf",
8484
},
8585
]),
86+
[],
8687
);
8788
expect(attachments[0]?.attachment.label).toBe("report.pdf");
8889
});
8990

9091
it("restores the original name from a legacy managed inbound UUID suffix when fileName is absent", () => {
91-
const attachments = extractTranscriptAttachments(
92+
const attachments = extractMessageAttachments(
9293
userMessageWithMedia([
9394
{
9495
path: `media://inbound/openclaw-attachment-test---${MANAGED_UUID}.docx`,
9596
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
9697
},
9798
]),
99+
[],
98100
);
99101
expect(attachments[0]?.attachment.label).toBe("openclaw-attachment-test.docx");
100102
});
101103

102104
it("leaves non-managed https attachment paths unchanged", () => {
103105
// `---old` is not a canonical managed UUID suffix, so it must not be stripped
104106
// from https URLs (which never carry the collision-safe managed suffix).
105-
const attachments = extractTranscriptAttachments(
107+
const attachments = extractMessageAttachments(
106108
userMessageWithMedia([
107109
{
108110
path: "https://example.com/files/openclaw-attachment-test---old.docx",
109111
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
110112
},
111113
]),
114+
[],
112115
);
113116
expect(attachments[0]?.attachment.label).toBe("openclaw-attachment-test---old.docx");
114117
});
115118

116119
it("does not strip a managed inbound basename that lacks a UUID suffix", () => {
117-
const attachments = extractTranscriptAttachments(
120+
const attachments = extractMessageAttachments(
118121
userMessageWithMedia([
119122
{
120123
path: "media://inbound/plain-name.docx",
121124
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
122125
},
123126
]),
127+
[],
124128
);
125129
expect(attachments[0]?.attachment.label).toBe("plain-name.docx");
126130
});
127131

128132
it("strips only the terminal managed UUID suffix, preserving a UUID-shaped segment in the original name", () => {
129133
// Legacy record (no persisted fileName) whose original filename itself
130134
// contains a "---<uuid>"-shaped segment before the terminal managed suffix.
131-
const attachments = extractTranscriptAttachments(
135+
const attachments = extractMessageAttachments(
132136
userMessageWithMedia([
133137
{
134138
path: `media://inbound/report---a1b2c3d4-e5f6-7890-abcd-ef1234567890-final---${MANAGED_UUID}.docx`,
135139
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
136140
},
137141
]),
142+
[],
138143
);
139144
expect(attachments[0]?.attachment.label).toBe(
140145
"report---a1b2c3d4-e5f6-7890-abcd-ef1234567890-final.docx",
@@ -143,8 +148,9 @@ describe("chat history attachment card labels", () => {
143148

144149
it("preserves a dotted UUID-shaped segment in a legacy attachment name", () => {
145150
const path = `media://inbound/report---a1b2c3d4-e5f6-7890-abcd-ef1234567890.backup---${MANAGED_UUID}.pdf`;
146-
const attachments = extractTranscriptAttachments(
151+
const attachments = extractMessageAttachments(
147152
userMessageWithMedia([{ path, contentType: "application/pdf" }]),
153+
[],
148154
);
149155

150156
expect(attachments[0]?.attachment).toMatchObject({

‎ui/src/pages/chat/components/chat-message-media.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ function crossOriginStructuredSvgAttachment(
386386
};
387387
}
388388

389-
export function extractStructuredSvgAttachments(message: unknown): AttachmentItem[] {
389+
function extractStructuredSvgAttachments(message: unknown): AttachmentItem[] {
390390
const content = asNonArrayRecord(message).content;
391391
if (!Array.isArray(content)) {
392392
return [];
@@ -698,7 +698,7 @@ export function extractMessageAttachments(
698698
});
699699
}
700700

701-
export function extractTranscriptAttachments(message: unknown): AttachmentItem[] {
701+
function extractTranscriptAttachments(message: unknown): AttachmentItem[] {
702702
const attachments: AttachmentItem[] = [];
703703
for (const {
704704
path: mediaPath,

‎ui/src/pages/chat/components/chat-transcript-projection.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ export function projectChatTranscript(
513513
for (const group of groups) {
514514
for (const source of group.messages) {
515515
const sourceMessageId = persistedMessageEntryId(source.message);
516-
if (sourceMessageId && resolveMessageReplyText(source.message).trim()) {
516+
// The preview resolves content lazily; indexing only needs persisted identities.
517+
if (sourceMessageId) {
517518
messageRowKeysById.set(sourceMessageId, item.key);
518519
loadedReplySources.set(sourceMessageId, {
519520
message: source.message,

0 commit comments

Comments
 (0)