macos: show pwd for jump options

pull/9945/head
Mitchell Hashimoto 2025-12-17 09:44:01 -08:00
parent b30e94c0ec
commit 1fd3f27e26
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
2 changed files with 24 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import SwiftUI
struct CommandOption: Identifiable, Hashable {
let id = UUID()
let title: String
let subtitle: String?
let description: String?
let symbols: [String]?
let leadingIcon: String?
@ -13,6 +14,7 @@ struct CommandOption: Identifiable, Hashable {
init(
title: String,
subtitle: String? = nil,
description: String? = nil,
symbols: [String]? = nil,
leadingIcon: String? = nil,
@ -22,6 +24,7 @@ struct CommandOption: Identifiable, Hashable {
action: @escaping () -> Void
) {
self.title = title
self.subtitle = subtitle
self.description = description
self.symbols = symbols
self.leadingIcon = leadingIcon
@ -55,7 +58,10 @@ struct CommandPaletteView: View {
if query.isEmpty {
return options
} else {
return options.filter { $0.title.localizedCaseInsensitiveContains(query) }
return options.filter {
$0.title.localizedCaseInsensitiveContains(query) ||
($0.subtitle?.localizedCaseInsensitiveContains(query) ?? false)
}
}
}
@ -298,8 +304,16 @@ fileprivate struct CommandRow: View {
.font(.system(size: 14, weight: .medium))
}
Text(option.title)
.fontWeight(option.emphasis ? .medium : .regular)
VStack(alignment: .leading, spacing: 2) {
Text(option.title)
.fontWeight(option.emphasis ? .medium : .regular)
if let subtitle = option.subtitle {
Text(subtitle)
.font(.caption)
.foregroundStyle(.secondary)
}
}
Spacer()

View File

@ -142,10 +142,16 @@ struct TerminalCommandPaletteView: View {
return controller.surfaceTree.map { surface in
let title = surface.title.isEmpty ? window.title : surface.title
let displayTitle = title.isEmpty ? "Untitled" : title
let pwd = surface.pwd?.abbreviatedPath
let subtitle: String? = if let pwd, !displayTitle.contains(pwd) {
pwd
} else {
nil
}
return CommandOption(
title: "Focus: \(displayTitle)",
description: surface.pwd?.abbreviatedPath,
subtitle: subtitle,
leadingIcon: "rectangle.on.rectangle",
leadingColor: displayColor?.displayColor.map { Color($0) }
) {