feat(mission-control): rename sessions inline in the Recent sessions flyout

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-10-01 17:35:13 +02:00
co-authored by Claude Sonnet 5.5
parent d9355383a4
commit 5bf08873bd
8 changed files with 198 additions and 11 deletions
@@ -5,6 +5,7 @@ using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Platform.Storage;
@@ -40,6 +41,31 @@ public partial class MissionControlView : UserControl
OverviewGrid.AddHandler(PointerReleasedEvent, OnTilePointerReleased);
}
// Inline rename in the Recent sessions flyout. Deliberately not Buttons: the Click handler above would hide the flyout.
private void OnSessionTitleDoubleTapped(object? sender, TappedEventArgs e)
{
if (sender is not TextBlock { DataContext: RecentSessionViewModel row, Parent: Panel panel }) return;
row.BeginEdit();
var box = panel.Children.OfType<TextBox>().FirstOrDefault();
// Deferred: the TextBox only becomes visible (focusable) after the binding update.
Avalonia.Threading.Dispatcher.UIThread.Post(() => { box?.Focus(); box?.SelectAll(); });
}
private void OnSessionTitleEditKeyDown(object? sender, KeyEventArgs e)
{
if (sender is not TextBox { DataContext: RecentSessionViewModel row }) return;
if (e.Key == Key.Enter) row.CommitRenameCommand.Execute(null);
else if (e.Key == Key.Escape) row.CancelEdit();
else return;
e.Handled = true; // Escape would otherwise close the flyout too
}
private void OnSessionTitleEditLostFocus(object? sender, RoutedEventArgs e)
{
if (sender is TextBox { DataContext: RecentSessionViewModel row })
row.CommitRenameCommand.Execute(null);
}
// Ticks the "Running now" elapsed times while the view is on screen.
private Avalonia.Threading.DispatcherTimer? _elapsedTimer;