fix(confidence-engine): restore finding controls on reopen
This commit is contained in:
@@ -1381,15 +1381,35 @@ export default function ReasoningWorkspace({
|
||||
|
||||
// ── Derive presentation data: exact existing Findings for the current focused Contribution ──
|
||||
let currentFindings = [];
|
||||
if (focused?.result?.correlationId && findings) {
|
||||
const correlationId = focused.result.correlationId;
|
||||
const matchedContribution = (focusedContributions || []).find(
|
||||
(c) => c.correlationId === correlationId,
|
||||
);
|
||||
if (matchedContribution) {
|
||||
currentFindings = findings.filter(
|
||||
(f) => f.contributionId === matchedContribution.id,
|
||||
if (findings) {
|
||||
const hasCorrelationId = !!focused?.result?.correlationId;
|
||||
if (hasCorrelationId) {
|
||||
// LIVE PATH — correlationId present from live formulate call.
|
||||
const correlationId = focused.result.correlationId;
|
||||
const matchedContribution = (focusedContributions || []).find(
|
||||
(c) => c.correlationId === correlationId,
|
||||
);
|
||||
if (matchedContribution) {
|
||||
currentFindings = findings.filter(
|
||||
(f) => f.contributionId === matchedContribution.id,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// REOPEN PATH — cold reopen from persisted state has no correlationId.
|
||||
// Use persisted Contribution.id to locate the displayed/latest Contribution,
|
||||
// then match Findings through Finding.contributionId === Contribution.id.
|
||||
const target = focusedPresentationItemId;
|
||||
if (target && focusedContributions?.length) {
|
||||
const threadContribs = focusedContributions.filter(
|
||||
(c) => c.targetNodeId === target || c.originatingTargetNodeId === target,
|
||||
);
|
||||
if (threadContribs.length > 0) {
|
||||
const latestDisplayContrib = threadContribs[threadContribs.length - 1];
|
||||
currentFindings = findings.filter(
|
||||
(f) => f.contributionId === latestDisplayContrib.id,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user