Public Access
Desktop: stop the status bar's session timer when the shell ends
This commit is contained in:
1 parent
619f49a35a
commit
22b4d82ba8
3 files changed
+29
-3
No files matched your search
@@ -4518,7 +4518,7 @@ internal sealed partial class MainWindowViewModel : ObservableObject, IAsyncDisp
|
|||||||
{
|
{
|
||||||
if (Tabs.FirstOrDefault(tab => tab.SessionId == e.SessionId) is { } tab)
|
if (Tabs.FirstOrDefault(tab => tab.SessionId == e.SessionId) is { } tab)
|
||||||
{
|
{
|
||||||
tab.Ended(e.Outcome.End, e.Outcome.Description);
|
tab.Ended(e.Outcome.End, e.Outcome.Description, clock.GetUtcNow());
|
||||||
|
|
||||||
// Only for the tab being looked at, which is what these three already ask. The rectangle does not
|
// Only for the tab being looked at, which is what these three already ask. The rectangle does not
|
||||||
// change — a dead tab keeps its pane and its scrollback — but the status bar under it does, and
|
// change — a dead tab keeps its pane and its scrollback — but the status bar under it does, and
|
||||||
@@ -4998,7 +4998,12 @@ internal sealed partial class MainWindowViewModel : ObservableObject, IAsyncDisp
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var elapsed = clock.GetUtcNow() - started;
|
// Up to the end, for a shell that has one: how long it ran, not how long ago it started.
|
||||||
|
var until = Surface is ShellSurface.Terminal && SelectedTab?.EndedAt is { } ended
|
||||||
|
? ended
|
||||||
|
: clock.GetUtcNow();
|
||||||
|
|
||||||
|
var elapsed = until - started;
|
||||||
|
|
||||||
if (elapsed < TimeSpan.Zero)
|
if (elapsed < TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -274,6 +274,15 @@ internal sealed partial class TerminalTabViewModel : ObservableObject
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
internal DateTimeOffset? StartedAt { get; set; }
|
internal DateTimeOffset? StartedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>When the session behind this tab ended, or null while it has not.</summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// What stops the status bar's timer. It used to go on counting from <see cref="StartedAt"/> to now over a
|
||||||
|
/// shell that had exited an hour earlier, which made "how long that shell ran" — the fact the remark above
|
||||||
|
/// keeps <see cref="StartedAt"/> for — the one thing it no longer said. Stamped by <see cref="Ended"/> from
|
||||||
|
/// the shell's clock, and cleared whenever a new session takes the tab.
|
||||||
|
/// </remarks>
|
||||||
|
internal DateTimeOffset? EndedAt { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The negotiated server-to-client cipher, for the status bar — or null while there is no session.
|
/// The negotiated server-to-client cipher, for the status bar — or null while there is no session.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -620,6 +629,7 @@ internal sealed partial class TerminalTabViewModel : ObservableObject
|
|||||||
// stale-fact failure this pair exists to remove.
|
// stale-fact failure this pair exists to remove.
|
||||||
EndReason = null;
|
EndReason = null;
|
||||||
EndDescription = null;
|
EndDescription = null;
|
||||||
|
EndedAt = null;
|
||||||
|
|
||||||
IsLive = true;
|
IsLive = true;
|
||||||
State = TerminalTabState.Open;
|
State = TerminalTabState.Open;
|
||||||
@@ -679,13 +689,14 @@ internal sealed partial class TerminalTabViewModel : ObservableObject
|
|||||||
/// live attempt dead. <see cref="Advance"/> guards its own reports for the same reason.
|
/// live attempt dead. <see cref="Advance"/> guards its own reports for the same reason.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
internal void Ended(SshSessionEnd end, string description)
|
internal void Ended(SshSessionEnd end, string description, DateTimeOffset at)
|
||||||
{
|
{
|
||||||
if (State is not TerminalTabState.Open)
|
if (State is not TerminalTabState.Open)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EndedAt ??= at;
|
||||||
EndReason = end;
|
EndReason = end;
|
||||||
EndDescription = description;
|
EndDescription = description;
|
||||||
IsLive = false;
|
IsLive = false;
|
||||||
@@ -733,6 +744,7 @@ internal sealed partial class TerminalTabViewModel : ObservableObject
|
|||||||
// Cleared with the session they were facts about. Keeping them would put the previous connection's
|
// Cleared with the session they were facts about. Keeping them would put the previous connection's
|
||||||
// cipher in the status bar beside a handshake that has not negotiated one yet.
|
// cipher in the status bar beside a handshake that has not negotiated one yet.
|
||||||
StartedAt = null;
|
StartedAt = null;
|
||||||
|
EndedAt = null;
|
||||||
Cipher = null;
|
Cipher = null;
|
||||||
HostKeyAlgorithm = null;
|
HostKeyAlgorithm = null;
|
||||||
IdentityLabel = null;
|
IdentityLabel = null;
|
||||||
|
|||||||
@@ -2075,6 +2075,15 @@ public sealed partial class ShellFlowTests : IAsyncLifetime
|
|||||||
// Still worth offering, because the tab and the machine are both still there — what it is not is an
|
// Still worth offering, because the tab and the machine are both still there — what it is not is an
|
||||||
// alarm.
|
// alarm.
|
||||||
shell.CanReconnectSelectedTab.ShouldBeTrue();
|
shell.CanReconnectSelectedTab.ShouldBeTrue();
|
||||||
|
|
||||||
|
// And the timer stopped with it: how long that shell ran, rather than how long ago it started. The
|
||||||
|
// shell's clock here is the system's, so the second has to actually pass for the two to differ.
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(1.2), Token);
|
||||||
|
|
||||||
|
var ran = tab.EndedAt.ShouldNotBeNull() - tab.StartedAt.ShouldNotBeNull();
|
||||||
|
|
||||||
|
shell.SessionElapsedText.ShouldBe(string.Create(
|
||||||
|
CultureInfo.InvariantCulture, $"session {(int)ran.TotalHours:00}:{ran.Minutes:00}:{ran.Seconds:00}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|||||||
Reference in new issue
Block a user