From d701709c08f98a8b6e2791fcbb1e9291624e3236 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Thu, 04 Jun 2026 01:24:54 +0800
Subject: [PATCH] Prepare 7.8.12 App Store submission materials
---
Apptag/ContentView.swift | 187 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 168 insertions(+), 19 deletions(-)
diff --git a/Apptag/ContentView.swift b/Apptag/ContentView.swift
index 275e8d3..86e511f 100644
--- a/Apptag/ContentView.swift
+++ b/Apptag/ContentView.swift
@@ -318,6 +318,7 @@
var appDragResetToken = 0
var bubbleDraftNote = ""
var tagNavigationHoveredGroupName: String? = nil
+ var tagNavigationAppDropTargetName: String? = nil
var tagNavigationLastHoverScrollID: String? = nil
var tagNavigationLastHoverScrollAt: Date? = nil
}
@@ -387,6 +388,8 @@
@State private var quickSearchFocusToken = 0
@State private var quickSearchSelectionScrollToken = 0
@State private var quickSearchCloseHidesOverlay = false
+ @State private var quickSearchOnlySession = false
+ @State private var quickSearchOpenedAt: Date? = nil
@State private var quickSearchErrorMessage: String? = nil
@State private var initialQuickSearchConsumed = false
@@ -394,8 +397,10 @@
self.hideOverlay = hideOverlay
self.initialQuickSearchSource = initialQuickSearchSource
let startsInQuickSearch = initialQuickSearchSource != nil
+ let startsInQuickSearchOnlySession = initialQuickSearchSource == QuickSearchOpenSource.globalHidden
_quickSearchVisible = State(initialValue: startsInQuickSearch)
- _quickSearchCloseHidesOverlay = State(initialValue: initialQuickSearchSource == QuickSearchOpenSource.globalHidden)
+ _quickSearchCloseHidesOverlay = State(initialValue: startsInQuickSearchOnlySession)
+ _quickSearchOnlySession = State(initialValue: startsInQuickSearchOnlySession)
_quickSearchFocusToken = State(initialValue: startsInQuickSearch ? 1 : 0)
}
@@ -447,7 +452,10 @@
}
private var shouldRenderAppGridBehindQuickSearch: Bool {
- !quickSearchVisible || !quickSearchCloseHidesOverlay
+ if quickSearchOnlySession {
+ return false
+ }
+ return !quickSearchVisible || !quickSearchCloseHidesOverlay
}
var body: some View {
@@ -527,16 +535,23 @@
refreshAppsIfNeeded()
if let initialQuickSearchSource, !initialQuickSearchConsumed {
initialQuickSearchConsumed = true
- quickSearchCloseHidesOverlay = initialQuickSearchSource == QuickSearchOpenSource.globalHidden
+ if initialQuickSearchSource == QuickSearchOpenSource.globalHidden {
+ quickSearchCloseHidesOverlay = true
+ quickSearchOnlySession = true
+ }
if !quickSearchVisible {
quickSearchVisible = true
quickSearchFocusToken &+= 1
}
+ quickSearchOpenedAt = Date()
refreshQuickSearchResults()
NotificationCenter.default.post(
name: .tagLauncherQuickSearchVisibilityChanged,
object: nil,
- userInfo: ["active": true]
+ userInfo: [
+ "active": true,
+ "hideOverlayOnClose": quickSearchCloseHidesOverlay
+ ]
)
}
}
@@ -548,13 +563,16 @@
.onReceive(NotificationCenter.default.publisher(for: .tagLauncherOverlayDidHide)) { _ in
resetTransientDragState()
closeQuickSearch(notify: true, hideOverlayIfNeeded: false)
+ quickSearchOnlySession = false
+ quickSearchCloseHidesOverlay = false
}
.onReceive(NotificationCenter.default.publisher(for: .tagLauncherQuickSearchRequested)) { notification in
let source = notification.userInfo?["source"] as? String ?? QuickSearchOpenSource.mainOverlay
openQuickSearch(source: source)
}
- .onReceive(NotificationCenter.default.publisher(for: .tagLauncherQuickSearchDismissRequested)) { _ in
- closeQuickSearch()
+ .onReceive(NotificationCenter.default.publisher(for: .tagLauncherQuickSearchDismissRequested)) { notification in
+ let source = notification.userInfo?["source"] as? String
+ closeQuickSearch(dismissalSource: source)
}
.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in
guard allApps.isEmpty, !refreshInProgress else { return }
@@ -648,7 +666,7 @@
.ignoresSafeArea()
.contentShape(Rectangle())
.onTapGesture {
- closeQuickSearch()
+ closeQuickSearch(dismissalSource: QuickSearchDismissSource.backdrop)
}
.zIndex(899)
@@ -705,17 +723,26 @@
private func openQuickSearch(source: String) {
guard canOpenQuickSearch else { return }
dismissAppBubble()
- quickSearchCloseHidesOverlay = source == QuickSearchOpenSource.globalHidden
+ if source == QuickSearchOpenSource.globalHidden {
+ quickSearchOnlySession = true
+ }
+ quickSearchCloseHidesOverlay = quickSearchCloseHidesOverlay
+ || source == QuickSearchOpenSource.globalHidden
quickSearchVisible = true
+ quickSearchOpenedAt = Date()
quickSearchQuery = ""
quickSearchManualSelection = false
quickSearchErrorMessage = nil
quickSearchFocusToken &+= 1
refreshQuickSearchResults()
+ refreshApps()
NotificationCenter.default.post(
name: .tagLauncherQuickSearchVisibilityChanged,
object: nil,
- userInfo: ["active": true]
+ userInfo: [
+ "active": true,
+ "hideOverlayOnClose": quickSearchCloseHidesOverlay
+ ]
)
}
@@ -727,31 +754,71 @@
&& !quickSearchVisible
}
- private func closeQuickSearch(notify: Bool = true, hideOverlayIfNeeded: Bool = true) {
+ private func closeQuickSearch(
+ notify: Bool = true,
+ hideOverlayIfNeeded: Bool = true,
+ dismissalSource: String? = nil
+ ) {
+ Diagnostics.log("content.quickSearch.closeRequest", [
+ "source": dismissalSource,
+ "notify": notify,
+ "hideOverlayIfNeeded": hideOverlayIfNeeded,
+ "quickSearchVisible": quickSearchVisible,
+ "quickSearchCloseHidesOverlay": quickSearchCloseHidesOverlay,
+ "quickSearchOnlySession": quickSearchOnlySession
+ ])
+ if shouldIgnoreEarlyQuickSearchDismiss(from: dismissalSource) {
+ return
+ }
let shouldHideOverlay = quickSearchVisible && quickSearchCloseHidesOverlay && hideOverlayIfNeeded
guard quickSearchVisible else { return }
quickSearchVisible = false
+ quickSearchOpenedAt = nil
quickSearchQuery = ""
quickSearchResults = []
quickSearchSelectedID = nil
quickSearchManualSelection = false
quickSearchErrorMessage = nil
- quickSearchCloseHidesOverlay = false
if notify {
NotificationCenter.default.post(
name: .tagLauncherQuickSearchVisibilityChanged,
object: nil,
- userInfo: ["active": false]
+ userInfo: [
+ "active": false,
+ "hideOverlayOnClose": shouldHideOverlay
+ ]
)
}
if shouldHideOverlay {
hideOverlay()
+ } else {
+ quickSearchCloseHidesOverlay = false
}
+ }
+
+ private func shouldIgnoreEarlyQuickSearchDismiss(from source: String?) -> Bool {
+ guard quickSearchVisible,
+ let quickSearchOpenedAt,
+ source == QuickSearchDismissSource.mouse || source == QuickSearchDismissSource.backdrop
+ else { return false }
+
+ let age = Date().timeIntervalSince(quickSearchOpenedAt)
+ let gracePeriod: TimeInterval = quickSearchOnlySession ? 1.25 : 0.30
+ guard age < gracePeriod else { return false }
+ Diagnostics.log("content.quickSearch.ignoredEarlyDismiss", [
+ "source": source,
+ "age": String(format: "%.3f", age),
+ "gracePeriod": String(format: "%.2f", gracePeriod)
+ ])
+ return true
}
private func refreshQuickSearchResults() {
let previousSelection = quickSearchSelectedID
- quickSearchResults = QuickSearchEngine.search(quickSearchQuery, documents: quickSearchDocuments)
+ quickSearchResults = QuickSearchEngine.search(
+ quickSearchQuery,
+ documents: quickSearchDocuments.filter { FileManager.default.fileExists(atPath: $0.app.path.path) }
+ )
if quickSearchResults.isEmpty {
quickSearchSelectedID = nil
@@ -770,6 +837,11 @@
}
private func handleQuickSearchCommand(_ command: QuickSearchCommand) {
+ Diagnostics.log("content.quickSearch.command", [
+ "command": String(describing: command),
+ "quickSearchCloseHidesOverlay": quickSearchCloseHidesOverlay,
+ "quickSearchOnlySession": quickSearchOnlySession
+ ])
switch command {
case .moveUp:
moveQuickSearchSelection(by: -1)
@@ -923,6 +995,7 @@
private func appKitTagNavigation(orientation: TagNavigationView.Orientation) -> some View {
let isHorizontal = orientation == .horizontal
+ let appDropTargetID = appGridInteraction.tagNavigationAppDropTargetName
return TagNavigationView(
items: tagLabels,
orientation: orientation,
@@ -931,6 +1004,8 @@
: NSEdgeInsets(top: 12, left: 12, bottom: 12, right: 12),
dragModeActive: tagNavDragModeActive,
draggingItemID: tagNavDragItem,
+ appDragModeActive: appGridInteraction.appDragModeActive,
+ appDropTargetID: appDropTargetID,
onActivate: { tagID in
activateTagNavigation(tagID)
},
@@ -940,6 +1015,9 @@
canReorder: { tagID in
canReorderTag(tagID)
},
+ canAcceptAppDrop: { tagID in
+ canAssignDroppedAppToTag(tagID)
+ },
onReorderBegan: { tagID in
beginTagNavReorder(tagID)
},
@@ -948,6 +1026,12 @@
},
onReorderEnded: {
endTagNavReorder()
+ },
+ onAppDropHoverChange: { tagID, active in
+ handleTagNavigationAppDropHover(tagID, active: active)
+ },
+ onAppDrop: { path, source, targetTag, copy in
+ dropAppOnTagNavigation(path: path, sourceTag: source, targetTag: targetTag, copy: copy)
}
)
}
@@ -1732,7 +1816,9 @@
}
private func handleAppGridScrollActivity() {
- appGridInteraction.hoveredBubble = nil
+ if appGridInteraction.hoveredBubble != nil {
+ appGridInteraction.hoveredBubble = nil
+ }
}
private func handleBubbleHover(app: AppInfo, frame: CGRect, event: AppBubbleHoverEvent) {
@@ -1876,6 +1962,13 @@
}
private func handleTagNavigationHover(_ id: String, active: Bool) {
+ if appGridInteraction.appDragModeActive {
+ if !active, appGridInteraction.tagNavigationHoveredGroupName == id {
+ appGridInteraction.tagNavigationHoveredGroupName = nil
+ }
+ return
+ }
+
guard active else {
if appGridInteraction.tagNavigationHoveredGroupName == id {
appGridInteraction.tagNavigationHoveredGroupName = nil
@@ -1886,6 +1979,24 @@
appGridInteraction.tagNavigationHoveredGroupName = id
fillColorlessContainer(id)
scrollToTagFromHover(id)
+ }
+
+ private func handleTagNavigationAppDropHover(_ id: String, active: Bool) {
+ guard appGridInteraction.appDragModeActive else {
+ if appGridInteraction.tagNavigationAppDropTargetName == id {
+ appGridInteraction.tagNavigationAppDropTargetName = nil
+ }
+ return
+ }
+
+ guard active, canAssignDroppedAppToTag(id) else {
+ if appGridInteraction.tagNavigationAppDropTargetName == id {
+ appGridInteraction.tagNavigationAppDropTargetName = nil
+ }
+ return
+ }
+
+ appGridInteraction.tagNavigationAppDropTargetName = id
}
private func scrollToTagFromHover(_ id: String) {
@@ -2023,6 +2134,22 @@
)
showDropRefresh()
refreshApps(forceLayoutRefresh: true)
+ }
+
+ private func dropAppOnTagNavigation(path: String, sourceTag: String, targetTag: String, copy: Bool) {
+ resetTransientDragState()
+ guard canAssignDroppedAppToTag(targetTag) else { return }
+ guard let app = allApps.first(where: { $0.path.path == path }) else { return }
+ guard !appHasTag(app, tagName: targetTag) else { return }
+ TagEditor.appendTags([targetTag], to: [path])
+ showDropRefresh()
+ refreshApps(forceLayoutRefresh: true)
+ }
+
+ private func canAssignDroppedAppToTag(_ tagName: String) -> Bool {
+ tagColors[tagName] != nil
+ && !isAppleBuiltInDropTarget(tagName)
+ && !isUncategorizedDropTarget(tagName)
}
private func dropAppOutsideGroup(path: String, sourceTag: String, copy: Bool) {
@@ -2236,12 +2363,17 @@
if active {
endTagNavReorder()
clearAppBubbleState()
+ appGridInteraction.tagNavigationAppDropTargetName = nil
}
appGridInteraction.appDragModeActive = active
+ if !active {
+ appGridInteraction.tagNavigationAppDropTargetName = nil
+ }
if active {
DispatchQueue.main.asyncAfter(deadline: .now() + 8) {
if appGridInteraction.appDragModeActive && !AppDragCoordinator.shared.hasActiveDrag {
appGridInteraction.appDragModeActive = false
+ appGridInteraction.tagNavigationAppDropTargetName = nil
}
}
}
@@ -2255,6 +2387,9 @@
AppDragCoordinator.shared.cancelDrag()
if appGridInteraction.appDragModeActive {
appGridInteraction.appDragModeActive = false
+ }
+ if appGridInteraction.tagNavigationAppDropTargetName != nil {
+ appGridInteraction.tagNavigationAppDropTargetName = nil
}
if hadAppDragState {
appGridInteraction.appDragResetToken &+= 1
@@ -2280,7 +2415,7 @@
}
}
- func refreshApps(forceLayoutRefresh: Bool = false) {
+ func refreshApps(forceLayoutRefresh: Bool = false, useCache: Bool = true) {
guard !refreshInProgress else {
if forceLayoutRefresh {
refreshAgainAfterCurrent = true
@@ -2291,7 +2426,7 @@
refreshInProgress = true
DispatchQueue.global(qos: .userInitiated).async {
- let result = AppLibraryController.refresh()
+ let result = AppLibraryController.refresh(useCache: useCache)
DispatchQueue.main.async {
applyAppLibrarySnapshot(result.snapshot)
handleSmartStartRunResult(result.smartStartResult)
@@ -2328,6 +2463,20 @@
) {
appGridInteraction.appDragModeActive = false
endTagNavReorder()
+ guard FileManager.default.fileExists(atPath: app.path.path) else {
+ AppIndexer.invalidateScanCache()
+ refreshApps()
+ onFailure?()
+ return
+ }
+
+ let closeQuickSearchAndOverlayBeforeOpening = closeQuickSearchOnSuccess
+ && closeOverlayOnSuccess
+ && (quickSearchCloseHidesOverlay || quickSearchOnlySession)
+ if closeQuickSearchAndOverlayBeforeOpening {
+ closeQuickSearch(hideOverlayIfNeeded: true)
+ hideOverlay()
+ }
let configuration = NSWorkspace.OpenConfiguration()
NSWorkspace.shared.openApplication(at: app.path, configuration: configuration) { _, error in
DispatchQueue.main.async {
@@ -2339,10 +2488,10 @@
DispatchQueue.global(qos: .utility).async {
TagEditor.recordLauncherOpen(for: app.path.path)
}
- if closeQuickSearchOnSuccess {
- closeQuickSearch(hideOverlayIfNeeded: false)
+ if closeQuickSearchOnSuccess && !closeQuickSearchAndOverlayBeforeOpening {
+ closeQuickSearch(hideOverlayIfNeeded: closeOverlayOnSuccess)
}
- if closeOverlayOnSuccess {
+ if closeOverlayOnSuccess && !closeQuickSearchAndOverlayBeforeOpening {
hideOverlay()
}
}
--
Gitblit v1.9.3