Skip to content

Commit 627835a

Browse files
authored
Show fancier version comparison in update dialog (#1916)
Related tiny-pilot/tinypilot-pro#1620 This PR backports the version comparison UI from Pro's update-dialog (based on our [discussion here](#1914 (comment))). Note that Community version strings look something like this `0.0.0-0+aaaaaaa` (where `aaaaaaa` is the git commit short hash). We purposefully strip the commit hash from being displayed because it doesn't look as nice. End result: - <img width="522" height="339" alt="Screenshot 2025-09-23 at 16 41 11" src="https://github.com/user-attachments/assets/6dfc5e11-424b-46e7-96a1-7fa234e53df8" /> - <img width="380" height="301" alt="Screenshot 2025-09-23 at 16 40 53" src="https://github.com/user-attachments/assets/b7824acf-0ca0-42c3-a81e-69e1e248f68d" /> <a data-ca-tag href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1916"><img src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review on CodeApprove" /></a>
1 parent 12830e2 commit 627835a

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

app/static/css/icons.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,30 @@
1818
border-right: var(--width) solid transparent;
1919
border-top: var(--height) solid var(--brand-creme-light);
2020
}
21+
22+
.icon-long-arrow {
23+
position: relative;
24+
width: 20px;
25+
}
26+
27+
.icon-long-arrow:before {
28+
position: absolute;
29+
content: "";
30+
top: -1px;
31+
left: 0;
32+
width: 90%;
33+
height: 2px;
34+
background: #000;
35+
}
36+
37+
.icon-long-arrow:after {
38+
position: absolute;
39+
content: "";
40+
top: -5px;
41+
right: 0;
42+
width: 0;
43+
height: 0;
44+
border-top: 5px solid transparent;
45+
border-bottom: 5px solid transparent;
46+
border-left: 10px solid #000;
47+
}

app/templates/custom-elements/update-dialog.html

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template id="update-dialog-template">
22
<style>
33
@import "css/style.css";
4+
@import "css/icons.css";
45

56
#checking,
67
#update-available,
@@ -43,6 +44,29 @@
4344
margin: 1rem 0;
4445
}
4546

47+
.versions-info {
48+
display: flex;
49+
align-items: center;
50+
justify-content: center;
51+
}
52+
53+
.version {
54+
border: 1px solid black;
55+
border-radius: 0.2rem;
56+
padding: 0.5rem 1rem;
57+
margin: 0 0.5rem;
58+
}
59+
60+
.version-number {
61+
font-size: 1rem;
62+
}
63+
64+
.version-label {
65+
font-size: 0.8rem;
66+
color: #444;
67+
text-transform: uppercase;
68+
}
69+
4670
#update-container details {
4771
margin-top: 1rem;
4872
}
@@ -73,6 +97,17 @@ <h3>Checking for Updates</h3>
7397

7498
<div id="update-available">
7599
<h3>Update TinyPilot</h3>
100+
<div class="versions-info">
101+
<div class="version version-local">
102+
<div class="version-number monospace"></div>
103+
<div class="version-label">Your version</div>
104+
</div>
105+
<div class="icon-long-arrow"></div>
106+
<div class="version version-latest">
107+
<div class="version-number monospace"></div>
108+
<div class="version-label">Latest version</div>
109+
</div>
110+
</div>
76111
<update-prompt-automatic
77112
id="update-prompt-automatic"
78113
></update-prompt-automatic>
@@ -81,6 +116,12 @@ <h3>Update TinyPilot</h3>
81116

82117
<div id="latest">
83118
<h3>No Updates Available</h3>
119+
<div class="versions-info">
120+
<div class="version version-local">
121+
<div class="version-number monospace"></div>
122+
<div class="version-label">Your version</div>
123+
</div>
124+
</div>
84125
<p>You are running the latest version of TinyPilot.</p>
85126
<button id="ok-latest" type="button">Close</button>
86127
</div>
@@ -226,12 +267,14 @@ <h3>Update Complete</h3>
226267
this.shadowRoot
227268
.querySelectorAll(".version-local .version-number")
228269
.forEach((e) => {
229-
e.innerText = localVersion.version;
270+
// Strip commit hash from version string.
271+
e.innerText = localVersion.version.split("+", 1)[0];
230272
});
231273
this.shadowRoot
232274
.querySelectorAll(".version-latest .version-number")
233275
.forEach((e) => {
234-
e.innerText = latestRelease.version;
276+
// Strip commit hash from version string.
277+
e.innerText = latestRelease.version.split("+", 1)[0];
235278
});
236279

237280
if (localVersion.version === latestRelease.version) {

0 commit comments

Comments
 (0)