feat: auto-focus terminal when selecting a session#14
Merged
Conversation
Clicking a sidebar session now moves keyboard focus into that session's terminal so the user can start typing immediately — previously focus stayed on the WPF sidebar Border and keystrokes went nowhere until the user clicked the terminal pane. - TerminalBridge.FocusTerminal now calls _webView.Focus() in addition to posting the JS focus message, so WPF keyboard focus actually moves onto the WebView2 host (the JS term.focus() alone does not do this when another WPF control holds focus). - New AppSettings.AutoFocusTerminalOnSelect (default true) gates the focus call inside MainViewModel.FocusSession, so users who prefer the previous behaviour can opt out. ActiveSession and the active-terminal highlight still update either way. - Settings window exposes the toggle under SESSION SETTINGS as "Auto-focus terminal when selecting a session". Closes #13
There was a problem hiding this comment.
Pull request overview
This PR improves session switching UX by automatically moving keyboard focus into the selected session’s terminal (WebView2) so users can type immediately, with a new setting to disable focus-on-select.
Changes:
- Update
TerminalBridge.FocusTerminal()to focus the WebView2 host control before sending the JS focus message. - Add
AppSettings.AutoFocusTerminalOnSelect(defaulttrue) and gate focus-on-select inMainViewModel.FocusSession. - Surface the new setting in the Settings window and persist it via existing state saving.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/CodeShellManager/Terminal/TerminalBridge.cs | Ensures WPF focus moves onto WebView2 before JS focus message is posted. |
| src/CodeShellManager/ViewModels/MainViewModel.cs | Gates focus-on-select behavior behind a new settings flag. |
| src/CodeShellManager/Models/AppState.cs | Adds a persisted AutoFocusTerminalOnSelect setting (default enabled). |
| src/CodeShellManager/Views/SettingsWindow.xaml | Adds a checkbox UI to toggle auto-focus-on-select. |
| src/CodeShellManager/Views/SettingsWindow.xaml.cs | Wires checkbox to edited settings clone/load/save. |
| src/CodeShellManager/MainWindow.xaml.cs | Copies edited setting back into the live view model settings before saving state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
23
to
+27
| _edited = new AppSettings | ||
| { | ||
| AutoRestoreSessions = current.AutoRestoreSessions, | ||
| AutoResumeClaude = current.AutoResumeClaude, | ||
| AutoFocusTerminalOnSelect = current.AutoFocusTerminalOnSelect, |
Contributor
There was a problem hiding this comment.
Applied in 10c6b07: SettingsWindow now deep-copies current.LaunchCommands into _edited (LaunchCommands = current.LaunchCommands.ToList()), so opening/saving Settings no longer resets customized launch commands to defaults.
Agent-Logs-Url: https://github.com/umage-ai/CodeShellManager/sessions/f2b0ac4f-cae3-43f7-bd3b-7a2c42e51fe7 Co-authored-by: AThraen <5888420+AThraen@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13.
Summary
Ctrl+Tabcycling) now moves keyboard focus into the selected session's terminal so the user can start typing immediately.TerminalBridge.FocusTerminal()now calls_webView.Focus()in addition to posting the JS focus message — without this, WPF keyboard focus stays on the clicked sidebar Border and the JSterm.focus()has no effect at the WPF level.AppSettings.AutoFocusTerminalOnSelect(defaulttrue) gates the focus call insideMainViewModel.FocusSession, surfaced as a checkbox in the Settings window under SESSION SETTINGS. When disabled,ActiveSessionand the active-terminal highlight still update; only the focus jump is skipped.Test plan
Ctrl+TabandCtrl+Shift+Tabcycle sessions and focus follows.state.json).OnWindowActivated).