diff --git a/crates/squid-platform/src/permissions.rs b/crates/squid-platform/src/permissions.rs index a1e5775..afaa2ec 100644 --- a/crates/squid-platform/src/permissions.rs +++ b/crates/squid-platform/src/permissions.rs @@ -582,6 +582,30 @@ mod windows { || trimmed.starts_with(r"\\") } + /// Store packages deny version-info reads to plain users, but their + /// install folder *is* the product identity: `…\WindowsApps\ + /// OpenAI.ChatGPT_1.2025_x64__w269v…\ChatGPT.exe` → "ChatGPT". Without + /// this every packaged app (ChatGPT, Terminal, Notepad) sinks into + /// 其他软件 even though the folder spells the product name out. + fn windows_store_product(path: &str) -> Option { + const MARK: &str = "\\windowsapps\\"; + let lowered = path.to_lowercase().replace('/', "\\"); + let at = lowered.find(MARK)? + MARK.len(); + // The scan lower-cases only to *locate* the folder; the slice from + // the original path keeps the real casing (`OpenAI.ChatGPT_…`). + let original = path.replace('/', "\\"); + let package = original[at..].split('\\').next()?; + let family = package.split('_').next()?; + let product = match family.split_once('.') { + // `Publisher.Product` — the product half is what users say. + Some((_, product)) if !product.trim().is_empty() => product, + Some((publisher, _)) => publisher, + None => family, + }; + let product = product.trim(); + (!product.is_empty()).then(|| product.to_string()) + } + /// Resolve `display_name` (and the software icon) for every scanned /// entry, once per binary. Also settles `target` / `target_exists`: the /// binary the row really runs, and whether it is still on disk (a missing @@ -621,6 +645,12 @@ mod windows { // software product when the binary carries real human strings; // everything else falls into the 其他软件 bucket. entry.named = description.is_some() || product.is_some(); + if !entry.named { + if let Some(product) = windows_store_product(&probed) { + entry.display_name = product; + entry.named = true; + } + } entry.icon = icon; } } @@ -2365,10 +2395,39 @@ mod windows { use super::{ approved_enabled, clean_module_path, exe_from_command, friendly_program_name, has_cjk, is_placeholder_label, module_folder_name, parse_csv_line, split_run_path, - task_settings_enabled, write_approved, CURRENT_VERSION, + task_settings_enabled, windows_store_product, write_approved, CURRENT_VERSION, }; use winreg::RegKey; + #[test] + fn store_packages_are_attributed_by_their_package_folder() { + // MSIX installs deny version-info reads, so the folder is the + // only honest product name: these must escape 其他软件. + assert_eq!( + windows_store_product( + r"C:\Program Files\WindowsApps\OpenAI.ChatGPT_1.2025.10.0_x64__w269v8zz8d6vy\ChatGPT.exe" + ) + .as_deref(), + Some("ChatGPT") + ); + assert_eq!( + windows_store_product( + r"C:\PROGRAM FILES\WINDOWSAPPS\Microsoft.WindowsTerminal_1.21\wt.exe" + ) + .as_deref(), + Some("WindowsTerminal") + ); + } + + #[test] + fn ordinary_paths_have_no_store_product() { + assert_eq!( + windows_store_product(r"D:\Program Files\Tencent\Weixin\Weixin.exe"), + None + ); + assert_eq!(windows_store_product("Weixin.exe"), None); + } + #[test] fn toggle_round_trips_through_the_approved_marker() { // The exact pair the UI toggle relies on: write_approved stores a diff --git a/src/pages/PermissionsPage.tsx b/src/pages/PermissionsPage.tsx index bffbfed..ff458eb 100644 --- a/src/pages/PermissionsPage.tsx +++ b/src/pages/PermissionsPage.tsx @@ -3,6 +3,7 @@ import { BellRing, ChevronRight, FolderOpen, + LayoutGrid, RefreshCw, Search, ShieldCheck, @@ -30,11 +31,6 @@ function scopeLabel(scope: string, t: (en: string, zh: string) => string): strin return scope === "machine" ? t("All users", "所有用户") : t("Current user", "当前用户"); } -// The icon shared by a software group: the first entry that carries one. -function softwareIcon(items: StartupItem[]): string { - return items.find((item) => item.icon)?.icon ?? ""; -} - // A row whose program binary no longer exists on disk — the config survived // an uninstall. MangoDisk calls these 残留项 and offers to delete the config. function isLeftover(item: StartupItem): boolean { @@ -78,6 +74,35 @@ function RowIcon({ icon, label }: { icon: string | null | undefined; label: stri ); } +// 其他软件 carries no real product identity, so it never rides a member's +// icon (ChatGPT's blue tile labelled 其他软件 read as a bug). A neutral +// apps-grid glyph says "a pile of things we could not attribute". +function GroupIcon({ + software, + items, + neutral, +}: { + software: string; + items: { icon: string | null }[]; + neutral: boolean; +}) { + if (neutral) { + return ( + + ); + } + const icon = items.find((item) => item.icon)?.icon; + return icon ? ( + + ) : ( + + ); +} + export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace }) { const { t } = useI18n(); const [query, setQuery] = useState(""); @@ -380,13 +405,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace }`} >

toggleGroupOpen(software)}> - {items.find((item) => item.icon)?.icon ? ( - - ) : ( - - )} + {software} {leftovers.length > 0 ? ( @@ -594,13 +613,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace return (

toggleExtGroupOpen(software)}> - {items.find((entry) => entry.icon)?.icon ? ( - e.icon)!.icon!} alt="" /> - ) : ( - - )} + {software} {allOn diff --git a/src/styles.css b/src/styles.css index 9adcb51..c6328fa 100644 --- a/src/styles.css +++ b/src/styles.css @@ -5002,6 +5002,16 @@ select:focus-visible, font-weight: var(--nex-weight-semibold); } +/* 其他软件 gets a neutral apps-grid glyph: the bucket carries no product + identity, so borrowing a member's icon (ChatGPT's tile, say) mislabels it. */ +.perm-group-icon-neutral { + display: inline-flex; + align-items: center; + justify-content: center; + background: #e8e4da; + color: #8d949e; +} + .perm-group b { color: #909fad; font-size: var(--nex-text-3xs);