Compare commits

..

25 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
5b9cac549a Suppress version reporting prompt when WLED is in AP mode
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-21 08:08:15 +00:00
copilot-swe-agent[bot]
0f03105693 Add privacy policy link to version reporting modal
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-20 19:54:00 +00:00
copilot-swe-agent[bot]
e79696fd75 Move flashSize to always-present fields (not optional)
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-20 03:08:38 +00:00
copilot-swe-agent[bot]
c1d2f2181d Remove conditional checks for brand and product fields (always present)
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-20 03:05:41 +00:00
copilot-swe-agent[bot]
75851f2f00 Fix releaseName to use release field instead of cn (codename)
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-20 02:59:35 +00:00
copilot-swe-agent[bot]
82dc46b5d3 Add optional fields from updated OpenAPI spec (brand, product, flashSize, psramSize)
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-20 02:49:56 +00:00
Will Tatam
79ced7d57e update usage prompt text 2025-11-19 23:34:37 +00:00
Will Tatam
a3d9fed00f Fix buttons 2025-11-19 23:20:41 +00:00
Will Tatam
551240b9a9 Pass the correct field for release 2025-11-19 22:49:30 +00:00
Will Tatam
58e63ad9d9 Fix usage url 2025-11-19 22:42:59 +00:00
copilot-swe-agent[bot]
2de76a5b6b Refactor showVersionUpgradePrompt to reduce duplication
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-19 21:42:51 +00:00
copilot-swe-agent[bot]
348ab4c485 Use existing /edit endpoint instead of dedicated version-info.json GET endpoint
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-19 21:36:55 +00:00
copilot-swe-agent[bot]
fce849eae9 Add different messaging for install vs upgrade prompts
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-19 21:13:33 +00:00
copilot-swe-agent[bot]
5bd4c23319 Return 404 when version-info.json doesn't exist instead of default JSON
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-19 21:01:03 +00:00
copilot-swe-agent[bot]
91ad8a89bc Reuse /upload endpoint instead of dedicated POST endpoint for version-info.json
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-19 20:52:58 +00:00
copilot-swe-agent[bot]
010eefe52a Add bootloaderSHA256 field to UpgradeEventRequest
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 19:20:51 +00:00
copilot-swe-agent[bot]
97c35d09cf Map fields to UpgradeEventRequest schema from OpenAPI spec
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 19:06:33 +00:00
copilot-swe-agent[bot]
1d006d0243 Wrap info data in 'info' field per UpgradeEventRequest structure
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 19:01:31 +00:00
copilot-swe-agent[bot]
97c3e10796 Only save version-info when API call succeeds, not on failure
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 18:53:08 +00:00
copilot-swe-agent[bot]
b50c050a89 Map info response fields to upgradeData structure field by field
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 18:50:55 +00:00
copilot-swe-agent[bot]
366f3d3854 Fetch fresh data from /json/info endpoint before reporting upgrade
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 18:39:14 +00:00
copilot-swe-agent[bot]
783634de86 Add opt-in version upgrade reporting with persistent user preferences
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 18:20:48 +00:00
copilot-swe-agent[bot]
bdc7e8cc91 Fix version reporting to pass oldVersion correctly and send full info object
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 18:14:52 +00:00
copilot-swe-agent[bot]
12387d424f Add version reporting feature - backend and frontend implementation
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
2025-11-17 18:08:35 +00:00
copilot-swe-agent[bot]
be981a4f91 Initial plan 2025-11-17 17:58:29 +00:00
3 changed files with 199 additions and 18 deletions

View File

@@ -1687,11 +1687,10 @@ void WS2812FX::setTransitionMode(bool t) {
// rare circumstances are: setting FPS to high number (i.e. 120) and have very slow effect that will need more
// time than 2 * _frametime (1000/FPS) to draw content
void WS2812FX::waitForIt() {
unsigned long waitStart = millis();
unsigned long maxWait = 2*getFrameTime() + 100; // TODO: this needs a proper fix for timeout! see #4779
while (isServicing() && (millis() - waitStart < maxWait)) delay(1); // safe even when millis() rolls over
unsigned long maxWait = millis() + 2*getFrameTime() + 100; // TODO: this needs a proper fix for timeout! see #4779
while (isServicing() && maxWait > millis()) delay(1);
#ifdef WLED_DEBUG
if (millis()-waitStart >= maxWait) DEBUG_PRINTLN(F("Waited for strip to finish servicing."));
if (millis() >= maxWait) DEBUG_PRINTLN(F("Waited for strip to finish servicing."));
#endif
};

View File

@@ -213,7 +213,7 @@ function createTop(element, editor){
function httpPostCb(st,resp){
if (st!=200) alert("ERROR "+st+": "+resp);
else {
showToast("Upload successful!");
alert("Upload successful!");
refreshTree();
}
}
@@ -264,7 +264,7 @@ function createTree(element, editor){
leaf.textContent=name;
var span = cE("span");
span.style.cssText = "font-size: 14px; color: #aaa; margin-left: 8px;";
span.textContent = (size > 0 ? Math.max(0.1, (size / 1024)).toFixed(1) : 0) + "KB"; // show size in KB, minimum 0.1 to not show 0KB for small files
span.textContent = (size / 1024).toFixed(1) + "KB";
leaf.appendChild(span);
leaf.onmouseover=function(){ leaf.style.background="#333"; };
leaf.onmouseout=function(){ leaf.style.background=""; };
@@ -377,13 +377,13 @@ function prettyLedmap(json){
rows.push(" " + obj.map.slice(i, i + width).map(pad).join(", "));
}
let pretty = "{\n";
let pretty = "{\n \"map\": [\n" + rows.join(",\n") + "\n ]";
for (let k of Object.keys(obj)) {
if (k !== "map") {
pretty += " \"" + k + "\": " + JSON.stringify(obj[k]) + ",\n"; // print all keys first (speeds up loading)
pretty += ",\n \"" + k + "\": " + JSON.stringify(obj[k]);
}
}
pretty += " \"map\": [\n" + rows.join(",\n") + "\n ]\n}";
pretty += "\n}";
return pretty;
} catch (e) {
return json;
@@ -493,7 +493,7 @@ function createEditor(element,file){
req.add("POST","/upload",fd,function(st,resp){
if (st!=200) alert("ERROR "+st+": "+resp);
else {
showToast("File saved");
alert("File saved successfully!");
refreshTree();
}
});
@@ -567,18 +567,10 @@ function onBodyLoad(){
var editor=createEditor("editor",vars.file);
globalTree=createTree("tree",editor);
createTop("top",editor);
// Add Ctrl+S / Cmd+S override to save the file
document.addEventListener('keydown', function(e) {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
e.preventDefault();
editor.save();
}
});
}
</script>
</head>
<body onload="onBodyLoad()">
<div id="toast"></div>
<div id="loader"><div class="loader"></div></div>
<div id="top"></div>
<div style="flex:1;position:relative">

View File

@@ -1756,6 +1756,7 @@ function requestJson(command=null)
if (json.info) {
let i = json.info;
parseInfo(i);
checkVersionUpgrade(i); // Check for version upgrade
populatePalettes(i);
if (isInfo) populateInfo(i);
if (simplifiedUI) simplifyUI();
@@ -3304,6 +3305,195 @@ function simplifyUI() {
gId("btns").style.display = "none";
}
// Version reporting feature
var versionCheckDone = false;
function checkVersionUpgrade(info) {
// Only check once per page load
if (versionCheckDone) return;
versionCheckDone = true;
// Suppress feature if in AP mode (no internet connection available)
if (info.wifi && info.wifi.ap) return;
// Fetch version-info.json using existing /edit endpoint
fetch(getURL('/edit?func=edit&path=/version-info.json'), {
method: 'get'
})
.then(res => {
if (res.status === 404) {
// File doesn't exist - first install, show install prompt
showVersionUpgradePrompt(info, null, info.ver);
return null;
}
if (!res.ok) {
throw new Error('Failed to fetch version-info.json');
}
return res.json();
})
.then(versionInfo => {
if (!versionInfo) return; // 404 case already handled
// Check if user opted out
if (versionInfo.neverAsk) return;
// Check if version has changed
const currentVersion = info.ver;
const storedVersion = versionInfo.version || '';
if (storedVersion && storedVersion !== currentVersion) {
// Version has changed, show upgrade prompt
showVersionUpgradePrompt(info, storedVersion, currentVersion);
} else if (!storedVersion) {
// Empty version in file, show install prompt
showVersionUpgradePrompt(info, null, currentVersion);
}
})
.catch(e => {
console.log('Failed to load version-info.json', e);
// On error, save current version for next time
if (info && info.ver) {
updateVersionInfo(info.ver, false);
}
});
}
function showVersionUpgradePrompt(info, oldVersion, newVersion) {
// Determine if this is an install or upgrade
const isInstall = !oldVersion;
// Create overlay and dialog
const overlay = d.createElement('div');
overlay.id = 'versionUpgradeOverlay';
overlay.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.7);z-index:10000;display:flex;align-items:center;justify-content:center;';
const dialog = d.createElement('div');
dialog.style.cssText = 'background:var(--c-1);border-radius:10px;padding:25px;max-width:500px;margin:20px;box-shadow:0 4px 6px rgba(0,0,0,0.3);';
// Build contextual message based on install vs upgrade
const title = isInstall
? '🎉 Thank you for installing WLED!'
: '🎉 WLED Upgrade Detected!';
const description = isInstall
? `You are now running WLED <strong>${newVersion}</strong>.`
: `Your WLED has been upgraded from <strong>${oldVersion}</strong> to <strong>${newVersion}</strong>.`;
const question = 'Would you like to help the WLED development team by reporting your installation? This helps us understand what hardware and versions are being used.'
dialog.innerHTML = `
<h2 style="margin-top:0;color:var(--c-f);">${title}</h2>
<p style="color:var(--c-f);">${description}</p>
<p style="color:var(--c-f);">${question}</p>
<p style="color:var(--c-f);font-size:0.9em;">
<a href="https://kno.wled.ge/about/privacy-policy/" target="_blank" style="color:var(--c-6);">Learn more about what data is collected and why</a>
</p>
<div style="margin-top:20px;">
<button id="versionReportYes" class="btn">Yes</button>
<button id="versionReportNo" class="btn">Not Now</button>
<button id="versionReportNever" class="btn">Never Ask</button>
</div>
`;
overlay.appendChild(dialog);
d.body.appendChild(overlay);
// Add event listeners
gId('versionReportYes').addEventListener('click', () => {
reportUpgradeEvent(info, oldVersion, newVersion);
d.body.removeChild(overlay);
});
gId('versionReportNo').addEventListener('click', () => {
// Don't update version, will ask again on next load
d.body.removeChild(overlay);
});
gId('versionReportNever').addEventListener('click', () => {
updateVersionInfo(newVersion, true);
d.body.removeChild(overlay);
showToast('You will not be asked again.');
});
}
function reportUpgradeEvent(info, oldVersion, newVersion) {
showToast('Reporting upgrade...');
// Fetch fresh data from /json/info endpoint as requested
fetch(getURL('/json/info'), {
method: 'get'
})
.then(res => res.json())
.then(infoData => {
// Map to UpgradeEventRequest structure per OpenAPI spec
// Required fields: deviceId, version, previousVersion, releaseName, chip, ledCount, isMatrix, bootloaderSHA256
const upgradeData = {
deviceId: infoData.mac || '', // Use MAC address as unique device ID
version: infoData.ver || '', // Current version string
previousVersion: oldVersion || '', // Previous version from version-info.json
releaseName: infoData.release || '', // Release name (e.g., "WLED 0.15.0")
chip: infoData.arch || '', // Chip architecture (esp32, esp8266, etc)
ledCount: infoData.leds ? infoData.leds.count : 0, // Number of LEDs
isMatrix: !!(infoData.leds && infoData.leds.matrix), // Whether it's a 2D matrix setup
bootloaderSHA256: infoData.bootloaderSHA256 || '', // Bootloader SHA256 hash
brand: infoData.brand, // Device brand (always present)
product: infoData.product, // Product name (always present)
flashSize: infoData.flash + 'MB' // Flash size (always present)
};
// Add optional fields if available
if (infoData.psram !== undefined) upgradeData.psramSize = infoData.psram + 'B';
// Note: partitionSizes not currently available in /json/info endpoint
// Make AJAX call to postUpgradeEvent API
return fetch('https://usage.wled.me/api/usage/upgrade', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(upgradeData)
});
})
.then(res => {
if (res.ok) {
showToast('Thank you for reporting!');
updateVersionInfo(newVersion, false);
} else {
showToast('Report failed. Please try again later.', true);
// Do NOT update version info on failure - user will be prompted again
}
})
.catch(e => {
console.log('Failed to report upgrade', e);
showToast('Report failed. Please try again later.', true);
// Do NOT update version info on error - user will be prompted again
});
}
function updateVersionInfo(version, neverAsk) {
const versionInfo = {
version: version,
neverAsk: neverAsk
};
// Create a Blob with JSON content and use /upload endpoint
const blob = new Blob([JSON.stringify(versionInfo)], { type: 'application/json' });
const formData = new FormData();
formData.append('data', blob, 'version-info.json');
fetch(getURL('/upload'), {
method: 'POST',
body: formData
})
.then(res => res.text())
.then(data => {
console.log('Version info updated', data);
})
.catch(e => {
console.log('Failed to update version-info.json', e);
});
}
size();
_C.style.setProperty('--n', N);