Repository navigation
Fix session restore suppression on relaunch #2469
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,6 +229,39 @@ final class AppDelegateWindowContextRoutingTests: XCTestCase { | |
| XCTAssertNotNil(createdWorkspace) | ||
| XCTAssertEqual(createdWorkspace?.currentDirectory, droppedDirectory.path) | ||
| } | ||
|
|
||
| func testApplicationOpenURLsIgnoresBundleSelfPaths() { | ||
| _ = NSApplication.shared | ||
| let app = AppDelegate() | ||
|
|
||
| let windowId = UUID() | ||
| let window = makeMainWindow(id: windowId) | ||
| defer { window.orderOut(nil) } | ||
|
|
||
| let manager = TabManager() | ||
| app.registerMainWindow( | ||
| window, | ||
| windowId: windowId, | ||
| tabManager: manager, | ||
| sidebarState: SidebarState(), | ||
| sidebarSelectionState: SidebarSelectionState() | ||
| ) | ||
|
|
||
| window.makeKeyAndOrderFront(nil) | ||
| _ = app.synchronizeActiveMainWindowContext(preferredWindow: window) | ||
|
|
||
| let existingWorkspaceIds = Set(manager.tabs.map(\.id)) | ||
| let embeddedExecutableURL = Bundle.main.bundleURL | ||
| .appendingPathComponent("Contents/MacOS/cmux", isDirectory: false) | ||
|
|
||
| app.application( | ||
| NSApplication.shared, | ||
| open: [embeddedExecutableURL] | ||
| ) | ||
|
|
||
| let createdWorkspace = manager.tabs.first { !existingWorkspaceIds.contains($0.id) } | ||
| XCTAssertNil(createdWorkspace) | ||
| } | ||
|
Comment on lines
+233
to
+264
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stabilize onboarding preconditions so this regression can’t pass for the wrong reason. If first-run onboarding suppresses Suggested patch func testApplicationOpenURLsIgnoresBundleSelfPaths() {
_ = NSApplication.shared
let app = AppDelegate()
@@
window.makeKeyAndOrderFront(nil)
_ = app.synchronizeActiveMainWindowContext(preferredWindow: window)
+ let defaults = UserDefaults.standard
+ let previousWelcomeShown = defaults.object(forKey: WelcomeSettings.shownKey)
+ defaults.set(true, forKey: WelcomeSettings.shownKey)
+ defer {
+ if let previousWelcomeShown {
+ defaults.set(previousWelcomeShown, forKey: WelcomeSettings.shownKey)
+ } else {
+ defaults.removeObject(forKey: WelcomeSettings.shownKey)
+ }
+ }
+
let existingWorkspaceIds = Set(manager.tabs.map(\.id))
let embeddedExecutableURL = Bundle.main.bundleURL
.appendingPathComponent("Contents/MacOS/cmux", isDirectory: false)🤖 Prompt for AI Agents
Comment on lines
+233
to
+264
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The existing This new test skips that guard. Since the snapshot is captured before the call under test, any welcome-generated tab that appears after the snapshot would cause a false |
||
| } | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normalizedComparisonURLfor excluded root recomputed per-input-URLisSameOrDescendant(_:of:)is called inside an inner closure (excludedRootURLs.contains(where:)), sonormalizedComparisonURL(rootURL)— which callsresolvingSymlinksInPath()(a synchronous filesystem stat chain) — is re-executed on the sameexcludedRootURLonce for every URL in the input array.For the typical launch-time use (
excludedRootURLs = [Bundle.main.bundleURL], a handful of URLs), the overhead is negligible. But the current shape makes it easy for a future caller to pass a largepathURLsarray and unknowingly amplify the I/O. Pre-computing the normalised roots before the loop would eliminate the redundancy at zero semantic cost.