Repository navigation
Fix branch name sanitization and improve UI refresh state handling #63
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7770bc7
fix: Improve branch name sanitization and refresh UI state
Tranthanh98 9e80fc7
feat: Open pull request details in a dedicated window
Tranthanh98 9d46358
fix: Refresh branch badges after local repository state changes
Tranthanh98 f9e7003
perf: Avoid redundant pull request list refreshes
Tranthanh98 bd44c7a
fix: address branch sanitization and refresh review feedback
Tranthanh98 4bff136
fix: Keep cached PRs visible during revalidation
Tranthanh98 130c566
Merge branch 'chore/fix-and-improve-re-render-ui' of https://github.c…
Tranthanh98 8e23b05
refactor: Restructure fetch and pull sheets into consistent layouts
Tranthanh98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
|
||
| import AppKit | ||
| import SwiftUI | ||
|
|
||
| @MainActor | ||
| final class PullRequestDetailWindowController: NSWindowController, NSWindowDelegate { | ||
| private var onClose: (() -> Void)? | ||
|
|
||
| init() { | ||
| super.init(window: nil) | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| func activateIfPresented() -> Bool { | ||
| guard let window else { return false } | ||
| window.makeKeyAndOrderFront(nil) | ||
| return true | ||
| } | ||
|
|
||
| func show<Content: View>(title: String, content: Content, onClose: @escaping () -> Void) { | ||
| close() | ||
| self.onClose = onClose | ||
| let screen = NSApp.keyWindow?.screen ?? NSScreen.main | ||
| let visibleFrame = screen?.visibleFrame ?? NSRect(x: 0, y: 0, width: 1200, height: 800) | ||
| let size = NSSize(width: min(1200, visibleFrame.width - 40), | ||
| height: min(800, visibleFrame.height - 80)) | ||
| let window = NSWindow(contentRect: NSRect(origin: .zero, size: size), | ||
| styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false) | ||
| window.title = title | ||
| window.isReleasedWhenClosed = false | ||
| window.tabbingMode = .disallowed | ||
| window.collectionBehavior = [.fullScreenNone] | ||
| window.standardWindowButton(.miniaturizeButton)?.isHidden = true | ||
| window.standardWindowButton(.zoomButton)?.isHidden = true | ||
| window.delegate = self | ||
| let hostingView = NSHostingView(rootView: GeometryReader { geometry in | ||
| content.frame(width: geometry.size.width, height: geometry.size.height) | ||
| }) | ||
| // Window geometry owns the viewport; diff content must not expand the window. | ||
| hostingView.sizingOptions = [] | ||
| window.contentView = hostingView | ||
| window.contentMinSize = NSSize(width: min(960, size.width), height: min(560, size.height)) | ||
| window.setContentSize(size) | ||
| window.setFrameOrigin(NSPoint(x: visibleFrame.midX - window.frame.width / 2, | ||
| y: visibleFrame.midY - window.frame.height / 2)) | ||
| self.window = window | ||
| showWindow(nil) | ||
| window.makeKeyAndOrderFront(nil) | ||
| } | ||
|
|
||
| func windowWillClose(_ notification: Notification) { | ||
| let callback = onClose | ||
| onClose = nil | ||
| window = nil | ||
| callback?() | ||
| } | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: Commit-Plus/commit-plus
Length of output: 5521
🏁 Script executed:
Repository: Commit-Plus/commit-plus
Length of output: 16305
🏁 Script executed:
sed -n '235,390p' macgit/App/PullRequestController.swiftRepository: Commit-Plus/commit-plus
Length of output: 6353
Honor the list cache expiry before fetching.
When
diskCache.entryreturns a fresh page andforceRefreshis false, apply the cached page and return. Continue fetching for expired entries and forced refreshes. The current flow always callsservice.listPullRequests, so opening the list within its 120-second TTL makes a redundant provider request and can show an error despite fresh cached data.Suggested fix
🤖 Prompt for AI Agents