diff --git a/crates/ui-egui/src/os_window.rs b/crates/ui-egui/src/os_window.rs index 35261c73ffc..b43c416f09d 100644 --- a/crates/ui-egui/src/os_window.rs +++ b/crates/ui-egui/src/os_window.rs @@ -37,8 +37,19 @@ pub const fn id_for(identity: LaunchIdentity) -> &'static str { } } +// Flatpak exports desktop entries under its fixed application ID, and the compositor +// needs the matching ID for each window. This only changes the display identifier; +// profile selection and stable service eligibility still use LaunchIdentity. +fn id_for_container(identity: LaunchIdentity, flatpak_id: Option<&str>) -> &'static str { + if identity == LaunchIdentity::NightlyV1 && flatpak_id == Some("ai.storyteller.photocraft.nightly") { + "ai.storyteller.photocraft.nightly" + } else { + id_for(identity) + } +} + pub fn app_id() -> &'static str { - id_for(identity()) + id_for_container(identity(), std::env::var("FLATPAK_ID").ok().as_deref()) } pub const fn name_for(identity: LaunchIdentity) -> &'static str { @@ -72,6 +83,15 @@ mod tests { #[cfg(test)] mod profile_tests { use super::*; + #[test] + fn nightly_flatpak_window_matches_exported_desktop_id() { + let nightly_flatpak = Some("ai.storyteller.photocraft.nightly"); + assert_eq!(id_for_container(LaunchIdentity::NightlyV1, nightly_flatpak), "ai.storyteller.photocraft.nightly"); + assert_eq!(id_for_container(LaunchIdentity::NightlyV1, None), "ai.storyteller.photocraft.nightly-v1"); + assert_eq!(id_for_container(LaunchIdentity::NightlyV1, Some(APP_ID)), "ai.storyteller.photocraft.nightly-v1"); + assert_eq!(id_for_container(LaunchIdentity::Stable, nightly_flatpak), APP_ID); + } + #[test] fn nightly_identity_is_distinct_and_never_enables_stable_services() { assert_eq!(id_for(LaunchIdentity::Stable), APP_ID); diff --git a/packaging/linux/flatpak-bundle.sh b/packaging/linux/flatpak-bundle.sh index e3e8dd2c40f..4388fde081c 100755 --- a/packaging/linux/flatpak-bundle.sh +++ b/packaging/linux/flatpak-bundle.sh @@ -72,7 +72,7 @@ WRAPPER chmod 755 "$WORK/stage/bin/photocraft" sed -e "s|^Icon=$APP_ID$|Icon=$FLATPAK_ID|" \ -e "s|^Name=PhotoCraft$|Name=PhotoCraft Nightly|" \ - -e 's|^StartupWMClass=.*|StartupWMClass=ai.storyteller.photocraft.nightly-v1|' \ + -e "s|^StartupWMClass=.*|StartupWMClass=$FLATPAK_ID|" \ -e '/^MimeType=/d' \ "$WORK/stage/share/applications/$APP_ID.desktop" >"$WORK/stage/share/applications/$FLATPAK_ID.desktop" rm -f "$WORK/stage/share/applications/$APP_ID.desktop" diff --git a/packaging/linux/package-docs-test.sh b/packaging/linux/package-docs-test.sh index 87c3c09b0f4..44cb12932bf 100755 --- a/packaging/linux/package-docs-test.sh +++ b/packaging/linux/package-docs-test.sh @@ -154,4 +154,18 @@ for index, arg in enumerate(args[:-1]): assert launch_out == ["--launch-profile", "nightly-v1", "--profile-root", str(temp / "xdg-data/photocraft-nightly"), "--", "sample.psd"], launch_out assert_docs(nightly_appdir / "usr/share/doc/photocraft") print("PASS: Nightly package.sh namespaces AppImage to ai.storyteller.photocraft.nightly-v1 and bootstraps nightly-v1 profile") + # Inspect the real native package staging without invoking the packager. + nfpm = tools / "nfpm" + nfpm.write_text("#!/bin/sh\nexit 0\n") + nfpm.chmod(0o755) + run(["bash", "packaging/linux/package.sh", "--skip-build", "--formats", "deb"], fixture, nightly_env) + native = target / "linux-package/nfpm-root/usr" + desktop = native / "share/applications/ai.storyteller.photocraft.nightly-v1.desktop" + entry = desktop.read_text().splitlines() + assert "Exec=photocraft-nightly %F" in entry, entry + assert "TryExec=photocraft-nightly" in entry, entry + assert "StartupWMClass=ai.storyteller.photocraft.nightly-v1" in entry, entry + assert not (native / "share/applications/ai.storyteller.photocraft.desktop").exists() + assert (native / "bin/photocraft-nightly").is_file() + print("PASS: Nightly native package desktop launches the isolated nightly executable") PY diff --git a/packaging/linux/package.sh b/packaging/linux/package.sh index 2ffbdc9161b..5b93a71f539 100755 --- a/packaging/linux/package.sh +++ b/packaging/linux/package.sh @@ -161,7 +161,8 @@ WRAPPER rm -f "$NFPM_STAGE/usr/bin/photocraft" mv "$NFPM_STAGE/usr/bin/photocraft-cli" "$NFPM_STAGE/usr/bin/$NFPM_CLI" mv "$NFPM_STAGE/usr/share/doc/photocraft" "$NFPM_STAGE/usr/share/doc/$NFPM_NAME" - sed -e "s|^Exec=photocraft\([[:space:]]\|$\)|Exec=$NFPM_BIN\1|" \ + sed -e "s|^Exec=photocraft\([[:space:]]\)|Exec=$NFPM_BIN\1|" \ + -e "s|^Exec=photocraft$|Exec=$NFPM_BIN|" \ -e "s|^TryExec=photocraft$|TryExec=$NFPM_BIN|" \ -e "s|^Icon=$APP_ID$|Icon=$NIGHTLY_DESK_ID|" \ -e "s|^Name=PhotoCraft$|Name=PhotoCraft Nightly|" \ @@ -209,6 +210,7 @@ WRAPPER # Without the completions (a cross build with no EMULATOR) the deb's zsh symlink would dangle, # so its entry is dropped too. DROP_LIB_TREE= + # Match the literal ${STAGE} token in nfpm.yaml before substituting it. # shellcheck disable=SC2016 [[ -d "$NFPM_STAGE/usr/lib" ]] || DROP_LIB_TREE='\|^ - src: \${STAGE}/usr/lib/|,+2d;' DROP_ZSH_LINK=