Skip to content
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

Feature showing messages to the users, fixes #3799 #4885

Merged
merged 42 commits into from
Jun 24, 2023

Conversation

gilbertsoft
Copy link
Member

@gilbertsoft gilbertsoft commented May 8, 2023

The Issue

We like to show messages to the user e.g. a hint to support DDEV with sponsoring the project.

How This PR Solves The Issue

This patch introduces an easy way to provide infos, warnings and rotating ticker messages in the remote-config repository which will be regulary downloaded and shown to the user.

Open tasks:

  • define a good first message about sponsoring DDEV
  • define some first tips

Manual Testing Instructions

To test this feature run a ddev command e.g. ddev describe, messages should be shown. Manipulate or delete the state file ~/.ddev/.state.yaml to get faster results. It's also possible to change the interval of the ticker in the ~/.ddev/global_config.yaml or switch to the testing branch of the remote-config, description to do so can be found in the config file.

Automated Testing Overview

Related Issue Link(s)

Release/Deployment Notes

@github-actions
Copy link

github-actions bot commented May 8, 2023

@gilbertsoft gilbertsoft force-pushed the task/upstream-infos branch 2 times, most recently from be5a781 to 8346344 Compare May 8, 2023 11:51
@rfay rfay changed the title Feature showing messages to the users Feature showing messages to the users, fixes #3799 May 8, 2023
@rfay
Copy link
Member

rfay commented May 8, 2023

It would be cool to be able to show a variety of messages, so people don't get bored. Instructional, etc.

@gilbertsoft
Copy link
Member Author

It would be cool to be able to show a variety of messages, so people don't get bored. Instructional, etc.

Nice idea. Like Docker Desktop does it on startup. Will think about...

@gilbertsoft gilbertsoft force-pushed the task/upstream-infos branch 2 times, most recently from 3c6640f to d1f8c9e Compare May 11, 2023 08:01
@gilbertsoft
Copy link
Member Author

It would be cool to be able to show a variety of messages, so people don't get bored. Instructional, etc.

Done

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Taking a first casual look through. I don't understand it all yet, but made some suggestions about naming, etc. It's a lot of code for a small feature of course.

I see lots and lots of unexpected stuff being loaded into vendor, like github.com/ProtonMail (go-crypto I guess, but pulls in lots more, why that and also x/crypto?)? github.com/cloudflare (circl I guess, but what for?)? and of course the duplicated go-github/v52

Currently, every ddev start repeats the same message, "Ensure maintenance and further development of DDEV see..." We don't want to repeat the same message all the time, and don't want to show a message on every command. Maybe once a day?

It does seem to rotate on some of the other messages, but I don't think we want to show any message on most commands. Just daily or whatever?

But it's currently just on start, is that true?

manifest.json Outdated Show resolved Hide resolved
docs/content/developers/manifest.md Outdated Show resolved Hide resolved
pkg/github/github.go Outdated Show resolved Hide resolved
pkg/github/github.go Outdated Show resolved Hide resolved
pkg/manifest/manifest.go Outdated Show resolved Hide resolved
m.Manifest, err = m.githubStorage.Pull()

if err != nil {
util.Error("Error while downloading manifest: %s", err)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we should be notifying the user about problems like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, is currently mainly for testing purposes, Debug would be fine here too!

pkg/manifest/messages.go Outdated Show resolved Hide resolved
pkg/manifest/storages/file_storage.go Outdated Show resolved Hide resolved
data fileStorageData
}

// fileStorageData is the structure used for the file.
Copy link
Member

Choose a reason for hiding this comment

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

If making a comment, at least give enough info to make it useful. Say what file, etc. Was this generated by Github Copilot?

Copy link
Member Author

Choose a reason for hiding this comment

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

A lot of comments will follow.... Also I like to have a description in each package what it is meant for.

pkg/manifest/storages/file_storage.go Outdated Show resolved Hide resolved
@gilbertsoft
Copy link
Member Author

Taking a first casual look through. I don't understand it all yet, but made some suggestions about naming, etc. It's a lot of code for a small feature of course.

I see lots and lots of unexpected stuff being loaded into vendor, like github.com/ProtonMail (go-crypto I guess, but pulls in lots more, why that and also x/crypto?)? github.com/cloudflare (circl I guess, but what for?)? and of course the duplicated go-github/v52

I've installed the latest version of go-github (v52) which is breaking and so far did not update the existing usages e.g. for ddev get or the update check. Imho we should do this later in a dedicated patch. So long, two version live together which does not hurt. The new version is also the reason for the new dependencies.

Currently, every ddev start repeats the same message, "Ensure maintenance and further development of DDEV see..." We don't want to repeat the same message all the time, and don't want to show a message on every command. Maybe once a day?

There are two features like mentioned in the docs: infos and warnings, which will show on every start, and the tips, which will rotate.

It does seem to rotate on some of the other messages, but I don't think we want to show any message on most commands. Just daily or whatever?

At the moment the messages are shown on ddev start. We should discuss how we like to have it.

The idea of infos and warnings is to have the posibility to show important messages to the user. This could make sense to be shown on most commands and on every call. E.g. if an update of an old version is important because of a security risk.

The tips is someting we also could implement to be shown once a day only, sounds good to me.

An ofc the messages should be printed in a nicer way, just did a simple output so far!

@rfay
Copy link
Member

rfay commented May 16, 2023

Requests from our meeting today:

