Skip to content
Open
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
1 change: 1 addition & 0 deletions ts/packages/agents/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"test:views:client": "jest --runInBand --testMatch \"**/views/client/**/*.test.ts\"",
"test:views:derived-browser": "node --test test/derivedViewBrowser.test.mjs",
"test:views:gateway": "node --test test/viewGateway.test.mjs test/viewDraftGateway.test.mjs test/viewLifecycle.test.mjs test/memoryHub.test.mjs test/memoryHubQuery.test.mjs test/memoryHubGraph.test.mjs test/memoryHubScopedKnowledge.test.mjs test/memoryHubSourceDependencies.test.mjs test/memoryHubCapture.test.mjs test/browserCaptureRpc.test.mjs test/memoryHubRunbookImports.test.mjs test/memoryHubWebAnalytics.test.mjs test/schemaQuestionRpc.test.mjs test/knowledgeRpc.test.mjs",
"test:views:wiki-review-browser": "node --test test/wikiAmbiguityBrowser.spec.mjs",
"tsc:agent": "tsc -p src/agent/tsconfig.json",
"tsc:puppeteer": "tsc -p src/puppeteer/tsconfig.json",
"tsc:views:client:typecheck": "tsc -p src/views/client/pdf/tsconfig.json && tsc -p src/views/client/library/tsconfig.json",
Expand Down
16 changes: 16 additions & 0 deletions ts/packages/agents/browser/src/agent/memoryViews.mts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
knowledgeCheckpointRequestSchema,
knowledgeCheckpointReadSchema,
knowledgeCheckpointWaitSchema,
wikiAmbiguityListRequestSchema,
wikiAmbiguityReviewActionSchema,
} from "@typeagent/memory-client";
import {
acquisitionProgress,
Expand Down Expand Up @@ -67,6 +69,8 @@ type ViewMethods = Pick<
| "memoryGetViewMaintenance"
| "memoryGetViewBuild"
| "memoryListViewBuilds"
| "memoryListWikiAmbiguityReviews"
| "memoryResolveWikiAmbiguityReview"
| "memoryCancelViewBuild"
| "memoryRetryViewBuild"
| "memoryContinueViewBuild"
Expand Down Expand Up @@ -222,6 +226,18 @@ export function createMemoryViewFunctions(
memoryGetViewBuild: (request) => views().getViewBuild(request),
memoryListViewBuilds: ({ corpusId }) =>
views().listViewBuilds(corpusId),
memoryListWikiAmbiguityReviews: (request) =>
views().listWikiAmbiguityReviews(
wikiAmbiguityListRequestSchema.parse(request).corpusId,
),
memoryResolveWikiAmbiguityReview: (request) => {
const { resolution, ...parsed } =
wikiAmbiguityReviewActionSchema.parse(request);
return views().resolveWikiAmbiguityReview({
...parsed,
...(resolution ? { resolution } : {}),
});
},
memoryCancelViewBuild: (request) => views().cancelViewBuild(request),
memoryRetryViewBuild: (request) => views().retryViewBuild(request),
memoryContinueViewBuild: (request) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

import { inventoryFixture } from "./memoryHubInventoryTestData";

import type { ViewBuildJob, ViewVersion } from "@typeagent/memory-service";
import type {
ViewBuildJob,
ViewVersion,
WikiAmbiguityReview,
} from "@typeagent/memory-service";
import { invokeMemory } from "./viewClient";
import {
mountMemoryHubViewActivity,
Expand Down Expand Up @@ -90,6 +94,135 @@ beforeEach(() => {
);
});

test.each([true, false])(
"durable Wiki review Inbox feed survives absent build-summary pages; resolution enabled: %s",
async (canResolve) => {
let review: WikiAmbiguityReview = {
id: "review",
corpusId: "alpha",
jobId: "historical-job",
candidateId: "candidate",
version: 2,
createdAt: "2026-11-15",
updatedAt: "2026-11-15",
state: "needsReview",
reason: "Retained unresolved Wiki proposal",
assessment: {
disposition: "ambiguous",
reason: "uncertain",
purpose: "candidate",
canonicalViewId: "",
sharedFragmentIds: [],
ambiguousViewIds: [],
essentialDistinctions: [],
},
participants: [
{
id: "candidate",
revisionId: null,
input: {
corpusId: "alpha",
actor: "fixture",
definition: {
viewId: "candidate",
kind: "wiki",
selector: { kind: "sources", sources: [] },
},
expectedVersion: 0,
bounds: {},
inputs: [],
pipeline: "informational-wiki-v1",
model: "offline",
fingerprint: "f",
},
},
],
request: {
model: "GPT_6_1_SOL",
logicalRequests: 1,
state: "unavailable",
},
};
invoke.mockImplementation(
inventoryFixture(async (method: string) => {
if (method === "memoryViewCapabilities")
return {
derivedViews: {
builds: true,
wikiAmbiguityReviews: true,
wikiAmbiguityResolution: canResolve,
},
};
if (method === "memoryListCorpora")
return [{ corpusId: "alpha", name: "Alpha" }];
if (method === "memoryListViewBuilds") return [];
if (method === "memoryListViews")
return { head: null, views: [] };
if (method === "memoryListWikiAmbiguityReviews")
return [review];
if (method === "memoryResolveWikiAmbiguityReview") {
review = {
...review,
state: "resolved",
reason: "Verified keep separate",
};
return review;
}
throw new Error(`Unexpected method ${method}`);
}),
);
const host = document.createElement("div");
const attention = document.createElement("div");
const counts = jest.fn();
const mounted = mountMemoryHubViewActivity(host, attention, {
scope: () => "alpha",
onError: jest.fn(),
onOpenView: jest.fn(),
onOpenBuild: jest.fn(),
onAttentionCount: counts,
});
try {
await mounted.refresh();
expect(attention.textContent).toContain(
"Retained unresolved Wiki proposal",
);
expect(counts).toHaveBeenLastCalledWith(1, false);
if (!canResolve) {
expect(attention.textContent).toContain(
"Wiki review is disabled",
);
expect(textButton(attention, "Keep separate").disabled).toBe(
true,
);
textButton(attention, "Keep separate").click();
expect(
invoke.mock.calls.some(
([method]) =>
method === "memoryResolveWikiAmbiguityReview",
),
).toBe(false);
return;
}
textButton(attention, "Keep separate").click();
await new Promise((done) => setTimeout(done, 0));
expect(invoke).toHaveBeenCalledWith(
"memoryResolveWikiAmbiguityReview",
{
corpusId: "alpha",
reviewId: "review",
expectedVersion: 2,
action: "keep_separate",
},
);
expect(attention.textContent).not.toContain(
"Retained unresolved Wiki proposal",
);
} finally {
mounted.dispose();
}
},
);

test("partial builds and failed targets remain explicit in Activity and Inbox", async () => {
const host = document.createElement("div");
const attention = document.createElement("div");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import type {
ViewBuildSummary,
ViewBuildResultSummary,
ViewSummaryPage,
WikiAmbiguityReview,
} from "@typeagent/memory-service";
import { invokeMemory } from "./viewClient";
import { MemoryHubInventoryPager } from "./memoryHubInventoryPager";
import type { InboxAttentionCard } from "./memoryHubInbox";
import { wikiAmbiguityAttention } from "./memoryHubWikiAmbiguity";
import {
rbButton,
rbChip,
Expand Down Expand Up @@ -392,6 +394,7 @@ export function mountMemoryHubViewActivity(
result: ViewBuildResultSummary,
current: number,
): Promise<boolean> {
if (result.wikiAmbiguityReviewId) return true;
if (result.conflictId) {
if (
result.conflictState === "resolved" ||
Expand Down Expand Up @@ -588,6 +591,26 @@ export function mountMemoryHubViewActivity(
attentionHost.prepend(heading);
}

function renderWikiReviews(
reviews: WikiAmbiguityReview[],
canResolve: boolean,
): void {
for (const review of reviews) {
if (review.state === "resolved") continue;
const card = wikiAmbiguityAttention(
review,
(request) =>
invokeMemory("memoryResolveWikiAmbiguityReview", request),
refresh,
options.onOpenView,
canResolve,
);
attentionHost.append(
options.presentAttention?.(card) ?? card.detail,
);
}
}

async function refresh(): Promise<void> {
const current = ++sequence;
const scope = options.scope();
Expand All @@ -609,7 +632,7 @@ export function mountMemoryHubViewActivity(
);
const groups = await Promise.all(
available.map(async (corpus) => {
const [jobs, alerts] = await Promise.all([
const [jobs, alerts, reviews] = await Promise.all([
jobPager.includes(corpus.corpusId)
? invokeMemory(
"memoryListViewBuildSummaries",
Expand All @@ -623,13 +646,19 @@ export function mountMemoryHubViewActivity(
capabilities.derivedViews?.maintenance === true,
)
: Promise.resolve(undefined),
!visible && capabilities.derivedViews?.wikiAmbiguityReviews
? invokeMemory("memoryListWikiAmbiguityReviews", {
corpusId: corpus.corpusId,
})
: Promise.resolve([]),
]);
return {
corpus,
jobs: jobs?.items ?? [],
alerts: alerts?.alerts ?? [],
jobPage: jobs,
attentionPage: alerts?.page,
reviews,
};
}),
);
Expand Down Expand Up @@ -658,6 +687,10 @@ export function mountMemoryHubViewActivity(
attentionHost.replaceChildren();
const rendered = await renderGroups(groups, current);
if (!rendered.current) return;
renderWikiReviews(
groups.flatMap((group) => group.reviews),
capabilities.derivedViews?.wikiAmbiguityResolution !== false,
);
const { total, running } = rendered;
status.textContent = total
? `Showing ${total} of ${jobPager.total} view operations`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,47 @@ describe("Memory Center preview-first views", () => {
},
);

test("partial support reader shows unresolved categories without conflating choice confidence or approval", async () => {
const original = invoke.getMockImplementation()!;
const wiki = {
...view,
content: { ...content, kind: "wiki", status: "partial" },
definition: { ...definition, kind: "wiki" },
quality: {
status: "partiallySupported",
confidence: 0.5,
unresolvedCategories: ["newContentSupport"],
decisions: [
{
category: "newContentSupport",
status: "partiallySupported",
choiceConfidence: 0.99,
},
],
},
};
invoke.mockImplementation(
inventoryFixture((method, params) =>
method === "memoryListViews"
? Promise.resolve({ ...snapshot, views: [wiki] })
: original(method, params),
),
);
await panel.refresh();
click(host, "Guide");
await settle();
const article = host.querySelector(".hub-view-document")!;
expect(article.textContent).toContain(
"Support: partiallySupported (policy score 0.5)",
);
expect(article.textContent).toContain(
"Needs further evidence or review: newContentSupport",
);
expect(article.textContent).toContain("not a calibrated probability");
expect(article.textContent).not.toContain("policy score 0.99");
expect(errors).toEqual([]);
});

test("reader icon toolbar opens an icon-and-text menu and restores keyboard and dialog focus", async () => {
await panel.refresh();
click(host, "Guide");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ import {
findPopulatedViewKinds,
} from "./memoryHubViewTypeFilter";

function articleCompleteness(content: DerivedViewContent): HTMLElement[] {
function articleCompleteness(
content: DerivedViewContent,
quality?: ViewVersion["quality"],
): HTMLElement[] {
if (
(content.kind !== "wiki" && content.kind !== "projectBrief") ||
!content.status
Expand All @@ -65,6 +68,14 @@ function articleCompleteness(content: DerivedViewContent): HTMLElement[] {
`Completeness: ${content.status}`,
content.status === "sufficient" ? "good" : "warn",
),
...(quality
? [
rbChip(
`Support: ${quality.status} (policy score ${quality.confidence})`,
quality.status === "supported" ? "good" : "warn",
),
]
: []),
];
}

Expand Down Expand Up @@ -99,6 +110,14 @@ function appendArticleIntroduction(
view: ViewVersion,
meta: HTMLElement,
): HTMLElement {
if (view.quality && view.quality.unresolvedCategories.length)
meta.append(
rbNode(
"p",
`Needs further evidence or review: ${view.quality.unresolvedCategories.join(", ")}. Support score is an ordinal policy, not a calibrated probability or publication approval.`,
"hub-view-note",
),
);
const hasInfobox =
view.content.kind === "wiki" || view.content.kind === "projectBrief";
const overviewLabel =
Expand Down Expand Up @@ -2073,7 +2092,7 @@ export function mountMemoryHubViews(
metaChips.append(
rbChip(viewKindLabels[view.content.kind]),
rbChip(`Version ${view.version}`),
...articleCompleteness(view.content),
...articleCompleteness(view.content, view.quality),
);
meta.append(metaChips, ...viewRevisionTime(view.createdAt));
article.append(title);
Expand Down
Loading
Loading