diff --git a/windows/src/WeChatBridge.Windows.Core/Identity/WeChatWindowTitleReader.cs b/windows/src/WeChatBridge.Windows.Core/Identity/WeChatWindowTitleReader.cs
index 39cf522..470cde8 100644
--- a/windows/src/WeChatBridge.Windows.Core/Identity/WeChatWindowTitleReader.cs
+++ b/windows/src/WeChatBridge.Windows.Core/Identity/WeChatWindowTitleReader.cs
@@ -19,20 +19,30 @@ public sealed class WeChatTitleReaderException(WeChatTitleReaderErrorKind kind,
}
///
-/// Windows port of WeChatTitleReader. On macOS the group name comes from
-/// Accessibility labels or a Screen-Recording screenshot of the title bar;
-/// Windows needs neither — the WeChat main window's own title bar text already
-/// contains the current chat name, and GetWindowText reads it without
-/// capturing any pixels. The privacy boundary is identical to the macOS
-/// Accessibility path: window titles only, no screen capture, no injection.
+/// Windows port of WeChatTitleReader: reads the chat name from WeChat's
+/// top-level window titles with GetWindowText, without capturing any
+/// pixels. The privacy boundary is identical to the macOS Accessibility path:
+/// window titles only, no screen capture, no injection.
+///
+/// WeChat 4.x (Weixin) titles its main window 「微信」 whatever chat is open, so
+/// a title that is only the app name is not a chat name. It is dropped here, so
+/// the caller falls through to the OCR read instead of filing every group as
+/// 「微信」 (issue #41).
///
public sealed class WeChatWindowTitleReader
{
/// Weixin.exe is WeChat 4.x; WeChat.exe is the 3.x line.
private static readonly string[] WeChatProcessNames = ["weixin", "wechat"];
+ /// What WeChat calls its own windows; never a chat name.
+ private static readonly HashSet AppNames =
+ new(StringComparer.OrdinalIgnoreCase) { "微信", "Weixin", "WeChat" };
+
private readonly Func> _windowTitles;
+ /// True for a title that names the app rather than a chat.
+ public static bool IsAppName(string title) => AppNames.Contains(title.Trim());
+
/// Injectable so tests parse titles without a
/// running WeChat. Null reads the real windows via user32.
public WeChatWindowTitleReader(Func>? windowTitles = null) =>
@@ -49,7 +59,7 @@ public GroupTitleParser.Title Read()
if (titles.Count == 0)
throw new WeChatTitleReaderException(
WeChatTitleReaderErrorKind.NoWindow, "没有找到可见的微信聊天窗口。");
- return GroupTitleParser.Parse(titles)
+ return GroupTitleParser.Parse(titles.Where(title => !IsAppName(title)))
?? throw new WeChatTitleReaderException(
WeChatTitleReaderErrorKind.EmptyTitle, "没有识别出微信群名。");
}
diff --git a/windows/src/WeChatBridge.Windows/Services/WeChatUiTitleReader.cs b/windows/src/WeChatBridge.Windows/Services/WeChatUiTitleReader.cs
index 1fe0155..f879a51 100644
--- a/windows/src/WeChatBridge.Windows/Services/WeChatUiTitleReader.cs
+++ b/windows/src/WeChatBridge.Windows/Services/WeChatUiTitleReader.cs
@@ -52,7 +52,11 @@ public static class WeChatUiTitleReader
///
public static GroupTitleParser.Title? Read()
{
- var candidates = ChatTitleCandidates();
+ // A bare 「微信」 is the app, not the chat: dropping it lets the caller
+ // fall through to the next reader (issue #41).
+ var candidates = ChatTitleCandidates()
+ .Where(candidate => !WeChatWindowTitleReader.IsAppName(candidate))
+ .ToList();
if (candidates.Count == 0)
return null;
foreach (var candidate in candidates)
diff --git a/windows/tests/WeChatBridge.Windows.Tests/SceneDecisionTests.cs b/windows/tests/WeChatBridge.Windows.Tests/SceneDecisionTests.cs
index 87db7fd..805e295 100644
--- a/windows/tests/WeChatBridge.Windows.Tests/SceneDecisionTests.cs
+++ b/windows/tests/WeChatBridge.Windows.Tests/SceneDecisionTests.cs
@@ -620,6 +620,30 @@ public void WindowTitleReaderParsesInjectedTitles()
Assert.Null(empty.TryRead());
}
+ ///
+ /// Issue #41: WeChat 4.x titles its main window 「微信」 whatever chat is
+ /// open. That title must read as "no name" so the OCR fallback runs,
+ /// instead of every group being filed under 「微信」.
+ ///
+ [Fact]
+ public void WindowTitleReaderIgnoresTheAppName()
+ {
+ foreach (var appName in new[] { "微信", "Weixin", "WeChat", " weixin " })
+ {
+ var reader = new WeChatWindowTitleReader(() => [appName]);
+ var error = Assert.Throws(() => reader.Read());
+ Assert.Equal(WeChatTitleReaderErrorKind.EmptyTitle, error.Kind);
+ Assert.Null(reader.TryRead());
+ }
+
+ var mixed = new WeChatWindowTitleReader(() => ["微信", "华东客户群 (128)"]);
+ Assert.Equal("华东客户群", mixed.Read().Name);
+
+ // The longest-line fallback must not pick the app name over a real chat.
+ var direct = new WeChatWindowTitleReader(() => ["微信", "张三"]);
+ Assert.Equal("张三", direct.Read().Name);
+ }
+
[Fact]
public void DefaultSceneRequiresExplicitSelection()
{