@gilbertsoft
Copy link
Member Author

Requests from our meeting today:

* [ ]   Improve the upstream amplitude-go PR with an example of what could go wrong and more detail. We want them to understand it and pull it.

* [x]  In the fork, https://github.com/ddev/analytics-go#readme, replace the README.md with an explanation of the reason for the fork, the link to the PR, etc. [Deliver instrumentation data directly to amplitude, fixes #4335 #4866](https://github.com/ddev/ddev/pull/4866)

* [x]   Add the PR ink to the OP of this PR

* [ ]  (And please rebase, again :) )

This belongs to #4866

@gilbertsoft
Copy link
Member Author

@rfay what about remote config instead of manifest?

@rfay
Copy link
Member

rfay commented May 17, 2023

"remoteconfig" sounds OK to me.

I just realized that the time interval between showing messages should/could be specified in the manifest.json/remoteconfig.json (preferably remoteconfig.jsonc if we have a way to successfully read jsonc). Then we'd be able to introduce more important warnings, etc.

@rfay
Copy link
Member

rfay commented Jun 13, 2023

Rebased. Is this ready for review?

@rfay
Copy link
Member

rfay commented Jun 22, 2023

I haven't yet been able to make this work or get any kind of notification. We should do a screenshare to look at it tomorrow.

However, when it does work, it should absolutely not be creating any output except on ddev start IMO.

@rfay
Copy link
Member

rfay commented Jun 22, 2023

Yay, it worked, but we'll probably have to figure out something about wrapping.

image image

@rfay
Copy link
Member

rfay commented Jun 22, 2023

Do you mind if I push this into the PR?

diff --git a/pkg/config/remoteconfig/messages.go b/pkg/config/remoteconfig/messages.go
index 605aaa54a..c3e649ba9 100644
--- a/pkg/config/remoteconfig/messages.go
+++ b/pkg/config/remoteconfig/messages.go
@@ -265,19 +265,27 @@ func applyTableStyle(preset preset, writer table.Writer) {
 		},
 	})
 
+	style := writer.Style()
+
+	style.Options.SeparateRows = false
+	style.Options.SeparateFooter = false
+	style.Options.SeparateColumns = false
+	style.Options.SeparateHeader = false
+	style.Options.DrawBorder = false
+
 	switch preset {
 	case information:
-		writer.Style().Color = table.ColorOptions{
+		style.Color = table.ColorOptions{
 			Header: text.Colors{text.BgHiYellow, text.FgBlack},
 			Row:    text.Colors{text.BgHiYellow, text.FgBlack},
 		}
 	case warning:
-		writer.Style().Color = table.ColorOptions{
+		style.Color = table.ColorOptions{
 			Header: text.Colors{text.BgHiRed, text.FgBlack},
 			Row:    text.Colors{text.BgHiRed, text.FgBlack},
 		}
 	case ticker:
-		writer.Style().Color = table.ColorOptions{
+		style.Color = table.ColorOptions{
 			Header: text.Colors{text.BgHiWhite, text.FgBlack},
 			Row:    text.Colors{text.BgHiWhite, text.FgBlack},
 		}

Result is
image

@rfay
Copy link
Member

rfay commented Jun 22, 2023

Per discussion in remote-images, let's go ahead and detect terminal width and wrap. I actually think the table code has this built in, and it will work fine for single-column stuff like this.

@rfay
Copy link
Member

rfay commented Jun 22, 2023

(Working on wrapping right now)

@rfay
Copy link
Member

rfay commented Jun 22, 2023

I think the remote config isn't created if it doesn't exist and the .state.yaml says that it might have been updated. I doubt this much matters. But it breaks testing.

@rfay
Copy link
Member

rfay commented Jun 22, 2023

I'm pretty sure these notes would be more effective at the beginning of ddev start instead of at the end.

@rfay
Copy link
Member

rfay commented Jun 22, 2023

I took the liberty to push a wrapping change in in e6bb8bf, we can revert if you don't like it. But here's what it looks like:

image image

@gilbertsoft
Copy link
Member Author

I took the liberty to push a wrapping change in in e6bb8bf, we can revert if you don't like it. But here's what it looks like:
image image

Looks good, thanks!

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Minor change requests, this seems to be working great. It's a really heavy load for what we expected, but I know you have great hopes for some of the things you added. Maybe we'll be able to use them where they can be used.

I tested with various terminal window sizes, and tested with internet disabled, and all seems to go well.

cmd/ddev/cmd/debug-message-conditions.go Show resolved Hide resolved
docs/content/developers/remote-config.md Outdated Show resolved Hide resolved
internal/build/remote_config.go Outdated Show resolved Hide resolved
pkg/config/remoteconfig/config.go Show resolved Hide resolved
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Thanks for all the hard work on this, let's get it in. Please pull it when you're ready. Don't worry about the wsl failure, I'm sure it would clear, not related to this anyway.

@gilbertsoft
Copy link
Member Author

Thanks for all the hard work on this, let's get it in. Please pull it when you're ready. Don't worry about the wsl failure, I'm sure it would clear, not related to this anyway.

Yes, had to restart the WSL test system, was completely broken.

@gilbertsoft gilbertsoft merged commit 4dc214b into ddev:master Jun 24, 2023
16 of 17 checks passed
@gilbertsoft gilbertsoft deleted the task/upstream-infos branch June 24, 2023 20:11
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.

None yet

3 participants