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) ──────
function InvestigationHistoryCard({ turn }) {
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 (
<details
@@ -231,22 +237,25 @@ function InvestigationHistoryCard({ turn }) {
open={!isCollapsed}
>
<summary className="cursor-pointer px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900">
{isCollapsed ? "▶ " : "▼ "}
{"✓ "}
{turn.question.length > 60 && !isCollapsed
? turn.question.slice(0, 60) + "…"
: turn.question}
{isAnswered && <span aria-hidden="true"> </span>}
{displayedQuestion}
</summary>
<div className="px-4 pb-3 pt-1 space-y-2">
<p><strong>Your answer</strong></p>
<div className="space-y-2 px-4 pb-3 pt-1">
<p>
<strong>Your answer</strong>
</p>
<p className="text-gray-700">{turn.answer}</p>
{turn.acknowledgement && (
<>
<hr className="border-gray-200" />
<p><strong>What changed</strong></p>
<p className="italic text-gray-500">{turn.acknowledgement}</p>
<p>
<strong>What changed</strong>
</p>
<p className="italic text-gray-500">
{turn.acknowledgement}
</p>
</>
)}
</div>