Dynamic tab naming for SSH/Telnet via PuTTY terminal title tracking#3153
Dynamic tab naming for SSH/Telnet via PuTTY terminal title tracking#3153Copilot wants to merge 2 commits intov1.78.2-devfrom
Conversation
Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
|
There was a problem hiding this comment.
Pull request overview
Adds opt-in dynamic tab naming for PuTTY-based protocols by tracking the PuTTY window title and propagating title changes into the tab text, improving usability when chaining SSH sessions.
Changes:
- Introduces a
TitleChangedevent onProtocolBaseand wires it through connection initiation to the UI. - Implements periodic PuTTY
MainWindowTitlepolling inPuttyBaseand raises title-change events on updates. - Adds a new user option + localized UI string to enable/disable terminal-title-based tab naming.
Reviewed changes
Copilot reviewed 7 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| mRemoteNG/UI/Window/ConnectionWindow.cs | Handles TitleChanged to update the active connection tab text (thread-safe). |
| mRemoteNG/UI/Forms/OptionsPages/TabsPanelsPage.cs | Loads/saves/applies language for the new “Use terminal title…” option. |
| mRemoteNG/UI/Forms/OptionsPages/TabsPanelsPage.Designer.cs | Adds the checkbox control to the Tabs & Panels options UI. |
| mRemoteNG/Properties/OptionsTabsPanelsPage.settings | Adds a new persisted user setting UseTerminalTitleForTabs. |
| mRemoteNG/Properties/OptionsTabsPanelsPage.Designer.cs | Adds generated property accessor for UseTerminalTitleForTabs. |
| mRemoteNG/Language/Language.resx | Adds localized string for the new option label. |
| mRemoteNG/Language/Language.Designer.cs | Adds generated resource accessor for UseTerminalTitleForTabs. |
| mRemoteNG/Connection/Protocol/PuttyBase.cs | Starts a 500ms timer to poll PuTTY window title and raises TitleChanged. |
| mRemoteNG/Connection/Protocol/ProtocolBase.cs | Adds the TitleChanged event and protected raiser method. |
| mRemoteNG/Connection/ConnectionInitiator.cs | Wires TitleChanged to ConnectionWindow event handler. |
Files not reviewed (3)
- mRemoteNG/Language/Language.Designer.cs: Language not supported
- mRemoteNG/Properties/OptionsTabsPanelsPage.Designer.cs: Language not supported
- mRemoteNG/UI/Forms/OptionsPages/TabsPanelsPage.Designer.cs: Language not supported
| Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, | ||
| "PuTTY title monitoring stopped: " + ex.Message, true); |
There was a problem hiding this comment.
This MessageCollector entry uses a hard-coded English string ("PuTTY title monitoring stopped..."). Since these messages are user-visible elsewhere in the app, it should be moved into Language.resx (similar to other PuTTY messages in this class) to keep localization consistent.
| Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, | |
| "PuTTY title monitoring stopped: " + ex.Message, true); | |
| Runtime.MessageCollector.AddMessage( | |
| MessageClass.InformationMsg, | |
| Language.PuttyTitleMonitoringStopped + Environment.NewLine + ex.Message, | |
| true); |
| string connectionName = protocolBase.InterfaceControl.Info?.Name ?? ""; | ||
| string tabText = string.IsNullOrEmpty(newTitle) | ||
| ? connectionName | ||
| : $"{newTitle} ({connectionName})"; | ||
| tabText = tabText.Replace("&", "&&"); |
There was a problem hiding this comment.
When terminal-title tracking is enabled, this handler overwrites ConnectionTab.TabText with {title} ({connectionName}), which drops existing tab naming preferences (e.g., ShowProtocolOnTabs / ShowLogonInfoOnTabs) that are applied when the tab is created. This makes the corresponding options ineffective after the first title update. Consider reusing the same base tab-title construction used in AddConnectionTab (or preserving the current suffix) so the dynamic title composes with existing tab text settings.
| chkShowLogonInfoOnTabs.Checked = Properties.OptionsTabsPanelsPage.Default.ShowLogonInfoOnTabs; | ||
| chkShowProtocolOnTabs.Checked = Properties.OptionsTabsPanelsPage.Default.ShowProtocolOnTabs; | ||
| chkUseTerminalTitleForTabs.Checked = Properties.OptionsTabsPanelsPage.Default.UseTerminalTitleForTabs; | ||
| chkIdentifyQuickConnectTabs.Checked = Properties.OptionsTabsPanelsPage.Default.IdentifyQuickConnectTabs; |
There was a problem hiding this comment.
The new UseTerminalTitleForTabs option is persisted in user settings, but it isn't integrated into the existing registry-policy mechanism used on this page (controls are disabled when corresponding OptRegistryTabsPanelsPage entries are set). As-is, admins cannot enforce/lock this new option via registry like the other Tabs & Panels settings. Consider adding a WinRegistryEntry<bool> UseTerminalTitleForTabs to OptRegistryTabsPanelsPage and disabling chkUseTerminalTitleForTabs in LoadRegistrySettings when it’s set.
| // Start monitoring PuTTY window title for dynamic tab naming | ||
| _lastWindowTitle = PuttyProcess.MainWindowTitle; | ||
| _titleMonitorTimer = new System.Threading.Timer(MonitorPuttyTitle, null, TitleMonitorIntervalMs, TitleMonitorIntervalMs); | ||
|
|
There was a problem hiding this comment.
The PuTTY window-title polling timer is started unconditionally on every PuTTY-based connection, even when the new UseTerminalTitleForTabs option is disabled. This makes the feature effectively not opt-in and adds a periodic Process.Refresh()/MainWindowTitle poll for all SSH/Telnet sessions. Consider only creating/starting the timer when the option is enabled (and optionally stopping it if the option is later turned off).
Superseded — Feature Already Implemented (Superior Version)Dynamic tab naming based on PuTTY terminal title is already fully implemented in the current codebase with a significantly more robust architecture. What this PR does
What the codebase already has
Additional merge blockersEven if the feature weren't implemented, this PR has heavy conflicts across all 10 files:
Only gapThe current codebase has terminal title tracking always active for PuTTY connections — no opt-in toggle exists. If desired, it can be added as a ~15 line follow-up. Thank you @Kvarkas for the feature request. Closing as superseded.
|



Tab names for PuTTY-based connections (SSH, Telnet, etc.) are set once at connection time and never updated, making it impossible to track which server you're actually on after chaining SSH sessions.
Approach
Monitor the PuTTY process window title on a 500ms timer. When the shell updates the terminal title (via OSC escape sequences), PuTTY reflects this in its window title — mRemoteNG now propagates that change to the tab text as
{terminal_title} ({connection_name}).Example: Connect to "Server A", then SSH to
192.168.1.2astest:test@192.168.1.2 (Server A)Changes
ProtocolBase— addedTitleChangedevent +Event_TitleChangedprotected methodPuttyBase— pollsPuttyProcess.MainWindowTitleevery 500ms viaSystem.Threading.Timer; firesTitleChangedon change; disposes timer on closeConnectionInitiator— wiresProt_Event_TitleChangedhandler inSetConnectionFormEventHandlersConnectionWindow—Prot_Event_TitleChangedupdatesConnectionTab.TabTextwith proper thread-safe invoke; formats as{title} ({connectionName})OptionsTabsPanelsPage— newUseTerminalTitleForTabsboolean setting (default:false, opt-in)TabsPanelsPage— new checkbox "Use terminal title for tab names (SSH/Telnet)" in Options → Tabs & PanelsLanguage.resx/Language.Designer.cs— localization string for the new optionOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.