Files
PaperClipAI/packages/paperclip-runner/devtools/issue-thread/src/IssueHeader.tsx
Dotta 560e7e48b5 feat(runner): add SDK and developer tooling (#12608)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The runner package already provides the production protocol and
execution spine.
> - Contributors still need stable SDK surfaces, deterministic test
tools, and local inspection tools.
> - Those surfaces share generated contracts and must change as one
package boundary.
> - This pull request adds the package-local SDK, labs, examples, and
drift checks.
> - The benefit is a reviewable developer platform that does not change
application execution selection.

## Linked Issues or Issue Description

**Subsystem affected**

`packages/paperclip-runner` — runner SDK, conformance tools, and
developer tooling.

**Problem or motivation**

The production runner spine is present, but package consumers cannot
build deterministic integrations, inspect sessions, or verify
provider-neutral behavior through supported surfaces.

**Proposed solution**

Add browser, React, standalone, live-session, scenario, conformance, and
evaluation surfaces. Add generated contract inventories and
package-local verification scripts. Keep production application routing
unchanged.

**Alternatives considered**

We considered splitting each generated catalog, SDK surface, and demo
into separate pull requests. Those changes share exports, fixtures, and
drift gates. Splitting them would create intermediate package states
that do not build.

**Roadmap alignment**

No overlapping item appears in `ROADMAP.md`. This work extends the
runner package that is already on `master`.

## What Changed

- Add browser, React, standalone, live-session, and issue-thread SDK
surfaces.
- Add deterministic mock control-plane, scenario, conformance, replay,
and evaluation tools.
- Add bounded Codex, OpenCode, and ACPX development transports and
fixtures.
- Keep deferred managed-provider execution fail-closed. Persisted
compatibility data remains readable.
- Add generated capability inventories with their source files and drift
checks.
- Add examples, package documentation, browser checks, and
clean-consumer checks.
- Preserve the reviewed protocol bounds, replay compatibility aliases,
process environment isolation, and semantic redaction limits.
- Update the ACPX package patch that the existing workspace patch
registry already tracks.
- Do not change `pnpm-lock.yaml`, repository workflows, server runtime
selection, or the application UI.

## Verification

GitHub Actions is the verification authority for this pull request. The
repository CI, package TypeScript and Rust checks, package tests,
generated-output drift checks, browser checks, security scans, and
Greptile review must pass on the exact head.

Local test suites were not run because this series uses parallel GitHub
Actions for verification.

## Risks

This is a large greenfield package change. The main risks are public
export drift, generated-output drift, and optional React consumer
compatibility. Package boundary checks, clean-consumer checks, and
browser tests cover those risks. Production adapter selection and server
execution are outside this pull request.

## Stack

1. **This PR:** runner SDK and developer tooling.
2. [Codex production server
integration](https://github.com/paperclipai/paperclip/pull/12616).
3. [Provider-neutral task-thread
UI](https://github.com/paperclipai/paperclip/pull/12617).

## Model Used

OpenAI Codex, GPT-5, high-reasoning mode, with tool use and code
execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have described the issue in-PR following the feature request
template
- [x] I have not referenced internal/instance-local Paperclip issues or
links
- [x] My branch name describes the change and contains no internal
Paperclip ticket id
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-08-31 21:33:11 -05:00

214 lines
8.3 KiB
TypeScript

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<HTMLDivElement | null>(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 (
<header className="pit-header" data-session-mode={snapshot.mode}>
<div className="pit-header-primary">
<div className="pit-header-title-row">
<span className="pit-identifier">{snapshot.issue.identifier}</span>
<h1 className="pit-title">{snapshot.issue.title}</h1>
<StatusBadge status={snapshot.issue.status} />
</div>
<div className="pit-header-controls">
{!chat && !readOnly ? (
<>
<label className="pit-visually-hidden" htmlFor="scenario-picker">Scenario</label>
<select className="pit-select pit-desktop-only" id="scenario-picker" value={snapshot.issue.fixtureProfile} onChange={(event) => onSelectScenario(event.target.value)} data-testid="scenario-picker">
{scenarios.map((scenario) => <option key={scenario} value={scenario}>{scenario}</option>)}
</select>
<button type="button" className="pit-button pit-desktop-only" onClick={onReplay} data-testid="replay-button"><Icon name="play" /> Replay</button>
</>
) : null}
{!readOnly ? <button type="button" className="pit-icon-button pit-desktop-only" data-variant="destructive" onClick={onReset} data-testid="reset-button" title={chat ? "Reset chat" : "Reset scenario"} aria-label={chat ? "Reset chat" : "Reset scenario"}><Icon name="reset" /></button> : null}
{!readOnly ? <button type="button" className="pit-icon-button" data-variant="destructive" onClick={onStop} disabled={!turnActive} data-testid="stop-button" title="Stop turn" aria-label="Stop turn"><Icon name="stop" /></button> : null}
<button type="button" className="pit-button pit-desktop-only" aria-expanded={evidenceOpen} onClick={onToggleEvidence} data-testid="evidence-toggle"><Icon name="evidence" /> DevTools{denialCount > 0 ? ` (${denialCount})` : ""}</button>
</div>
</div>
<div className="pit-header-context">
<div className="pit-chip-row" data-testid="identity-chips">
<Chip tone={snapshot.mode === "live" ? "live" : undefined} testId="agent-chip">
{snapshot.identity.agentLabel}
{snapshot.identity.replaySource !== null
? ` · ${snapshot.identity.replaySource} source`
: ""}
</Chip>
<Chip testId="runner-chip">
<span
className="pit-process-dot"
data-attached={snapshot.identity.runnerAttached}
aria-hidden="true"
/>
{snapshot.identity.runnerLabel}
<span className="pit-visually-hidden">
{snapshot.identity.runnerAttached ? "attached" : "detached"}
</span>
</Chip>
<Chip tone="mock" title={snapshot.identity.controlPlaneTooltip} testId="control-plane-chip">
{snapshot.identity.controlPlaneLabel}
</Chip>
{chat && cleanRoomToken !== null ? (
<Chip tone="accent" testId="clean-room-identity">
Clean room {cleanRoomToken}
</Chip>
) : null}
</div>
<PriorityIcon priority={snapshot.issue.priority} />
{snapshot.issue.assignee !== null ? <span className="pit-assignee">{snapshot.issue.assignee}</span> : null}
<span className="pit-run-state" title={snapshot.issue.runState}>{snapshot.issue.runState}</span>
<div className="pit-menu pit-mobile-only" ref={menuRef}>
<button
type="button"
className="pit-button"
aria-expanded={menuOpen}
aria-haspopup="menu"
onClick={() => setMenuOpen((current) => !current)}
data-testid="overflow-menu-button"
>
<span aria-hidden="true">⋯</span>
<span className="pit-visually-hidden">More actions</span>
</button>
{menuOpen ? (
<div className="pit-menu-list" role="menu" data-testid="overflow-menu">
{chat ? null : (
<>
<label className="pit-menu-item" htmlFor="scenario-picker-mobile">
Scenario
<select
className="pit-select"
id="scenario-picker-mobile"
value={snapshot.issue.fixtureProfile}
onChange={(event) => {
setMenuOpen(false);
onSelectScenario(event.target.value);
}}
>
{scenarios.map((scenario) => (
<option key={scenario} value={scenario}>
{scenario}
</option>
))}
</select>
</label>
<button
type="button"
role="menuitem"
className="pit-menu-item"
onClick={() => {
setMenuOpen(false);
onReplay();
}}
>
Replay
</button>
</>
)}
<button
type="button"
role="menuitem"
className="pit-menu-item"
onClick={() => {
setMenuOpen(false);
onReset();
}}
>
{chat ? "Reset chat" : "Reset scenario"}
</button>
</div>
) : null}
</div>
</div>
<div className="pit-segmented" role="tablist" aria-label="Thread or evidence">
<button
type="button"
role="tab"
className="pit-segment"
aria-selected={segment === "thread"}
onClick={() => onSelectSegment("thread")}
data-testid="segment-thread"
>
Thread
</button>
<button
type="button"
role="tab"
className="pit-segment"
aria-selected={segment === "evidence"}
onClick={() => onSelectSegment("evidence")}
data-testid="segment-evidence"
>
Evidence
{denialCount > 0 ? (
<span className="pit-segment-badge" data-testid="segment-denial-badge">
{denialCount}
</span>
) : null}
</button>
</div>
</header>
);
}