This commit is contained in:
Peter Steinberger 2025-06-23 18:36:36 +02:00
parent a14d02e20f
commit 8768bb0eb3
24 changed files with 149 additions and 148 deletions

View file

@ -89,7 +89,7 @@ final class LivePreviewManager {
}
}
case .exit(_):
case .exit:
subscription.isSessionActive = false
default:

View file

@ -57,7 +57,7 @@ struct EnhancedConnectionView: View {
Spacer(minLength: 50)
}
.padding()
}
}
.scrollBounceBehavior(.basedOnSize)
}
.toolbar(.hidden, for: .navigationBar)

View file

@ -116,11 +116,10 @@ struct SessionCreateView: View {
// Error Message
if presentedError != nil {
ErrorBanner(
message: presentedError?.error.localizedDescription ?? "An error occurred",
onDismiss: {
message: presentedError?.error.localizedDescription ?? "An error occurred"
) {
presentedError = nil
}
)
.overlay(
RoundedRectangle(cornerRadius: Theme.CornerRadius.small)
.stroke(Theme.Colors.errorAccent.opacity(0.3), lineWidth: 1)

View file

@ -388,7 +388,6 @@ struct SessionListView: View {
}
}
/// View model for managing session list state and operations.
@MainActor
@Observable
@ -463,8 +462,8 @@ struct SessionHeaderView: View {
let onKillAll: () -> Void
let onCleanupAll: () -> Void
private var runningCount: Int { sessions.count { $0.isRunning }}
private var exitedCount: Int { sessions.count { !$0.isRunning }}
private var runningCount: Int { sessions.count { $0.isRunning } }
private var exitedCount: Int { sessions.count { !$0.isRunning } }
var body: some View {
VStack(spacing: Theme.Spacing.medium) {

View file

@ -69,9 +69,8 @@ struct CtrlKeyGrid: View {
ForEach(currentKeys, id: \.0) { key, description in
CtrlGridKeyButton(
key: key,
description: description,
onPress: { sendCtrlKey(key) }
)
description: description
) { sendCtrlKey(key) }
}
}
.padding()
@ -144,7 +143,7 @@ struct CtrlGridKeyButton: View {
@State private var showingTooltip = false
var body: some View {
Button(action: onPress, label: {
Button(action: onPress) {
VStack(spacing: 4) {
Text("^" + key)
.font(Theme.Typography.terminalSystem(size: 20, weight: .bold))
@ -171,7 +170,7 @@ struct CtrlGridKeyButton: View {
color: isPressed ? Theme.Colors.primaryAccent.opacity(0.3) : .clear,
radius: isPressed ? 8 : 0
)
})
}
.buttonStyle(PlainButtonStyle())
.scaleEffect(isPressed ? 0.95 : 1.0)
.animation(.easeInOut(duration: 0.1), value: isPressed)

View file

@ -14,7 +14,7 @@ struct TerminalBufferPreview: View {
}
var body: some View {
GeometryReader { geometry in
GeometryReader { _ in
ScrollViewReader { scrollProxy in
ScrollView([.horizontal, .vertical], showsIndicators: false) {
VStack(alignment: .leading, spacing: 0) {

View file

@ -523,12 +523,11 @@ struct TerminalView: View {
.focused($isInputFocused)
.overlay(
ScrollToBottomButton(
isVisible: showScrollToBottom,
action: {
isVisible: showScrollToBottom
) {
viewModel.scrollToBottom()
showScrollToBottom = false
}
)
.padding(.bottom, Theme.Spacing.large)
.padding(.leading, Theme.Spacing.large),
alignment: .bottomLeading

View file

@ -230,15 +230,14 @@ final class BunServer {
}
} catch {
// Log more detailed error information
let errorMessage: String
if let bunError = error as? BunServerError {
errorMessage = bunError.localizedDescription
let errorMessage: String = if let bunError = error as? BunServerError {
bunError.localizedDescription
} else if let urlError = error as? URLError {
errorMessage = "Network error: \(urlError.localizedDescription) (Code: \(urlError.code.rawValue))"
"Network error: \(urlError.localizedDescription) (Code: \(urlError.code.rawValue))"
} else if let posixError = error as? POSIXError {
errorMessage = "System error: \(posixError.localizedDescription) (Code: \(posixError.code.rawValue))"
"System error: \(posixError.localizedDescription) (Code: \(posixError.code.rawValue))"
} else {
errorMessage = error.localizedDescription
error.localizedDescription
}
logger.error("Failed to start Bun server: \(errorMessage)")

View file

@ -12,33 +12,33 @@ enum ServerError: LocalizedError {
var errorDescription: String? {
switch self {
case .repeatedCrashes:
return "Server keeps crashing"
"Server keeps crashing"
case .portInUse(let port):
return "Port \(port) is already in use"
"Port \(port) is already in use"
case .startupFailed(let reason):
return "Server startup failed: \(reason)"
"Server startup failed: \(reason)"
}
}
var failureReason: String? {
switch self {
case .repeatedCrashes(let count):
return "The server crashed \(count) times in a row"
"The server crashed \(count) times in a row"
case .portInUse(let port):
return "Another process is using port \(port)"
"Another process is using port \(port)"
case .startupFailed:
return nil
nil
}
}
var recoverySuggestion: String? {
switch self {
case .repeatedCrashes:
return "Check the logs for errors or try a different port"
"Check the logs for errors or try a different port"
case .portInUse:
return "Stop the other process or choose a different port"
"Stop the other process or choose a different port"
case .startupFailed:
return "Check the server configuration and try again"
"Check the server configuration and try again"
}
}
}
@ -508,28 +508,28 @@ enum ServerManagerError: LocalizedError {
var errorDescription: String? {
switch self {
case .portInUseByApp(let appName, let port, _):
return "Port \(port) is in use by \(appName)"
"Port \(port) is in use by \(appName)"
}
}
var failureReason: String? {
switch self {
case .portInUseByApp:
return "The port is being used by another application"
"The port is being used by another application"
}
}
var recoverySuggestion: String? {
switch self {
case .portInUseByApp(_, _, let alternatives):
return "Try one of these ports: \(alternatives.map(String.init).joined(separator: ", "))"
"Try one of these ports: \(alternatives.map(String.init).joined(separator: ", "))"
}
}
var helpAnchor: String? {
switch self {
case .portInUseByApp:
return "port-conflict"
"port-conflict"
}
}
}

View file

@ -31,7 +31,9 @@ extension View {
_ title: String = "Error",
error: Binding<Error?>,
onDismiss: (() -> Void)? = nil
) -> some View {
)
-> some View
{
modifier(ErrorAlertModifier(error: error, title: title, onDismiss: onDismiss))
}
}
@ -46,7 +48,9 @@ extension Task where Failure == Error {
priority: TaskPriority? = nil,
errorBinding: Binding<Error?>,
operation: @escaping () async throws -> T
) -> Task<T, Error> {
)
-> Task<T, Error>
{
Task<T, Error>(priority: priority) {
do {
return try await operation()
@ -142,7 +146,7 @@ struct AsyncErrorBoundary<Content: View>: View {
// MARK: - Environment Values
private struct AsyncErrorHandlerKey: EnvironmentKey {
nonisolated(unsafe) static let defaultValue = AsyncErrorHandler(handler: { _ in })
nonisolated(unsafe) static let defaultValue = AsyncErrorHandler { _ in }
}
extension EnvironmentValues {

View file

@ -219,9 +219,9 @@ struct ServerStatusView: View {
private var statusText: String {
if isRunning {
return "Server running"
"Server running"
} else {
return "Server stopped"
"Server stopped"
}
}

View file

@ -1,5 +1,5 @@
import SwiftUI
import os
import SwiftUI
/// View displaying detailed information about a specific terminal session
struct SessionDetailView: View {

View file

@ -685,82 +685,82 @@ private struct PortConfigurationView: View {
// Port conflict warning
if let conflict = portConflict {
VStack(alignment: .leading, spacing: 6) {
HStack(spacing: 4) {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundColor(.orange)
.font(.caption)
VStack(alignment: .leading, spacing: 6) {
HStack(spacing: 4) {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundColor(.orange)
.font(.caption)
Text("Port \(conflict.port) is used by \(conflict.process.name)")
.font(.caption)
.foregroundColor(.orange)
}
Text("Port \(conflict.port) is used by \(conflict.process.name)")
.font(.caption)
.foregroundColor(.orange)
}
HStack(spacing: 8) {
if !conflict.alternativePorts.isEmpty {
HStack(spacing: 4) {
Text("Try port:")
.font(.caption)
.foregroundStyle(.secondary)
HStack(spacing: 8) {
if !conflict.alternativePorts.isEmpty {
HStack(spacing: 4) {
Text("Try port:")
.font(.caption)
.foregroundStyle(.secondary)
ForEach(conflict.alternativePorts.prefix(3), id: \.self) { port in
Button(String(port)) {
serverPort = String(port)
portNumber = port
restartServerWithNewPort(port)
ForEach(conflict.alternativePorts.prefix(3), id: \.self) { port in
Button(String(port)) {
serverPort = String(port)
portNumber = port
restartServerWithNewPort(port)
}
.buttonStyle(.link)
.font(.caption)
}
Button("Choose...") {
showPortPicker()
}
.buttonStyle(.link)
.font(.caption)
}
}
Button("Choose...") {
showPortPicker()
Spacer()
Button {
Task {
await forceQuitConflictingProcess(conflict)
}
} label: {
HStack(spacing: 4) {
Image(systemName: "xmark.circle.fill")
.font(.caption)
Text("Kill Process")
.font(.caption)
}
.buttonStyle(.link)
.font(.caption)
}
.buttonStyle(.borderedProminent)
.controlSize(.small)
.tint(.red)
}
Spacer()
Button {
Task {
await forceQuitConflictingProcess(conflict)
}
} label: {
HStack(spacing: 4) {
Image(systemName: "xmark.circle.fill")
.font(.caption)
Text("Kill Process")
.font(.caption)
}
}
.buttonStyle(.borderedProminent)
.controlSize(.small)
.tint(.red)
}
}
.padding(.vertical, 8)
.padding(.horizontal, 12)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Color.orange.opacity(0.1))
.cornerRadius(6)
} else if !serverManager.isRunning && serverManager.lastError != nil {
// Show general server error if no specific port conflict
HStack(spacing: 4) {
Image(systemName: "exclamationmark.circle.fill")
.foregroundColor(.red)
.font(.caption)
.padding(.vertical, 8)
.padding(.horizontal, 12)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Color.orange.opacity(0.1))
.cornerRadius(6)
} else if !serverManager.isRunning && serverManager.lastError != nil {
// Show general server error if no specific port conflict
HStack(spacing: 4) {
Image(systemName: "exclamationmark.circle.fill")
.foregroundColor(.red)
.font(.caption)
Text("Server failed to start")
Text("Server failed to start")
.font(.caption)
.foregroundColor(.red)
}
} else {
Text("The server will automatically restart when the port is changed.")
.font(.caption)
.foregroundColor(.red)
}
} else {
Text("The server will automatically restart when the port is changed.")
.font(.caption)
.foregroundStyle(.secondary)
.padding(.top, 4)
.foregroundStyle(.secondary)
.padding(.top, 4)
}
}
}

View file

@ -1,5 +1,5 @@
import SwiftUI
import os
import SwiftUI
/// Shared glowing app icon component with configurable animation and effects.
///
@ -7,7 +7,7 @@ import os
/// floating animation, and interactive behaviors. It can be used in both the Welcome
/// and About views with different configurations.
struct GlowingAppIcon: View {
// Configuration
/// Configuration
let size: CGFloat
private let logger = Logger(subsystem: "sh.vibetunnel.vibetunnel", category: "GlowingAppIcon")

View file

@ -1,8 +1,8 @@
import AppKit
import Foundation
import Observation
import os.log
import SwiftUI
import Observation
/// Terminal launch result with window/tab information
struct TerminalLaunchResult {
@ -689,7 +689,7 @@ final class TerminalLauncher {
let fullCommand: String
// Check if we have a Bun executable (it would be bundled as vibetunnel)
let bunServerActive = Bundle.main.path(forResource: "vibetunnel", ofType: nil) != nil &&
!command.contains("TTY_SESSION_ID=") // If command already has session ID, it's from Go server
!command.contains("TTY_SESSION_ID=") // If command already has session ID, it's from Go server
if bunServerActive {
// For Bun server, use fwd command
logger.info("Using Bun server session creation via fwd")

View file

@ -163,6 +163,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, @preconcurrency UNUser
}
// Initialize dock icon visibility through DockIconManager
DockIconManager.initialize()
DockIconManager.shared.updateDockVisibility()
// Show welcome screen when version changes
@ -320,7 +321,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, @preconcurrency UNUser
@objc
private func openDashboard() {
if let serverManager = app?.serverManager,
let url = URL(string: "http://localhost:\(serverManager.port)") {
let url = URL(string: "http://localhost:\(serverManager.port)")
{
NSWorkspace.shared.open(url)
}
}