fix(tui): keep unavailable Windows shares as ordinary text - #462
Merged
Merged
Conversation
Windows reports an unreachable host or a missing share as UNKNOWN rather than ENOENT, so mentioning a UNC path made the whole message fail instead of being sent as plain text. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
x-lixu
approved these changes
Sep 18, 2026
x-lixu
left a comment
Collaborator
There was a problem hiding this comment.
感谢修复不可用 Windows 共享路径导致整条 TUI 消息无法发送的问题。已合入最新 main,并将 UNKNOWN 放行范围收窄为 Windows UNC 路径的 stat 查找失败,保留本地路径、权限和实际读取错误。新增跨平台模拟回归覆盖三种文本输入形式,并确认显式附件选择仍报错。本地 60 项 TUI 测试通过,最新全部 CI(含原生 Windows 用例)通过。
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.
变更说明
TUI 把输入里的路径当成候选附件去
stat(),取不到时按"这只是普通文字"继续发送。但判断条件只认
ENOENT/ENOTDIR:Windows 上不可达的主机或不存在的共享返回的是
ERROR_BAD_NETPATH/ERROR_BAD_NET_NAME,Node 无法映射,统一报成UNKNOWN(errno -4094):于是只要消息里提到一个当前取不到的共享路径(NAS 关机、VPN 未连、共享已撤销,
或者只是在跟 Agent 讨论某个共享目录),
inputPartsFromText()就会抛出UNKNOWN: unknown error,整条消息发不出去——而同样不存在的本地路径(
C:\Users\me\missing.txt)会正常作为文字发送。三条路径(整段粘贴、文中内联、
@提及)都受影响。本仓库在 #429 里已经显式支持了
\\server\share这种 UNC 路径的识别,这里补上它对应的失败分支:取不到的共享路径与本地缺失路径一视同仁,按普通
文字发送。目录、超限、无权限读取等"路径确实存在但不能用"的错误仍然照旧上报。
验证
新增
tui/test/input-parts.test.mjs的keeps an unavailable Windows share as ordinary text(非 Windows 自动 skip)。用\\127.0.0.1\...这个一定可达、但共享名不存在的地址,避免依赖 DNS 或外部网络(本地实测 4–24ms 返回)。
修复前(未改动的 upstream/main,Windows 11 + Node 24.17):
修复后本地全部通过,并与未改动的 upstream/main 基线对比无回归:
npm testnpm run lintnpm run build兼容性与安全
CHANGELOG.md)因此读取或上传任何文件。回滚方式是还原本次提交。
🤖 Generated with Claude Code