-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/snap: record snap-run-inhibit notice #13770
cmd/snap: record snap-run-inhibit notice #13770
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #13770 +/- ##
==========================================
- Coverage 78.92% 78.91% -0.01%
==========================================
Files 1043 1044 +1
Lines 134425 134510 +85
==========================================
+ Hits 106089 106154 +65
- Misses 21722 21732 +10
- Partials 6614 6624 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
0b632dc
to
f93ea05
Compare
client/notices.go
Outdated
@@ -0,0 +1,64 @@ | |||
// Copyright (c) 2024 Canonical Ltd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm commenting on the first line that this patch should be split.
The changes to client are stand-alone and can be proposed straight way.
The changes to cmd/snap should be split out and can depend on the larger patch-set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, Thank you!
f93ea05
to
74ed28c
Compare
74ed28c
to
bbc4050
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
general question about the old code
cmd/snap/inhibit.go
Outdated
// no snap (i.e. snapd-desktop-integration) is listening, let's fallback | ||
// to normal graphical flow. | ||
return false, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original graphical flow never really worked before, so not sure we should keep it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, better to remove it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As discussed yesterday, my only concern is about compatibility for all the. Releases of Ubuntu who are upgrading to the snapd? You may not have the special desktop snap, which enables the notices to be displayed. Perhaps we can consider the case of a display enabled user without the special interface connected, using a tty, to display message linking to something on the forum. |
cmd/snap/inhibit.go
Outdated
return &graphicalFlow{instanceName: instanceName} | ||
var newInhibitionFlow = func(cli *client.Client, instanceName string) inhibitionFlow { | ||
if isGraphicalFlowSupported(cli) { | ||
return &graphicalFlow{instanceName: instanceName, cli: cli} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we simply always emit the notice but do the fallback if there is no connection etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question
@zyga according to https://ubuntu-archive-team.ubuntu.com/seeds/ubuntu.jammy/desktop-minimal
It seems that installing snapd-desktop-integration is a part of the upgrade process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
cmd/snap/inhibit.go
Outdated
// Fallback to text notification if marker "snap-refresh-observe" | ||
// interface is not connected. | ||
if isStdoutTTY && !markerInterfaceConnected(gf.cli) { | ||
fmt.Fprintf(Stdout, i18n.G("snap package %q is being refreshed, please wait\n"), gf.instanceName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there cases where regardless of sitting on a tty we'd like to produce the message to stderr? TBH even with the current check's I'd still write this to stderr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I will update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, thank you!
I removed the text fallback spread test variant to avoid blocking this PR further because it was inconsistent across systems due to the terminal checks in snapd. It is hard to mock a real terminal in all systems while redirecting output to a file for testing. The extra variant can be added in a follow up PR when I come up with a better way to trick snap command it is running in a terminal while redirecting output for parsing. |
a0e7915
to
a6dcbd9
Compare
Record a snap-run-inhibit notice when snap run is inhibited due refresh. * cmd/snap: remove old desktop notifications (thanks @pedronis @zyga) * cmd/snap: always send notices when snap run is inhibited + fallback to text if no snap has the marker snap-refresh-observe interface connected and a terminal is detected. * cmd/snap: send text fallback notification to stderr (thanks @bboozzoo) * cmd/snap: initialize inhibition flow only when it is needed Signed-off-by: Zeyad Gouda <[email protected]>
* test/main/snap-run-inhibition-flow: remove text fallback check Text fallback is inconsistent across systems due to the terminal checks in snapd. It is hard to mock a real terminal in all systems while redirecting output to a file for testing. Signed-off-by: Zeyad Gouda <[email protected]>
a6dcbd9
to
9f15777
Compare
This PR builds on #13791 (
and should be rebased after #13791 gets mergedalready rebased) to enable the "snap-run during refresh UX" flow described in SD167.This simply allows
snap run
to issue (per-user)snap-run-inhibit
notices when it is inhibited for refresh. This notice can later be consumed by something likesnapd-desktop-integration
snap replacing the old flow of directly callingsnapd-desktop-integration
on dbus.As fallback if no snap exists with the marker
snap-refresh-observe
interface #13619, a normal notification is sent using the user agent.NOTE: The graphical flow (using notices or the fallback) is hidden behind the
refresh-app-awareness-ux
experimental flag #13479.NOTE: depending if #13747 lands first or this PR, the tests structure will need to be updated because they touch similar parts of the tests.