diff --git a/crates/app/src/engine/pc_ports.rs b/crates/app/src/engine/pc_ports.rs index 12d93b33..6f7c9003 100644 --- a/crates/app/src/engine/pc_ports.rs +++ b/crates/app/src/engine/pc_ports.rs @@ -380,6 +380,7 @@ pub struct PortFiltersPatch { pub guided: Option, pub verified: Option, pub installed: Option, + pub platform: Option, } /// Reads `null` as `Some(None)` and a value as `Some(Some(value))`; a missing field stays `None`. @@ -1237,6 +1238,7 @@ impl PortsService { preferences: &preferences, facts: &facts, active_jobs: &active, + installs_supported: self.config.platform.supports_installs(), })) } @@ -1424,6 +1426,9 @@ fn apply_preferences(preferences: &mut PortPreferences, patch: &PortPreferencesP if let Some(installed) = filters.installed { preferences.installed = installed; } + if let Some(platform) = filters.platform { + preferences.platform_filter = platform; + } } if let Some(last_parent) = &patch.last_parent_folder { preferences.last_parent = last_parent.clone(); diff --git a/crates/app/src/engine/pc_ports/view.rs b/crates/app/src/engine/pc_ports/view.rs index 72f187ff..3615ee74 100644 --- a/crates/app/src/engine/pc_ports/view.rs +++ b/crates/app/src/engine/pc_ports/view.rs @@ -54,6 +54,8 @@ pub struct ViewInput<'a> { pub facts: &'a HashMap, /// Job ids the install runner currently owns. pub active_jobs: &'a HashSet, + /// False on a platform that serves the catalog without an install runner. + pub installs_supported: bool, } /// Builds the complete PC ports projection. @@ -77,6 +79,7 @@ pub fn build(input: ViewInput<'_>) -> PortsView { entry, installed_keys.get(&entry.catalog_id).cloned(), &facts, + input.installs_supported, ) }) .collect::>(); @@ -134,6 +137,7 @@ pub fn entry_view( entry: &CatalogEntry, installed_registration_key: Option, facts: &EntryFacts, + installs_supported: bool, ) -> PortEntryView { let pinned = entry .pinned_release @@ -149,11 +153,14 @@ pub fn entry_view( }); let withdrawn = !entry.withdrawn.is_empty() || facts.withdrawn; let no_asset_reason = facts.no_asset_reason; - let installable = entry.supports_windows() + let installable = installs_supported + && entry.supports_windows() && !withdrawn && (verified || pinned.is_some()) && no_asset_reason.is_none(); - let install_block_reason = if withdrawn { + let install_block_reason = if !installs_supported { + Some(PortInstallBlockReason::ComingSoon) + } else if withdrawn { Some(PortInstallBlockReason::Withdrawn) } else if !verified && pinned.is_none() { Some(PortInstallBlockReason::NoVerifiedRelease) @@ -541,6 +548,7 @@ fn preferences_view(preferences: &PortPreferences) -> PortPreferencesView { guided: preferences.guided, verified: preferences.verified, installed: preferences.installed, + platform: preferences.platform_filter, }, last_parent_folder: preferences.last_parent.clone(), } @@ -886,6 +894,7 @@ mod tests { preferences, facts, active_jobs: active, + installs_supported: true, } } @@ -937,13 +946,13 @@ mod tests { no_asset_reason: Some(PortNoAssetReason::InstallerOnly), withdrawn: false, }; - let view = entry_view(&withdrawn, None, &EntryFacts::default()); + let view = entry_view(&withdrawn, None, &EntryFacts::default(), true); assert_eq!( view.install_block_reason, Some(PortInstallBlockReason::Withdrawn) ); assert!(!view.installable); - let view = entry_view(&entry(), None, &facts); + let view = entry_view(&entry(), None, &facts, true); assert_eq!( view.install_block_reason, Some(PortInstallBlockReason::InstallerOnly) @@ -1160,7 +1169,7 @@ mod tests { .map(|release| (release.version.as_str(), release.withdrawn)), Some(("v0.9.38", true)) ); - let view = entry_view(&entry, None, &facts); + let view = entry_view(&entry, None, &facts, true); assert!(!view.installable); assert_eq!( view.install_block_reason, @@ -1168,6 +1177,21 @@ mod tests { ); } + #[test] + fn a_catalog_only_platform_blocks_every_install_with_coming_soon() { + // A Windows-capable, verified entry is still blocked where the install runner is absent. + let view = entry_view(&entry(), None, &EntryFacts::default(), false); + assert!(!view.installable); + assert_eq!( + view.install_block_reason, + Some(PortInstallBlockReason::ComingSoon) + ); + // The same entry is installable on a platform with an install runner. + let view = entry_view(&entry(), None, &EntryFacts::default(), true); + assert!(view.installable); + assert_eq!(view.install_block_reason, None); + } + #[test] fn iso_dates_follow_the_gregorian_calendar() { assert_eq!(iso_date(0), None); diff --git a/crates/app/src/engine/tests/pc_ports.rs b/crates/app/src/engine/tests/pc_ports.rs index 7934b727..da1250f1 100644 --- a/crates/app/src/engine/tests/pc_ports.rs +++ b/crates/app/src/engine/tests/pc_ports.rs @@ -525,6 +525,46 @@ async fn the_catalog_status_carries_seconds_and_the_entries_are_merged() { service.shutdown(); } +#[tokio::test] +async fn linux_serves_the_catalog_read_only_and_refuses_installs() { + let _serial = serial().lock().await; + let db = database(); + let store: Arc = Arc::new(db.ports_store()); + let local: Arc = Arc::new(db.local_game_store()); + let catalog = Arc::new(FakeCatalog::new( + vec![entry()], + Some(entry()), + vec![release(Some(format!("sha256:{}", "a".repeat(64))), None)], + )); + let mut config = service_config(store, local, catalog); + config.platform = gamenode_core::ports::PortPlatform::Linux; + assert!( + config.install.is_none(), + "a Linux build has no install dependencies" + ); + let (service, rx) = start(config); + assert!(!service.is_supported()); + service.open(); + let view = wait_for_view(&rx, |view| view.catalog.state == PortCatalogState::Ready); + assert_eq!(view.catalog.entry_count, 1); + assert_eq!(view.entries.len(), 1); + assert!(view.jobs.is_empty(), "a read-only build queues no jobs"); + + let error = service + .install(&PortInstallRequest { + plugin_request_id: None, + catalog_id: "qcat_lantern".into(), + parent_folder: std::env::temp_dir().to_string_lossy().into_owned(), + supplied: Vec::new(), + accept_unverified_checksum: false, + accept_malware_flag: false, + retry_job_id: None, + }) + .expect_err("a Linux build cannot install"); + assert_eq!(error, PortsError::Unsupported); + service.shutdown(); +} + #[tokio::test] async fn preferences_round_trip_and_reach_the_view() { let _serial = serial().lock().await; @@ -541,6 +581,7 @@ async fn preferences_round_trip_and_reach_the_view() { guided: Some(true), verified: Some(false), installed: Some(false), + platform: Some(gamenode_core::ports::PortPlatformFilter::NativeLinux), }), last_parent_folder: Some(Some(r"D:\Ports".into())), }) @@ -548,6 +589,10 @@ async fn preferences_round_trip_and_reach_the_view() { let stored = store.preferences().unwrap(); assert_eq!(stored.view, PortViewMode::List); assert_eq!(stored.consoles, ["PlayStation 4"]); + assert_eq!( + stored.platform_filter, + gamenode_core::ports::PortPlatformFilter::NativeLinux + ); assert!(stored.guided); assert_eq!(stored.last_parent.as_deref(), Some(r"D:\Ports")); let view = wait_for_view(&rx, |view| { diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 9a716b84..e58d083c 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -414,30 +414,35 @@ fn main() -> Result<(), Box> { )); // The service loads the overlay, recovers interrupted installs and starts its workers on a - // dedicated thread; construction returns immediately. - let pc_ports = if gamenode_core::ports::PortPlatform::current().supports_installs() { - let data_dir = paths.data_dir().to_owned(); - Some(PortsService::start(PortsServiceConfig { - store: Arc::clone(&port_store), - local_games: local_game_store.clone(), - catalog: Arc::new(gamenode_platform::ports::QuiverClient::new()?), - overlay_fetcher: Arc::new( - gamenode_platform::ports::overlay_source::HttpOverlayFetcher::new(), - ), - clock: Arc::new(gamenode_platform::ports::SystemClock), - data_dir: data_dir.clone(), - platform: gamenode_core::ports::PortPlatform::current(), - install: Some(InstallDeps { - fetcher: Arc::new(gamenode_platform::download::HttpDownloadFetcher::new()?), - url_policy: Arc::new(gamenode_platform::download::HttpsDownloadPolicy), - user_roots: gamenode_platform::ports::UserDataRoots::host()?, - identity: Arc::new(gamenode_platform::ports::SystemExecutableIdentity), - packages: Arc::new(gamenode_platform::ports::PinnedExtractor::new(data_dir)?), - }), - })) + // dedicated thread; construction returns immediately. The catalog also runs where installs are + // unsupported: the service is read-only there and the install runner stays absent. + let port_platform = gamenode_core::ports::PortPlatform::current(); + let data_dir = paths.data_dir().to_owned(); + let install = if port_platform.supports_installs() { + Some(InstallDeps { + fetcher: Arc::new(gamenode_platform::download::HttpDownloadFetcher::new()?), + url_policy: Arc::new(gamenode_platform::download::HttpsDownloadPolicy), + user_roots: gamenode_platform::ports::UserDataRoots::host()?, + identity: Arc::new(gamenode_platform::ports::SystemExecutableIdentity), + packages: Arc::new(gamenode_platform::ports::PinnedExtractor::new( + data_dir.clone(), + )?), + }) } else { None }; + let pc_ports = Some(PortsService::start(PortsServiceConfig { + store: Arc::clone(&port_store), + local_games: local_game_store.clone(), + catalog: Arc::new(gamenode_platform::ports::QuiverClient::new()?), + overlay_fetcher: Arc::new( + gamenode_platform::ports::overlay_source::HttpOverlayFetcher::new(), + ), + clock: Arc::new(gamenode_platform::ports::SystemClock), + data_dir, + platform: port_platform, + install, + })); let pub_clone = publisher.clone(); let achievement_store = store.achievement_store(); diff --git a/crates/core/src/ports/mod.rs b/crates/core/src/ports/mod.rs index 51ffd726..47cc4aa9 100644 --- a/crates/core/src/ports/mod.rs +++ b/crates/core/src/ports/mod.rs @@ -34,8 +34,8 @@ pub use plan::{ sanitize_folder_name, select_asset, select_release, space_estimate, }; pub use store::{ - PortInstallation, PortJobResume, PortJobRow, PortOverlayRow, PortPreferences, PortStore, - PortViewMode, + PortInstallation, PortJobResume, PortJobRow, PortOverlayRow, PortPlatformFilter, + PortPreferences, PortStore, PortViewMode, }; pub use view::{ PortArgumentKind, PortArgumentSpec, PortArtKind, PortArtView, PortCatalogError, diff --git a/crates/core/src/ports/store.rs b/crates/core/src/ports/store.rs index 0f359697..3887358d 100644 --- a/crates/core/src/ports/store.rs +++ b/crates/core/src/ports/store.rs @@ -185,6 +185,19 @@ pub enum PortViewMode { List, } +/// Which platform slice of the catalog the remembered filter shows. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum PortPlatformFilter { + /// Every entry, including Windows-only ports. + #[default] + All, + /// Entries whose declared platforms include Linux. + NativeLinux, + /// Entries that declare Windows and do not declare Linux. + WindowsOnly, +} + /// Remembered catalog view, filters and last install parent folder. The search text is not stored. #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -198,6 +211,8 @@ pub struct PortPreferences { pub verified: bool, /// Only entries installed by GameNode. pub installed: bool, + /// The remembered platform slice; defaults to every entry. + pub platform_filter: PortPlatformFilter, /// The parent folder offered first by the next install. pub last_parent: Option, } @@ -247,10 +262,14 @@ mod tests { assert!(!preferences.guided); assert!(!preferences.verified); assert!(!preferences.installed); + assert_eq!( + preferences.platform_filter, + crate::ports::PortPlatformFilter::All + ); assert_eq!(preferences.last_parent, None); assert_eq!( serde_json::to_string(&preferences).unwrap(), - r#"{"view":"grid","consoles":[],"guided":false,"verified":false,"installed":false,"lastParent":null}"# + r#"{"view":"grid","consoles":[],"guided":false,"verified":false,"installed":false,"platformFilter":"all","lastParent":null}"# ); } } diff --git a/crates/core/src/ports/view.rs b/crates/core/src/ports/view.rs index 31747379..08c799e4 100644 --- a/crates/core/src/ports/view.rs +++ b/crates/core/src/ports/view.rs @@ -12,7 +12,7 @@ use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; -use crate::ports::store::PortViewMode; +use crate::ports::store::{PortPlatformFilter, PortViewMode}; /// Where the PC ports destination exists. Reported through `AppInfo.platform` as well. #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] @@ -130,6 +130,8 @@ pub enum PortNoAssetReason { #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum PortInstallBlockReason { + /// This build serves the catalog but cannot install ports yet (Linux phase 1). + ComingSoon, Withdrawn, NoVerifiedRelease, InstallerOnly, @@ -333,6 +335,8 @@ pub struct PortFiltersView { pub guided: bool, pub verified: bool, pub installed: bool, + #[serde(default)] + pub platform: PortPlatformFilter, } /// Remembered view state. diff --git a/crates/platform/src/ports_db.rs b/crates/platform/src/ports_db.rs index 48649908..bece9d44 100644 --- a/crates/platform/src/ports_db.rs +++ b/crates/platform/src/ports_db.rs @@ -20,12 +20,14 @@ use std::collections::BTreeMap; use std::sync::{Arc, Mutex}; +use serde::Deserialize; + use gamenode_core::drm_free::Registration; use gamenode_core::ports::catalog::CatalogSnapshot; use gamenode_core::ports::job::PortJobPhase; use gamenode_core::ports::{ - PortInstallation, PortJobResume, PortJobRow, PortOverlayRow, PortPreferences, PortStore, - PortViewMode, StorageError, + PortInstallation, PortJobResume, PortJobRow, PortOverlayRow, PortPlatformFilter, + PortPreferences, PortStore, PortViewMode, StorageError, }; use rusqlite::{Connection, OptionalExtension, params}; @@ -596,6 +598,7 @@ impl PortStore for SqlitePortStore { guided: filters.guided, verified: filters.verified, installed: filters.installed, + platform_filter: filters.platform, last_parent, }) } @@ -607,6 +610,7 @@ impl PortStore for SqlitePortStore { guided: preferences.guided, verified: preferences.verified, installed: preferences.installed, + platform: preferences.platform_filter, }; let filters = serde_json::to_string(&filters).map_err(failed)?; let view = match preferences.view { @@ -641,6 +645,21 @@ struct StoredFilters { guided: bool, verified: bool, installed: bool, + /// An unknown value from a newer build falls back to `All` instead of failing the read. + #[serde(default, deserialize_with = "platform_filter_or_all")] + platform: PortPlatformFilter, +} + +fn platform_filter_or_all<'de, D>(deserializer: D) -> Result +where + D: serde::Deserializer<'de>, +{ + let value = Option::::deserialize(deserializer)?; + Ok(match value.as_deref() { + Some("nativeLinux") => PortPlatformFilter::NativeLinux, + Some("windowsOnly") => PortPlatformFilter::WindowsOnly, + _ => PortPlatformFilter::All, + }) } #[cfg(test)] @@ -1188,6 +1207,7 @@ mod tests { guided: true, verified: true, installed: false, + platform_filter: PortPlatformFilter::NativeLinux, last_parent: Some(r"D:\Ports".into()), }; store.save_preferences(&saved).unwrap(); @@ -1202,6 +1222,7 @@ mod tests { guided: true, verified: true, installed: false, + platform_filter: PortPlatformFilter::NativeLinux, last_parent: Some(r"D:\Ports".into()), } ); @@ -1213,9 +1234,21 @@ mod tests { [], ) .unwrap(); + let legacy = reopened.preferences().unwrap(); + assert_eq!(legacy.consoles, vec!["ps4".to_owned()]); + // A filters row written before the platform filter existed reads as `All`. + assert_eq!(legacy.platform_filter, PortPlatformFilter::All); + + // A value from a newer build falls back to `All` instead of failing the read. + crate::db::lock(&reopened.conn) + .execute( + r#"UPDATE port_preferences SET filters_json = '{"platform":"steamdeck"}' WHERE id = 1"#, + [], + ) + .unwrap(); assert_eq!( - reopened.preferences().unwrap().consoles, - vec!["ps4".to_owned()] + reopened.preferences().unwrap().platform_filter, + PortPlatformFilter::All ); // An unreadable filter row falls back to no filters without blocking PC ports. diff --git a/openspec/changes/add-linux-pc-port-catalog/tasks.md b/openspec/changes/add-linux-pc-port-catalog/tasks.md index 051fef20..da569ca1 100644 --- a/openspec/changes/add-linux-pc-port-catalog/tasks.md +++ b/openspec/changes/add-linux-pc-port-catalog/tasks.md @@ -10,21 +10,46 @@ capabilities. Windows behavior and the existing Windows acceptance are not reope the recipe's tool requirements, not from `supportedOS` alone. Expose native/blocked/unknown and the reason in the catalog view model. Verify Linux-only, Windows-only, mixed and inconsistent upstream claims (an OS listed without an asset) produce the expected availability. -- [ ] 1.2 Start the PC ports catalog service on signed-in Linux builds in read-only mode while the +- [x] 1.2 Start the PC ports catalog service on signed-in Linux builds in read-only mode while the install service stays Windows-only. Keep the existing Windows catalog path unchanged. -- [ ] 1.3 Show `EXPLORE → PC ports` on signed-in Linux builds with an “Em breve”/“Coming Soon” + - Completion (2026-11-22): `main.rs` now starts `PortsService` on every platform and builds + `InstallDeps` only where `supports_installs()` is true, so Linux gets the catalog worker with no + install runner. `install`, `prepare_install`, `pick_executable` and `clear_cache` still return + `Unsupported`; the plugin routes report `UNAVAILABLE` before any job starts. Windows keeps the + same construction. Regression: `engine::tests::pc_ports::linux_serves_the_catalog_read_only_and_refuses_installs`. +- [x] 1.3 Show `EXPLORE → PC ports` on signed-in Linux builds with an “Em breve”/“Coming Soon” label on the destination and in the catalog header. Verify signed-out and non-Linux builds keep their existing visibility. -- [ ] 1.4 Add the persisted platform filter **All** (default), **Native Linux** and + - Completion (2026-11-22): the sidebar shows PC ports for `windows` and `linux`, with a + `sidebar-ports-coming-soon` badge on Linux; `App.tsx` renders `PortsView` on both platforms + (the original gate hid the destination after the click). The catalog header carries + `banner-ports-coming-soon`. Signed-out and macOS builds keep the previous visibility. Tests: + `Sidebar.test.tsx`, `App.integration.test.tsx` (`opens the read-only PC ports catalog on Linux`). +- [x] 1.4 Add the persisted platform filter **All** (default), **Native Linux** and **Windows-only** on Linux. Verify the filter survives restart, an unknown value falls back to All, and Windows filters are unchanged. -- [ ] 1.5 Keep every entry browsable on Linux in phase 1, but disable Install for all of them with + - Completion (2026-11-22): `PortPlatformFilter` is stored in `PortPreferences` and inside the + existing `port_preferences.filters_json`, with an unknown value reading as `All`; the toolbar + select exists only on Linux (the read-only phase) and Windows keeps its previous controls. + Filtering uses the entry's declared `supportedOS`; installs stay blocked. Tests: platform + store round-trip plus legacy/unknown fallback and the UI platform filter. +- [x] 1.5 Keep every entry browsable on Linux in phase 1, but disable Install for all of them with the Coming Soon reason. The detail pane shows available platforms and the phase note. Verify no download, extractor, launch or library registration is started from a blocked card; Windows-only cards explain that Proton is future work. -- [ ] 1.6 Add en and pt-BR strings, `VITE_UI_MOCK=1` fixtures for native Linux, Windows-only and + - Completion (2026-11-22): `PortInstallBlockReason::ComingSoon` overrides every other reason on a + platform without an install runner, so a verified Windows-capable entry is still blocked; the + detail pane shows a Platforms row and the translated note. No setup, download, extractor or + registration starts because the button is disabled and the service refuses the request. + Untested here: the Proton note stays phase 2, when native installs exist. +- [x] 1.6 Add en and pt-BR strings, `VITE_UI_MOCK=1` fixtures for native Linux, Windows-only and mixed entries, and component tests for the Coming Soon label, filter, blocked card and detail note. + - Completion (2026-11-22): en/pt-BR cover the label, banner, platform filter and platform names. + The mock catalog has a mixed entry (`Aster Vale`), a native Linux entry (`Beyond the Pines`) and + Windows-only entries, reachable with `VITE_UI_MOCK=1` plus `?platform=linux`. Component tests + cover the label, banner, filter, blocked install and Platforms row; the i18n parity test allows + the proper-noun platform names. - [ ] 1.7 Run a native Linux packaged-host check: open PC ports, see Coming Soon, list the cached catalog, filter native Linux and Windows-only, and confirm no install/network download starts. Record the evidence as a packaging check. diff --git a/ui/src/App.integration.test.tsx b/ui/src/App.integration.test.tsx index be237a87..b06950f6 100644 --- a/ui/src/App.integration.test.tsx +++ b/ui/src/App.integration.test.tsx @@ -22,6 +22,7 @@ const invokeLog: Array<{ cmd: string; args?: Record }> = []; const order: string[] = []; let current: Snapshot; let locale = 'en'; +let appPlatform: 'windows' | 'linux' | 'macos' = 'windows'; let pendingSnapshot: Promise | null = null; vi.mock('@tauri-apps/api/core', () => ({ @@ -38,7 +39,7 @@ vi.mock('@tauri-apps/api/core', () => ({ osVersion: 'Test OS 1.0', arch: 'x86_64', backgroundSupported: false, - platform: 'windows', + platform: appPlatform, } satisfies AppInfo; } if (cmd === 'get_license_notices') return 'GPL-3.0-only notices'; @@ -351,6 +352,24 @@ describe('App (integration: real component tree over a fake Tauri host)', () => }); }); + it('opens the read-only PC ports catalog on Linux', async () => { + appPlatform = 'linux'; + try { + await mountApp(); + await publish(signedIn(current)); + + fireEvent.click( + within(await screen.findByTestId('sidebar-ports')).getByRole('button'), + ); + + expect(await screen.findByTestId('ports-view')).toBeInTheDocument(); + expect(await screen.findByTestId('banner-ports-coming-soon')).toBeInTheDocument(); + expect(calls('ports_open')).toHaveLength(1); + } finally { + appPlatform = 'windows'; + } + }); + it('switches the content area to PC ports and back to the filtered library', async () => { await mountApp(); await publish(signedIn(current)); diff --git a/ui/src/App.tsx b/ui/src/App.tsx index b288466d..63b03da8 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -169,7 +169,8 @@ export const App: React.FC = () => { typeof navigator !== 'undefined' ? navigator.userAgent : null, appInfo.data?.platform, ); - const portsVisible = signedIn && platform === 'windows'; + const portsVisible = + signedIn && (platform === 'windows' || platform === 'linux'); let main: React.ReactNode; if (destination === 'ports' && portsVisible) { diff --git a/ui/src/api/ports.ts b/ui/src/api/ports.ts index b1126e8c..f1a198ce 100644 --- a/ui/src/api/ports.ts +++ b/ui/src/api/ports.ts @@ -119,6 +119,7 @@ export type PortNoAssetReason = /** Why Install is unavailable for an entry. */ export type PortInstallBlockReason = + | 'comingSoon' | 'withdrawn' | 'noVerifiedRelease' | PortNoAssetReason; @@ -306,9 +307,13 @@ export interface PortJobView { export type PortViewMode = 'grid' | 'list'; /** Catalog filters; they combine with AND. */ +export type PortPlatformFilter = 'all' | 'nativeLinux' | 'windowsOnly'; + export interface PortFilters { /** Console names from `PortEntryView.consoles`; empty means every console. */ consoles: string[]; + /** Platform slice; only the Linux read-only phase shows the control. */ + platform?: PortPlatformFilter; /** Only entries with guided setup. */ guided: boolean; /** Only entries with a verified release. */ diff --git a/ui/src/api/types.ts b/ui/src/api/types.ts index 2c7b879d..afa61a56 100644 --- a/ui/src/api/types.ts +++ b/ui/src/api/types.ts @@ -2336,6 +2336,7 @@ export function createDefaultPortsView(): PortsView { guided: false, verified: false, installed: false, + platform: 'all', }, lastParentFolder: null, }, diff --git a/ui/src/features/ports/PortsView.tsx b/ui/src/features/ports/PortsView.tsx index 33b4fcb1..563b58ab 100644 --- a/ui/src/features/ports/PortsView.tsx +++ b/ui/src/features/ports/PortsView.tsx @@ -1,14 +1,13 @@ import React, { useDeferredValue, useEffect, useMemo, useState } from 'react'; import { commands } from '../../api/commands'; -import { - usePortsView, - type PortFilters, - type PortViewMode, -} from '../../api/ports'; +import { detectPortPlatform, usePortsView } from '../../api/ports'; +import type { PortFilters, PortViewMode } from '../../api/ports'; +import { useAppInfo } from '../../api/useSnapshot'; import { useI18n } from '../../i18n'; import { uiStore, useUiStore } from '../../store/uiStore'; import { formatI18n } from '../library/formatters'; import { + PortComingSoonBanner, PortCredit, PortEmptyState, PortGrid, @@ -30,6 +29,7 @@ const DEFAULT_FILTERS: PortFilters = { guided: false, verified: false, installed: false, + platform: 'all', }; /** @@ -43,7 +43,13 @@ const DEFAULT_FILTERS: PortFilters = { */ export const PortsView: React.FC = () => { const ports = usePortsView(); + const appInfo = useAppInfo(); const { t, locale } = useI18n(); + const platform = detectPortPlatform( + typeof navigator !== 'undefined' ? navigator.userAgent : null, + appInfo?.data?.platform, + ); + const comingSoon = platform === 'linux'; const [search, setSearch] = useState(''); const deferredSearch = useDeferredValue(search); @@ -58,7 +64,10 @@ export const PortsView: React.FC = () => { }, [focusCatalogId]); const preferences = ports.preferences; - const filters = preferences?.filters ?? DEFAULT_FILTERS; + const storedFilters = preferences?.filters ?? DEFAULT_FILTERS; + // The control only exists in the read-only phase; elsewhere a persisted value must not hide + // entries with no way to clear it. + const filters = comingSoon ? storedFilters : { ...storedFilters, platform: 'all' as const }; const view: PortViewMode = preferences?.view ?? 'grid'; const catalog = ports.catalog; const entries = ports.entries; @@ -138,6 +147,7 @@ export const PortsView: React.FC = () => { view={view} onViewChange={setView} consoles={consoles} + showPlatformFilter={comingSoon} visibleCount={filtered.length} totalCount={entries.length} refreshing={refreshing} @@ -146,6 +156,7 @@ export const PortsView: React.FC = () => {
+ {comingSoon && } {refreshing && entries.length > 0 && } {catalog.state === 'stale' && ( { ); }; +/** + * Read-only phase note. The catalog is served on a platform whose install runner is absent, so + * browsing works and every Install action stays disabled. + */ +export const PortComingSoonBanner: React.FC = () => { + const { t } = useI18n(); + return ( +
+ {t('Ports::Browsing only. Installing PC ports on Linux is coming soon.')} +
+ ); +}; + export interface PortStaleBannerProps { fetchedAt: number | null; age: string; diff --git a/ui/src/features/ports/catalog/PortsToolbar.tsx b/ui/src/features/ports/catalog/PortsToolbar.tsx index e080b303..9e60635d 100644 --- a/ui/src/features/ports/catalog/PortsToolbar.tsx +++ b/ui/src/features/ports/catalog/PortsToolbar.tsx @@ -23,6 +23,8 @@ export interface PortsToolbarProps { view: PortViewMode; onViewChange: (view: PortViewMode) => void; consoles: string[]; + /** The platform control exists only where the catalog is read-only (Linux phase 1). */ + showPlatformFilter?: boolean; visibleCount: number; totalCount: number; refreshing: boolean; @@ -48,6 +50,7 @@ export const PortsToolbar: React.FC = ({ view, onViewChange, consoles, + showPlatformFilter = false, visibleCount, totalCount, refreshing, @@ -67,6 +70,16 @@ export const PortsToolbar: React.FC = ({ }), }); } + if (showPlatformFilter && (filters.platform ?? 'all') !== 'all') { + chips.push({ + id: 'platform', + label: + filters.platform === 'nativeLinux' + ? t('Ports::Linux (native)') + : t('Ports::Windows-only'), + remove: () => onFiltersChange({ ...filters, platform: 'all' }), + }); + } if (filters.guided) { chips.push({ id: 'guided', @@ -164,6 +177,28 @@ export const PortsToolbar: React.FC = ({ + {showPlatformFilter && ( + + )} + {toggle('guided', t('Ports::Guided setup'), filters.guided, (value) => onFiltersChange({ ...filters, guided: value }), )} diff --git a/ui/src/features/ports/catalog/format.ts b/ui/src/features/ports/catalog/format.ts index 30f3b289..463fe4ff 100644 --- a/ui/src/features/ports/catalog/format.ts +++ b/ui/src/features/ports/catalog/format.ts @@ -38,6 +38,16 @@ export function filterPortEntries( ); if (!matchesConsole) return false; } + if (filters.platform === 'nativeLinux') { + const native = entry.supportedOS.some( + (os) => os.trim().toLowerCase() === 'linux', + ); + if (!native) return false; + } + if (filters.platform === 'windowsOnly') { + const declared = entry.supportedOS.map((os) => os.trim().toLowerCase()); + if (!declared.includes('windows') || declared.includes('linux')) return false; + } if (filters.guided && !entry.guided) return false; if (filters.verified && !entry.verified) return false; if (filters.installed && !entry.installedRegistrationKey) return false; @@ -52,6 +62,7 @@ export function filterPortEntries( export function portFiltersAreDefault(filters: PortFilters): boolean { return ( filters.consoles.length === 0 && + (filters.platform ?? 'all') === 'all' && !filters.guided && !filters.verified && !filters.installed @@ -86,6 +97,8 @@ export function installBlockReasonText( t: Translate, ): string | null { switch (reason) { + case 'comingSoon': + return t('Ports::Installing PC ports on Linux is coming soon.'); case 'withdrawn': return t('Ports::This port was withdrawn upstream.'); case 'noVerifiedRelease': @@ -103,6 +116,20 @@ export function installBlockReasonText( } } +/** A human name for an operating-system id the catalog declares. */ +export function portPlatformName(os: string, t: Translate): string { + switch (os.trim().toLowerCase()) { + case 'windows': + return t('Ports::Windows'); + case 'linux': + return t('Ports::Linux'); + case 'macos': + return t('Ports::macOS'); + default: + return os; + } +} + export function placementRootLabel( root: PortPlacementRoot | null, t: Translate, diff --git a/ui/src/features/ports/detail/PortDetailPane.tsx b/ui/src/features/ports/detail/PortDetailPane.tsx index 6815dd1a..1966110a 100644 --- a/ui/src/features/ports/detail/PortDetailPane.tsx +++ b/ui/src/features/ports/detail/PortDetailPane.tsx @@ -21,6 +21,7 @@ import { formatPortDate, installBlockReasonText, placementRootLabel, + portPlatformName, setupSlotKindLabel, versionLabel, type Translate, @@ -278,6 +279,19 @@ export const PortDetailPane: React.FC = ({ entry, onClose } {entry.consoles.join(', ')}
+ {entry.supportedOS.length > 0 && ( +
+ {t('Ports::Platforms')} + + {entry.supportedOS + .map((os) => portPlatformName(os, t)) + .join(', ')} + +
+ )} {detail?.developer && (
{t('Ports::Developer')} diff --git a/ui/src/features/ports/ports.test.tsx b/ui/src/features/ports/ports.test.tsx index 736883b7..542f5b1d 100644 --- a/ui/src/features/ports/ports.test.tsx +++ b/ui/src/features/ports/ports.test.tsx @@ -270,6 +270,84 @@ describe('Ports catalog', () => { vi.restoreAllMocks(); }); + it('filters by the declared platform and persists the choice', () => { + const ports = makePorts(); + ports.entries = [ + entry({ + catalogId: 'qcat_linux', + supportedOS: ['linux', 'windows'], + installable: false, + installBlockReason: 'comingSoon', + }), + entry({ + catalogId: 'qcat_windows', + supportedOS: ['windows'], + installable: false, + installBlockReason: 'comingSoon', + }), + entry({ + catalogId: 'qcat_native', + supportedOS: ['linux'], + installable: false, + installBlockReason: 'comingSoon', + }), + ]; + ports.preferences.filters.platform = 'nativeLinux'; + const view = renderPorts(ports); + + expect(screen.getByTestId('port-tile-qcat_linux')).toBeInTheDocument(); + expect(screen.getByTestId('port-tile-qcat_native')).toBeInTheDocument(); + expect(screen.queryByTestId('port-tile-qcat_windows')).not.toBeInTheDocument(); + + // The control persists the choice; the host answers with a new snapshot. + fireEvent.change(screen.getByTestId('ports-platform-filter'), { + target: { value: 'windowsOnly' }, + }); + expect(commands.portsSetPreferences).toHaveBeenLastCalledWith({ + filters: expect.objectContaining({ platform: 'windowsOnly' }), + }); + view.unmount(); + + ports.preferences.filters.platform = 'windowsOnly'; + renderPorts(ports); + expect(screen.getByTestId('port-tile-qcat_windows')).toBeInTheDocument(); + expect(screen.queryByTestId('port-tile-qcat_linux')).not.toBeInTheDocument(); + expect(screen.queryByTestId('port-tile-qcat_native')).not.toBeInTheDocument(); + }); + + it('hides the platform filter on Windows', async () => { + vi.spyOn(commands, 'getAppInfo').mockResolvedValue({ + locale: 'en', + version: '0.1.0', + backgroundSupported: false, + platform: 'windows', + }); + renderPorts(makePorts()); + + await waitFor(() => + expect(screen.queryByTestId('ports-platform-filter')).not.toBeInTheDocument(), + ); + }); + + it('marks the catalog read-only on Linux and hides the note on Windows', async () => { + const first = renderPorts(makePorts()); + expect(await screen.findByTestId('banner-ports-coming-soon')).toHaveTextContent( + 'Browsing only. Installing PC ports on Linux is coming soon.', + ); + first.unmount(); + + vi.spyOn(commands, 'getAppInfo').mockResolvedValue({ + locale: 'en', + version: '0.1.0', + backgroundSupported: false, + platform: 'windows', + }); + renderPorts(makePorts()); + await waitFor(() => + expect(screen.queryByTestId('banner-ports-coming-soon')).not.toBeInTheDocument(), + ); + }); + it('filters by search over names and game titles, and by the persisted toggles', async () => { renderPorts(makePorts()); @@ -417,6 +495,24 @@ describe('Ports catalog', () => { ); }); + it('blocks every install with the coming soon reason on a read-only platform', () => { + const ports = makePorts(); + ports.entries = ports.entries.map((item) => ({ + ...item, + installable: false, + installBlockReason: 'comingSoon' as const, + })); + renderPorts(ports); + + fireEvent.click(screen.getByTestId('port-tile-qcat_aster')); + + expect(screen.getByTestId('port-install-btn')).toBeDisabled(); + expect(screen.getByTestId('port-install-reason')).toHaveTextContent( + 'Installing PC ports on Linux is coming soon.', + ); + expect(screen.getByTestId('port-detail-platforms')).toHaveTextContent('Windows'); + }); + it('lists guided requirements with accepted versions, optional slots and the package option', async () => { renderPorts(makePorts()); diff --git a/ui/src/features/shell/Sidebar.test.tsx b/ui/src/features/shell/Sidebar.test.tsx index 61b6d2df..20923a6f 100644 --- a/ui/src/features/shell/Sidebar.test.tsx +++ b/ui/src/features/shell/Sidebar.test.tsx @@ -425,19 +425,33 @@ describe('Sidebar', () => { expect(within(screen.getByTestId('sidebar-ports')).getByTestId('sidebar-ports-badge')).toHaveTextContent( '3', ); + expect(screen.queryByTestId('sidebar-ports-coming-soon')).not.toBeInTheDocument(); fireEvent.click(screen.getByRole('button', { name: 'PC ports' })); expect(uiStore.state.activeDestination).toBe('ports'); expect(portsOpen).toHaveBeenCalledTimes(1); view.unmount(); + }); + + it('shows the PC ports destination on Linux with a coming soon label', () => { + const portsOpen = vi.spyOn(commands, 'portsOpen').mockResolvedValue(); renderSidebar({ library: makeLibrary(), localGames: emptyLocal(), - ports, + ports: { ...createDefaultPortsView(), unseenCount: 3 }, signedIn: true, platform: 'linux', }); - expect(screen.queryByTestId('sidebar-ports')).not.toBeInTheDocument(); + + expect( + within(screen.getByTestId('sidebar-ports')).getByTestId( + 'sidebar-ports-coming-soon', + ), + ).toHaveTextContent('Coming soon'); + expect(screen.queryByTestId('sidebar-ports-badge')).not.toBeInTheDocument(); + fireEvent.click(screen.getByRole('button', { name: 'PC ports' })); + expect(uiStore.state.activeDestination).toBe('ports'); + expect(portsOpen).toHaveBeenCalledTimes(1); }); it('renders the 72px rail with accessible rows, keyboard activation and no resize handle', async () => { diff --git a/ui/src/features/shell/Sidebar.tsx b/ui/src/features/shell/Sidebar.tsx index 38f7a56e..4b98a1ad 100644 --- a/ui/src/features/shell/Sidebar.tsx +++ b/ui/src/features/shell/Sidebar.tsx @@ -144,7 +144,11 @@ export function Sidebar({ typeof navigator !== 'undefined' ? navigator.userAgent : null, appInfo?.data?.platform, ); - const showPortsDestination = signedIn && platform === 'windows'; + // The catalog is browsable wherever the host serves it. Installs are still Windows-only, so a + // Linux build labels the destination as coming soon instead of hiding it. + const showPortsDestination = + signedIn && (platform === 'windows' || platform === 'linux'); + const portsComingSoon = platform === 'linux'; const collapsed = library?.layout?.sidebarCollapsed ?? false; const storedWidth = library?.layout?.sidebarWidth ?? 240; @@ -491,7 +495,16 @@ export function Sidebar({ count={collapsed && unseenInstalls > 0 ? unseenInstalls : undefined} countTone="brand" trailing={ - !collapsed && unseenInstalls > 0 ? ( + portsComingSoon ? ( + !collapsed ? ( + + {t('Ports::Coming soon')} + + ) : undefined + ) : !collapsed && unseenInstalls > 0 ? ( { const placeholders = (value: string) => (value.match(/\{[^}]*\}/g) ?? []).sort(); // Words that are already the same in Brazilian Portuguese, plus the percent symbol. - const identicalAllowed = new Set(['Ports::Console', 'Ports::Port', 'Ports::{}%']); + // Platform names are proper nouns in both catalogs. + const identicalAllowed = new Set([ + 'Ports::Console', + 'Ports::Port', + 'Ports::{}%', + 'Ports::Windows', + 'Ports::Linux', + 'Ports::macOS', + ]); for (const key of portsEnKeys) { const enValue = (en as Record)[key]; diff --git a/ui/src/i18n/pt-BR.ts b/ui/src/i18n/pt-BR.ts index c60943d2..71445f19 100644 --- a/ui/src/i18n/pt-BR.ts +++ b/ui/src/i18n/pt-BR.ts @@ -2044,6 +2044,17 @@ export const ptBR: TranslationCatalog = { "My account": "Minha conta", "Add a game": "Adicionar jogo", "Discovered games": "Jogos descobertos", + "Ports::Coming soon": "Em breve", + "Ports::Browsing only. Installing PC ports on Linux is coming soon.": "Somente navegação. A instalação de ports para PC no Linux chega em breve.", + "Ports::Installing PC ports on Linux is coming soon.": "A instalação de ports para PC no Linux chega em breve.", + "Ports::Platforms": "Plataformas", + "Ports::Windows": "Windows", + "Ports::Linux": "Linux", + "Ports::macOS": "macOS", + "Ports::Platform": "Plataforma", + "Ports::All platforms": "Todas as plataformas", + "Ports::Linux (native)": "Linux (nativo)", + "Ports::Windows-only": "Somente Windows", "Ports::{} installs running or unseen": "{} instalações em andamento ou ainda não vistas", "Ports::Refreshing the catalog": "Atualizando o catálogo", "Ports::Catalog ready": "Catálogo pronto", diff --git a/ui/src/mock/host.ts b/ui/src/mock/host.ts index 24214b87..c3d531ea 100644 --- a/ui/src/mock/host.ts +++ b/ui/src/mock/host.ts @@ -1665,7 +1665,7 @@ function createMockPortEntries(): PortEntryView[] { name: "Beyond the Pines: Director's Cut", games: ['Beyond the Pines'], consoles: ['PlayStation 3'], - supportedOS: ['windows'], + supportedOS: ['linux'], verified: true, prerelease: false, version: '0.9.1', @@ -1928,6 +1928,7 @@ function createMockPortsView(scenario: 'default' | 'unavailable'): PortsView { guided: false, verified: false, installed: false, + platform: 'all', }, lastParentFolder: null, },