From ce7499a83ca109e1ae5ad0f5fc93344642d9c690 Mon Sep 17 00:00:00 2001 From: Andrew Blakeslee Moore Date: Sun, 5 Jul 2026 19:44:13 -0700 Subject: [PATCH] Tool Call Card Alignment Nucleic-Session: FFDE42E0-22AB-4478-B2E2-FF69B2753CEE Co-authored-by: Nucleic --- .../NucleicRemote/Views/TranscriptRow.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/NucleicRemote/NucleicRemote/Views/TranscriptRow.swift b/NucleicRemote/NucleicRemote/Views/TranscriptRow.swift index 6e6a2f4..287940f 100644 --- a/NucleicRemote/NucleicRemote/Views/TranscriptRow.swift +++ b/NucleicRemote/NucleicRemote/Views/TranscriptRow.swift @@ -64,6 +64,28 @@ struct TranscriptRow: View { } private func modelLabel(_ model: String) -> String { model.isEmpty ? "agent" : model } + + /// The pretty card for a *completed* AskUserQuestion whose result records the user's choices, + /// or nil when this isn't that (wrong tool, still pending, errored, or an unexpected result + /// shape) — in which case the row falls back to a normal tool card. Mirrors the Mac's + /// `answeredQuestionCard`. + private func answeredQuestionCard(_ group: ToolGroup) -> AskUserQuestionResultCard? { + guard group.isAskUserQuestion, !group.isError, let result = group.result, + let questions = AskUserQuestion.questions(from: group.input) else { return nil } + let answers = AskUserQuestion.answers(in: result.resultText, for: questions) + guard !answers.isEmpty else { return nil } + return AskUserQuestionResultCard(questions: questions, answers: answers) + } + + /// A git-commit `Bash` pipeline rendered as the structured commit card the Mac shows at the row + /// level (subject + Markdown body + the new hash + "Show command"), or nil for any non-commit + /// call — which keeps the normal collapsible tool card. Mirrors the Mac's `gitCommitCard`. + private func gitCommitRowCard(_ group: ToolGroup) -> GitCommitCard? { + guard let command = group.bashCommand, let commit = GitCommitSummary.parse(command) + else { return nil } + let output = group.result.map(\.resultText).flatMap { $0.isEmpty ? nil : $0 } + return GitCommitCard(commit: commit, rawCommand: command, output: output) + } } /// Render an assistant/user message with the full Markdown renderer the Mac transcript uses