From 15ea0f1dd20114219ed27b3e44bcd158027e5bb1 Mon Sep 17 00:00:00 2001 From: Andrew Blakeslee Moore Date: Sat, 4 Jul 2026 00:38:59 -0700 Subject: [PATCH] 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 --- NucleicRemote/NucleicRemote/Models/RemoteStore.swift | 10 ++++++++-- .../NucleicRemote/Views/ApprovalCardView.swift | 7 ++++--- .../NucleicRemote/Views/Transcript/ToolGroupRow.swift | 10 ++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/NucleicRemote/NucleicRemote/Models/RemoteStore.swift b/NucleicRemote/NucleicRemote/Models/RemoteStore.swift index 6ceabc8..d237e58 100644 --- a/NucleicRemote/NucleicRemote/Models/RemoteStore.swift +++ b/NucleicRemote/NucleicRemote/Models/RemoteStore.swift @@ -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). diff --git a/NucleicRemote/NucleicRemote/Views/ApprovalCardView.swift b/NucleicRemote/NucleicRemote/Views/ApprovalCardView.swift index b8a09bb..8bdbad9 100644 --- a/NucleicRemote/NucleicRemote/Views/ApprovalCardView.swift +++ b/NucleicRemote/NucleicRemote/Views/ApprovalCardView.swift @@ -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) diff --git a/NucleicRemote/NucleicRemote/Views/Transcript/ToolGroupRow.swift b/NucleicRemote/NucleicRemote/Views/Transcript/ToolGroupRow.swift index f097150..3eda77d 100644 --- a/NucleicRemote/NucleicRemote/Views/Transcript/ToolGroupRow.swift +++ b/NucleicRemote/NucleicRemote/Views/Transcript/ToolGroupRow.swift @@ -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) }