Merged
Conversation
edc5ff8 to
0d051dd
Compare
Contributor
Greptile OverviewGreptile SummaryThis PR successfully ports Electron service's window management functionality to Tauri, implementing automatic focus detection and window switching capabilities. Key Changes:
Implementation Quality:
The code is well-tested with both unit tests and E2E tests, and the window management logic is generic and framework-agnostic like the Electron service it was ported from. Confidence Score: 4.5/5
|
| Filename | Overview |
|---|---|
| packages/tauri-service/src/window.ts | New file implementing window management functionality ported from Electron service, includes focus detection and window switching logic |
| packages/tauri-plugin/src/commands.rs | Added three window management commands: get_active_window_label, list_windows, and get_window_states |
| packages/tauri-service/test/window.spec.ts | Unit tests for window management functions, all tests are correctly implemented and passing |
| fixtures/e2e-apps/tauri/src-tauri/src/main.rs | Added switch_to_main command and splash window creation logic for testing window management |
| packages/tauri-service/src/service.ts | Integrated ensureActiveWindowFocus into beforeCommand hook to automatically manage window focus |
Sequence Diagram
sequenceDiagram
participant Test as Test Code
participant Service as TauriWorkerService
participant Window as window.ts
participant Browser as WebDriver Browser
participant Plugin as Tauri Plugin (Rust)
participant App as Tauri App
Test->>Browser: Execute DOM command (e.g., getTitle)
Browser->>Service: beforeCommand hook triggered
Service->>Window: ensureActiveWindowFocus(browser, commandName)
alt Command requires focus check
Window->>Browser: tauri.execute('get_window_states')
Browser->>Plugin: invoke('plugin:wdio|get_window_states')
Plugin->>App: Iterate webview_windows()
App-->>Plugin: Window details (label, title, is_visible, is_focused)
Plugin-->>Browser: WindowState[]
Browser-->>Window: states array
Window->>Window: findActiveWindow(states)
Note over Window: Priority: visible+focused > visible > focused > first
Window->>Browser: getTitle() - current window
Browser-->>Window: current title
alt Current title != active window title
Window->>Browser: getWindowHandles()
Browser-->>Window: handles array
loop For each handle
Window->>Browser: switchToWindow(handle)
Window->>Browser: getTitle()
Browser-->>Window: window title
Note over Window: Build titleToHandle map
end
Window->>Browser: switchToWindow(activeWindow.handle)
Note over Window: Switch to active window by exact title match
end
end
Window-->>Service: Focus ensured
Service-->>Browser: Continue with command execution
cbf2235 to
5fc17ad
Compare
5fc17ad to
f09c955
Compare
3bbe968 to
6415f91
Compare
c872a4e to
59f15ab
Compare
099df2b to
8190c06
Compare
8190c06 to
a044a9f
Compare
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Porting the electron service window management to tauri