Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/CodeShellManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,16 @@
Click="Layout_ThreeByThree_Click" FontSize="9" Padding="4,4"/>
</StackPanel>

<Button DockPanel.Dock="Left" AutomationProperties.AutomationId="NewSessionBtn" Content="+ New Session" Style="{StaticResource ToolBtn}"
Foreground="#a6e3a1" Click="NewSession_Click" Margin="0,0,4,0"/>
<Button x:Name="RecentSessionsBtn" DockPanel.Dock="Left" AutomationProperties.AutomationId="RecentSessionsBtn"
Content="🕘 Recent ▾" Style="{StaticResource ToolBtn}" Click="RecentSessions_Click" Margin="0,0,4,0"
ToolTip="Jump to a recently used session (Ctrl+Shift+E)"/>
<!-- Last child of the DockPanel fills the remaining width, so the left-hand
buttons share a left-aligned StackPanel — a bare button here stretches
across the middle of the toolbar. -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
<Button AutomationProperties.AutomationId="NewSessionBtn" Content="+ New Session" Style="{StaticResource ToolBtn}"
Foreground="#a6e3a1" Click="NewSession_Click" Margin="0,0,4,0"/>
<Button x:Name="RecentSessionsBtn" AutomationProperties.AutomationId="RecentSessionsBtn"
Content="🕘 Recent ▾" Style="{StaticResource ToolBtn}" Click="RecentSessions_Click" Margin="0,0,4,0"
ToolTip="Jump to a recently used session (Ctrl+Shift+E)"/>
</StackPanel>
</DockPanel>
</Border>

Expand Down
6 changes: 4 additions & 2 deletions tests/CodeShellManager.UITests/RecentSessionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public sealed class RecentSessionsTests : IClassFixture<AppFixture>
private MenuItem[] OpenRecentMenu()
{
AppActions.Press(AppActions.WaitForElement(_f.MainWindow, "RecentSessionsBtn"));
// A ContextMenu is a popup: UI Automation lists it as an unnamed top-level window of
// the app's process with the Menu inside — not under the main window.
// A ContextMenu is a popup: an unnamed Window with the Menu inside. UI Automation lists
// it either at the top level of the app's process (seen on a locked desktop) or as a
// child of the main window (seen on an unlocked one), so look in both places.
var menu = Retry.WhileNull(
() => _f.Automation.GetDesktop()
.FindAllChildren(cf => cf.ByProcessId(_f.App.ProcessId))
.SelectMany(w => w.FindAllChildren(cf => cf.ByControlType(ControlType.Window)).Prepend(w))
.Select(w => w.FindFirstChild(cf => cf.ByControlType(ControlType.Menu)))
.FirstOrDefault(m => m != null),
TimeSpan.FromSeconds(5)).Result
Expand Down
Loading