iPad: render multi-step / destructive shell pipelines as a step list

The desktop CommandStepsCard breaks a shell pipeline (a rm/git chain) into a
step list with the destructive delete flagged, instead of a raw blob. Rather
than duplicate a parser, deliver that value by reusing the existing, tested
HostCommandSummary + HostCommandBreakdown (a general command parser whose
Invocation already carries a `destructive` flag for rm/rmdir) on the two paths
that still showed raw text:

- ToolCallCard.details: a shell tool whose command has >1 invocation or is
  destructive now renders the compact step breakdown (deletes glyphed/tinted in
  red) with the literal command under "Show command"; simple one-liners keep the
  plain input block.
- ApprovalCardView: the parsed breakdown (with its sudo/deletes risk banner) now
  covers any Bash pipeline / destructive approval, not just host_exec.

Demo transcript gains a destructive cleanup pipeline (rm -rf && git worktree
prune && git branch -D) so the step list is exercisable offline.

Verified in the iPad simulator: the pipeline expands to a step list with
`rm -rf` flagged in red.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
2026-07-04 00:38:59 -07:00
co-authored by Claude Opus 4.8
parent 149af312dc
commit 15ea0f1dd2
3 changed files with 20 additions and 7 deletions
@@ -627,6 +627,9 @@ final class RemoteStore: ObservableObject {
// A realistic `git commit` (heredoc message) so the transcript's structured commit card
// is exercisable offline: expand the Bash call to see the subject + Markdown body.
let demoCommitCommand = "git commit -F - <<'EOF'\nfix: harden auth middleware\n\nRequire a Bearer token and reject a missing or blank one.\n\n- extract `requireSession`\n- add a `Bearer` prefix check\nEOF"
// A multi-step, destructive shell pipeline so the transcript's step list (with the delete
// flagged in red) is exercisable offline: expand the Bash call to see the breakdown.
let demoCleanupCommand = "cd ~/code/nucleic && rm -rf .worktrees/auth-old && git worktree prune && git branch -D nucleic/auth-old"
openEvents = [
event(1, .sessionStarted(SessionStarted(
backendSessionID: "demo", model: "claude-opus-4-8[1m]", cwd: "~/code/nucleic", toolNames: []))),
@@ -645,8 +648,11 @@ final class RemoteStore: ObservableObject {
event(14, .toolCallStarted(ToolCall(toolCallID: "t4", name: "Bash", input: ["command": .string(demoCommitCommand)]))),
event(15, .toolCallCompleted(ToolCall(toolCallID: "t4", name: "Bash", input: ["command": .string(demoCommitCommand)]))),
event(16, .toolResult(ToolResult(toolCallID: "t4", content: "[nucleic/auth-refactor 1a2b3c4] fix: harden auth middleware\n 2 files changed, 312 insertions(+), 40 deletions(-)", isError: false))),
event(17, .usage(Usage(inputTokens: 84_300, outputTokens: 2_140, costUSD: 0.0421, contextInputTokens: 84_300))),
event(18, .runFinished(RunFinished(outcome: .completed, finalText: "Done."))),
event(17, .toolCallStarted(ToolCall(toolCallID: "t5", name: "Bash", input: ["command": .string(demoCleanupCommand)]))),
event(18, .toolCallCompleted(ToolCall(toolCallID: "t5", name: "Bash", input: ["command": .string(demoCleanupCommand)]))),
event(19, .toolResult(ToolResult(toolCallID: "t5", content: "Removed 1 worktree; deleted branch nucleic/auth-old.", isError: false))),
event(20, .usage(Usage(inputTokens: 84_300, outputTokens: 2_140, costUSD: 0.0421, contextInputTokens: 84_300))),
event(21, .runFinished(RunFinished(outcome: .completed, finalText: "Done."))),
]
// If this session is blocked on a human, surface a real approval card so the
// Allow/Deny loop is exercisable in the demo (the seeded `a1` session).
@@ -40,9 +40,10 @@ struct ApprovalCardView: View {
if let command = approval.input["command"]?.stringValue,
let commit = GitCommitSummary.parse(command) {
GitCommitCard(commit: commit, rawCommand: command)
} else if approval.toolName == HostCommandSummary.hostExecToolName,
let command = approval.input["command"]?.stringValue,
let parsed = HostCommandSummary.summary(for: command) {
} else if let command = approval.input["command"]?.stringValue,
let parsed = HostCommandSummary.summary(for: command),
approval.toolName == HostCommandSummary.hostExecToolName
|| parsed.invocations.count > 1 || parsed.isDestructive {
HostCommandBreakdown(summary: parsed)
Text("Exact command").font(.caption2.weight(.semibold)).foregroundStyle(.secondary)
ApprovalDetailBox(text: command)
@@ -49,10 +49,16 @@ struct ToolCallCard: View {
@ViewBuilder private var details: some View {
let input = group.input.approvalDetail
// A git commit reads as a structured commit card (subject + Markdown body), like the Mac —
// the raw command stays one tap away under "Show command".
// A git commit reads as a structured commit card (subject + Markdown body); a multi-step or
// destructive shell pipeline reads as a compact step list (deletes flagged in red) — both
// like the Mac, with the literal command one tap away under "Show command". Everything else
// keeps the plain input block.
if isShellTool, let commit = GitCommitSummary.parse(input) {
GitCommitCard(commit: commit, rawCommand: input)
} else if isShellTool, let summary = HostCommandSummary.summary(for: input),
summary.invocations.count > 1 || summary.isDestructive {
HostCommandBreakdown(summary: summary, showPurpose: false)
CommandDisclosure(command: input, accent: Palette.accent)
} else if !input.isEmpty {
ToolBlock(label: "Input", text: input, mono: true)
}