From 21e7c4b8378146f04e4e8f73288f9fceec828055 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sun, 25 Oct 2026 00:50:57 +0800 Subject: [PATCH] fix(ui): shorten native measurement precision Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../goal-research-progress.tsx | 20 +++++++++++++++---- .../research-native-reading.mjs | 20 +++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/apps/presentation/dashboard/src/features/personal-workspace/goal-research-progress.tsx b/apps/presentation/dashboard/src/features/personal-workspace/goal-research-progress.tsx index f552954c5f..1210ffdf9f 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/goal-research-progress.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/goal-research-progress.tsx @@ -98,12 +98,24 @@ export function episodeQuestionGroups(result: Tr }); } +// Keep headline values readable without rounding a nonzero measurement to zero. +// Full native precision remains available in the existing evidence/details. +function formatNativeMeasurement(value: number, zh: boolean, signed = false) { + const magnitude = Math.abs(value); + const scientific = magnitude > 0 && (magnitude < 0.0001 || magnitude >= 1_000_000); + return new Intl.NumberFormat(zh ? "zh-CN" : "en", { + maximumFractionDigits: 4, + ...(scientific ? {notation: "scientific", maximumSignificantDigits: 4} : {}), + signDisplay: signed ? "exceptZero" : "auto", + }).format(value === 0 ? 0 : value); +} + // Format the native owner's existing projection, without deriving a gain, // deciding adoption, or borrowing values from another pack. function RetainedImprovement({native, zh, onCitation}: {native: NonNullable; zh: boolean; onCitation: (citation: AssessmentCitation, origin?: HTMLButtonElement) => void}) { const outcomes = native.projection, improvement = outcomes.retained_improvement; if (!improvement) return null; - const format = (value: number) => new Intl.NumberFormat(zh ? "zh-CN" : "en", {maximumSignificantDigits: 10, signDisplay: "exceptZero"}).format(value); + const format = (value: number) => formatNativeMeasurement(value, zh, true); const label = zh ? "已采用成果增量" : "Retained improvement"; return

{label}

