From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager v2 2/3] api: provide GUI versions via index and /cluster/resources
Date: Thu, 19 Nov 2026 16:38:03 +0100 [thread overview]
Message-ID: <20261119153935.3989613-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261119153935.3989613-1-d.csapak@proxmox.com>
Index has these versions anyway, just expose them to the UI via the
usual `Proxmox` object.
In the /cluster/resources API call, we add that information to the node
that is handling the request (which is normally the same where the index
was loaded from).
Cache the pwt versions locally for 60 seconds, so we don't hit the file
read on every call, but force it for every index call (like we did
before).
With this information, the UI can detect an outdated UI version still
running.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
PVE/API2/Cluster.pm | 31 +++++++++++++++++++++++++++++++
PVE/API2Tools.pm | 22 ++++++++++++++++++----
PVE/Service/pveproxy.pm | 2 +-
www/index.html.tpl | 6 +++++-
4 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index aaec3ec3..114ba033 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -21,6 +21,7 @@ use PVE::RPCEnvironment;
use PVE::SafeSyslog;
use PVE::Storage;
use PVE::Tools qw(extract_param);
+use PVE::pvecfg;
use PVE::API2::ACMEAccount;
use PVE::API2::ACMEPlugin;
@@ -504,6 +505,25 @@ __PACKAGE__->register_method({
default => 'x86_64',
optional => 1,
},
+ 'versions' => {
+ description => "Optional package versions (for type 'node').",
+ type => 'object',
+ optional => 1,
+ properties => {
+ 'pve-manager' => {
+ type => "string",
+ optional => 1,
+ description =>
+ "The pve-manager version of this node. Only included for the node handling the request.",
+ },
+ 'proxmox-widget-toolkit' => {
+ type => "string",
+ optional => 1,
+ description =>
+ "The proxmox-widget-toolkit version of this node. Only included for the node handling the request.",
+ },
+ },
+ },
},
},
},
@@ -619,6 +639,8 @@ __PACKAGE__->register_method({
my $static_node_info = PVE::Cluster::get_node_kv("static-info");
if (!$param->{type} || $param->{type} eq 'node') {
+ my $nodename = PVE::INotify::nodename();
+
foreach my $node (@$nodelist) {
my $can_audit = $rpcenv->check($authuser, "/nodes/$node", ['Sys.Audit'], 1);
my $entry =
@@ -635,6 +657,15 @@ __PACKAGE__->register_method({
$entry->{'hastate'} = $status;
}
+ if ($node eq $nodename) {
+ my $pwt_version = PVE::API2Tools::read_pwt_version();
+
+ $entry->{versions} = { 'pve-manager' => PVE::pvecfg::version() };
+ # an empty version means reading failed, omit it to avoid false positives
+ $entry->{versions}->{'proxmox-widget-toolkit'} = $pwt_version
+ if $pwt_version ne '';
+ }
+
push @$res, $entry;
}
}
diff --git a/PVE/API2Tools.pm b/PVE/API2Tools.pm
index f137b172..1bbfeafa 100644
--- a/PVE/API2Tools.pm
+++ b/PVE/API2Tools.pm
@@ -277,11 +277,25 @@ sub pwt_base_dir {
return '/usr/share/javascript/proxmox-widget-toolkit';
}
+my $pwt_version_cache = {};
+
sub read_pwt_version {
- my $base_dir = pwt_base_dir();
- my $wtversionraw = PVE::File::file_read_first_line("$base_dir/proxmoxlib.js") // '';
- my $wtversion = $wtversionraw =~ m|^// (.*)$| ? $1 : '';
- return $wtversion;
+ my ($force) = @_;
+
+ my $time = time();
+ if (
+ $force
+ || !defined($pwt_version_cache->{version})
+ || $pwt_version_cache->{time} + 60 < $time
+ ) {
+ my $base_dir = pwt_base_dir();
+ my $wtversionraw = PVE::File::file_read_first_line("$base_dir/proxmoxlib.js") // '';
+ my $wtversion = $wtversionraw =~ m|^// (.*)$| ? $1 : '';
+ $pwt_version_cache->{version} = $wtversion;
+ $pwt_version_cache->{time} = $time;
+ }
+
+ return $pwt_version_cache->{version};
}
1;
diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
index dc97f815..ed047d27 100755
--- a/PVE/Service/pveproxy.pm
+++ b/PVE/Service/pveproxy.pm
@@ -262,7 +262,7 @@ sub get_index {
my $version = PVE::pvecfg::version();
- my $wtversion = PVE::API2Tools::read_pwt_version();
+ my $wtversion = PVE::API2Tools::read_pwt_version(1); # force read
# while we could use the actual pkg version (e.g., shipped as pkg-version file in each
# respective package's /usr/share/<pkg> folder, this way it should also work when using make
diff --git a/www/index.html.tpl b/www/index.html.tpl
index 125c1046..21345822 100644
--- a/www/index.html.tpl
+++ b/www/index.html.tpl
@@ -48,7 +48,11 @@
NodeArch: '[% arch %]',
UserName: '[% username %]',
CSRFPreventionToken: '[% token %]',
- ConsentText: '[% consenttext.squote %]'
+ ConsentText: '[% consenttext.squote %]',
+ GUIVersions: {
+ 'pve-manager': '[% version %]',
+ 'proxmox-widget-toolkit': '[% wtversion %]',
+ },
};
</script>
<script type="text/javascript" src="/proxmoxlib.js?ver=[% wtversion %]"></script>
--
2.47.3
next prev parent reply other threads:[~2026-11-19 15:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 15:38 [PATCH pve-manager v2 0/3] ui: prompt users for reload when web ui version changes Dominik Csapak
2026-11-19 15:38 ` [PATCH pve-manager v2 1/3] api: factor out read_pwt_version and pwt_base_dir Dominik Csapak
2026-11-19 15:38 ` Dominik Csapak [this message]
2026-11-19 15:38 ` [PATCH pve-manager v2 3/3] ui: workspace: prompt user for reload when UI packages were updated Dominik Csapak
2026-11-19 17:13 ` superseded: [PATCH pve-manager v2 0/3] ui: prompt users for reload when web ui version changes Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119153935.3989613-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox