Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/browser/features/Memory/MemoryBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,20 @@ function MemoryFileRow(props: MemoryFileRowProps) {
);
}

function uniqueConsolidationSummaryLines(
summaries: ReadonlyArray<string | null | undefined>
): string[] {
const seen = new Set<string>();
const lines: string[] = [];
for (const summary of summaries) {
const line = summary?.trim();
if (!line || seen.has(line)) continue;
seen.add(line);
lines.push(line);
}
return lines;
}

function formatConsolidationRecord(record: MemoryConsolidationRecordPayload | null): string {
if (record === null) return "never";
const appliedCount = record.ops.filter((op) => op.applied).length;
Expand Down Expand Up @@ -556,14 +570,15 @@ function ConsolidationFooter(props: {
: "never";
const harvestError =
status?.latestHarvestRecord?.status === "failed" ? status.latestHarvestRecord.error : undefined;
const summaryTitle = [
// One consolidation pass can cover workspace, project, and global memory at
// once, so those scope records often share the exact same summary. Keep the
// per-scope status lines below, but avoid repeating identical tooltip text.
const summaryTitle = uniqueConsolidationSummaryLines([
status?.workspaceRecord?.summary,
status?.projectRecord?.summary,
status?.globalRecord?.summary,
status?.latestHarvestRecord?.error,
]
.filter(Boolean)
.join("\n");
]).join("\n");

return (
<div className="border-border-light flex items-center justify-between gap-2 border-t px-3 py-2 text-xs">
Expand Down
33 changes: 33 additions & 0 deletions src/browser/features/RightSidebar/Memory/MemoryTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,39 @@ describe("MemoryTab", () => {
expect(getByText(/^Project:/).textContent).not.toContain("manual");
});

test("deduplicates identical consolidation summaries in the tooltip", async () => {
const sharedRecord = {
...DEFAULT_CONSOLIDATION_RECORD,
summary: "shared consolidation summary",
};
fake = createFakeMemoryApi([], {
consolidationStatus: {
workspaceRecord: sharedRecord,
projectRecord: sharedRecord,
globalRecord: sharedRecord,
latestHarvestRecord: null,
projectAvailable: true,
},
});
const { findByText } = render(<MemoryTab workspaceId="ws-1" />);

const workspaceLine = await findByText(/^Workspace: .*manual/);
const statusBlock = workspaceLine.parentElement;
expect(statusBlock).not.toBeNull();
fireEvent.pointerMove(statusBlock!);

await waitFor(() => {
const tooltipBlocks = Array.from(
document.querySelectorAll<HTMLElement>(".whitespace-pre-line")
);
expect(tooltipBlocks.length).toBeGreaterThan(0);
for (const block of tooltipBlocks) {
const matches = block.textContent?.match(/shared consolidation summary/g) ?? [];
expect(matches).toHaveLength(1);
}
});
});

test("consolidation summary does not leave a native title tooltip", async () => {
fake = createFakeMemoryApi([], {
consolidationStatus: {
Expand Down
5 changes: 4 additions & 1 deletion src/node/services/historyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ export class HistoryService {
let summary: MuxMessage | undefined;
const lowerBound = metadata.previousBoundaryHistorySequence;

await this.iterateForward(workspaceId, (chunk) => {
const iteration = await this.iterateFullHistory(workspaceId, "forward", (chunk) => {
for (const message of chunk) {
const sequence = message.metadata?.historySequence;
if (!isNonNegativeInteger(sequence)) continue;
Expand All @@ -921,6 +921,9 @@ export class HistoryService {
messages.push(message);
}
});
if (!iteration.success) {
return Err(`Failed to read compaction epoch messages: ${iteration.error}`);
}

if (summary === undefined) {
return Err(`Compaction summary not found: ${metadata.summaryMessageId}`);
Expand Down
Loading