@@ -113,7 +125,7 @@ function RetainedImprovement({native, zh, onCitation}: {native: NonNullable{zh ? "历史捕获 · 当前结果未核验" : "Historical capture · current result unverified"}

: null}
{improvement.value === null ? "—" : format(improvement.value)} - {improvement.value === null ? (zh ? "未知" : "Unknown") : outcomes.metric.unit} · {outcomes.metric.name}{improvement.baseline ? ` · ${zh ? "基线" : "baseline"} ${improvement.baseline.value}` : ""} + {improvement.value === null ? (zh ? "未知" : "Unknown") : outcomes.metric.unit} · {outcomes.metric.name}{improvement.baseline ? ` · ${zh ? "基线" : "baseline"} ${formatNativeMeasurement(improvement.baseline.value, zh)}` : ""}
{([[improvement.baseline, zh ? "比较基线" : "Comparison baseline"], [outcomes.retained, zh ? "实际保留" : "Actually retained"]] as const).map(([point, title]) =>
{title}
{point ? : (zh ? "未知" : "Unknown")}
)}
{zh ? "保留依据" : "Retention evidence"}
{improvement.retention_citation ? : (zh ? "未采集" : "Uncaptured")}
@@ -133,7 +145,7 @@ function NativeResults({native, zh, onCitation}: {native: ResearchProgressPack[" const point = outcomes[key]; return
{zh ? cn : en}
{point ? : {zh ? "未知" : "Unknown"}{key === "best_valid" ? · {outcomes.metric.unit} : null}}
; }; return
@@ -158,7 +170,7 @@ function NativeResults({native, zh, onCitation}: {native: ResearchProgressPack["
{zh ? "来源" : "Source"}
{native.artifact}
{native.artifact_sha256}
{points.map(([key, cn, en]) => { const point = outcomes[key]; - return point ?
{zh ? cn : en}
{point.candidate_ref}
{zh ? "提交" : "Submission"} {point.submission_index} · {zh ? "提交时间" : "Submitted at"}: {point.submitted_at ?? (zh ? "未知" : "Unknown")}
{zh ? "收到结果" : "Result received"}: {point.observed_at}
: null; + return point ?
{zh ? cn : en}
{String(point.value)} {outcomes.metric.unit}
{point.candidate_ref}
{zh ? "提交" : "Submission"} {point.submission_index} · {zh ? "提交时间" : "Submitted at"}: {point.submitted_at ?? (zh ? "未知" : "Unknown")}
{zh ? "收到结果" : "Result received"}: {point.observed_at}
: null; })}
    {outcomes.limitations.map((line, i) =>
  • {line}
  • )}
diff --git a/examples/personal-workspace-browser/research-native-reading.mjs b/examples/personal-workspace-browser/research-native-reading.mjs index 9e9f3dec0d..a7f3548510 100644 --- a/examples/personal-workspace-browser/research-native-reading.mjs +++ b/examples/personal-workspace-browser/research-native-reading.mjs @@ -19,6 +19,12 @@ export const researchNativeReadingScenario = { {id: "partial", values: [8, 7, 9], higher: true, retained: 1, partial: true, expected: [9, null, 9, 7]}, {id: "empty", values: [], higher: true, retained: null, partial: true, expected: [null, null, null, null]}, {id: "long-unit", values: [3, 1, 2], higher: false, retained: 0, unit: "synthetic-unit-".repeat(5), expected: [1, 3, 2, 3]}, + {id: "decimal", values: [0.8123456789012345, 0.8765432109876543, 0.8123456789012345], higher: true, retained: 1, + expected: [0.8765432109876543, 0.8123456789012345, 0.8123456789012345, 0.8765432109876543], display: ["0.8765", "0.8123", "0.8123", "0.8765"], gain: "+0.0642"}, + {id: "tiny", values: [0.0000001234567890123456, 0.0000001123456789012345], higher: true, retained: 1, + expected: [0.0000001234567890123456, 0.0000001234567890123456, 0.0000001123456789012345, 0.0000001123456789012345], display: ["1.235E-7", "1.235E-7", "1.123E-7", "1.123E-7"], gain: "-1.111E-8"}, + {id: "large", values: [123456789.12345679], higher: true, retained: 0, + expected: [123456789.12345679, 123456789.12345679, 123456789.12345679, 123456789.12345679], display: ["1.235E8", "1.235E8", "1.235E8", "1.235E8"], gain: "0"}, ]; const root = await mkdtemp(resolve(tmpdir(), "loopx-native-reading-")); let owner, page; @@ -40,6 +46,8 @@ export const researchNativeReadingScenario = { submitted_at: null, observed_at: `2026-01-01T00:0${index + 1}:00Z`, valid: value !== null, value, citation: {source_id: "facts", first_line: index + 1, last_line: index + 1}, })); + if (c.gain) native.comparison = {baseline_result_id: "result-0", + retention_citation: {source_id: "facts", first_line: c.retained + 1, last_line: c.retained + 1}}; const text = c.values.map((v, i) => `Synthetic observation ${i}: value ${v ?? "unknown"}; valid ${v !== null}.`).join("\n") || "No measurements captured."; a.artifacts["facts.txt"] = text; a.artifacts["native.json"] = JSON.stringify(native); @@ -67,8 +75,12 @@ export const researchNativeReadingScenario = { if (c.expected[index] === null) { assert.equal(await reading.locator("button").count(), 0); assert.match(await reading.innerText(), /未知/); - } else assert.equal(await reading.locator("strong").textContent(), String(c.expected[index])); + } else { + assert.equal(await reading.locator("strong").textContent(), c.display?.[index] ?? String(c.expected[index])); + assert((await reading.locator("button").getAttribute("aria-label")).includes(String(c.expected[index])), "The exact native value remains bound to the evidence action"); + } } + if (c.gain) assert.equal(await page.locator("[data-retained-improvement]").textContent(), c.gain); assert.match(await native.innerText(), c.higher ? /越高越好/ : /越低越好/); assert.match(await native.locator(".research-native-best .research-native-unit").textContent(), new RegExp(c.unit ?? "points"), "The raw unit remains visible even when no valid measurement exists"); assert.match(await native.locator(".research-native-scope").innerText(), new RegExp(`${c.values.filter(v => v !== null).length} / ${c.values.length}.*有效结果`)); @@ -79,6 +91,7 @@ export const researchNativeReadingScenario = { await details.locator(":scope > summary").focus(); await page.keyboard.press("Enter"); assert.match(await details.innerText(), /2026-01-01T00:00:00Z/); + if (c.display) for (const value of c.expected) assert((await details.innerText()).includes(String(value)), "Expanded sources retain the full native precision"); assert(await details.evaluate(e => parseFloat(getComputedStyle(e).fontSize) >= 14)); assert(await native.evaluate(e => e.scrollWidth <= e.clientWidth + 1)); if (c.id === "lower-negative") { @@ -113,6 +126,9 @@ export const researchNativeReadingScenario = { await page.evaluate(() => localStorage.setItem("loopx-pw-locale", "en")); await page.reload({waitUntil: "domcontentloaded"}); await page.getByRole("region", {name: "Native measurements", exact: true}).waitFor(); + await selector.selectOption({label: "decimal"}); + await page.waitForFunction(() => document.querySelector('[data-native-point="best_valid"] strong')?.textContent === "0.8765"); + assert.equal(await page.locator("[data-retained-improvement]").textContent(), "+0.0642"); await page.getByRole("button", {name: "About native measurements", exact: true}).focus(); await page.getByRole("tooltip").waitFor({state: "visible"}); await page.keyboard.press("Escape"); @@ -121,7 +137,7 @@ export const researchNativeReadingScenario = { assert.equal(readback.mutation_attempts, 0); assert.deepEqual(errors, []); return {coverageEntries: collectCoverage ? await page.coverage.stopJSCoverage() : [], - note: "real-owner native result roles: signed/zero/invalid/missing/partial, exact citations, readable desktop/390/200%, Chinese and English; no mutation"}; + note: "real-owner native result roles: signed/zero/invalid/missing/partial, compact decimal/tiny/large values with full-precision details, exact citations, readable desktop/390/200%, Chinese and English; no mutation"}; } finally { await page?.close(); await owner?.close();