From 20f11018ce086062071ef59f57b5a8dbf88d722f Mon Sep 17 00:00:00 2001 From: cui Date: Thu, 19 Feb 2026 22:24:32 +0800 Subject: [PATCH 1/2] fix: lte should be lt like in linux.rs (#14344) --- src/platform/windows.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/windows.rs b/src/platform/windows.rs index c40e87441e1..582451240fe 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -107,9 +107,9 @@ pub fn get_focused_display(displays: Vec) -> Option { let center_x = rect.left + (rect.right - rect.left) / 2; let center_y = rect.top + (rect.bottom - rect.top) / 2; center_x >= display.x - && center_x <= display.x + display.width + && center_x < display.x + display.width && center_y >= display.y - && center_y <= display.y + display.height + && center_y < display.y + display.height }) } } From 34ceeac36e866b7aaae888683cd8b17752ea7a57 Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Thu, 19 Feb 2026 23:45:06 +0800 Subject: [PATCH 2/2] fix(terminal): fix tabKey parsing for peerIds containing underscores (#14354) Terminal tab keys use the format "peerId_terminalId". The previous code used split('_')[0] or startsWith('$peerId_') to extract the peerId, which breaks when the peerId itself contains underscores. This can happen in two scenarios: - Hostname-based ID: when OPTION_ALLOW_HOSTNAME_AS_ID is enabled, the peerId is derived from the system hostname, which commonly contains underscores (e.g. "my_dev_machine"). - Custom ID: the validation regex ^[a-zA-Z][\w-]{5,15}$ allows underscores since \w matches [a-zA-Z0-9_], so IDs like "my_dev_01" are valid. Fix all three parsing sites in terminal_tab_page.dart to use lastIndexOf('_'), which is safe because terminalId is always a plain integer with no underscores. --- .../lib/desktop/pages/terminal_tab_page.dart | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/flutter/lib/desktop/pages/terminal_tab_page.dart b/flutter/lib/desktop/pages/terminal_tab_page.dart index e06dee32183..cd8d84abedb 100644 --- a/flutter/lib/desktop/pages/terminal_tab_page.dart +++ b/flutter/lib/desktop/pages/terminal_tab_page.dart @@ -194,7 +194,10 @@ class _TerminalTabPageState extends State { final currentTab = tabController.state.value.selectedTabInfo; assert(call.arguments is String, "Expected String arguments for kWindowEventActiveSession, got ${call.arguments.runtimeType}"); - if (currentTab.key.startsWith(call.arguments)) { + // Use lastIndexOf to handle peerIds containing underscores + final lastUnderscore = currentTab.key.lastIndexOf('_'); + if (lastUnderscore > 0 && + currentTab.key.substring(0, lastUnderscore) == call.arguments) { windowOnTop(windowId()); return true; } @@ -329,7 +332,10 @@ class _TerminalTabPageState extends State { void _addNewTerminal(String peerId, {int? terminalId}) { // Find first tab for this peer to get connection parameters final firstTab = tabController.state.value.tabs.firstWhere( - (tab) => tab.key.startsWith('$peerId\_'), + (tab) { + final last = tab.key.lastIndexOf('_'); + return last > 0 && tab.key.substring(0, last) == peerId; + }, ); if (firstTab.page is TerminalPage) { final page = firstTab.page as TerminalPage; @@ -350,9 +356,10 @@ class _TerminalTabPageState extends State { void _addNewTerminalForCurrentPeer({int? terminalId}) { final currentTab = tabController.state.value.selectedTabInfo; - final parts = currentTab.key.split('_'); - if (parts.isNotEmpty) { - final peerId = parts[0]; + final tabKey = currentTab.key; + final lastUnderscore = tabKey.lastIndexOf('_'); + if (lastUnderscore > 0) { + final peerId = tabKey.substring(0, lastUnderscore); _addNewTerminal(peerId, terminalId: terminalId); } } @@ -369,9 +376,10 @@ class _TerminalTabPageState extends State { labelGetter: DesktopTab.tablabelGetter, tabMenuBuilder: (key) { // Extract peerId from tab key (format: "peerId_terminalId") - final parts = key.split('_'); - if (parts.isEmpty) return Container(); - final peerId = parts[0]; + // Use lastIndexOf to handle peerIds containing underscores + final lastUnderscore = key.lastIndexOf('_'); + if (lastUnderscore <= 0) return Container(); + final peerId = key.substring(0, lastUnderscore); return _tabMenuBuilder(peerId, () {}); }, ));