Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/skills/desktop-contract.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: desktop-contract
version: "1.0"
last_updated: "2026-09-05"
last_updated: "2026-09-16"
id: desktop-contract
one_line_purpose: Maintain Utah identity, Bluefin desktop defaults, and first-boot Flatpak policy.
entry_point: docs/skills/desktop-contract.md
Expand Down Expand Up @@ -81,7 +81,10 @@ Building GSConnect runs meson install. Because `desktop-file-utils` is not
published by Hummingbird or Utah's repository, `scripts/build-gnome-extensions.sh`
disables GSConnect's `update_desktop_database` meson post-install hook to avoid
failing on the missing utility. MIME and schema databases are handled by the
system and glib-compile-schemas.
system and glib-compile-schemas. Additionally, `scripts/build-gnome-extensions.sh`
guards `src/shell/clipboard.js` against GNOME 48+ final GTypes: wrapping
`GSConnectShellClipboard` registration in a try/catch prevents module load failures
on `GjsPrivate.DBusImplementation`, gracefully degrading to an inert portal on GNOME 51.

## Services and login defaults

Expand Down
4 changes: 2 additions & 2 deletions docs/skills/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generated_at": "2026-09-05",
"generated_at": "2026-09-16",
"schema_version": "1.0",
"skills": [
{
Expand Down Expand Up @@ -53,7 +53,7 @@
],
"description": "The runtime desktop contract in contracts/bluefin-desktop.toml and its in-image verifiers. Use when changing branding, os-release, service presets, GNOME extensions, or first-boot Flatpak behavior.",
"version": "1.0",
"last_updated": "2026-09-05",
"last_updated": "2026-09-16",
"doc_type": "policy"
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/skills/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This file is a human-readable mirror of `index.json`. Both are generated by
`scripts/generate_skill_index.py` — do not hand-edit either file.

Generated: 2026-09-05 · schema 1.0 · 8 skills
Generated: 2026-09-16 · schema 1.0 · 8 skills

| id | category | status | one-line purpose |
|---|---|---|---|
Expand Down
62 changes: 62 additions & 0 deletions scripts/build-gnome-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,72 @@ glib-compile-schemas --strict /usr/share/gnome-shell/extensions/gradia-integrati
# Disable update-desktop-database hook since desktop-file-utils is unavailable in Hummingbird/Utah repositories.
gsconnect_dir="/usr/share/gnome-shell/extensions/gsconnect@andyholmes.github.io"
sed -i 's/update_desktop_database: true/update_desktop_database: false/' "${gsconnect_dir}/meson.build"

# GNOME 48+ makes GjsPrivate.DBusImplementation a final GType, so
# GObject.registerClass(... extends GjsPrivate.DBusImplementation) throws
# "Cannot inherit from a final type" at module load, which takes the whole
# GSConnect extension down. Wrap the registration in try/catch so a final base
# type degrades to an inert portal instead of a hard load failure. Fail loudly
# if the upstream lines move so a submodule bump cannot silently drop the fix.
gs_clipboard="${gsconnect_dir}/src/shell/clipboard.js"
python3 - "${gs_clipboard}" <<'PY'
import sys
from pathlib import Path

path = Path(sys.argv[1])
content = path.read_text(encoding="utf-8")

old_start = "export const Clipboard = GObject.registerClass({"
new_start = """let Clipboard;
try {
Clipboard = GObject.registerClass({"""

old_end = """ if (this._handleMethodCallId > 0) {
this.disconnect(this._handleMethodCallId);
this._handleMethodCallId = 0;
this.unexport();
}
}
});"""

new_end = """ if (this._handleMethodCallId > 0) {
this.disconnect(this._handleMethodCallId);
this._handleMethodCallId = 0;
this.unexport();
}
}
});
} catch (_e) {
// GNOME 48+ makes GjsPrivate.DBusImplementation a final GType, so the
// Wayland background clipboard portal cannot be registered as a
// subclass of it: registerClass throws "Cannot inherit from a final
// type" at module load, which otherwise takes the whole extension down.
// Fall back to an inert portal so the rest of GSConnect still loads;
// clipboard sync through this portal is disabled on such shells.
console.warn(`GSConnect: clipboard portal disabled on this GNOME version: ${_e}`);
Clipboard = class { destroy() {} };
}
export { Clipboard };"""

if old_start not in content or old_end not in content:
sys.exit("gsconnect clipboard.js no longer matches expected DBusImplementation class structure; re-check the GNOME 51 guard")

content = content.replace(old_start, new_start, 1)
content = content.replace(old_end, new_end, 1)
path.write_text(content, encoding="utf-8")
PY

meson setup --prefix=/usr "${gsconnect_dir}" "${gsconnect_dir}/_build"
meson install -C "${gsconnect_dir}/_build" --skip-subprojects
# GSConnect installs schemas to /usr/share/glib-2.0/schemas and meson compiles them automatically

# Assert the installed extension carries the guard
test -f "${gsconnect_dir}/shell/clipboard.js"
if ! grep -q "clipboard portal disabled on this GNOME version" "${gsconnect_dir}/shell/clipboard.js"; then
echo "gsconnect shell/clipboard.js was not installed with the GNOME 51 final-type guard" >&2
exit 1
fi

# Custom Command Menu
glib-compile-schemas --strict /usr/share/gnome-shell/extensions/custom-command-list@storageb.github.com/schemas

Expand Down
59 changes: 59 additions & 0 deletions tests/test_gnome_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Test GNOME extension maintenance guards and patches."""

from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest

ROOT = Path(__file__).resolve().parents[1]


class GnomeExtensionPatchTests(unittest.TestCase):
def test_build_script_contains_gsconnect_final_type_guard(self):
script = (ROOT / "scripts/build-gnome-extensions.sh").read_text()
self.assertIn("GjsPrivate.DBusImplementation a final GType", script)
self.assertIn("clipboard portal disabled on this GNOME version", script)
self.assertIn("Clipboard = class { destroy() {} };", script)

def test_gsconnect_clipboard_patch_applies_and_validates(self):
src_clipboard = (
ROOT
/ "system_files/shared/usr/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/src/shell/clipboard.js"
)
if not src_clipboard.is_file():
self.skipTest("gsconnect submodule not initialized")

with tempfile.TemporaryDirectory() as tmp:
tmp_clipboard = Path(tmp) / "clipboard.js"
shutil.copyfile(src_clipboard, tmp_clipboard)

# Extract python patch snippet from build-gnome-extensions.sh
script = (ROOT / "scripts/build-gnome-extensions.sh").read_text()
self.assertIn("python3 - \"${gs_clipboard}\" <<'PY'", script)
py_code = script.split("python3 - \"${gs_clipboard}\" <<'PY'\n", 1)[1].split("\nPY\n", 1)[0]

proc = subprocess.run(
["python3", "-c", py_code, str(tmp_clipboard)],
capture_output=True,
text=True,
)
self.assertEqual(proc.returncode, 0, f"patch script failed: {proc.stderr}")

patched_text = tmp_clipboard.read_text(encoding="utf-8")
self.assertIn("clipboard portal disabled on this GNOME version", patched_text)
self.assertIn("Clipboard = class { destroy() {} };", patched_text)
self.assertIn("export { Clipboard };", patched_text)

# If node is present, check syntax
if shutil.which("node"):
res = subprocess.run(
["node", "--check", str(tmp_clipboard)],
capture_output=True,
text=True,
)
self.assertEqual(res.returncode, 0, f"syntax error in patched clipboard.js: {res.stderr}")


if __name__ == "__main__":
unittest.main()