app-center icon indicating copy to clipboard operation
app-center copied to clipboard

Track active changes throughout the application

Open d-loose opened this issue 1 year ago • 6 comments

Currently, active snap changes are only being tracked on the snap page. To take better advantage of snapd's capabilities, those changes should be monitored in an application-wide scope. This would allow for application-level progress bars when installing/removing/updating multiple snaps and resolve issues like #1360.

As the 23.10 release is approaching it's clear that this is beyond the scope of the MVP - I'm putting this here for future reference :slightly_smiling_face:

d-loose avatar Oct 05 '23 08:10 d-loose

Hello,

As a newcomer to the open-source world, I’m excited about making my first contribution.

I would like to take this change, however, I need some assistance in understanding the snapd API for retrieving information about ‘snapd changes’.

I’ve explored the SnapdClient and its getChanges method, which provides details about current changes. However, I’m facing an issue: there doesn’t seem to be a property that uniquely identifies the affected snap.

image

In the screenshot above, the 0ad snap is being installed, and the getChanges method returns relevant information. However, I’m unable to determine the name of the snap to map it correctly.

The snapNames list appears to be empty. Is this behavior expected, or could it be a bug?

codinesh avatar Nov 29 '23 18:11 codinesh

Hey, looking forward to seeing your contributions!

The snapNames list appears to be empty. Is this behavior expected, or could it be a bug?

I think I've noticed this before, but didn't investigate it further at the time - it's definitely inconvenient. Maybe it's worth asking the snapd team about this (the forum is probably the best communication channel). It's possible to retrieve the list of changes for a given snap using the getChanges method, which accepts an optional name argument (passing it via the for query parameter to the /v2/changes endpoint). I'm not sure how helpful this is, though, since you need to know the name of the snap for which you want to get the changes in advance. So we'd have to track the names of the snaps whose changes we want to monitor in the app. If the API response included the name of the involved snaps in every response it would be easily possible to monitor all changes of all snaps the system so that we could update the UI even if a snap change is triggered by an external application (i.e. run snap install foo in a terminal and there'd be a progress bar in app-center etc).

d-loose avatar Nov 30 '23 09:11 d-loose

Thanks for sharing the information @d-loose. Yes, we can get changes for a snap by its name, I am thinking that might cause multiple calls and performance issues.

We have to make /snaps call first and then loop through each snap for the changes and identify any active changes. Will keep this in mind as workaround.

Posted a topic for this in Snapcraft forum, will wait for a response.

codinesh avatar Nov 30 '23 11:11 codinesh

We have to make /snaps call first and then loop through each snap for the changes and identify any active changes. Will keep this in mind as workaround.

For a workaround, I'd probably keep it a bit simpler than that - instead of tracking active changes for all snaps (e.g. by polling snapd in regular intervals), I'd maintain a list of changes locally and add/remove items to it whenever we invoke a snap action through the UI. This way we'd at least track all of our "own" changes without sending a lot of requests through snapd.

Posted a topic for this in Snapcraft forum, will wait for a response.

Thanks a lot!

d-loose avatar Nov 30 '23 12:11 d-loose

Hello @d-loose, thank you for suggestion, I have made code changes to track the list of snaps being installed/uninstalled and show in separate table.

Here is the screenshot of the local version of app in my machine. I am still working on some improvements in code and UX, like adding a progress indicator and show more details in the row.

Any suggestions or feedback on the behavior and experience for showing the currently installing apps. image

I have considered showing a new entry in existing 'Installed and updated' apps table (instead of in a new table), with a progress indicator, but following the design of showing separate table for Updates, felt a new table for installing snaps would be apt. Is it acceptable thought or does merging with existing 'Installed and updated' makes more sense?

codinesh avatar Dec 03 '23 18:12 codinesh

Hey @codinesh - looks great so far! I don't think we have spent much time on the UI/UX for this. @anasereijo could you have a quick look whenever you have a little time? :)

d-loose avatar Dec 06 '23 09:12 d-loose