-
Notifications
You must be signed in to change notification settings - Fork 59
[macOS] Add quick feedback popup with toolbar button, screenshot, and diagnostics for internal users #4467
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
Open
samhouts
wants to merge
15
commits into
main
Choose a base branch
from
shouts/quickfeedback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[macOS] Add quick feedback popup with toolbar button, screenshot, and diagnostics for internal users #4467
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0176189
Add quick internal feedback popup
samhouts 2f6d581
Merge branch 'main' into shouts/quickfeedback
samhouts d009e18
Add QuickFeedback feature and screenshot support
samhouts aacd853
Use design system feedback icon
samhouts 91f3f33
Merge branch 'main' into shouts/quickfeedback
samhouts 58c70f2
Isolate feedback store, sync cookies & messaging
samhouts e0c8875
Merge branch 'shouts/quickfeedback' of https://github.com/duckduckgo/…
samhouts de3e6f6
Make diagnostics testable; refine feedback cleanup
samhouts 9d59781
Hide feedback popup; remove textarea autofill
samhouts bd4aa62
Cleanup: remove whitespace and redundant comment
samhouts fab7c08
Use quickFeedbackService for internal requests
samhouts 9bf249e
Remove feedback form submission messaging
samhouts f3b966a
Merge branch 'main' into shouts/quickfeedback
samhouts 8615c34
Make sign-out bar height adjustable
samhouts 5e30cc6
Replace IOKit GPU detection with Metal
samhouts 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
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
133 changes: 133 additions & 0 deletions
133
macOS/DuckDuckGo/Feedback/QuickFeedback/QuickFeedbackDiagnosticsCollector.swift
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,133 @@ | ||
| // | ||
| // QuickFeedbackDiagnosticsCollector.swift | ||
| // | ||
| // Copyright © 2026 DuckDuckGo. All rights reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
|
|
||
| import AppKit | ||
| import Foundation | ||
| import IOKit | ||
|
|
||
| final class QuickFeedbackDiagnosticsCollector { | ||
|
|
||
| private weak var tabCountProvider: TabCountProviding? | ||
| private let launchDate: Date | ||
|
|
||
| init(tabCountProvider: TabCountProviding? = nil, launchDate: Date = Date()) { | ||
| self.tabCountProvider = tabCountProvider | ||
| self.launchDate = launchDate | ||
| } | ||
|
|
||
| func collectDiagnostics() -> String { | ||
| var lines = [String]() | ||
|
|
||
| lines.append("--- Diagnostics (auto-collected) ---") | ||
|
|
||
| let appVersionModel = AppVersionModel() | ||
| lines.append("App Version: \(appVersionModel.versionLabelShort) (\(appVersionModel.distributionLabel))") | ||
|
|
||
| let osVersion = ProcessInfo.processInfo.operatingSystemVersion | ||
| lines.append("macOS: \(osVersion.majorVersion).\(osVersion.minorVersion).\(osVersion.patchVersion)") | ||
|
|
||
| #if arch(arm64) | ||
| lines.append("Architecture: Apple Silicon (arm64)") | ||
| #elseif arch(x86_64) | ||
| lines.append("Architecture: Intel (x86_64)") | ||
| #else | ||
| lines.append("Architecture: unknown") | ||
| #endif | ||
|
|
||
| lines.append("GPU: \(gpuSummary())") | ||
| lines.append("Memory: \(memorySummary())") | ||
| lines.append("Disk: \(diskSummary())") | ||
|
|
||
| if let provider = tabCountProvider { | ||
| lines.append("Tabs: \(provider.tabCount) tabs / \(provider.windowCount) windows") | ||
| } | ||
|
|
||
| lines.append("Session: \(sessionLength())") | ||
|
|
||
| return lines.joined(separator: "\n") | ||
| } | ||
|
|
||
| // MARK: - Private | ||
|
|
||
| private func gpuSummary() -> String { | ||
| var iterator: io_iterator_t = 0 | ||
| let port: mach_port_t | ||
| if #available(macOS 12.0, *) { | ||
| port = kIOMainPortDefault | ||
| } else { | ||
| port = kIOMasterPortDefault | ||
| } | ||
| let result = IOServiceGetMatchingServices(port, IOServiceMatching("IOPCIDevice"), &iterator) | ||
| guard result == KERN_SUCCESS else { return "unknown" } | ||
| defer { IOObjectRelease(iterator) } | ||
|
|
||
| var names = [String]() | ||
| var entry: io_object_t = IOIteratorNext(iterator) | ||
| while entry != 0 { | ||
| if let modelData = IORegistryEntryCreateCFProperty(entry, "model" as CFString, kCFAllocatorDefault, 0)?.takeRetainedValue() as? Data, | ||
| let model = String(data: modelData.prefix(while: { $0 != 0 }), encoding: .utf8) { | ||
| names.append(model) | ||
| } | ||
| IOObjectRelease(entry) | ||
| entry = IOIteratorNext(iterator) | ||
| } | ||
|
|
||
| return names.isEmpty ? "unknown" : names.joined(separator: ", ") | ||
| } | ||
|
|
||
| private func memorySummary() -> String { | ||
| let physicalGB = Double(ProcessInfo.processInfo.physicalMemory) / 1_073_741_824.0 | ||
|
|
||
| var info = mach_task_basic_info() | ||
| var count = mach_msg_type_number_t(MemoryLayout<mach_task_basic_info>.size / MemoryLayout<natural_t>.size) | ||
| let result = withUnsafeMutablePointer(to: &info) { | ||
| $0.withMemoryRebound(to: integer_t.self, capacity: Int(count)) { | ||
| task_info(mach_task_self_, task_flavor_t(MACH_TASK_BASIC_INFO), $0, &count) | ||
| } | ||
| } | ||
|
|
||
| if result == KERN_SUCCESS { | ||
| let browserMB = info.resident_size / (1024 * 1024) | ||
| return String(format: "%llu MB browser, %.0f GB total", browserMB, physicalGB) | ||
| } | ||
| return String(format: "%.0f GB total", physicalGB) | ||
| } | ||
|
|
||
| private func diskSummary() -> String { | ||
| guard let homeURL = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first, | ||
| let values = try? homeURL.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey]), | ||
| let freeBytes = values.volumeAvailableCapacityForImportantUsage else { | ||
| return "unknown" | ||
| } | ||
| let freeGB = freeBytes / (1024 * 1024 * 1024) | ||
| return "\(freeGB) GB free" | ||
| } | ||
|
|
||
| private func sessionLength() -> String { | ||
| let uptime = Date().timeIntervalSince(launchDate) | ||
| if uptime < 60 { return "under a minute" } | ||
| if uptime < 3600 { return "\(Int(uptime / 60)) minutes" } | ||
| if uptime < 86400 { return "\(Int(uptime / 3600)) hours" } | ||
| return "\(Int(uptime / 86400)) days" | ||
| } | ||
| } | ||
|
|
||
| protocol TabCountProviding: AnyObject { | ||
| var tabCount: Int { get } | ||
| var windowCount: Int { get } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.