From 08d6bcbbf16ea931440ef4054b786f08a37fbe46 Mon Sep 17 00:00:00 2001 From: Kaede Akino Date: Sat, 12 Sep 2026 07:50:19 +0800 Subject: [PATCH] Compact iOS terminal snippet previews --- TFI/Features/Terminal/MobileTerminalSnippetsView.swift | 5 +++-- TFITests/MobileTerminalListTests.swift | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/TFI/Features/Terminal/MobileTerminalSnippetsView.swift b/TFI/Features/Terminal/MobileTerminalSnippetsView.swift index 6e93017e..84e86759 100644 --- a/TFI/Features/Terminal/MobileTerminalSnippetsView.swift +++ b/TFI/Features/Terminal/MobileTerminalSnippetsView.swift @@ -23,7 +23,7 @@ struct MobileTerminalSnippetsView: View { } else { MobileNativeList( items: snippets, - estimatedRowHeight: 76, + estimatedRowHeight: 60, refreshID: workspace.connected, onSelect: insert ) { snippet in @@ -51,7 +51,8 @@ struct MobileTerminalSnippetsView: View { Text(snippet.body) .font(.caption.monospaced()) .foregroundStyle(.secondary) - .lineLimit(2) + .lineLimit(1) + .truncationMode(.tail) } Spacer(minLength: 8) MobileTerminalRiskIndicator(assessment: CommandRiskClassifier.assess(snippet.body)) diff --git a/TFITests/MobileTerminalListTests.swift b/TFITests/MobileTerminalListTests.swift index 84665d35..08f82ed2 100644 --- a/TFITests/MobileTerminalListTests.swift +++ b/TFITests/MobileTerminalListTests.swift @@ -11,7 +11,7 @@ struct MobileTerminalListTests { let app = try MobileAppModel(inMemory: true) let host = TermindDomain.Host(name: "Test", host: "example.invalid") app.library.upsert(host) - app.library.upsert(Snippet(title: "List files", body: "ls -la")) + app.library.upsert(Snippet(title: "List files", body: "ls -la\npwd")) app.commandHistory.record("pwd", for: host.id) let workspace = MobileWorkspace( descriptor: MobileWorkspaceDescriptor(hostID: host.id, title: host.name, kind: .ssh), @@ -54,7 +54,7 @@ struct MobileTerminalListTests { #expect(MobileTerminalRiskIndicator.accessibilityIdentifier(for: .destructive) == "TerminalRisk.destructive") } - @Test func terminalHistoryUsesTheCompactSidebarContentAndSingleClickInsertion() throws { + @Test func terminalListsUseCompactSidebarContentAndSingleClickInsertion() throws { let root = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent() let history = try String( contentsOf: root.appending(path: "TFI/Features/Terminal/MobileCommandHistoryView.swift"), @@ -67,6 +67,12 @@ struct MobileTerminalListTests { #expect(history.contains(".lineLimit(2)")) #expect(!history.contains("Exit Status")) #expect(history.contains("MobileTerminalRiskIndicator")) + let bodyStart = try #require(snippets.range(of: "Text(snippet.body)")) + let bodyEnd = try #require(snippets[bodyStart.upperBound...].range(of: "Spacer(minLength: 8)")) + let bodyPreview = snippets[bodyStart.lowerBound..