-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix blank terminal pane when notification fires on another tab #1155
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -749,6 +749,83 @@ final class WindowBackgroundSelectionGateTests: XCTestCase { | |
| } | ||
| } | ||
|
|
||
| final class WindowBackgroundSurfaceBackgroundGuaranteeTests: XCTestCase { | ||
| func testShouldApplyRejectsWhenOwningSelectionDiffersButSurfaceMustStayVisible() { | ||
| let surfaceTabId = UUID() | ||
| let differentSelectedTab = UUID() | ||
|
|
||
| let rejected = !GhosttyNSView.shouldApplyWindowBackground( | ||
| surfaceTabId: surfaceTabId, | ||
| owningManagerExists: true, | ||
| owningSelectedTabId: differentSelectedTab, | ||
| activeSelectedTabId: surfaceTabId | ||
| ) | ||
| XCTAssertTrue(rejected, "Guard should reject when owning selection differs — this is the #914 trigger condition") | ||
| } | ||
|
|
||
| func testShouldApplyRejectsWhenActiveSelectionDiffersWithNoOwningManager() { | ||
| let surfaceTabId = UUID() | ||
| let differentActiveTab = UUID() | ||
|
|
||
| let rejected = !GhosttyNSView.shouldApplyWindowBackground( | ||
| surfaceTabId: surfaceTabId, | ||
| owningManagerExists: false, | ||
| owningSelectedTabId: nil, | ||
| activeSelectedTabId: differentActiveTab | ||
| ) | ||
| XCTAssertTrue(rejected, "Guard should reject when active selection differs — surface background must still be maintained") | ||
| } | ||
| } | ||
|
|
||
| final class NotificationTabReorderDeferralTests: XCTestCase { | ||
| func testMoveTabToTopIsDeferredInsideAddNotification() throws { | ||
| let projectRoot = findProjectRoot() | ||
| let storeURL = projectRoot.appendingPathComponent("Sources/TerminalNotificationStore.swift") | ||
| let source = try String(contentsOf: storeURL, encoding: .utf8) | ||
|
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. P2: This test asserts source-code strings instead of runtime behavior, violating the repository test policy and creating brittle regression coverage. Prompt for AI agents |
||
|
|
||
| guard let methodStart = source.range(of: "func addNotification(tabId:") else { | ||
| XCTFail("Failed to locate addNotification(tabId:) in TerminalNotificationStore.swift") | ||
| return | ||
| } | ||
|
|
||
| let searchRange = methodStart.upperBound..<source.endIndex | ||
| let methodEnd = source.range(of: "\n func ", range: searchRange)?.lowerBound ?? source.endIndex | ||
| let methodBody = String(source[methodStart.lowerBound..<methodEnd]) | ||
|
|
||
| XCTAssertTrue( | ||
| methodBody.contains("DispatchQueue.main.async"), | ||
| "addNotification must defer moveTabToTop via DispatchQueue.main.async (#914)." | ||
| ) | ||
| XCTAssertTrue( | ||
| methodBody.contains("moveTabToTop"), | ||
| "addNotification must call moveTabToTop for auto-reorder behavior." | ||
| ) | ||
|
|
||
| if let reorderStart = methodBody.range(of: "WorkspaceAutoReorderSettings.isEnabled()") { | ||
| let reorderSection = String(methodBody[reorderStart.lowerBound..<methodBody.endIndex]) | ||
| if let asyncStart = reorderSection.range(of: "DispatchQueue.main.async") { | ||
| let beforeAsync = String(reorderSection[reorderSection.startIndex..<asyncStart.lowerBound]) | ||
| XCTAssertFalse( | ||
| beforeAsync.contains("moveTabToTop"), | ||
| "moveTabToTop must be inside the DispatchQueue.main.async block, not before it (#914)." | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func findProjectRoot() -> URL { | ||
| var dir = URL(fileURLWithPath: #file).deletingLastPathComponent().deletingLastPathComponent() | ||
| for _ in 0..<10 { | ||
| let marker = dir.appendingPathComponent("GhosttyTabs.xcodeproj") | ||
| if FileManager.default.fileExists(atPath: marker.path) { | ||
| return dir | ||
| } | ||
| dir = dir.deletingLastPathComponent() | ||
| } | ||
| return URL(fileURLWithPath: FileManager.default.currentDirectoryPath) | ||
| } | ||
|
Comment on lines
+780
to
+826
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. Test does not verify the claimed deferral behavior. The test claims to validate that
The verbose comments (lines 797-806, 810-813, 822-828) describe the intent, but the actual test body doesn't enforce it. Per learnings, tests should verify observable runtime behavior through executable paths. Consider either:
Based on learnings: "Tests must verify observable runtime behavior through executable paths (unit/integration/e2e/CLI), not implementation shape". 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| final class NotificationBurstCoalescerTests: XCTestCase { | ||
| func testSignalsInSameBurstFlushOnce() { | ||
| let coalescer = NotificationBurstCoalescer(delay: 0.01) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.