Repository navigation
Fix missing command palette open-in targets #1621
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 4 commits
48d034b
2863ed8
f370426
f4cc7c8
b65c794
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 |
|---|---|---|
|
|
@@ -299,6 +299,7 @@ final class CommandPaletteAllSurfacesUITests: XCTestCase { | |
| private var socketPath = "" | ||
| private let hiddenSurfaceToken = "cmux-command-palette-hidden-surface" | ||
| private let visibleSurfaceToken = "cmux-command-palette-visible-surface" | ||
| private let noMatchWorkspaceQuery = "cmux-command-palette-no-match" | ||
|
|
||
| override func setUp() { | ||
| super.setUp() | ||
|
|
@@ -475,6 +476,69 @@ final class CommandPaletteAllSurfacesUITests: XCTestCase { | |
| ) | ||
| } | ||
|
|
||
| func testSwitcherEmptyStateDoesNotBlinkWhileRefiningNoMatchQuery() throws { | ||
| let app = XCUIApplication() | ||
| app.launchArguments += ["-AppleLanguages", "(en)", "-AppleLocale", "en_US"] | ||
| app.launchEnvironment["CMUX_UI_TEST_MODE"] = "1" | ||
| app.launchEnvironment["CMUX_SOCKET_PATH"] = socketPath | ||
| launchAndActivate(app) | ||
|
|
||
| XCTAssertTrue( | ||
| sidebarHelpPollUntil(timeout: 8.0) { | ||
| app.windows.count >= 1 | ||
| }, | ||
| "Expected the main window to be visible" | ||
| ) | ||
| XCTAssertTrue(waitForSocketPong(timeout: 12.0), "Expected control socket at \(socketPath)") | ||
|
|
||
| let mainWindowId = try XCTUnwrap( | ||
| socketCommand("current_window")?.trimmingCharacters(in: .whitespacesAndNewlines) | ||
| ) | ||
| try seedWorkspaceSwitcherCorpus(workspaceCount: 96) | ||
|
|
||
| let searchField = app.textFields["CommandPaletteSearchField"] | ||
| app.typeKey("p", modifierFlags: [.command]) | ||
| XCTAssertTrue(searchField.waitForExistence(timeout: 5.0), "Expected command palette search field") | ||
| searchField.click() | ||
|
|
||
| try debugTypeText(String(repeating: "z", count: 8)) | ||
|
|
||
| let emptyLabel = app.staticTexts["No workspaces match your search."].firstMatch | ||
| XCTAssertTrue( | ||
| sidebarHelpPollUntil(timeout: 5.0) { | ||
| guard emptyLabel.exists else { return false } | ||
| guard let snapshot = commandPaletteSnapshot(windowId: mainWindowId) else { return false } | ||
| return (snapshot["query"] as? String) == String(repeating: "z", count: 8) | ||
| && self.commandPaletteResultRows(from: snapshot).isEmpty | ||
| }, | ||
| "Expected the switcher to reach a visible no-results state before refining the query" | ||
| ) | ||
|
|
||
| try debugTypeText("z") | ||
|
|
||
| let emptyLabelDisappearedWhileRefining = sidebarHelpPollUntil(timeout: 0.5, pollInterval: 0.01) { | ||
| !emptyLabel.exists | ||
| } | ||
| XCTAssertFalse( | ||
| emptyLabelDisappearedWhileRefining, | ||
| "Expected refining an already-empty switcher query to keep the empty-state label visible" | ||
| ) | ||
|
|
||
| let refinedSnapshot = try XCTUnwrap( | ||
| waitForCommandPaletteSnapshot( | ||
| windowId: mainWindowId, | ||
| query: String(repeating: "z", count: 9), | ||
| timeout: 5.0 | ||
| ) { snapshot in | ||
| self.commandPaletteResultRows(from: snapshot).isEmpty | ||
| } | ||
| ) | ||
|
Comment on lines
+519
to
+535
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 no-blink assertion stops well before the refined query is allowed to settle. You only watch the empty-state label for 0.5s, but the refined snapshot is allowed 5s to arrive. On slower CI, the label can disappear after that 0.5s window and this still passes. Keep the visibility check running until the 9-character snapshot is observed. 🤖 Prompt for AI Agents |
||
| XCTAssertTrue( | ||
| commandPaletteResultRows(from: refinedSnapshot).isEmpty, | ||
| "Expected the refined no-match query to stay empty. snapshot=\(refinedSnapshot)" | ||
| ) | ||
| } | ||
|
Comment on lines
+479
to
+540
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. This regression test is scoped to shared command-palette refresh behavior, not the open-target fix. It locks a “no blink while refining” guarantee onto shared switcher refresh infrastructure, so this PR now depends on a broader UX behavior that maintainers have explicitly asked to keep out of feature-scoped changes. Based on learnings, " 🤖 Prompt for AI Agents |
||
|
|
||
| private func launchAndActivate(_ app: XCUIApplication) { | ||
| app.launch() | ||
| XCTAssertTrue( | ||
|
|
@@ -592,6 +656,46 @@ final class CommandPaletteAllSurfacesUITests: XCTestCase { | |
| return UUID(uuidString: value) != nil ? value : nil | ||
| } | ||
|
|
||
| private func debugTypeText(_ text: String) throws { | ||
| let response = try XCTUnwrap( | ||
| socketJSON( | ||
| method: "debug.type", | ||
| params: ["text": text] | ||
| ), | ||
| "Expected a response from debug.type" | ||
| ) | ||
| XCTAssertEqual(response["ok"] as? Bool, true, "Expected debug.type to succeed. response=\(response)") | ||
| } | ||
|
|
||
| private func seedWorkspaceSwitcherCorpus(workspaceCount: Int) throws { | ||
| guard workspaceCount > 1 else { return } | ||
|
|
||
| for index in 1..<workspaceCount { | ||
| let workspaceId = try XCTUnwrap( | ||
| okUUID(from: socketCommand("new_workspace")), | ||
| "Expected new_workspace to return a workspace ID" | ||
| ) | ||
| let title = "\(noMatchWorkspaceQuery)-\(index)-" + String(repeating: "workspace-", count: 8) | ||
| let response = try XCTUnwrap( | ||
| socketJSON( | ||
| method: "workspace.rename", | ||
| params: [ | ||
| "workspace_id": workspaceId, | ||
| "title": title, | ||
| ] | ||
| ), | ||
| "Expected a response from workspace.rename" | ||
| ) | ||
| XCTAssertEqual( | ||
| response["ok"] as? Bool, | ||
| true, | ||
| "Expected workspace.rename to succeed. response=\(response)" | ||
| ) | ||
| } | ||
|
|
||
| XCTAssertEqual(socketCommand("select_workspace 0"), "OK") | ||
| } | ||
|
|
||
| private func socketCommand(_ command: String) -> String? { | ||
| ControlSocketClient(path: socketPath, responseTimeout: 2.0).sendLine(command) | ||
| } | ||
|
|
||
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.
Assert that the seeded switcher corpus is actually searchable before the no-match check.
seedWorkspaceSwitcherCorpusonly sendsnew_workspace/workspace.rename; it never waits for those titles to land in switcher results. If indexing lags, this test can pass against the default workspace set and stop exercising the large-corpus path it is supposed to cover.Also applies to: 670-698
🤖 Prompt for AI Agents