In-session phase presentation: header chip + dotted boundary dividers

- components/phase-divider.tsx: PhaseChip (header, next to the session
  title: phase-colored dot + Probing/Planning/Teaching) and PhaseDivider
  (the transcript boundary: color-coded dotted rules + a small chip —
  'Plan · N nodes' at the plan seam, 'Teaching' at the teach seam; probe
  never renders, phases only advance). planNodeCount reads the seam
  message's first plan tree.
- chat.tsx: dividers render at MESSAGE boundaries (phaseTimeline, one
  linear fold) — the seam is the transition to the message's phase, so
  the seam message's prose sits below its divider. requiresReveal now
  uses phaseAt3 teach (an occupied node), so probe- AND plan-phase
  questions auto-open.
- Retired the part-level plan-divider (artifact registry): the boundary
  is message-level, not part-level. Its tests replaced by
  render-phase-divider tests; core/phases gains tested phaseTimeline.
This commit is contained in:
Amos
2026-09-01 18:31:01 +03:00
parent 05359301e2
commit fbe4f16305
9 changed files with 276 additions and 92 deletions
+25
View File
@@ -127,3 +127,28 @@ export function phaseAt3(messages: readonly Phase3Message[], upToIndex?: number)
}
return phase;
}
/**
* The phase at EVERY message index, in one forward fold — the transcript
* dividers render one per boundary, so phaseAt3(m, i) per index would
* rescan 0..i each time (quadratic); this is the same derivation, linear.
* out[i] === phaseAt3(messages, i) for every index.
*/
export function phaseTimeline(messages: readonly Phase3Message[]): Phase3[] {
const out: Phase3[] = [];
let phase: Phase3 = "probe";
for (let i = 0; i < messages.length; i++) {
const parts = messages[i]?.parts;
if (parts) {
for (const part of parts) {
if (!part.type.startsWith("tool-plan_") || part.state !== "output-available") continue;
const tree = (part.output as PlanOutput | undefined)?.tree as PhaseTree | undefined;
if (!tree || !Array.isArray(tree.nodes)) continue;
const candidate = phaseOfTree(tree);
if (PHASE3_RANK[candidate] > PHASE3_RANK[phase]) phase = candidate;
}
}
out.push(phase);
}
return out;
}