()
| 1601 | // MARK: - App Detection and Context-Aware Prompts |
| 1602 | |
| 1603 | private func getCurrentAppInfo() -> (name: String, bundleId: String, windowTitle: String) { |
| 1604 | if let frontmostApp = NSWorkspace.shared.frontmostApplication { |
| 1605 | let name = frontmostApp.localizedName ?? "Unknown" |
| 1606 | let bundleId = frontmostApp.bundleIdentifier ?? "unknown" |
| 1607 | let title = self.getFrontmostWindowTitle(ownerPid: frontmostApp.processIdentifier) ?? "" |
| 1608 | return (name: name, bundleId: bundleId, windowTitle: title) |
| 1609 | } |
| 1610 | return (name: "Unknown", bundleId: "unknown", windowTitle: "") |
| 1611 | } |
| 1612 | |
| 1613 | /// Best-effort frontmost window title lookup for the current app |
| 1614 | private func getFrontmostWindowTitle(ownerPid: pid_t) -> String? { |
no test coverage detected