import { useEffect, useRef, useState } from "react"; import type { CapabilityIssueThreadSnapshot } from "../../../src/issue-thread/types"; import { Icon } from "./Icons"; import { Chip, PriorityIcon, StatusBadge } from "./primitives"; /** * Sticky issue header (contract §1 and §2). The three identity chips are never * hidden by scroll, mode is data rather than styling, and on mobile Stop stays * outside the overflow menu whenever a turn is active. */ export interface IssueHeaderProps { snapshot: CapabilityIssueThreadSnapshot; scenarios: string[]; /** `chat` is the clean room: no preset scenario, no recording to replay. */ surface?: "issue" | "chat"; /** Immutable eval recordings use the same inspector without live controls. */ readOnly?: boolean; /** Clean-room tenant token, rendered so identity rotation is visible. */ cleanRoomToken?: string | null; evidenceOpen: boolean; denialCount: number; segment: "thread" | "evidence"; onToggleEvidence: () => void; onSelectScenario: (scenario: string) => void; onReplay: () => void; onReset: () => void; onStop: () => void; onSelectSegment: (segment: "thread" | "evidence") => void; } export function IssueHeader(props: IssueHeaderProps) { const { snapshot, scenarios, surface = "issue", readOnly = false, cleanRoomToken = null, evidenceOpen, denialCount, segment, onToggleEvidence, onSelectScenario, onReplay, onReset, onStop, onSelectSegment, } = props; const chat = surface === "chat"; const [menuOpen, setMenuOpen] = useState(false); const menuRef = useRef(null); const turnActive = snapshot.composer.state === "streaming" || snapshot.composer.state === "sending"; useEffect(() => { if (!menuOpen) return; function onKeyDown(event: KeyboardEvent) { if (event.key === "Escape") setMenuOpen(false); } document.addEventListener("keydown", onKeyDown); return () => document.removeEventListener("keydown", onKeyDown); }, [menuOpen]); return (
{snapshot.issue.identifier}

{snapshot.issue.title}

{!chat && !readOnly ? ( <> ) : null} {!readOnly ? : null} {!readOnly ? : null}
{snapshot.identity.agentLabel} {snapshot.identity.replaySource !== null ? ` · ${snapshot.identity.replaySource} source` : ""} {snapshot.identity.controlPlaneLabel} {chat && cleanRoomToken !== null ? ( Clean room {cleanRoomToken} ) : null}
{snapshot.issue.assignee !== null ? {snapshot.issue.assignee} : null} {snapshot.issue.runState}
{menuOpen ? (
{chat ? null : ( <> )}
) : null}
); }