X Tutup
Skip to content

Dynamic tab naming for SSH/Telnet via PuTTY terminal title tracking#3153

Draft
Copilot wants to merge 2 commits intov1.78.2-devfrom
copilot/add-dynamic-tab-naming
Draft

Dynamic tab naming for SSH/Telnet via PuTTY terminal title tracking#3153
Copilot wants to merge 2 commits intov1.78.2-devfrom
copilot/add-dynamic-tab-naming

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

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.2 as test:

  • Tab shows → test@192.168.1.2 (Server A)

Changes

  • ProtocolBase — added TitleChanged event + Event_TitleChanged protected method
  • PuttyBase — polls PuttyProcess.MainWindowTitle every 500ms via System.Threading.Timer; fires TitleChanged on change; disposes timer on close
  • ConnectionInitiator — wires Prot_Event_TitleChanged handler in SetConnectionFormEventHandlers
  • ConnectionWindowProt_Event_TitleChanged updates ConnectionTab.TabText with proper thread-safe invoke; formats as {title} ({connectionName})
  • OptionsTabsPanelsPage — new UseTerminalTitleForTabs boolean setting (default: false, opt-in)
  • TabsPanelsPage — new checkbox "Use terminal title for tab names (SSH/Telnet)" in Options → Tabs & Panels
  • Language.resx / Language.Designer.cs — localization string for the new option
Original prompt

This section details on the original issue you should resolve

<issue_title>Dynamic tab name</issue_title>
<issue_description>It would be very useful to have dynamic tab naming for ssh connections.
Example:

  1. Connect to "Server A" as user "testor" where hostname is "servera"
  2. Tab should be named "testor@servera (Server A)"
  3. SSH from "Server A" to another server at IP 192.168.1.2 with user "test"
  4. Tab should be named "test@192.168.1.2 (Server A)"

This is extremely useful when you manage hundred of servers.
This is the same with:
https://mremoteng.atlassian.net/browse/MR-571

Could not find the same ticket on github.</issue_description>

Comments on the Issue (you are @copilot in this section)

@Kvarkas hello, unfortunately we are moving forward and its a lot of changes in 1.77.x version including .Net 6 framework... so please wait for a new stable release of 1.77

🔒 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.

Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
@sonarqubecloud
Copy link

Copilot AI changed the title [WIP] Add dynamic tab naming for SSH connections Dynamic tab naming for SSH/Telnet via PuTTY terminal title tracking Feb 20, 2026
Copilot AI requested a review from Kvarkas February 20, 2026 13:53
@Kvarkas Kvarkas requested a review from Copilot February 20, 2026 13:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TitleChanged event on ProtocolBase and wires it through connection initiation to the UI.
  • Implements periodic PuTTY MainWindowTitle polling in PuttyBase and 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

Comment on lines +395 to +396
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
"PuTTY title monitoring stopped: " + ex.Message, true);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
"PuTTY title monitoring stopped: " + ex.Message, true);
Runtime.MessageCollector.AddMessage(
MessageClass.InformationMsg,
Language.PuttyTitleMonitoringStopped + Environment.NewLine + ex.Message,
true);

Copilot uses AI. Check for mistakes.
Comment on lines +843 to +847
string connectionName = protocolBase.InterfaceControl.Info?.Name ?? "";
string tabText = string.IsNullOrEmpty(newTitle)
? connectionName
: $"{newTitle} ({connectionName})";
tabText = tabText.Replace("&", "&&");
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 75 to 78
chkShowLogonInfoOnTabs.Checked = Properties.OptionsTabsPanelsPage.Default.ShowLogonInfoOnTabs;
chkShowProtocolOnTabs.Checked = Properties.OptionsTabsPanelsPage.Default.ShowProtocolOnTabs;
chkUseTerminalTitleForTabs.Checked = Properties.OptionsTabsPanelsPage.Default.UseTerminalTitleForTabs;
chkIdentifyQuickConnectTabs.Checked = Properties.OptionsTabsPanelsPage.Default.IdentifyQuickConnectTabs;
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +340 to +343
// Start monitoring PuTTY window title for dynamic tab naming
_lastWindowTitle = PuttyProcess.MainWindowTitle;
_titleMonitorTimer = new System.Threading.Timer(MonitorPuttyTitle, null, TitleMonitorIntervalMs, TitleMonitorIntervalMs);

Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
@robertpopa22
Copy link

robertpopa22 commented Feb 24, 2026

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

  • Adds a 500ms polling timer on PuttyBase monitoring PuttyProcess.MainWindowTitle
  • Fires TitleChanged event up to ConnectionWindow which updates tab text
  • Adds UseTerminalTitleForTabs opt-in toggle in Options > Tabs & Panels

What the codebase already has

Aspect This PR Current codebase
Title reading Process.MainWindowTitle P/Invoke ReadTerminalWindowTitle() with 512-char buffer
Thread safety None (lock-free) _terminalTitleSync lock-based synchronization
Lifecycle Timer start in constructor StartTerminalTitleTracking() / StopTerminalTitleTracking() with proper cleanup on all exit paths (ProcessExited, Connect, Close, error)
Fallback None Restores original tab text when terminal title reverts to initial value or becomes empty
Tab updates Event bubbled to ConnectionWindow Direct ApplyTabText() via connectionTab.TabText with InvokeRequired check
Unread activity Not handled Sets HasUnreadActivity on inactive tabs when title changes
Extensibility Hardcoded Virtual methods: UseTerminalTitlePollingTimer, UpdateTabTitleFromTerminalTitle(), ReadTerminalWindowTitle()
Logon info Not handled Integration with ShowLogonInfoOnTabs setting (appends logon suffix)

Additional merge blockers

Even if the feature weren't implemented, this PR has heavy conflicts across all 10 files:

  • TabsPanelsPage.Designer.cs — layout completely different (12+ new controls added since PR base)
  • OptionsTabsPanelsPage.settings — grew from ~42 to 80 settings
  • ProtocolBase.csTitleChanged event pattern not used in current architecture
  • ConnectionWindow.cs — handler for non-existent event

Only gap

The 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.


We sincerely appreciate the mRemoteNG maintainers and the wonderful community that has kept this project alive and thriving for over a decade. Your work powers thousands of IT professionals worldwide, including us. Our fork builds entirely on your foundation — we're preparing a consolidated Pull Request to contribute these improvements back to the official project. Thank you for everything you've built.

— robertpopa22, community contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic tab name

4 participants

X Tutup