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

feat: propagate the window title from browser view to main window #2719

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

hennejg
Copy link

@hennejg hennejg commented May 12, 2023

Summary

Propagate the window title provided by the browser view, which would normally set the window/tab's title, to the MainWindow, so that the application's title reflects the currently selected server, workspace and channel.

The use case for me is that I work on many different projects and have automated my time-tracking using ManicTime. With this tool I can auto-tag time spent in applications, windows and thus correlate this time with projects. The window title is one of the properties that can be used to disambiguate between the various tasks being carried out.

Checklist

Device Information

Windows 10

Release Note

The application windows's title now reflects the current channel/user, workspace and server name.

@mattermost-build
Copy link
Contributor

Hello @hennejg,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

Per the Mattermost Contribution Guide, we need to add you to the list of approved contributors for the Mattermost project.

Please help complete the Mattermost contribution license agreement?
Once you have signed the CLA, please comment with /check-cla and confirm that the CLA check is green.

This is a standard procedure for many open source projects.

Please let us know if you have any questions.

We are very happy to have you join our growing community! If you're not yet a member, please consider joining our Contributors community channel to meet other contributors and discuss new opportunities with the core team.

@hennejg
Copy link
Author

hennejg commented May 12, 2023

/check-cla

Copy link
Member

@devinbinnie devinbinnie 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 the PR @hennejg!

I've added a couple comments for review.

src/main/views/MattermostBrowserView.ts Outdated Show resolved Hide resolved
this.log.debug('handleTitleUpdate', title);

this.log.info('handleTitleUpdate', title);
MainWindow.get()?.setTitle('Mattermost Desktop - ' + title);
Copy link
Member

@devinbinnie devinbinnie May 15, 2023

Choose a reason for hiding this comment

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

This should reflect the app's name in case the app is whitelabelled. Unfortunately right now most people will just override the title in the webpack.config.renderer.js file, so we need to think about how to best capture that.

We could make a call to app.getName() which currently returns Mattermost for most builds, but that would be a change from what it currently is.

@matthewbirtch @abhijit-singh Any thoughts about what this could look like?

Choose a reason for hiding this comment

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

@devinbinnie I think I'm lacking context here. I'm not exactly sure what you're asking us. Can you elaborate a bit more about what aspect of the Window title you want UX input on?

Copy link
Member

Choose a reason for hiding this comment

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

@matthewbirtch Sorry about that. What we're looking to refine is the window title of the application. So for example, the prompt you see here on Window, when you hover the taskbar icon:
image

You can also see it on Linux as the native title bar:
image

I don't think you can see it on macOS, but I could be wrong.

Choose a reason for hiding this comment

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

Not sure it needs to include 'Desktop App' - I would just say 'Mattermost'.

But from the PR description, it looks like you're hoping to incorporate the selected server, team and channel as well?

I would propose Mattermost - {Channel Name} - {Team Name} - {Server Name}

That feels like a lot to include in a window title though. Maybe we can omit the Team?

Copy link
Author

Choose a reason for hiding this comment

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

Please note that the pull request, in its current form, just forwards the window title from the server application, whatever that may set, as the app title prefixed by the application's own application title. Trying to slim it down would either require a deeper interfacing between the electron wrapper and the server webapp or relying on specific title formats, both of which would introduce a dependency of which I'm not sure whether would be desirable.

Also, the application title is derived from the configured application title by capturing the initial title setting in order to support whitelabeling as per @devinbinnie 's objection here: #2719 (comment). So the change from "Mattermost Desktop App" to just "Mattermost" would require changing the title in webpack.config.renderer.js, however, I'm unsure about the ramifications this would have.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, so I am not really clear on whether we have a consensus here or what it is. The behaviour introduced by the current state of the PR is to capture whatever the initial title of the application was. This title may have been the default title from webpack.config.renderer.js or something provided during while-labeling. When the underlying webapp updates the window title, the initial title is concatenated with the webapp title using a dash.

In the default configuration, this behaviour results in the title pattern Mattermost Desktop App - {Channel Name} - {Team Name} {Server Name} (please note that there is no dash between team name and server name.

Changing the prefix from "Mattermost Desktop App" to "Mattermost" as suggested by @matthewbirtch would imho be best done by changing it in webpack.config.renderer.js, however, as noted, I don't know whether this could cause problems elsewhere.
Changing the remainder of the pattern, on the other hand, would require parsing the window title provided by the contained webapp and re-assembling it as desired. While easy to do, this would introduce a dependency between Mattermost Desktop and the Mattermost Webapp's title pattern, which doesn't really sound desirable. Of course, the pattern could also be changed in the webapp itself but that would be out of scope for this PR.

Copy link
Member

Choose a reason for hiding this comment

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

@matthewbirtch I'll let you have the final say here on what we want the title to look like. I'm definitely more on board for just having it say Mattermost instead of Mattermost Desktop App.

@hennejg I'm happy to take a stab at helping finish up this PR if you need assistance getting the title right. Again, I think we can avoid changing things in the Webpack file if we just use the call I mentioned above.

Copy link
Author

Choose a reason for hiding this comment

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

@hennejg I'm happy to take a stab at helping finish up this PR if you need assistance getting the title right. Again, I think we can avoid changing things in the Webpack file if we just use the call I mentioned above.

I am sorry, but I still confused about what we are trying to achieve here. I was under the impression that deriving the window title from what is configured in webpack.config.renderer.js (via the HtmlWebpackPlugin's title) is the desired behaviour, e.g. to allow while-labeling. Over there, the title is configured to be Mattermost Desktop App, though. If it should still be just Mattermost and a change to webpack.config.renderer.js isn't the right way to achieve that, it would certainly be trivial to replace Mattermost Desktop App with Mattermost programmatically.

Copy link
Member

Choose a reason for hiding this comment

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

@hennejg Whitelabelling usually involving changing the applications name in package.json. Currently under productName ours is Mattermost, but if you change that then app.name changes in Electron as well. This is what we should be using for whitelabelling, not the Webpack file. The webpack file only provides a default, like how you would hardcode the <title> tag.

We want to be able to programmatically override this, and add additional information as well.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I think now we're on the same page. I updated the PR to derive the title prefix from app.name. However, unfortunately I am unable to test this right now, because app.name doesn't work in dev mode but only in packaged mode. And I can't easily package due to my very weird VS setup (I am mostly doing embedded development).

src/main/views/MattermostBrowserView.test.js Outdated Show resolved Hide resolved
@devinbinnie devinbinnie added 2: Dev Review Requires review by a core committer 1: UX Review Requires review by a UX Designer labels May 15, 2023
@hennejg hennejg requested a review from devinbinnie May 17, 2023 19:07
@mattermost-build
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@hennejg
Copy link
Author

hennejg commented Jun 10, 2023

Please note that I am currently on holidays. I'll look into your comments some time next week.

@yasserfaraazkhan
Copy link
Contributor

/update-branch

@devinbinnie
Copy link
Member

@hennejg Are you still planning on working on this?

@hennejg
Copy link
Author

hennejg commented Sep 14, 2023

@devinbinnie sorry, that topic landed on the back-burner. I'll try to finde some time ASAP.

@mattermost-build
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@hennejg
Copy link
Author

hennejg commented Oct 4, 2023

Sorry for the delay. I had a look at this. Although I did not make any more changes, I think the PR is ready for review as-is. Issues raised earlier have been addressed. If there is anything else that needs to be done, I'd need some hints.

@devinbinnie
Copy link
Member

/update-branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1: UX Review Requires review by a UX Designer 2: Dev Review Requires review by a core committer Contributor Lifecycle/1:stale release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants