Repository Public License
1// ORIX Convert — App/Sources/Features/SmartDrop/WorkspaceModel.swift2// Description: State of the Smart Drop workspace: analysed files grouped by detected format, the destination chosen3// for each group, option values (secrets stay in memory only), preflight warnings and output settings.4// Author: Simon-Pierre Boucher — contact@spboucher.ai5import AppKit6import ConvertCore7import Observation89/// One analysed file (or one dropped folder, for folder-level operations).10struct StagedFile: Identifiable, Sendable {11 let url: URL12 /// The analyzer's result; `nil` for a folder entry.13 let item: SmartDropItem?14 /// Files found inside, for a folder entry.15 var folderFileCount: Int?1617 var id: URL { url }18 var detection: DetectionResult? { item?.detection }19 var size: Int64? { item?.facts.size }20 var mismatch: Bool { item?.detection.mismatch ?? false }2122 /// "1920 × 1080", "12 pages", "3 min 2 s"… from what the engine really read; `nil` when nothing was read.23 var summary: String? {24 if let count = folderFileCount { return L("%lld files", count) }25 guard let inspection = item?.inspection else { return nil }26 var parts: [String] = []27 if let w = inspection.pixelWidth, let h = inspection.pixelHeight { parts.append("\(Fmt.count(w)) × \(Fmt.count(h))") }28 if let pages = inspection.pageCount { parts.append(pages == 1 ? L("1 page") : L("%lld pages", pages)) }29 if let duration = inspection.durationSeconds { parts.append(Fmt.duration(duration)) }30 if let rows = inspection.rowCount { parts.append(L("%lld rows", rows)) }31 if let entries = inspection.entryCount { parts.append(L("%lld entries", entries)) }32 return parts.isEmpty ? nil : parts.joined(separator: " · ")33 }34}3536/// The destination chosen for a group, with the real plan behind it.37struct TargetChoice: Equatable, Sendable {38 let destination: FormatID39 let operation: String?40 let plan: ConversionPlan41 var id: String { destination.rawValue + (operation.map { "#" + $0 } ?? "") }42 var lastStep: ConversionPath? { plan.steps.last }43 /// A generic operation (create an archive, compress): planned from the `.folder` pseudo-source and enqueued with44 /// `sourceFormat: .folder`, whatever the files are.45 var isGeneric = false46 /// Operation title ("Merge PDFs") or the destination's name.47 var title: String { lastStep?.title.map { LE($0) } ?? destination.displayName }48 var acceptsMultipleSources: Bool { plan.acceptsMultipleSources }49}5051/// Warnings of a group gathered across its files.52struct WarningSummary: Identifiable, Hashable, Sendable {53 let severity: ConversionWarning.Severity54 let code: String55 let message: String56 /// Files that raised it.57 let fileCount: Int58 /// The warning comes from the path itself and applies to every file.59 let appliesToAll: Bool60 var id: String { code + "|" + message }61}6263@Observable final class StagedGroup: Identifiable {64 let id: String65 let format: FormatID?66 let isFolderGroup: Bool67 var files: [StagedFile]68 var targets: [ConversionTarget]69 var operations: [ConversionTarget]70 var recommended: [ConversionTarget]71 var chained: [FormatID]72 /// Identifiers of the operations of `operations` that apply to any file (see `TargetChoice.isGeneric`).73 var genericIDs: Set<String> = []74 var choice: TargetChoice?75 var descriptors: [OptionDescriptor] = []76 /// Values the user set explicitly. Keys containing "password" live here only: never persisted.77 var optionValues: [String: OptionValue] = [:]78 /// Convert all the files into ONE output (paths that accept several sources).79 var combine = false80 var expanded = false81 var warnings: [WarningSummary] = []82 var isCheckingWarnings = false83 @ObservationIgnored var preflightTask: Task<Void, Never>?8485 init(id: String, format: FormatID?, isFolderGroup: Bool = false, files: [StagedFile], targets: [ConversionTarget], operations: [ConversionTarget],86 recommended: [ConversionTarget], chained: [FormatID]) {87 self.id = id; self.format = format; self.isFolderGroup = isFolderGroup; self.files = files88 self.targets = targets; self.operations = operations; self.recommended = recommended; self.chained = chained89 }9091 var isConvertible: Bool { !targets.isEmpty || !operations.isEmpty || !chained.isEmpty }92 var totalBytes: Int64 { files.reduce(0) { $0 + ($1.size ?? 0) } }93 var mismatchCount: Int { files.filter(\.mismatch).count }94 var options: ConversionOptions { ConversionOptions(optionValues) }95 var canCombine: Bool { choice?.acceptsMultipleSources == true && files.count > 1 }96 /// A merge-like operation needs at least two inputs.97 var needsMoreFiles: Bool { choice?.acceptsMultipleSources == true && choice?.operation != nil && files.count < 2 && choice?.isGeneric != true && !isFolderGroup }98 var willRun: Bool { choice != nil && !needsMoreFiles }99 /// Jobs this group will create.100 var jobCount: Int { !willRun ? 0 : (combine && canCombine ? 1 : files.count) }101 var dataLossFileCount: Int { warnings.filter { $0.severity == .dataLoss }.map(\.fileCount).max() ?? 0 }102103 var title: String {104 if isFolderGroup { return files.count == 1 ? L("1 folder") : L("%lld folders", files.count) }105 guard let format else { return files.count == 1 ? L("1 unrecognised file") : L("%lld unrecognised files", files.count) }106 return files.count == 1 ? L("1 %@ file", format.displayName) : L("%lld %@ files", files.count, format.displayName)107 }108}109110/// Where the results of the next batch go.111struct OutputSettings: Equatable {112 var mode: OutputLocationMode113 var folder: URL?114 var nameTemplate: String115 var conflictPolicy: ConflictPolicy116 var allowReplacingSource = false117}118119@Observable final class WorkspaceModel {120 @ObservationIgnored unowned let app: AppModel121 var groups: [StagedGroup] = []122 var isAnalyzing = false123 var analyzingCount = 0124 var skipped: [(url: URL, reason: String)] = []125 var truncated = false126 var selectedGroupID: String?127 var output: OutputSettings128 /// Message shown after an action that could not proceed (read-only folder, nothing to convert…).129 var notice: String?130131 init(app: AppModel) {132 self.app = app133 let s = app.settings.stored134 output = OutputSettings(mode: s.outputMode, folder: app.settings.outputFolder, nameTemplate: s.nameTemplate, conflictPolicy: s.conflictPolicy)135 }136137 /// Preview shown in the side inspector for the selected file (loaded only while the Preview area is open).138 let inspectorPreview = FilePreviewModel()139 var showInspectorPreview = false140141 /// The file the inspector previews: the selected row when it belongs to `group`, else the group's first file.142 func previewedFile(in group: StagedGroup) -> StagedFile? {143 group.files.first { $0.id == selectedFileID } ?? group.files.first144 }145146 /// Loads (or reloads) the inspector preview when it is open and shows another file.147 func refreshInspectorPreview(for group: StagedGroup?) {148 guard showInspectorPreview, let group, !group.isFolderGroup, let file = previewedFile(in: group) else { inspectorPreview.clear(); return }149 if inspectorPreview.url != file.url { inspectorPreview.load(file.url, format: file.detection?.format, inspection: file.item?.inspection) }150 }151152 /// File row selected with the mouse or the keyboard (arrows, space = Quick Look, delete = remove).153 var selectedFileID: URL?154 /// Multi-source conversions (engine | destination | operation) for which the groups that share them are combined155 /// into ONE output, across formats (JPEG + PNG + HEIC → one PDF).156 var crossCombine: Set<String> = []157158 var isEmpty: Bool { groups.isEmpty && !isAnalyzing }159 var fileCount: Int { groups.reduce(0) { $0 + $1.files.count } }160 var jobCount: Int {161 groups.filter { !isCrossCombined($0) }.reduce(0) { $0 + $1.jobCount } + activeCrossKeys.count162 }163164 // MARK: Combining across formats165166 /// Identifies the multi-source path a group has chosen; `nil` when its choice takes one file at a time.167 func combineKey(_ group: StagedGroup) -> String? {168 guard let choice = group.choice, choice.acceptsMultipleSources, let step = choice.lastStep else { return nil }169 // Folders join other groups only for generic operations (one archive of files and folders).170 if group.isFolderGroup && step.source != .folder { return nil }171 return "\(step.engine)|\(choice.destination.rawValue)|\(choice.operation ?? "")"172 }173174 /// The other groups whose files can join this group's output: every one of them has chosen the same175 /// multi-source path (same engine, destination and operation) for its own format.176 func combinePartners(of group: StagedGroup) -> [StagedGroup] {177 guard let key = combineKey(group) else { return [] }178 return groups.filter { $0.id != group.id && combineKey($0) == key }179 }180181 func isCrossCombined(_ group: StagedGroup) -> Bool {182 guard let key = combineKey(group), crossCombine.contains(key) else { return false }183 return !combinePartners(of: group).isEmpty184 }185186 func setCrossCombine(_ on: Bool, for group: StagedGroup) {187 guard let key = combineKey(group) else { return }188 if on { crossCombine.insert(key) } else { crossCombine.remove(key) }189 }190191 private var activeCrossKeys: [String] {192 var keys: [String] = []193 for group in groups where isCrossCombined(group) { if let key = combineKey(group), !keys.contains(key) { keys.append(key) } }194 return keys195 }196197 // MARK: File selection198199 /// File rows currently drawn, in order (collapsed groups show their first rows only).200 var visibleFiles: [(file: StagedFile, group: StagedGroup)] {201 groups.flatMap { group in (group.expanded ? group.files : Array(group.files.prefix(StagedGroup.collapsedRows))).map { ($0, group) } }202 }203204 func moveFileSelection(by offset: Int) {205 let rows = visibleFiles206 guard !rows.isEmpty else { return }207 guard let current = selectedFileID, let index = rows.firstIndex(where: { $0.file.id == current }) else {208 selectedFileID = (offset > 0 ? rows.first : rows.last)?.file.id209 return210 }211 let next = rows[min(rows.count - 1, max(0, index + offset))]212 selectedFileID = next.file.id213 selectedGroupID = next.group.id214 }215216 /// Removes the selected row and selects its neighbour.217 func removeSelectedFile() {218 let rows = visibleFiles219 guard let current = selectedFileID, let index = rows.firstIndex(where: { $0.file.id == current }) else { return }220 remove(rows[index].file, from: rows[index].group)221 let remaining = visibleFiles222 selectedFileID = remaining.isEmpty ? nil : remaining[min(index, remaining.count - 1)].file.id223 }224 var selectedGroup: StagedGroup? { groups.first { $0.id == selectedGroupID } }225 var dataLossFileCount: Int { groups.filter(\.willRun).reduce(0) { $0 + $1.dataLossFileCount } }226227 // MARK: Ingest228229 /// Analyses dropped items by content and merges them into the staged groups.230 func ingest(_ urls: [URL]) async {231 let existing = Set(groups.flatMap { $0.files.map(\.url.standardizedFileURL.path) })232 let fresh = urls.filter { !existing.contains($0.standardizedFileURL.path) }233 guard !fresh.isEmpty else { return }234 isAnalyzing = true235 analyzingCount += fresh.count236 let analyzer = app.manager.smartDrop237 let analysis = await Task.detached(priority: .userInitiated) { await analyzer.analyze(fresh) }.value238 analyzingCount = max(0, analyzingCount - fresh.count)239 isAnalyzing = analyzingCount > 0240 merge(analysis)241 }242243 private func merge(_ analysis: SmartDropAnalysis) {244 skipped += analysis.skipped245 truncated = truncated || analysis.truncated246 let known = Set(groups.flatMap { $0.files.map(\.url.standardizedFileURL.path) })247 var byFormat: [String: [SmartDropItem]] = [:]248 var orderOfFormats: [String] = []249 for item in analysis.items where !known.contains(item.url.standardizedFileURL.path) {250 let key = item.format?.rawValue ?? "unknown"251 if byFormat[key] == nil { orderOfFormats.append(key) }252 byFormat[key, default: []].append(item)253 }254 for key in orderOfFormats {255 guard let items = byFormat[key], let first = items.first else { continue }256 let files = items.map { StagedFile(url: $0.url, item: $0) }257 if let group = groups.first(where: { $0.id == key }) {258 group.files += files259 schedulePreflight(group)260 } else {261 // Generic operations ("Create ZIP archive", "Compress to gzip") are offered for every group, including262 // files nothing recognises; they are never the default choice.263 let generic = (analysis.selectionOperations + analysis.fileOperations).filter { candidate in !first.operations.contains { $0.id == candidate.id } }264 let group = StagedGroup(id: key, format: first.format, files: files, targets: first.targets, operations: first.operations + generic,265 recommended: first.recommended, chained: first.chainedDestinations)266 group.genericIDs = Set(generic.map(\.id))267 groups.append(group)268 let wanted = app.launch.target?.split(separator: "#", maxSplits: 1).map(String.init) ?? []269 if let format = wanted.first, select(destination: FormatID(format), operation: wanted.count > 1 ? wanted[1] : nil, in: group) {270 } else if let best = first.recommended.first ?? first.targets.first {271 select(destination: best.destination, operation: best.operation, in: group)272 }273 if group.choice == nil { schedulePreflight(group) }274 }275 }276 // Folder-level operations (e.g. create an archive): offered, never selected by default.277 let folders = analysis.folders.filter { !$0.targets.isEmpty && !known.contains($0.url.standardizedFileURL.path) }278 if let firstFolder = folders.first {279 let files = folders.map { StagedFile(url: $0.url, item: nil, folderFileCount: $0.fileCount) }280 if let group = groups.first(where: { $0.id == "folder" }) {281 group.files += files282 } else {283 let plain = firstFolder.targets.filter { $0.operation == nil }284 groups.append(StagedGroup(id: "folder", format: .folder, isFolderGroup: true, files: files, targets: plain,285 operations: firstFolder.targets.filter { $0.operation != nil }, recommended: [], chained: []))286 }287 }288 groups.sort { ($0.isConvertible ? 0 : 1, $0.isFolderGroup ? 1 : 0) < ($1.isConvertible ? 0 : 1, $1.isFolderGroup ? 1 : 0) }289 if selectedGroupID == nil || selectedGroup == nil { selectedGroupID = groups.first(where: \.isConvertible)?.id }290 }291292 // MARK: Editing293294 /// Chooses a destination for a group. Returns `false` when no real plan exists.295 @discardableResult296 func select(destination: FormatID, operation: String?, in group: StagedGroup) -> Bool {297 let id = destination.rawValue + (operation.map { "#" + $0 } ?? "")298 let generic = !group.isFolderGroup && group.genericIDs.contains(id)299 guard let source = generic ? FormatID.folder : group.format,300 let plan = try? app.manager.planner.plan(from: source, to: destination, operation: operation, allowChaining: !generic) else { return false }301 var choice = TargetChoice(destination: destination, operation: operation, plan: plan)302 choice.isGeneric = generic303 guard choice != group.choice else { return true }304 group.choice = choice305 group.descriptors = plan.steps.last.flatMap { step in app.registry.engine(id: step.engine)?.options(for: step) } ?? []306 let valid = Set(group.descriptors.map(\.id))307 group.optionValues = group.optionValues.filter { valid.contains($0.key) }308 // Merge-like operations always combine; plain multi-source conversions (images → PDF) keep one file each309 // unless asked.310 group.combine = choice.acceptsMultipleSources && operation != nil311 // One archive for everything that asked for the same archive: groups that choose the same generic312 // multi-source operation are combined unless the user separates them.313 if (generic || group.isFolderGroup), let key = combineKey(group), groups.contains(where: { $0.id != group.id && combineKey($0) == key }) { crossCombine.insert(key) }314 schedulePreflight(group)315 return true316 }317318 func clearChoice(in group: StagedGroup) {319 group.choice = nil320 group.descriptors = []321 group.optionValues = [:]322 group.combine = false323 schedulePreflight(group)324 }325326 func setOption(_ key: String, _ value: OptionValue?, in group: StagedGroup) {327 if let descriptor = group.descriptors.first(where: { $0.id == key }), descriptor.defaultValue == value {328 group.optionValues[key] = nil329 } else {330 group.optionValues[key] = value331 }332 schedulePreflight(group, debounce: true)333 }334335 func resetOptions(in group: StagedGroup) {336 group.optionValues = [:]337 schedulePreflight(group)338 }339340 func remove(_ group: StagedGroup) {341 group.preflightTask?.cancel()342 groups.removeAll { $0.id == group.id }343 if selectedGroupID == group.id { selectedGroupID = groups.first(where: \.isConvertible)?.id }344 if groups.isEmpty { skipped = []; truncated = false }345 }346347 func remove(_ file: StagedFile, from group: StagedGroup) {348 group.files.removeAll { $0.id == file.id }349 if group.files.isEmpty { remove(group) } else { schedulePreflight(group) }350 }351352 func moveFiles(in group: StagedGroup, from offsets: IndexSet, to destination: Int) {353 group.files.move(fromOffsets: offsets, toOffset: destination)354 }355356 func clear() {357 groups.forEach { $0.preflightTask?.cancel() }358 groups = []359 skipped = []360 truncated = false361 selectedGroupID = nil362 selectedFileID = nil363 crossCombine = []364 notice = nil365 }366367 // MARK: Preflight368369 /// Gathers what must be shown before converting: path limitations, the engine's preflight for each file with the370 /// current options, and the analyzer's own findings (wrong extension, protected, empty…).371 func schedulePreflight(_ group: StagedGroup, debounce: Bool = false) {372 group.preflightTask?.cancel()373 let files = group.files374 let choice = group.choice375 let options = group.options376 let analyzer = app.manager.smartDrop377 group.isCheckingWarnings = true378 group.preflightTask = Task { [weak group] in379 if debounce { try? await Task.sleep(for: .milliseconds(250)) }380 if Task.isCancelled { return }381 let summaries = await Task.detached(priority: .utility) {382 Self.summarize(files: files, choice: choice, options: options, analyzer: analyzer)383 }.value384 if Task.isCancelled { return }385 group?.warnings = summaries386 group?.isCheckingWarnings = false387 }388 }389390 nonisolated private static func summarize(files: [StagedFile], choice: TargetChoice?, options: ConversionOptions, analyzer: SmartDropAnalyzer) -> [WarningSummary] {391 struct Bucket { var warning: ConversionWarning; var count: Int; var fromPath: Bool }392 var buckets: [String: Bucket] = [:]393 var order: [String] = []394 func add(_ warning: ConversionWarning, fromPath: Bool) {395 let key = fromPath ? "path|" + warning.message : warning.code396 if buckets[key] == nil { order.append(key); buckets[key] = Bucket(warning: warning, count: 0, fromPath: fromPath) }397 buckets[key]?.count += 1398 }399 for file in files {400 if Task.isCancelled { return [] }401 guard let item = file.item else { continue }402 var warnings = item.warnings403 if let choice, let result = try? analyzer.preflight(item, to: choice.destination, operation: choice.operation, options: options) {404 warnings = result.warnings405 }406 var seen = Set<String>()407 for warning in warnings {408 let fromPath = warning.code == "limitation" || warning.code == "chained-plan"409 // One count per file and per kind of warning.410 if seen.insert(fromPath ? warning.message : warning.code).inserted { add(warning, fromPath: fromPath) }411 }412 }413 if let choice, choice.isGeneric || files.contains(where: { $0.item == nil }) {414 for limitation in choice.plan.limitations { add(ConversionWarning(.info, code: "limitation", limitation), fromPath: true) }415 }416 func rank(_ s: ConversionWarning.Severity) -> Int { s == .dataLoss ? 0 : (s == .caution ? 1 : 2) }417 return order.compactMap { buckets[$0] }418 .map { WarningSummary(severity: $0.warning.severity, code: $0.warning.code, message: $0.warning.message, fileCount: $0.count, appliesToAll: $0.fromPath) }419 .sorted { rank($0.severity) < rank($1.severity) }420 }421422 // MARK: Presets423424 func apply(_ preset: ConversionPreset, to group: StagedGroup) {425 guard select(destination: preset.destinationFormat, operation: preset.operation, in: group) else {426 notice = L("This preset cannot be applied: no conversion from %@ to %@ exists.", group.format?.displayName ?? "?", preset.destinationFormat.displayName)427 return428 }429 let valid = Set(group.descriptors.map(\.id))430 group.optionValues = preset.options.values.filter { valid.contains($0.key) }431 schedulePreflight(group)432 }433434 /// Saves the group's current destination and options as a user preset. Secrets are never included.435 func savePreset(named name: String, from group: StagedGroup) async {436 guard let choice = group.choice, choice.isGeneric || group.format != nil else { return }437 let preset = ConversionPreset(name: name, source: choice.isGeneric ? .any : .format(group.format ?? .folder), destinationFormat: choice.destination, operation: choice.operation,438 options: group.options.redactingSecrets())439 do { _ = try await app.presets.add(preset) } catch { notice = error.localizedDescription }440 await app.reloadPresets()441 }442443 // MARK: Converting444445 /// Preview of the name the first file of a group would get.446 func namePreview(for group: StagedGroup?) -> String {447 let file = group?.files.first448 let context = OutputNameContext(name: file?.url.deletingPathExtension().lastPathComponent ?? L("holiday photo"),449 ext: file?.url.pathExtension.lowercased() ?? "heic", date: Date(), counter: 1,450 width: file?.item?.inspection.pixelWidth, height: file?.item?.inspection.pixelHeight)451 let base = OutputNameTemplate.render(output.nameTemplate, context)452 let ext = group?.choice.flatMap { $0.destination.catalogEntry?.preferredExtension } ?? "png"453 return group?.choice?.destination == .folder ? base : OutputNameTemplate.fileName(base: base, ext: ext)454 }455456 /// Builds the job requests for everything staged. `directory` overrides the output folder ("ask each time").457 func makeRequests(directory: URL?) -> [ConversionJobRequest] {458 let folder: URL? = switch output.mode {459 case .sameFolder: nil460 case .chosenFolder: output.folder461 case .askEachTime: directory462 }463 let destination = OutputDestination(directory: directory ?? folder, nameTemplate: output.nameTemplate, conflictPolicy: output.conflictPolicy,464 allowReplacingSource: output.conflictPolicy == .replace && output.allowReplacingSource)465 var requests: [ConversionJobRequest] = []466 let record = app.settings.stored.historyEnabled467 // Groups combined across formats: one job per shared multi-source path, files in the order of the groups.468 var crossDone = Set<String>()469 for group in groups where isCrossCombined(group) {470 guard let key = combineKey(group), crossDone.insert(key).inserted, let choice = group.choice else { continue }471 let members = groups.filter { combineKey($0) == key }472 // A dropped folder is staged twice: as a folder entry and as the files found inside it. In one archive473 // the folder is the unit — its files are not added a second time next to it.474 let sources = Self.withoutNestedItems(members.flatMap { $0.files.map(\.url) })475 requests.append(ConversionJobRequest(sources: sources, sourceFormat: choice.isGeneric ? .folder : group.format, destinationFormat: choice.destination,476 operation: choice.operation, options: group.options, destination: destination, recordInHistory: record))477 }478 for group in groups where group.willRun && !isCrossCombined(group) {479 guard let choice = group.choice else { continue }480 if group.combine && group.canCombine {481 requests.append(ConversionJobRequest(sources: group.files.map(\.url), sourceFormat: choice.isGeneric ? .folder : group.format, destinationFormat: choice.destination,482 operation: choice.operation, options: group.options, destination: destination, recordInHistory: record))483 } else {484 for file in group.files {485 requests.append(ConversionJobRequest(sources: [file.url], sourceFormat: choice.isGeneric ? .folder : group.format, destinationFormat: choice.destination,486 operation: choice.operation, options: group.options, destination: destination, recordInHistory: record))487 }488 }489 }490 return requests491 }492493 /// The items of one multi-source job without those that lie inside another item of the same list (a file of a494 /// folder that is itself in the list) and without repeats; order kept.495 nonisolated static func withoutNestedItems(_ urls: [URL]) -> [URL] {496 let paths = urls.map { $0.standardizedFileURL.path }497 var seen = Set<String>()498 var kept: [URL] = []499 for (url, path) in zip(urls, paths) {500 guard seen.insert(path).inserted else { continue }501 let nested = paths.contains { other in other != path && path.hasPrefix(other.hasSuffix("/") ? other : other + "/") }502 if !nested { kept.append(url) }503 }504 return kept505 }506507 /// Removes from the staging area what was sent to the queue.508 func clearConverted() {509 let sent = Set(groups.filter { $0.willRun || isCrossCombined($0) }.map(\.id))510 for group in groups where sent.contains(group.id) { group.preflightTask?.cancel() }511 groups.removeAll { sent.contains($0.id) }512 if let selected = selectedFileID, !groups.contains(where: { $0.files.contains { $0.id == selected } }) { selectedFileID = nil }513 selectedGroupID = groups.first(where: \.isConvertible)?.id514 if groups.isEmpty { skipped = []; truncated = false }515 }516}517