Show sibling projects and whether they have updates
Release / release (push) Successful in 14s

A Sibling projects menu item, shown when any are installed, says which
have a newer version (from `sibling check --porcelain`, run with each
update check). It opens a dialog listing each sibling's version and
state, with buttons to run `sibling update` for one or all of them in a
terminal. A newer sibling also counts as an available update for the
Update pill, the header and the top bar dot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 12:37:14 -07:00
co-authored by Claude Opus 5.5
parent a302a0ed0b
commit 9e514eb9ed
4 changed files with 323 additions and 12 deletions
+131 -10
View File
@@ -14,7 +14,7 @@ import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
import * as Cli from './lib/cli.js';
import {ConfigureDialog, ConfirmDialog, VersionDialog} from './lib/dialogs.js';
import {ConfigureDialog, ConfirmDialog, SiblingsDialog, VersionDialog} from './lib/dialogs.js';
// What each command is called, what it does in a few words, and its icon
const COMMANDS = {
@@ -55,6 +55,12 @@ const COMMANDS = {
},
};
// Runs that change the system, so only one may run at a time. `sibling update`
// runs as "siblings" for all of them, or "sibling-<name>" for one.
function changesSystem(name) {
return name === 'update' || name === 'refresh' || name === 'siblings' || name.startsWith('sibling-');
}
// Icons for configure's items, by name
const CONFIGURE_ICONS = {
'core': 'network-server-symbolic',
@@ -181,6 +187,8 @@ class Indicator extends PanelMenu.Button {
this._titles = new Map(); // status name -> title for notifications
this._rebootNeeded = false;
this._configureTodo = 0;
this._siblingNames = []; // installed, from disk
this._siblings = null; // the last `sibling check`, or null before one
this._checkCancellable = null;
this._timeouts = new Set();
@@ -243,6 +251,15 @@ class Indicator extends PanelMenu.Button {
this._items = {};
this._items.update = this._addCommand('update');
this._items.refresh = this._addCommand('refresh');
// Shown only when there are sibling projects
this._siblingsItem = new ActionItem({
icon: 'application-x-addon-symbolic',
title: 'Sibling projects',
description: '',
});
this._siblingsItem.visible = false;
this._siblingsItem.connect('activate', () => this._openSiblings());
this.menu.addMenuItem(this._siblingsItem);
this._checkItem = new ActionItem({
icon: 'system-search-symbolic',
title: 'Check for updates',
@@ -297,6 +314,23 @@ class Indicator extends PanelMenu.Button {
}).open();
}
_openSiblings() {
// Until the first check, list what's installed with nothing known about it
const known = this._siblings ?? this._siblingNames.map(name =>
({name, installed: '', modified: false, state: 'unknown', available: null}));
new SiblingsDialog({
siblings: known,
isRunning: name => this._running.has('update') || this._running.has('siblings') ||
this._running.has(`sibling-${name}`),
onChecked: siblings => {
this._siblings = siblings;
this._updateIndicator();
},
onUpdate: name => this._runTracked(`sibling-${name}`, `Update ${name}`, ['sibling', 'update', name]),
onUpdateAll: () => this._runTracked('siblings', 'Update sibling projects', ['sibling', 'update']),
}).open();
}
// Everything that can be read locally without the network
async _refreshLocal() {
const version = await Cli.localVersion();
@@ -308,6 +342,14 @@ class Indicator extends PanelMenu.Button {
this._rebootNeeded = GLib.file_test(Cli.REBOOT_NEEDED, GLib.FileTest.EXISTS);
this._lastUpdate = Cli.mtime(Cli.PACMAN_UPDATE_LOG);
const names = await Cli.installedSiblings();
if (!this._header)
return;
this._siblingNames = names;
// Forget removed siblings; ones added since the last check show at the next
if (this._siblings)
this._siblings = this._siblings.filter(s => names.includes(s.name));
try {
const items = await Cli.configureItems();
if (!this._header)
@@ -340,10 +382,13 @@ class Indicator extends PanelMenu.Button {
async _checkNow() {
if (this._checkCancellable)
return;
this._checkCancellable = new Gio.Cancellable();
const cancellable = this._checkCancellable = new Gio.Cancellable();
this._checkItem.pill.setState('Checking…', 'running');
try {
const result = await Cli.checkForUpdate(this._checkCancellable);
const [result] = await Promise.all([
Cli.checkForUpdate(cancellable),
this._checkSiblings(cancellable),
]);
this._update = {...result, checkedAt: GLib.get_real_time() / 1e6};
} catch {
return; // cancelled: the extension is being disabled
@@ -354,6 +399,23 @@ class Indicator extends PanelMenu.Button {
this._updateIndicator();
}
// Look for newer versions of the sibling projects. Keeps the last result
// if sibling can't run; throws only when cancelled.
async _checkSiblings(cancellable) {
this._siblingNames = await Cli.installedSiblings();
if (this._siblingNames.length === 0) {
this._siblings = [];
return;
}
try {
this._siblings = await Cli.checkSiblings(cancellable);
} catch (e) {
if (e.matches?.(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
throw e;
console.warn(`CoreDesktop: couldn't check sibling projects: ${e.message}`);
}
}
// Bring the menu, header and top bar icon in line with what's known
_updateIndicator() {
if (!this._header)
@@ -361,6 +423,9 @@ class Indicator extends PanelMenu.Button {
const {state, version, checkedAt} = this._update;
const running = [...this._running.keys()];
const updating = this._running.has('update') || this._running.has('refresh');
const siblings = this._siblings ?? [];
const newerSiblings = siblings.filter(s => s.state === 'available').length;
const somethingNewer = state === 'available' || newerSiblings > 0;
// Header status line
if (this._running.has('update'))
@@ -371,6 +436,10 @@ class Indicator extends PanelMenu.Button {
this._header.setStatus('Restart to finish the last update', 'warning');
else if (state === 'available')
this._header.setStatus(`${version} is available`, 'accent');
else if (state === 'current' && newerSiblings > 0)
this._header.setStatus(newerSiblings === 1
? 'A sibling project has a newer version'
: `${newerSiblings} sibling projects have newer versions`, 'accent');
else if (state === 'current')
this._header.setStatus('Up to date', 'success');
else if (checkedAt)
@@ -383,16 +452,18 @@ class Indicator extends PanelMenu.Button {
this._checkItem.description.text = checkedAt
? `Last checked ${Cli.timeAgo(checkedAt)}${this._lastUpdate
? ` · last updated ${Cli.timeAgo(this._lastUpdate)}` : ''}`
: 'See whether a newer CoreDesktop is out';
: 'See whether a newer CoreDesktop or sibling project is out';
this._rebootItem.visible = this._rebootNeeded && !updating;
this._updateSiblingsItem(running);
// Pills on the commands
const configuring = running.some(k => k === 'configure' || k.startsWith('configure-'));
for (const [key, item] of Object.entries(this._items)) {
if (this._running.has(key) || (key === 'configure' && configuring))
item.pill.setState('Running…', 'running');
else if (key === 'update' && state === 'available')
else if (key === 'update' && somethingNewer)
item.pill.setState('New version', 'accent');
else if (key === 'configure' && this._configureTodo > 0)
item.pill.setState(`${this._configureTodo} to do`, 'warning');
@@ -412,7 +483,7 @@ class Indicator extends PanelMenu.Button {
});
}
const badge = this._settings.get_boolean('show-badge') && !updating &&
(this._rebootNeeded || state === 'available');
(this._rebootNeeded || somethingNewer);
this._badge.visible = badge;
this._badge.remove_style_class_name('warning');
if (this._rebootNeeded)
@@ -423,11 +494,39 @@ class Indicator extends PanelMenu.Button {
accessible += ', updating';
else if (this._rebootNeeded)
accessible += ', restart needed';
else if (state === 'available')
else if (somethingNewer)
accessible += ', update available';
this.accessible_name = accessible;
}
// The Sibling projects item: how many, and whether any is newer
_updateSiblingsItem(running) {
const count = this._siblingNames.length;
this._siblingsItem.visible = count > 0;
if (count === 0)
return;
const siblings = this._siblings ?? [];
const newer = siblings.filter(s => s.state === 'available');
const unknown = siblings.filter(s => s.state === 'unknown').length;
let description;
if (newer.length > 0)
description = `Newer: ${newer.map(s => s.name).join(', ')}`;
else if (!this._siblings)
description = `${count} installed`;
else if (unknown > 0)
description = `${count} installed, couldn't check ${unknown}`;
else
description = count === 1 ? '1 installed, up to date' : `${count} installed, all up to date`;
this._siblingsItem.description.text = description;
if (running.some(k => k === 'update' || k === 'siblings' || k.startsWith('sibling-')))
this._siblingsItem.pill.setState('Running…', 'running');
else if (newer.length > 0)
this._siblingsItem.pill.setState(newer.length === 1 ? '1 new' : `${newer.length} new`, 'accent');
else
this._siblingsItem.pill.setState(null);
}
_runCommand(key) {
if (key === 'version') {
new VersionDialog({onUpdate: () => this._runCommand('update')}).open();
@@ -458,10 +557,9 @@ class Indicator extends PanelMenu.Button {
this._notify(`${title} is already running`, 'Look for its terminal window.');
return;
}
if ((name === 'update' || name === 'refresh') &&
(this._running.has('update') || this._running.has('refresh'))) {
if (changesSystem(name) && [...this._running.keys()].some(changesSystem)) {
this._notify('Wait for the current run to finish',
'Update and refresh both change the system, so run one at a time.');
'Update, refresh and sibling updates all change the system, so run one at a time.');
return;
}
const ok = Cli.runInTerminal(this._ext.path, this._settings.get_string('terminal'),
@@ -559,9 +657,14 @@ class Indicator extends PanelMenu.Button {
const title = this._titles.get(name) ?? COMMANDS[name]?.title ?? name;
this._titles.delete(name);
const sibling = name === 'siblings' || name.startsWith('sibling-');
if (name === 'update' && code === 0)
this._update = {state: 'current', version: null, checkedAt: GLib.get_real_time() / 1e6};
this._refreshLocal().then(() => {
// Update and sibling update change the siblings' versions: look again
if (name === 'update' || sibling)
this._checkSiblingsNow();
if (!this._settings.get_boolean('notify-finished'))
return;
if (code === 0) {
@@ -571,6 +674,9 @@ class Indicator extends PanelMenu.Button {
'success', restart ? [['Restart now', () => this._restart()]] : []);
} else if (code === 129 || code === 130) {
this._notify(`${title} was stopped`, 'Its window was closed before it finished.', 'warning');
} else if (sibling) {
this._notify(`${title} ran into problems`,
'Its terminal window says what went wrong.', 'error');
} else {
const actions = [['Open log', () => this._openLatestLog()]];
if (name === 'update' || name === 'refresh')
@@ -581,6 +687,21 @@ class Indicator extends PanelMenu.Button {
});
}
// Check the siblings alone, unless a full check is already running
async _checkSiblingsNow() {
if (this._checkCancellable)
return;
const cancellable = this._checkCancellable = new Gio.Cancellable();
try {
await this._checkSiblings(cancellable);
} catch {
return; // cancelled: the extension is being disabled
} finally {
this._checkCancellable = null;
}
this._updateIndicator();
}
_restart() {
// GNOME's own restart dialog, with its countdown and cancel button
try {