Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: start coder connect on launch after SE is installed#113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 1 commit intomainfromethan/only-start-when-ready
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletionsCoder-Desktop/Coder-Desktop/Coder_DesktopApp.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
vpn = CoderVPNService()
state = AppState(onChange: vpn.configureTunnelProviderProtocol)
fileSyncDaemon = MutagenDaemon()
if state.startVPNOnLaunch {
vpn.startWhenReady = true
}
vpn.installSystemExtension()
}

func applicationDidFinishLaunching(_: Notification) {
Expand DownExpand Up@@ -68,16 +72,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if await !vpn.loadNetworkExtensionConfig() {
state.reconfigure()
}
if state.startVPNOnLaunch {
await vpn.start()
}
}
// TODO: Start the daemon only once a file sync is configured
Task {
await fileSyncDaemon.start()
}
}

deinit {
NotificationCenter.default.removeObserver(self)
}

Comment on lines +82 to +85
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Drive-by fix: this was on the wrong class, though that wasn't causing any issues.

// This function MUST eventually call `NSApp.reply(toApplicationShouldTerminate: true)`
// or return `.terminateNow`
func applicationShouldTerminate(_: NSApplication) -> NSApplication.TerminateReply {
Expand Down
22 changes: 17 additions & 5 deletionsCoder-Desktop/Coder-Desktop/VPN/VPNService.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,16 @@ enum VPNServiceState: Equatable {
case disconnecting
case connected
case failed(VPNServiceError)

var canBeStarted: Bool {
switch self {
// A tunnel failure should not prevent a reconnect attempt
case .disabled, .failed:
true
default:
false
}
}
}

enum VPNServiceError: Error, Equatable {
Expand DownExpand Up@@ -54,11 +64,18 @@ final class CoderVPNService: NSObject, VPNService {
guard neState == .enabled || neState == .disabled else {
return .failed(.networkExtensionError(neState))
}
if startWhenReady, tunnelState.canBeStarted {
startWhenReady = false
Task { await start() }
}
return tunnelState
}

@Published var menuState: VPNMenuState = .init()

// Whether the VPN should start as soon as possible
var startWhenReady: Bool = false

// systemExtnDelegate holds a reference to the SystemExtensionDelegate so that it doesn't get
// garbage collected while the OSSystemExtensionRequest is in flight, since the OS framework
// only stores a weak reference to the delegate.
Expand All@@ -68,11 +85,6 @@ final class CoderVPNService: NSObject, VPNService {

override init() {
super.init()
installSystemExtension()
}

deinit {
NotificationCenter.default.removeObserver(self)
}

func start() async {
Expand Down
6 changes: 6 additions & 0 deletionsCoder-Desktop/Coder-DesktopTests/LoginFormTests.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,6 +107,12 @@ struct LoginTests {
data: [.get: Client.encoder.encode(buildInfo)]
).register()

try Mock(
url: url.appendingPathComponent("/api/v2/users/me"),
statusCode: 200,
data: [.get: Client.encoder.encode(User(id: UUID(), username: "username"))]
).register()

Comment on lines +110 to +115
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Drive-by fix: We need to mock this route as the token is validated before the server version.

try await ViewHosting.host(view) {
try await sut.inspection.inspect { view in
try view.find(ViewType.TextField.self).setInput(url.absoluteString)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp