Skip to content

Conversation

@bobrippling
Copy link
Collaborator

@bobrippling bobrippling commented Dec 22, 2025

This allows users to hide clkinfos they aren't using. No extra cost since we use the clkinfo cache

Closes espruino/EspruinoAppLoaderCore#83

  • Fix bootupdate: it isn't triggering when I change clock_info.json, need to force the boot code regeneration/bootupdate.js to run
  • Test

@RKBoss6
Copy link
Contributor

RKBoss6 commented Jan 4, 2026

Hey - quick question. If the user excludes a specific clock info, will that mean that apps specifically trying to load that clockInfo won't be able to? Eg. An app only uses one clock info like 'sunrise clockinfo' but everywhere else it's omitted?

@bobrippling
Copy link
Collaborator Author

Hey - quick question. If the user excludes a specific clock info, will that mean that apps specifically trying to load that clockInfo won't be able to? Eg. An app only uses one clock info like 'sunrise clockinfo' but everywhere else it's omitted?

It depends how the clkinfo is loaded. If require('clkinfo').load() is used, the excluded ones will be skipped:

var clkInfoCache = require('Storage').read('.clkinfocache');
if (clkInfoCache!==undefined) {
// note: code below is included in clkinfocache by bootupdate.js
// we use clkinfocache if it exists as it's faster
eval(clkInfoCache);
} else require("Storage").list(/clkinfo\.js$/).forEach(fn => {
// In case there exists already a menu object b with the same name as the next
// object a, we append the items. Otherwise we add the new object a to the list.
try{
var a = eval(require("Storage").read(fn))();
var b = menu.find(x => x.name === a.name);
if(b) b.items = b.items.concat(a.items);
else menu = menu.concat(a);
} catch(e){
console.log("Could not load clock info "+E.toJS(fn)+": "+e);
}
});

How does the app in question use (for example) sunrise clkinfo?

@bobrippling
Copy link
Collaborator Author

@gfwilliams how does this look?

.keys(settings.exclude)
.filter(k => !(k.replace(re, "") in filterMenu))
.forEach(k => {
delete settings.exclude[k];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very tiny thing: suppose someone installs a clockinfo, excludes it, and then deletes it. You handle that here, but only save it if the user actually changes something in the menu. Maybe just add a changed=true; ... if (changed) save() so at least just looking at the menu would be enough to remove the entry?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, done!

@gfwilliams
Copy link
Member

gfwilliams commented Jan 6, 2026

That looks perfect to me - really nice and tidy.

I wouldn't worry about the 'what if an app used a clockinfo' thing - I'm not aware of any apps doing that, and even then someone would have to explicitly disable the clockinfo.

bootupdate isn't triggering when I change clock_info.json

The easiest way to do that would be to just rewrite 'setting.json'. Rewriting with the same data won't work as Espruino is smart enough to detect that, but I'm sure you could add something like s.toggle = !s.toggle that'd be enough. Or you could store the exclude list in setting.json instead?

I wouldn't add a check for the contents of the clockinfo JSON file as that's just another read and possible delay.

@bobrippling
Copy link
Collaborator Author

bootupdate isn't triggering when I change clock_info.json

The easiest way to do that would be to just rewrite 'setting.json'
...
something like s.toggle = !s.toggle that'd be enough

Thanks, sorted!

@gfwilliams
Copy link
Member

Looks perfect - thank you! Shall we merge?

@bobrippling
Copy link
Collaborator Author

Sounds good to me - thanks again!

@bobrippling bobrippling merged commit 49818ad into espruino:master Jan 12, 2026
1 check passed
@bobrippling bobrippling deleted the feat/clkinfo-filtering branch January 12, 2026 21:13
@thyttan
Copy link
Collaborator

thyttan commented Jan 20, 2026

Not sure it's from this. But clock infos misbehave on my watch, fw 2v28.70 iflash. Have you noticed anything? I'll try debugging some tomorrow. Haven't used clock infos in a while so not sure when it would have started.

@RKBoss6
Copy link
Contributor

RKBoss6 commented Jan 20, 2026

How so? For me on regular cutting-edge fw, nothing seems out of the ordinary using this version

@thyttan
Copy link
Collaborator

thyttan commented Jan 20, 2026

OK - thanks! Interesting and a little reassuring :)

@bobrippling
Copy link
Collaborator Author

I've not noticed anything, but haven't changed the setup after I filtered down the clkinfos. What's the misbehaviour?

@RKBoss6
Copy link
Contributor

RKBoss6 commented Jan 22, 2026

@thyttan What's the problem you're having? Recently, my ClockInfos started bugging out too, and wouldn't update the screen to show the new clockInfo, saying :

Uncaught Error: Function code is undefined, not a string
    at menuHideItem (clock_info:293:23)
      itm.hide(options);
                      ^
    at clock_info:327:31
      menuHideItem(oldMenuItem);

Even though it was never a problem before, which now crashes my clock face each time. I had updated to this version prior, but the issue wasn't there, and now it just randomly is showing up...

@thyttan
Copy link
Collaborator

thyttan commented Jan 22, 2026

Yes, I think we're seing the same thing now then 🙃

Would you have the time to file a bug report @RKBoss6?

@RKBoss6
Copy link
Contributor

RKBoss6 commented Jan 22, 2026

Yeah, I can get on that in a bit!

@gfwilliams
Copy link
Member

Ah, interesting. Can you file it on the Espruino project?

The idea was to detect broken functions but I guess the interpreter decides not even to try allocating a code variable if the function is empty

@RKBoss6
Copy link
Contributor

RKBoss6 commented Jan 22, 2026

Yeah, I can copy the issue over to the espruino repo

@gfwilliams
Copy link
Member

Just fixed that issue: espruino/Espruino#2681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have optional clkinfo

4 participants