refactor: terminal result card states open closed

This commit is contained in:
2026-08-04 19:11:47 +01:00
parent cadf74d461
commit 98f398ec8b
+18 -9
View File
@@ -223,6 +223,12 @@ function PlainLanguageCard({ summary }) {
// ── Investigation history card (readable notebook style) ────── // ── Investigation history card (readable notebook style) ──────
function InvestigationHistoryCard({ turn }) { function InvestigationHistoryCard({ turn }) {
const isCollapsed = turn._collapsed; const isCollapsed = turn._collapsed;
const isAnswered = Boolean(turn.answer?.trim());
const displayedQuestion =
isCollapsed && turn.question.length > 60
? `${turn.question.slice(0, 60)}`
: turn.question;
return ( return (
<details <details
@@ -231,22 +237,25 @@ function InvestigationHistoryCard({ turn }) {
open={!isCollapsed} open={!isCollapsed}
> >
<summary className="cursor-pointer px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900"> <summary className="cursor-pointer px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900">
{isCollapsed ? "▶ " : "▼ "} {isAnswered && <span aria-hidden="true"> </span>}
{"✓ "} {displayedQuestion}
{turn.question.length > 60 && !isCollapsed
? turn.question.slice(0, 60) + "…"
: turn.question}
</summary> </summary>
<div className="px-4 pb-3 pt-1 space-y-2"> <div className="space-y-2 px-4 pb-3 pt-1">
<p><strong>Your answer</strong></p> <p>
<strong>Your answer</strong>
</p>
<p className="text-gray-700">{turn.answer}</p> <p className="text-gray-700">{turn.answer}</p>
{turn.acknowledgement && ( {turn.acknowledgement && (
<> <>
<hr className="border-gray-200" /> <hr className="border-gray-200" />
<p><strong>What changed</strong></p> <p>
<p className="italic text-gray-500">{turn.acknowledgement}</p> <strong>What changed</strong>
</p>
<p className="italic text-gray-500">
{turn.acknowledgement}
</p>
</> </>
)} )}
</div> </div>