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

Show indicator of bell in tab #8637

Merged
12 commits merged into from Jan 22, 2021
Merged

Show indicator of bell in tab #8637

12 commits merged into from Jan 22, 2021

Conversation

PankajBhojwani
Copy link
Contributor

@PankajBhojwani PankajBhojwani commented Dec 22, 2020

When we emit a BEL (visual or audible), show an indicator in the tab
header

If the tab the BEL is coming from is not focused when the BEL is raised,
the indicator in its header will be removed when the tab gains focus. If
the tab was already focused when the BEL was emitted, then the indicator
goes away after 2 seconds.

Closes #8106

@ghost ghost added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Dec 22, 2020
@skyline75489
Copy link
Collaborator

First of all, love the work, as always. Second, I think we should revisit the "hide bell after 1 second" design. In iTerm2, I observed the following behaviour:

  • If a bell rings in the currently focused tab, the bell indicator only disappears if there's intereactions from users, for example, typing something.
  • If a bell rings in another tab, the bell indicator disappears as soon as that tab gains focus.

This design should help people easily find what the actual tab is causing the bell. But if it just disappears automatically, then people might still be confused about it.

@PankajBhojwani
Copy link
Contributor Author

This design should help people easily find what the actual tab is causing the bell. But if it just disappears automatically, then people might still be confused about it.

I think that makes sense, thanks for the suggestion!

If a bell rings in the currently focused tab, the bell indicator only disappears if there's intereactions from users, for example, typing something.

This will bear some thinking about what entails as an interaction

@skyline75489
Copy link
Collaborator

skyline75489 commented Dec 23, 2020 via email

@PankajBhojwani
Copy link
Contributor Author

PankajBhojwani commented Jan 7, 2021

Had a chat with @DHowett, we will implement this as: the bell indicator goes away when the tab receives focus, and if the tab was already focused when the bell was raised then the indicator goes away after a small amount of time.

We are choosing this implementation for now because of the dubiousness of what an interaction means (aside from typing there's also clicking a link for example) and also because of edge cases such as the tab key-up from alt tabbing into the tab being considered a key press.

@PankajBhojwani PankajBhojwani changed the title [DRAFT] Show indicator of bell in tab Show indicator of bell in tab Jan 8, 2021
@PankajBhojwani PankajBhojwani marked this pull request as ready for review January 8, 2021 19:24
@skyline75489
Copy link
Collaborator

Thanks @PankajBhojwani for the thoughtful implementation. Personally I do not use speakers that much so I’m really looking forward to this feature.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jan 13, 2021
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jan 13, 2021
@zadjii-msft zadjii-msft self-assigned this Jan 15, 2021
@zadjii-msft
Copy link
Member

Okay my initial feedback is regarding this discussion:
#8133 (comment)

Should we put the bell on the right of the tab title? I don't love that it causes the whole string to jump back and forth

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Okay this is all reasonable to me. I guess my biggest concern is on the bell placement. I really think it should be on the right.

  🌛
💪 💪
  👖

In a follow-up, we could have the bell "fade out", like it does in browsers, as opposed to just immediately hiding.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jan 15, 2021
@PankajBhojwani
Copy link
Contributor Author

I guess my biggest concern is on the bell placement. I really think it should be on the right.

In browsers if you have sound coming from a tab the bell/speaker icon shows up on the left though! Since we chose the progress ring placement to match how browsers do it, should we do the same for the bell?

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jan 15, 2021
@zadjii-msft
Copy link
Member

ah shiz, someone caught me not selfhosting

Edgium:
image

Firefox
image

So that's why I'm confused 😬

@Don-Vito Don-Vito mentioned this pull request Jan 16, 2021
@DHowett
Copy link
Member

DHowett commented Jan 19, 2021

left! left! left!

@zadjii-msft
Copy link
Member

Yea I lost this fight

image

@zadjii-msft zadjii-msft dismissed their stale review January 19, 2021 23:06

I was outvoted

@skyline75489
Copy link
Collaborator

TBH I’m OK with both placement.

Wait, you can dismiss a review? How many features GitHub has added?...

@DHowett
Copy link
Member

DHowett commented Jan 21, 2021

Moved from body

When the tab has focus:
bell1

When the tab does not have focus:
bell2

Comment on lines 64 to 66
auto weakThis{ get_weak() };

if (auto tab{ weakThis.get() })
Copy link
Member

Choose a reason for hiding this comment

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

This will always pass. Since you constructed the event handler (line 290) with a weak reference, c++/winrt automatically ensures that you have a strong living reference inside this function. You can safely use this or just.. use unqualified members.

if (auto tab{ weakThis.get() })
{
tab->ShowBellIndicator(false);
tab->_bellIndicatorTimer.value().Stop();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tab->_bellIndicatorTimer.value().Stop();
tab->_bellIndicatorTimer->Stop();

tab->_UpdateActivePane(sender);
tab->_RecalculateAndApplyTabColor();
}
tab->_focusState = WUX::FocusState::Programmatic;
Copy link
Member

Choose a reason for hiding this comment

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

i hope this is right! what else is _focusState being used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only other places (before this PR) _focusState was being checked/updated: TerminalTab::_RefreshVisualState and TerminalTab::Focus

However, without this addition, the tab does not know when the app itself loses focus (by alt-tab/minimize etc) so it used to still think it is focused even though the app itself and the underlying control(s) are all unfocused.

if (tab)
{
// update this tab's focus state
tab->_focusState = WUX::FocusState::Unfocused;
Copy link
Member

Choose a reason for hiding this comment

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

just to be sure - there will be a moment, when you move from pane A to pane B, that the tab thinks it does not have focus?

Comment on lines 286 to 292
if (auto tab{ weakThis.get() })
{
DispatcherTimer bellIndicatorTimer;
bellIndicatorTimer.Interval(std::chrono::milliseconds(2000));
bellIndicatorTimer.Tick({ get_weak(), &TerminalTab::_BellIndicatorTimerTick });
bellIndicatorTimer.Start();
tab->_bellIndicatorTimer.emplace(std::move(bellIndicatorTimer));
Copy link
Member

Choose a reason for hiding this comment

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

can an application DOS us by spamming bell? it will make us start a huge number of timers, and keep overwriting the optional.

Copy link
Member

Choose a reason for hiding this comment

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

(we'll waste memory for up to 2 seconds at which point they'll start to fire)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes good catch! We now only create a new timer if the optional doesn't have a value

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jan 21, 2021
@DHowett
Copy link
Member

DHowett commented Jan 21, 2021

In PowerShell, try this:

"`a"*1000

You will be rewarded with...

(ed8.1f90): C++ EH exception - code e06d7363 (first chance)
(ed8.1f90): C++ EH exception - code e06d7363 (first chance)
TerminalApp.dll!00007FFD2B20C922: ReturnHr(1) tid(1f90) 8007023E {Application Error}
The exception %s (0x    Msg:[std::exception: Bad optional access] 

This also happens during normal belling, unfortunately. It doesn't take a thousand, that just made it quite reproable. 😄

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jan 21, 2021
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 22, 2021
@ghost
Copy link

ghost commented Jan 22, 2021

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 02fd7a0 into main Jan 22, 2021
@ghost ghost deleted the dev/pabhoj/bell_in_tab branch January 22, 2021 23:48
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
When we emit a BEL (visual or audible), show an indicator in the tab
header

If the tab the BEL is coming from is not focused when the BEL is raised,
the indicator in its header will be removed when the tab gains focus. If
the tab was already focused when the BEL was emitted, then the indicator
goes away after 2 seconds.

Closes microsoft#8106
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: show an indicator if there's a bell in the tab
5 participants