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
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@
.research-density span.is-gap { border-top: 0; }
.research-gap-key { display: inline-block; width: 10px; height: 10px; border: 1px solid var(--pw-red); border-radius: 2px; }
.research-bar-key { display: inline-block; width: 10px; height: 10px; margin-inline-end: 4px; background: var(--pw-blue-soft); border-top: 2px solid var(--pw-blue); border-radius: 2px 2px 0 0; }
.research-row-label .research-decision-key { gap: 2px 8px; }
.research-decision-key > span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.research-decision-ticks { position: relative; height: 12px; margin-top: 4px; }
.research-decision-ticks span { position: absolute; top: 0; width: 3px; height: 10px; margin-left: -1px; border-radius: 1px; background: var(--pw-blue); }
.research-decision-ticks span.is-replan, .research-tick-key.is-replan { background: var(--pw-orbit); }
.research-tick-key { display: inline-block; width: 3px; height: 10px; border-radius: 1px; background: var(--pw-blue); }
.research-decision-ticks span, .research-tick-key { display: inline-block; width: 3px; height: 10px; border-radius: 1px; background: var(--pw-blue); }
.research-decision-ticks span { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.research-decision-ticks .is-replan, .research-tick-key.is-replan { width: 7px; height: 7px; rotate: 45deg; background: var(--pw-text); }
.research-phase-divider { position: absolute; top: -4px; height: 76px; border-left: 1px dashed var(--pw-faint); pointer-events: none; }
.research-axis { position: relative; height: 22px; margin-top: 2px; border-top: 1px solid var(--pw-line); }
.research-axis time { position: absolute; top: 5px; transform: translateX(-50%); color: var(--pw-muted); font-size: var(--text-caption); white-space: nowrap; }
Expand Down Expand Up @@ -240,7 +242,7 @@
.research-trail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--pw-muted); font-size: var(--text-caption); }
.research-trail-question > .research-link { margin: 8px 0 0 36px; min-height: 44px; }
.research-outcome { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: var(--text-caption); font-weight: 600; background: var(--pw-blue-soft); color: var(--pw-blue-ink); }
.research-outcome.is-replan { background: var(--pw-tone); color: var(--pw-orbit); }
.research-outcome.is-replan { background: var(--pw-hover); color: var(--pw-text); }
.research-outcome.is-stop, .research-outcome.is-ask_human { background: var(--pw-amber-bg); color: var(--pw-text); }
.research-link { padding: 0; border: 0; background: none; color: var(--pw-blue-ink); font: inherit; text-decoration: underline; cursor: pointer; }
.research-trail > .research-link { margin-top: 8px; font-size: var(--text-caption); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ export function GoalResearchTimeline({timeline, complete, zh, selectedIds, selec
style={{left: pct(group.at)}} onClick={event => onSelectMany(ids, event.currentTarget)}><span>{ids.length}</span></button>;
});
const trail = groupExploreTimelineDecisions(timeline, phase);
const decisionOutcomes = [...new Set(timeline.decisions.map(item => item.sections!.decision!.outcome))];
const timedDecisions = timeline.decisions.filter(item => item.at !== null);
const decisionCounts = new Map<string, number>();
for (const item of timedDecisions) {
const outcome = item.sections!.decision!.outcome;
decisionCounts.set(outcome, (decisionCounts.get(outcome) ?? 0) + 1);
}
const undatedDecisions = timeline.decisions.length - timedDecisions.length;
const groupedIds = new Set(dayGroups.flatMap(group => group.nodes.map(node => node.id)));
const swarm = timeline.singles.filter(id => !groupedIds.has(id)).map(id => timeline.nodes.get(id)!).filter(item => item.first !== null);
const unknownTime = [...timeline.nodes.values()].filter(item => item.first === null).length;
Expand Down Expand Up @@ -140,7 +146,7 @@ export function GoalResearchTimeline({timeline, complete, zh, selectedIds, selec
<ContextHelp label={zh ? "时间线读法" : "Reading the timeline"}>
{complete ? <p>{phaseNote}</p> : null}
<p className="research-density-help"><i className="research-bar-key" aria-hidden/>{complete ? copy.densityHint : copy.partialDensityHint}{zh ? "。" : ". "}{zh ? "无记录空档不代表研究停止。" : "A recording gap does not establish that research stopped."}</p>
<p>{zh ? "悬停刻度可查看对应的本地时间。" : "Hover over a tick for its local time."}</p>
<p>{zh ? "悬停标记可查看记录时间。决策数量覆盖已读取的记录,时段选择只高亮对应的标记。" : "Hover over a mark for its record time. Counts cover the loaded records. Selecting a period highlights its marks."}</p>
<p>{findingCopy.meaning}</p>
{!timeline.structuredCount ? <p>{copy.unstructuredHint}</p> : null}
<p>{copy.routeHint}{zh ? "。" : ". "}{zh ? "相邻点合拢,数字为研究项数,一次展开原始时间与依据。" : "Nearby points group; the number counts research items. Select once for original times and sources."}</p>
Expand All @@ -151,15 +157,19 @@ export function GoalResearchTimeline({timeline, complete, zh, selectedIds, selec
</div>
</div>
<div className="research-timeline-grid">
<div className="research-row-label"><strong>{copy.density}</strong><small>{axisLabel}</small><small>
{hasRecordingGaps ? <span><i className="research-gap-key" aria-hidden="true"/> {complete ? copy.gap : copy.partialGap}</span> : null}
{decisionOutcomes.map(outcome => <span key={outcome}><i className={`research-tick-key is-${outcome}`}/> {label(outcome)}</span>)}
</small></div>
<div className="research-row-label">
<strong>{copy.density}</strong><small>{axisLabel}</small>
{hasRecordingGaps ? <small><i className="research-gap-key" aria-hidden="true"/>{complete ? copy.gap : copy.partialGap}</small> : null}
{timeline.decisions.length ? <small className="research-decision-key" role="group" aria-label={copy.decisions}>
{[...decisionCounts].map(([outcome, count]) => <span key={outcome}><i className={`research-tick-key is-${outcome}`} aria-hidden="true"/> {label(outcome)} {count}</span>)}
{undatedDecisions ? <span>{copy.unknownTime} {undatedDecisions}</span> : null}
</small> : null}
</div>
<div className="research-row-plot">
<div className="research-density" ref={plot}>{timeline.bins.map((bin, index) => <span key={index} className={bin.events ? "" : "is-gap"} title={`${timeLabel(bin.start)} — ${timeLabel(bin.end)} · ${bin.events}`}
style={{height: bin.events ? `${Math.max(8, (bin.events / maxEvents) * 100)}%` : "100%"}}/>)}</div>
{timeline.decisions.length ? <div className="research-decision-ticks">{timeline.decisions.filter(item => item.at !== null).map(item => <span key={item.event.event_id}
title={`${label(item.sections!.decision!.outcome)} · ${item.at === null ? "—" : timeLabel(item.at)}`}
{timedDecisions.length ? <div className="research-decision-ticks" aria-hidden="true">{timedDecisions.map(item => <span key={item.event.event_id}
title={`${label(item.sections!.decision!.outcome)} · ${timeLabel(item.at!, true)}`}
className={`is-${item.sections!.decision!.outcome}${inPhase(item.at) ? "" : " is-dimmed"}`} style={{left: pct(item.at!)}}/>)}</div> : null}
{complete ? timeline.phases.slice(1).map(item => <span key={item.index} className="research-phase-divider" style={{left: pct(item.start)}}/>) : null}
<div className="research-axis" role="group" aria-label={axisLabel}>{ticks.map(offset => <time
Expand Down
37 changes: 29 additions & 8 deletions examples/personal-workspace-browser/research-history.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ for question in range(4):
finding_id=f'decision-{question}-{record}', title=f'Comparison {question}, decision {record}',
summary=summary, status=['confirmed', 'refuted', 'tentative'][record % 3],
recorded_at=f'2025-12-31T0{record}:00:00Z' if question == 3 else f'2026-01-0{question + 1}T0{record}:00:00Z'))
events.append(build_explore_finding_event(goal_id=goal, node_id='question-3',
finding_id='undated-decision', title='Undated decision', status='tentative', recorded_at='unknown',
summary='Input revision: synthetic-v1 Applicability: current Observation: Time unavailable. Interpretation: Outcome: wait'))
Path(sys.argv[1]).write_text(json.dumps({'goal_id': goal, 'display_name': 'Synthetic decision reading', 'events': events}, ensure_ascii=False))
`, fixture], {cwd: repoRoot});
let owner, page;
Expand All @@ -308,12 +311,14 @@ Path(sys.argv[1]).write_text(json.dumps({'goal_id': goal, 'display_name': 'Synth
await page.addInitScript(() => {if (!localStorage.getItem('loopx-pw-locale')) localStorage.setItem('loopx-pw-locale', 'zh-CN');});
await page.goto(`${owner.base}/chat/?goalId=${owner.goal_id}&view=research&statusUrl=%2Fstatus.json`, {waitUntil: 'domcontentloaded'});
const history = page.locator('.research-history');
await history.getByRole('status').filter({hasText: '24 / 24'}).waitFor();
await history.getByRole('status').filter({hasText: '25 / 25'}).waitFor();
const readLatePhase = async (locale, size) => {
const late = history.getByRole('button', {name: locale === 'zh-CN' ? /^后段 ·/ : /^Late ·/});
await late.focus();
await late.press('Enter');
assert.equal(await late.getAttribute('aria-pressed'), 'true');
assert.equal(await history.locator('.research-decision-key .is-replan').evaluate(key => key.parentElement.textContent.trim()),
locale === 'zh-CN' ? '转向 19' : 'Replan 19', 'Selecting a period keeps the whole-history decision count');
await page.screenshot({path: resolve(outputDir, 'recorded-phase-' + size + '-' + locale + '.png'), animations: 'disabled'});
assert.equal(await history.locator('[data-research-nodes~="question-2"]:not(.is-dimmed)').count(), 1,
'A question with a late record stays highlighted at its earlier first record');
Expand All @@ -322,6 +327,22 @@ Path(sys.argv[1]).write_text(json.dumps({'goal_id': goal, 'display_name': 'Synth
assert.match(await late.getAttribute('aria-label'), locale === 'zh-CN' ? /2 个有记录的研究项/ : /2 research items with records/);
await late.press('Enter');
};
const key = history.locator('.research-decision-key');
assert.equal(await key.locator('span').count(), 3, 'Dated outcomes and unknown times are accounted for separately');
assert.equal(await key.locator('.is-no_change').evaluate(mark => mark.parentElement.textContent.trim()), '无变化 1');
assert.match(await key.innerText(), /时间未知 1/);
assert.equal(await key.locator('.is-wait').count(), 0, 'An undated decision is not placed on the elapsed axis');
const marks = await history.locator('.research-decision-ticks span').evaluateAll(elements => elements.map(element => {
const style = getComputedStyle(element);
return {type: element.className, fill: style.backgroundColor, rotate: style.rotate};
}));
assert.equal(marks.length, 20);
assert.equal(marks.filter(mark => mark.type === 'is-replan').length, 19);
const replan = marks.find(mark => mark.type === 'is-replan');
assert.notEqual(replan.fill, 'rgba(0, 0, 0, 0)', 'Recorded changes of direction must be visible on the plot');
assert.notEqual(replan.rotate, marks.find(mark => mark.type === 'is-no_change').rotate);
assert.equal(await key.locator('.is-replan').evaluate(mark => getComputedStyle(mark).backgroundColor), replan.fill,
'The legend uses the same visible mark as the plot');
await readLatePhase('zh-CN', 'desktop');
const middle = history.getByRole('button', {name: /^中段 ·/});
await middle.press('Enter');
Expand Down Expand Up @@ -365,7 +386,7 @@ Path(sys.argv[1]).write_text(json.dumps({'goal_id': goal, 'display_name': 'Synth
for (const locale of ['zh-CN', 'en']) {
await page.evaluate(value => localStorage.setItem('loopx-pw-locale', value), locale);
await page.reload({waitUntil: 'domcontentloaded'});
await history.getByRole('status').filter({hasText: '24 / 24'}).waitFor();
await history.getByRole('status').filter({hasText: '25 / 25'}).waitFor();
await readLatePhase(locale, 'phone');
const row = group.locator('[data-research-decision]').first();
assert.match(await row.innerText(), locale === 'zh-CN' ? /停止 2.*保留 3/s : /Stopped 2.*Retained 3/s);
Expand Down Expand Up @@ -398,7 +419,7 @@ Path(sys.argv[1]).write_text(json.dumps({'goal_id': goal, 'display_name': 'Synth
await oldest.click();
assert.equal(new URL(page.url()).searchParams.get('research_finding'), 'decision-2-0');
await page.reload({waitUntil: 'domcontentloaded'});
await history.getByRole('status').filter({hasText: '24 / 24'}).waitFor();
await history.getByRole('status').filter({hasText: '25 / 25'}).waitFor();
await detail.waitFor();
assert.equal(new URL(page.url()).searchParams.get('research_finding'), 'decision-2-0', 'Reload keeps the exact historical finding');
await page.screenshot({path: resolve(outputDir, `decision-return-reader-${locale}.png`), animations: 'disabled'});
Expand Down Expand Up @@ -430,10 +451,10 @@ Path(sys.argv[1]).write_text(json.dumps({'goal_id': goal, 'display_name': 'Synth
await assertReturn(oldest);
await trail.getByRole('button', {name: locale === 'zh-CN' ? '显示更多问题 · 1' : 'Show more questions · 1', exact: true}).click();
const earlierQuestion = trail.locator('.research-trail-question').last();
await earlierQuestion.getByRole('button', {name: locale === 'zh-CN' ? '显示更早记录 · 2' : 'Show earlier records · 2', exact: true}).click();
const earlierDecision = earlierQuestion.locator('[data-research-decision]').last();
await earlierQuestion.getByRole('button', {name: locale === 'zh-CN' ? '显示更早记录 · 3' : 'Show earlier records · 3', exact: true}).click();
const earlierDecision = earlierQuestion.getByRole('button', {name: /Comparison 3, decision 0/});
await earlierDecision.click(); await page.reload({waitUntil: 'domcontentloaded'});
await history.getByRole('status').filter({hasText: '24 / 24'}).waitFor();
await history.getByRole('status').filter({hasText: '25 / 25'}).waitFor();
await detail.waitFor();
assert.equal(new URL(page.url()).searchParams.get('research_finding'), 'decision-3-0');
await detail.press('Escape');
Expand All @@ -448,9 +469,9 @@ Path(sys.argv[1]).write_text(json.dumps({'goal_id': goal, 'display_name': 'Synth
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1));
}
await page.setViewportSize({width: 1280, height: 900});
const desktopOrigin = trail.locator('.research-trail-question').last().locator('[data-research-decision]').last();
const desktopOrigin = trail.locator('.research-trail-question').last().getByRole('button', {name: /Comparison 3, decision 0/});
await desktopOrigin.click(); await page.reload({waitUntil: 'domcontentloaded'});
await history.getByRole('status').filter({hasText: '24 / 24'}).waitFor();
await history.getByRole('status').filter({hasText: '25 / 25'}).waitFor();
const desktopReader = history.locator('.research-history-detail');
await desktopReader.waitFor();
assert.equal(new URL(page.url()).searchParams.get('research_finding'), 'decision-3-0');
Expand Down
Loading