mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 21:05:40 +07:00
[GH-ISSUE #5072] [GUI] 聊天回答里的外部链接点了没有任何反应:Markdown 的 preventDefault 之后 openLink 只接管预览链接,外部 URL 没人接 #2359
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2359
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @xvcezrqpbxtpzblrt on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5072
English TL;DR: In 0.2.10 the chat link handler does route web addresses to the system browser (
Chat.tsx:221-227→openExternal), as designed for #4721. But the desktop shell's host spawn (apps/desktop/src-tauri/src/main.rs:463-475) never passesSTRATA_UI_MODE, while the CLI supervisor does (supervisor.rs:361). SoappUi.state()reportsmode: null— documented inapp-ui.mjs:12as "not started by the app" — andopen-external.ts:26(if (mode.mode === 'window')) therefore skips the host leg and falls back towindow.open(url,'_blank','noopener,noreferrer')(:22), which the codebase itself documents as a no-op inside the app window (artifacts.mjs:11: "the app window drops window.open: WebView2 has no new-window handler"). The click then does nothing, with no message. The samemode:nullalso setsappUpdate:'unavailable'.Area
[GUI] 桌面应用(外壳 + host + Web UI)
现象
在聊天里点助手回答中的外部链接(GitHub issue 链接这类),没有任何反应:不开浏览器、不开预览、不提示。本机 0.2.10,2026-11-03 多次出现。
环境(本机实测)
http://127.0.0.1:47831,WebView2 156.0.4314.58,Windows 10.0.26300host\dist\*的 mtime 是 2026-11-03 06:37:26现场实测(对着正在运行的 app 探的,2026-11-03 17:47)
GET http://127.0.0.1:47831/api/app/mode→ 200,响应体: →mode是null,不是'window';并且appUpdate被报成unavailableGET http://127.0.0.1:47831/→ 200 / 2172 字节 index.html;GET /nope-does-not-exist→ 200 + index.html(SPA 兜底)——说明 host 活着且正常,不是"服务没起来"POST /api/artifacts/open:我发的 JSON 被 PowerShell 的引号转义破坏,服务端回500 {"error":"Body must be JSON"}→ 这次探测无效,记 not run(真正走通 URL 腿会真的打开浏览器标签,没有做)机制链(全部为 tag v0.2.10 =
ffa80d73的行号,与你安装的产物时间一致)apps/host/src/components/Markdown.tsx:33-36—— 只有https?://、mailto:、#会渲染成<a … target="_blank" rel="noreferrer">,点击时if (onOpenLink && /^https?:/i.test(link[2])) { e.preventDefault(); onOpenLink(link[2]); };图片当链接时同理(:19-23,plan.kind === 'link'→preventDefault+onOpenLink(plan.href))apps/host/src/screens/Chat.tsx:221-227apps/host/src/lib/open-external.ts:17-31(关键 3 行):25const mode = d.known() ?? await d.load();(loadAppMode()读GET /api/app/mode,失败.catch(() => NONE)):26if (mode.mode === 'window') {→ 本机实测是null,这个分支不进:22/:30落到d.open(url)=window.open(url, '_blank', 'noopener,noreferrer'):27-28即使在window分支,POST /api/artifacts/open失败也是catch { /* the host could not: the page tries as well */ }—— "再试一次"就是那个在 app 窗口里不可能成功的window.open,两条失败路径都不出提示window.open在 app 窗口里是空操作,代码自己写明了:apps/host/server/artifacts.mjs:11mode从哪来:apps/host/server/app-ui.mjs:64注释:12:mode null = not started by the app (the host run by hand, a test, a source checkout)apps/desktop/src-tauri/src/main.rs:463-475传的是STRATA_PORT、STRATA_DIST、NODE_ENV、STRATA_PACKAGED、STRATA_REAL_ENGINE、STRATA_EXIT_WITH_PARENT—— 没有STRATA_UI_MODEapps/desktop/src-tauri/src/supervisor.rs:361cmd.env("STRATA_UI_MODE", mode),紧接着:363.env("STRATA_UI_REASON","chosen")→ 同一个 host 代码,终端启动时 mode 正确,桌面 app 启动时 mode 恒为
null这一处 mode:null 的连带影响
app-ui.mjs:85appUpdate: mode === 'browser' || mode === null ? 'unavailable' : …→ 实测正是"appUpdate":"unavailable":app 内自更新在桌面 app 里被报成不可用canQuit:false(同一 state),依赖 mode 的通知/退出/更新提示路径都退回"没有窗口进程"的分支[host] update · update-engine started是引擎更新通道,与 app 自更新不是一回事,不要混淆复现
https://链接curl http://127.0.0.1:<host端口>/api/app/mode→ 若mode为null即命中本条mode:null与appUpdate:"unavailable";行号在 tag v0.2.10(ffa80d73)逐条核对;exe 字符串计数已核。not run —— 端到端点击(无法程序化操作 UI)、POST /api/artifacts/open的 URL 腿(探测因 body 转义失败,且真跑会打开浏览器标签)、url.dll的导出表检查(我的 PE 解析报错,未得出结果)。failed —— 无建议
main.rs:463-475起 host 时补.env("STRATA_UI_MODE", "window")(与supervisor.rs:361一致;--browser时传browser),让桌面 app 与 CLI 走同一套语义open-external.ts把mode === null当"未卜"而不是"非窗口":先试POST /api/artifacts/open,失败再退window.open;两条都失败时必须有用户可见的失败提示(toast:"打不开外部链接,地址已复制"),不要静默target="_blank"在 app 里有确定行为(与 #5072 的原始症状同源)apps/host/tests/app-ui.test.mjs现在只测STRATA_UI_MODE:'window'/'browser'的 host 侧,没有测"桌面外壳是否真的传了这个变量"——加一个断言外壳 spawn 参数含STRATA_UI_MODE的测试;再在桌面冒烟里断言GET /api/app/mode的mode === "window"(这一条能立刻抓住本缺陷)版本说明(必须交代)
本条最初是按 0.2.9 检出写的(克隆时间 2026-11-02 14:46,落后
origin/main5,629 个提交),当时的结论是"openLink只处理预览链接,外部 URL 没人接"。0.2.10 已经改成openExternal+ #4721 的设计,旧结论对 0.2.10 不成立;现在的检出已对齐 tag v0.2.10 = ffa80d73(2026-11-03 06:37:27),与安装产物 mtime 06:37:26 对得上,正文按 v0.2.10 重写。相关已有讨论(先查过仓库)
open link、external browser、app/mode、STRATA_UI_MODE、链接 打不开;未见覆盖"外壳未传 STRATA_UI_MODE 导致 mode:null"的开放 issue本报告未包含
main.rs的 darwin/linux 分支未核);url.dll是否导出FileProtocolHandler(PE 解析失败,未得出);POST /api/artifacts/open正常 URL 时的端到端结果(需真开浏览器标签);mode=null 对通知与退出按钮的具体影响面(只实测了mode/appUpdate/canQuit三个字段)