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
1 change: 1 addition & 0 deletions src/CodeShellManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,7 @@ private void SettingsButton_Click(object sender, RoutedEventArgs e)
var edited = dialog.EditedSettings;
_vm.Settings.AutoRestoreSessions = edited.AutoRestoreSessions;
_vm.Settings.AutoResumeClaude = edited.AutoResumeClaude;
_vm.Settings.AutoFocusTerminalOnSelect = edited.AutoFocusTerminalOnSelect;
_vm.Settings.ShowToastNotifications = edited.ShowToastNotifications;
_vm.Settings.ShowNotificationSound = edited.ShowNotificationSound;
_vm.Settings.AnthropicApiKey = edited.AnthropicApiKey;
Expand Down
1 change: 1 addition & 0 deletions src/CodeShellManager/Models/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class AppSettings
{
public bool AutoRestoreSessions { get; set; } = true;
public bool AutoResumeClaude { get; set; } = true;
public bool AutoFocusTerminalOnSelect { get; set; } = true;
public bool ShowToastNotifications { get; set; } = false;
public bool ShowNotificationSound { get; set; } = false;
public string AnthropicApiKey { get; set; } = "";
Expand Down
10 changes: 9 additions & 1 deletion src/CodeShellManager/Terminal/TerminalBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,15 @@ public void FocusTerminal()
if (!_ready) return;
WpfApplication.Current?.Dispatcher.BeginInvoke(() =>
{
try { _webView.CoreWebView2?.PostWebMessageAsString("{\"type\":\"focus\"}"); }
try
{
// Move WPF keyboard focus onto the WebView2 host. Without this, focus
// can stay on whichever WPF control was last clicked (e.g. a sidebar
// item Border), so the JS term.focus() below has no effect at the
// WPF level and typing goes nowhere.
_webView.Focus();
_webView.CoreWebView2?.PostWebMessageAsString("{\"type\":\"focus\"}");
}
catch { }
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/CodeShellManager/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ private void FocusSession(SessionViewModel vm)
{
ActiveSession = vm;
vm.ClearAlert();
vm.Bridge?.FocusTerminal();
if (Settings.AutoFocusTerminalOnSelect)
vm.Bridge?.FocusTerminal();
vm.AlertDetector?.NotifyUserInteracted();
OnPropertyChanged(nameof(AlertCount));
}
Expand Down
3 changes: 3 additions & 0 deletions src/CodeShellManager/Views/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
<CheckBox x:Name="AutoResumeClaudeCheck" Content="Auto-resume Claude sessions on restore"
Margin="0,4,0,0"
ToolTip="When restoring sessions, append --resume &lt;sessionId&gt; to claude commands so Claude picks up the previous conversation."/>
<CheckBox x:Name="AutoFocusTerminalOnSelectCheck" Content="Auto-focus terminal when selecting a session"
Margin="0,4,0,0"
ToolTip="When clicking a session in the sidebar (or cycling with Ctrl+Tab), move keyboard focus into the terminal so you can start typing immediately."/>

<!-- Appearance -->
<TextBlock Text="APPEARANCE" Style="{StaticResource SectionHeader}"/>
Expand Down
4 changes: 4 additions & 0 deletions src/CodeShellManager/Views/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public SettingsWindow(AppSettings current, SearchService? searchService = null)
{
AutoRestoreSessions = current.AutoRestoreSessions,
AutoResumeClaude = current.AutoResumeClaude,
AutoFocusTerminalOnSelect = current.AutoFocusTerminalOnSelect,
ShowToastNotifications = current.ShowToastNotifications,
ShowNotificationSound = current.ShowNotificationSound,
AnthropicApiKey = current.AnthropicApiKey,
Expand All @@ -42,12 +43,14 @@ public SettingsWindow(AppSettings current, SearchService? searchService = null)
TerminalLineHeight = current.TerminalLineHeight,
IndexTerminalOutput = current.IndexTerminalOutput,
OutputRetentionDays = current.OutputRetentionDays,
LaunchCommands = current.LaunchCommands.ToList(),
};

// Populate controls
DefaultFolderBox.Text = _edited.DefaultWorkingFolder;
AutoRestoreCheck.IsChecked = _edited.AutoRestoreSessions;
AutoResumeClaudeCheck.IsChecked = _edited.AutoResumeClaude;
AutoFocusTerminalOnSelectCheck.IsChecked = _edited.AutoFocusTerminalOnSelect;
ShowToastCheck.IsChecked = _edited.ShowToastNotifications;
ShowNotificationSoundCheck.IsChecked = _edited.ShowNotificationSound;
ShowGitBranchCheck.IsChecked = _edited.ShowGitBranch;
Expand Down Expand Up @@ -109,6 +112,7 @@ private void Save_Click(object sender, RoutedEventArgs e)
_edited.DefaultWorkingFolder = DefaultFolderBox.Text.Trim();
_edited.AutoRestoreSessions = AutoRestoreCheck.IsChecked == true;
_edited.AutoResumeClaude = AutoResumeClaudeCheck.IsChecked == true;
_edited.AutoFocusTerminalOnSelect = AutoFocusTerminalOnSelectCheck.IsChecked == true;
_edited.ShowToastNotifications = ShowToastCheck.IsChecked == true;
_edited.ShowNotificationSound = ShowNotificationSoundCheck.IsChecked == true;
_edited.ShowGitBranch = ShowGitBranchCheck.IsChecked == true;
Expand Down
Loading