Move terminal selection to Advanced

This commit is contained in:
Peter Steinberger 2025-06-17 11:41:13 +02:00
parent f23dc80a38
commit 784de80714
2 changed files with 68 additions and 46 deletions

View file

@ -58,6 +58,9 @@ struct AdvancedSettingsView: View {
Text("Integration")
.font(.headline)
}
// Terminal preference section
TerminalPreferenceSection()
// Advanced section
Section {
@ -94,3 +97,68 @@ struct AdvancedSettingsView: View {
}
}
}
// MARK: - Terminal Preference Section
private struct TerminalPreferenceSection: View {
@AppStorage("preferredTerminal") private var preferredTerminal = Terminal.terminal.rawValue
@State private var terminalLauncher = TerminalLauncher.shared
var body: some View {
Section {
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Preferred Terminal")
Spacer()
Picker("", selection: $preferredTerminal) {
ForEach(Terminal.installed, id: \.rawValue) { terminal in
HStack {
if let icon = terminal.appIcon {
Image(nsImage: icon)
.resizable()
.frame(width: 16, height: 16)
}
Text(terminal.displayName)
}
.tag(terminal.rawValue)
}
}
.pickerStyle(.menu)
.labelsHidden()
}
Text("Select which terminal application to use when creating new sessions")
.font(.caption)
.foregroundStyle(.secondary)
// Test button
HStack {
Text("Test Terminal")
Spacer()
Button("Test with 'banner hi'") {
Task {
do {
try terminalLauncher.launchCommand("banner hi")
} catch {
print("Failed to launch terminal test: \(error)")
}
}
}
.buttonStyle(.bordered)
}
Text("Opens a new terminal window with a test command")
.font(.caption)
.foregroundStyle(.secondary)
}
} header: {
Text("Terminal")
.font(.headline)
} footer: {
Text(
"VibeTunnel will use this terminal when launching new terminal sessions."
)
.font(.caption)
.frame(maxWidth: .infinity)
.multilineTextAlignment(.center)
}
}
}

View file

@ -65,8 +65,6 @@ struct DebugSettingsView: View {
logLevel: $logLevel
)
TerminalPreferenceSection()
DeveloperToolsSection(
showPurgeConfirmation: $showPurgeConfirmation,
showServerConsole: showServerConsole,
@ -630,47 +628,3 @@ private struct DeveloperToolsSection: View {
}
}
// MARK: - Terminal Preference Section
private struct TerminalPreferenceSection: View {
@AppStorage("preferredTerminal") private var preferredTerminal = Terminal.terminal.rawValue
var body: some View {
Section {
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Preferred Terminal")
Spacer()
Picker("", selection: $preferredTerminal) {
ForEach(Terminal.installed, id: \.rawValue) { terminal in
HStack {
if let icon = terminal.appIcon {
Image(nsImage: icon)
.resizable()
.frame(width: 16, height: 16)
}
Text(terminal.displayName)
}
.tag(terminal.rawValue)
}
}
.pickerStyle(.menu)
.labelsHidden()
}
Text("Select which terminal application to use when creating new sessions")
.font(.caption)
.foregroundStyle(.secondary)
}
} header: {
Text("Terminal Preference")
.font(.headline)
} footer: {
Text(
"VibeTunnel will use this terminal when launching new terminal sessions. Falls back to Terminal if the selected app is not available."
)
.font(.caption)
.frame(maxWidth: .infinity)
.multilineTextAlignment(.center)
}
}
}