Render sandbox runtime status in issue threads (#8594)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The issue thread is where operators watch active agent work and
decide whether a run is healthy.
> - Backend runtime-progress plumbing can expose a concise current
status, but users only benefit if the issue UI renders it in context.
> - The UI should show that current status as part of the active run
surface without turning it into durable transcript content.
> - This pull request adds the issue-thread rendering and message
formatting needed for sandbox runtime status.
> - The benefit is that active sandbox setup phases are visible from the
normal issue detail view.

## Linked Issues or Issue Description

Refs #248

No exact public GitHub issue was found for this UI rendering work. The
underlying problem is that active sandboxed runs can have backend
progress state without any concise issue-thread display, leaving users
to infer whether setup is still moving. This PR adds the UI layer on top
of the runtime-status API branch.

GitHub search performed for related or duplicate work: `sandbox runtime
status`, `sandbox restore index`, and `runtime progress`. No direct
duplicate PR was found.

## What Changed

- Included current runtime status in the heartbeat API client shape.
- Rendered active run status text in the issue chat thread when
available.
- Updated issue-chat message formatting helpers for runtime status
display.
- Added focused component and formatting tests for the new active-run
status behavior.

## Verification

- Local PII scan before push: high-confidence secret patterns, internal
issue links, local user paths, and private URL patterns checked across
all three split diffs; no real secrets or internal links found.
- `git diff --check feat/sandbox-runtime-status..feat/sandbox-status-ui`
- `pnpm exec vitest run ui/src/components/IssueChatThread.test.tsx
ui/src/lib/issue-chat-messages.test.ts` — 2 files, 91 tests passed.
- `pnpm run typecheck` passed on `feat/sandbox-status-ui`.
- `pnpm run build` passed on `feat/sandbox-status-ui`; Vite reported
existing CSS `::highlight` and chunk-size warnings.
- Visual evidence (desktop + mobile) is attached to the tracking issue
rather than committed to the repo.

## Risks

- This PR is stacked on the runtime-status API branch and depends on
that response/event shape.
- The status line is intentionally concise; long or sensitive status
content should continue to be bounded/redacted by the backend.
- The visual change is limited to active issue-thread runs with current
runtime status data.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

OpenAI GPT-5 via Codex coding agent, with shell/tool execution in a
local worktree. Exact context-window metadata is not exposed by the
runtime.

## 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 either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] 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 any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip CTO <cto@paperclip.local>
Co-authored-by: Paperclip CTO <noreply@paperclip.ing>
This commit is contained in:
authored and GitHub committed 2026-06-24 23:17:55 -07:00
1 parent a27e5ad002
commit 800dab1c64
5 files changed
+153 -33

No files matched your search

+4
View File
@@ -36,6 +36,8 @@ export interface ActiveRunForIssue {
lastUsefulActionAt?: string | Date | null;
nextAction?: string | null;
outputSilence?: HeartbeatRun["outputSilence"];
currentStatusMessage?: string | null;
currentStatusUpdatedAt?: string | Date | null;
}
export interface LiveRunForIssue {
@@ -60,6 +62,8 @@ export interface LiveRunForIssue {
lastUsefulActionAt?: string | null;
nextAction?: string | null;
outputSilence?: HeartbeatRun["outputSilence"];
currentStatusMessage?: string | null;
currentStatusUpdatedAt?: string | null;
}
export interface WatchdogDecisionInput {
@@ -3318,6 +3318,48 @@ describe("IssueChatThread", () => {
});
});
it("renders ephemeral active-run status below the working indicator", () => {
const root = createRoot(container);
act(() => {
root.render(
<MemoryRouter>
<IssueChatThread
comments={[]}
linkedRuns={[]}
timelineEvents={[]}
liveRuns={[]}
activeRun={{
id: "run-1",
issueId: "issue-1",
status: "running",
invocationSource: "comment",
triggerDetail: null,
startedAt: "2026-04-06T12:00:00.000Z",
finishedAt: null,
createdAt: "2026-04-06T12:00:00.000Z",
agentId: "agent-1",
agentName: "Agent 1",
adapterType: "codex_local",
currentStatusMessage: "Syncing git worktree to sandbox",
currentStatusUpdatedAt: "2026-04-06T12:00:05.000Z",
}}
onAdd={async () => {}}
enableLiveTranscriptPolling={false}
/>
</MemoryRouter>,
);
});
expect(container.textContent).toContain("Working...");
expect(container.textContent).toContain("Syncing git worktree to sandbox");
expect(container.querySelector('[title="Syncing git worktree to sandbox"]')).not.toBeNull();
act(() => {
root.unmount();
});
});
it("folds chain-of-thought when the same message transitions from running to complete", () => {
expect(resolveAssistantMessageFoldedState({
messageId: "message-1",
+60 -32
View File
@@ -874,6 +874,8 @@ function IssueChatChainOfThought({
const rawSegments = Array.isArray(custom.chainOfThoughtSegments)
? (custom.chainOfThoughtSegments as SegmentTiming[])
: [];
const currentStatusMessage =
typeof custom.currentStatusMessage === "string" ? custom.currentStatusMessage.trim() : "";
const segmentTiming = myIndex >= 0 ? rawSegments[myIndex] ?? null : null;
const isActive = isCoTSegmentActive({
isMessageRunning,
@@ -908,33 +910,45 @@ function IssueChatChainOfThought({
<div>
<button
type="button"
className="group flex w-full items-center gap-2.5 rounded-lg px-1 py-2 text-left transition-colors hover:bg-accent/5"
className="group flex w-full items-start gap-2.5 rounded-lg px-1 py-2 text-left transition-colors hover:bg-accent/5"
onClick={() => hasContent && setExpanded((v) => !v)}
>
<span className="inline-flex items-center gap-2 text-sm font-medium text-foreground/80">
{agentIcon ? (
<AgentIcon icon={agentIcon} className="h-4 w-4 shrink-0" />
) : isActive ? (
<Loader2 className="h-4 w-4 shrink-0 animate-spin text-muted-foreground" />
) : (
<span className="flex h-4 w-4 shrink-0 items-center justify-center">
<span className="h-1.5 w-1.5 rounded-full bg-emerald-500/70" />
<div className="min-w-0 flex-1">
<div className="flex min-w-0 items-center gap-2.5">
<span className="inline-flex items-center gap-2 text-sm font-medium text-foreground/80">
{agentIcon ? (
<AgentIcon icon={agentIcon} className="h-4 w-4 shrink-0" />
) : isActive ? (
<Loader2 className="h-4 w-4 shrink-0 animate-spin text-muted-foreground" />
) : (
<span className="flex h-4 w-4 shrink-0 items-center justify-center">
<span className="h-1.5 w-1.5 rounded-full bg-emerald-500/70" />
</span>
)}
{isActive ? (
<span className="shimmer-text">{headerVerb}</span>
) : (
headerVerb
)}
</span>
)}
{isActive ? (
<span className="shimmer-text">{headerVerb}</span>
) : (
headerVerb
)}
</span>
{headerSuffix ? (
<span className="text-xs text-muted-foreground/60">{headerSuffix}</span>
) : null}
{toolSummary ? (
<span className="text-xs text-muted-foreground/40">· {toolSummary}</span>
) : null}
{headerSuffix ? (
<span className="text-xs text-muted-foreground/60">{headerSuffix}</span>
) : null}
{toolSummary ? (
<span className="text-xs text-muted-foreground/40">· {toolSummary}</span>
) : null}
</div>
{isActive && currentStatusMessage ? (
<span
className="mt-0.5 block truncate pl-6 text-xs leading-4 text-muted-foreground/70"
title={currentStatusMessage}
>
{currentStatusMessage}
</span>
) : null}
</div>
{hasContent ? (
<ChevronDown className={cn("ml-auto h-4 w-4 shrink-0 text-muted-foreground/50 transition-transform", expanded && "rotate-180")} />
<ChevronDown className={cn("mt-0.5 h-4 w-4 shrink-0 text-muted-foreground/50 transition-transform", expanded && "rotate-180")} />
) : null}
</button>
{expanded && hasContent ? (
@@ -1579,6 +1593,8 @@ function IssueChatAssistantMessage({
? custom.notices.filter((notice): notice is string => typeof notice === "string" && notice.length > 0)
: [];
const waitingText = typeof custom.waitingText === "string" ? custom.waitingText : "";
const currentStatusMessage =
typeof custom.currentStatusMessage === "string" ? custom.currentStatusMessage.trim() : "";
const isRunning = message.role === "assistant" && message.status?.type === "running";
const runHref = runId && runAgentId ? `/agents/${runAgentId}/runs/${runId}` : null;
const canStopRun = Boolean(runId) && (isRunActive || runStatus === "queued" || runStatus === "running");
@@ -1855,15 +1871,25 @@ function IssueChatAssistantMessage({
<div className="space-y-3">
<IssueChatAssistantParts message={message} hasCoT={hasCoT} />
{message.content.length === 0 && waitingText ? (
<div className="flex items-center gap-2.5 rounded-lg px-1 py-2">
<span className="inline-flex items-center gap-2 text-sm font-medium text-foreground/80">
{agentIcon ? (
<AgentIcon icon={agentIcon} className="h-4 w-4 shrink-0" />
) : (
<Loader2 className="h-4 w-4 shrink-0 animate-spin text-muted-foreground" />
)}
<span className="shimmer-text">{waitingText}</span>
</span>
<div className="rounded-lg px-1 py-2">
<div className="flex min-w-0 items-center gap-2.5">
<span className="inline-flex items-center gap-2 text-sm font-medium text-foreground/80">
{agentIcon ? (
<AgentIcon icon={agentIcon} className="h-4 w-4 shrink-0" />
) : (
<Loader2 className="h-4 w-4 shrink-0 animate-spin text-muted-foreground" />
)}
<span className="shimmer-text">{waitingText}</span>
</span>
</div>
{isRunning && currentStatusMessage ? (
<div
className="mt-0.5 truncate pl-6 text-xs leading-4 text-muted-foreground/70"
title={currentStatusMessage}
>
{currentStatusMessage}
</div>
) : null}
</div>
) : null}
{notices.length > 0 ? (
@@ -4178,6 +4204,8 @@ export function IssueChatThread({
adapterType: activeRun.adapterType,
logBytes: activeRun.logBytes,
lastOutputBytes: activeRun.lastOutputBytes,
currentStatusMessage: activeRun.currentStatusMessage ?? null,
currentStatusUpdatedAt: toIsoString(activeRun.currentStatusUpdatedAt),
});
}
return [...deduped.values()].sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
+41 -1
View File
@@ -13,7 +13,7 @@ import type {
SuggestTasksInteraction,
} from "./issue-thread-interactions";
import type { IssueTimelineEvent } from "./issue-timeline-events";
import type { LiveRunForIssue } from "../api/heartbeats";
import type { ActiveRunForIssue, LiveRunForIssue } from "../api/heartbeats";
function createAgent(id: string, name: string): Agent {
return {
@@ -640,6 +640,46 @@ describe("buildIssueChatMessages", () => {
});
});
it("preserves ephemeral active-run status metadata for rendering", () => {
const activeRun: ActiveRunForIssue = {
id: "run-active-1",
status: "running",
invocationSource: "manual",
triggerDetail: null,
startedAt: "2026-04-06T12:03:00.000Z",
finishedAt: null,
createdAt: "2026-04-06T12:03:00.000Z",
agentId: "agent-1",
agentName: "CodexCoder",
adapterType: "codex_local",
currentStatusMessage: "Syncing git worktree to sandbox",
currentStatusUpdatedAt: "2026-04-06T12:03:05.000Z",
};
const messages = buildIssueChatMessages({
comments: [],
timelineEvents: [],
linkedRuns: [],
liveRuns: [],
activeRun,
currentUserId: "user-1",
});
expect(messages).toHaveLength(1);
expect(messages[0]).toMatchObject({
role: "assistant",
status: { type: "running" },
metadata: {
custom: {
kind: "live-run",
runId: "run-active-1",
currentStatusMessage: "Syncing git worktree to sandbox",
currentStatusUpdatedAt: "2026-04-06T12:03:05.000Z",
},
},
});
});
it("places request confirmations after later same-run handoff status and comment", () => {
const messages = buildIssueChatMessages({
comments: [
+6
View File
@@ -857,6 +857,10 @@ function normalizeLiveRuns(
agentName: activeRun.agentName,
adapterType: activeRun.adapterType,
issueId,
currentStatusMessage: activeRun.currentStatusMessage ?? null,
currentStatusUpdatedAt: activeRun.currentStatusUpdatedAt
? toDate(activeRun.currentStatusUpdatedAt).toISOString()
: null,
});
}
return [...deduped.values()].sort((a, b) => toTimestamp(a.createdAt) - toTimestamp(b.createdAt));
@@ -895,6 +899,8 @@ function createLiveRunMessage(args: {
waitingText,
chainOfThoughtLabel: runDurationLabel(run),
chainOfThoughtSegments: segments,
currentStatusMessage: run.currentStatusMessage ?? null,
currentStatusUpdatedAt: run.currentStatusUpdatedAt ?? null,
}),
};
return message;