You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "me2seeks (via GitHub)" <gi...@apache.org> on 2026/09/17 08:12:57 UTC
[PR] fix(desktop): open WorkHub external links [maka]
me2seeks opened a new pull request, #5446:
URL: https://github.com/apache/maka/pull/5446
## Summary
- forward safe assistant Markdown links from WorkHub to the OS external URL handler
- keep WorkHub navigation local and block unsafe schemes
- add regression coverage for popup and navigation link paths
Fixes #5445
## Validation
- `npm run build`
- `npm run typecheck`
- `npm run check:stale`
- `npx biome check apps/desktop/src/main/workhub-presentation.ts apps/desktop/src/main/__tests__/workhub-presentation.test.ts`
- `npm --workspace @maka/desktop run test:dist` (2720 passing)
- Electron fixture: clicked `[test link](https://example.com/)` in WorkHub; the OS handler launched the URL and WorkHub remained on its local surface.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(desktop): open WorkHub external links [maka]
Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks merged PR #5446:
URL: https://github.com/apache/maka/pull/5446
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(desktop): open WorkHub external links [maka]
Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks commented on code in PR #5446:
URL: https://github.com/apache/maka/pull/5446#discussion_r4035008667
##########
apps/desktop/src/main/workhub-presentation.ts:
##########
@@ -144,8 +145,17 @@ export function createWorkHubPresentation(deps: WorkHubPresentationDeps) {
releaseView = typeof release === 'function' ? release : undefined;
view.webContents.once('destroyed', releaseViewRegistration);
installMainWindowPermissionPolicy(view.webContents, entry.url);
- view.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
- view.webContents.on('will-navigate', (event) => event.preventDefault());
+ // Keep remote pages out of the WorkHub renderer while preserving the
+ // user-facing assistant-link contract used by the main Desktop window.
+ // WorkHub is a local conversation surface, not the embedded browser.
+ view.webContents.setWindowOpenHandler(({ url }) => {
+ if (isExternalUrl(url)) void shell.openExternal(url);
+ return { action: 'deny' };
+ });
+ view.webContents.on('will-navigate', (event, url) => {
Review Comment:
Fixed in b817ef8570c6b0bca6a6f6cf01ecac498c8db6ef.
WorkHub now handles the event that Electron 43.4.1 actually emits first: will-frame-navigate. Main-frame same-URL navigations are allowed to continue, main-frame allowlisted external URLs are prevented and handed to shell.openExternal, unsafe main-frame URLs are denied, and subframes remain denied. The test now simulates the same sequence by emitting will-frame-navigate first and only reaching will-navigate when the frame event was not prevented.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(desktop): open WorkHub external links [maka]
Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #5446:
URL: https://github.com/apache/maka/pull/5446#discussion_r4034825572
##########
apps/desktop/src/main/workhub-presentation.ts:
##########
@@ -144,8 +145,17 @@ export function createWorkHubPresentation(deps: WorkHubPresentationDeps) {
releaseView = typeof release === 'function' ? release : undefined;
view.webContents.once('destroyed', releaseViewRegistration);
installMainWindowPermissionPolicy(view.webContents, entry.url);
- view.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
- view.webContents.on('will-navigate', (event) => event.preventDefault());
+ // Keep remote pages out of the WorkHub renderer while preserving the
+ // user-facing assistant-link contract used by the main Desktop window.
+ // WorkHub is a local conversation surface, not the embedded browser.
+ view.webContents.setWindowOpenHandler(({ url }) => {
+ if (isExternalUrl(url)) void shell.openExternal(url);
+ return { action: 'deny' };
+ });
+ view.webContents.on('will-navigate', (event, url) => {
Review Comment:
[P3] The sibling handler you are matching has one more clause: a same-URL guard for the initial load.
`main-window.ts:477` reads:
```ts
const current = mainWindow?.webContents.getURL() ?? '';
if (current === url) return;
event.preventDefault();
if (isExternalUrl(url)) void shell.openExternal(url);
```
and the comment above it says the reason out loud — "The initial Vite dev-server / packaged `file://` load is allowed through (current URL equals navigation target while the renderer is settling)". So on that surface a navigation whose target equals the current URL does reach this handler.
This view loads the same entry: `resolveMainRendererEntry(deps.mainModuleDirectory, deps.viteDevServerUrl)` returns the Vite dev-server URL when one is set, otherwise a `file://` path. Packaged, a same-URL hit is harmless — `file://` is not in the allow set. Under `npm run dev` the entry is `http://localhost:<port>`, which *is* allowed, so a same-URL navigation now hands the dev renderer to the system browser. Before this change the handler only called `preventDefault()`, so the case had no visible effect and nothing would have surfaced it.
I could not confirm this fires: I cannot launch Electron on this machine, so what I have is the sibling's own comment asserting the case exists plus the fact that this entry is `http://` in dev — not an observation. Worth a check while you have the Windows fixture from #5445 open, since that repro runs `npm run dev`. If it does fire, the fix is the two lines above.
<details><summary>简体中文</summary>
你正在对齐的那个同类处理器比这里多一条:针对初始加载的"同 URL 放行"。
`main-window.ts:477` 先取 `getURL()`,若与目标相同就直接 return,之后才 `preventDefault()` 并转交外链。它上面的注释把理由写明了 ——「初始的 Vite dev server / 打包后的 `file://` 加载会被放行(渲染器稳定过程中,当前 URL 与导航目标相同)」。也就是说在那个界面上,目标等于当前 URL 的导航确实会走到这个处理器。
这个 view 加载的是同一个入口:`resolveMainRendererEntry` 在设置了 dev server 时返回 Vite 的 URL,否则返回 `file://` 路径。打包态下同 URL 命中是无害的,`file://` 不在允许集里;但 `npm run dev` 下入口是 `http://localhost:<port>`,**在**允许集里,于是同 URL 导航会把 dev 渲染器交给系统浏览器打开。改动之前这个处理器只调 `preventDefault()`,所以这种情况没有可见后果,也不会被发现。
**我没能确认它真的会触发**:这台机器起不来 Electron,我手上的只是同类实现自己的注释断言了这种情况存在,加上这个入口在 dev 下是 `http://` —— 这是推理,不是观察。#5445 的复现步骤正好是 `npm run dev`,你那边的 Windows 环境还在的话顺手验一下即可。真会触发的话,修法就是上面那两行。
</details>
##########
apps/desktop/src/main/workhub-presentation.ts:
##########
@@ -144,8 +145,17 @@ export function createWorkHubPresentation(deps: WorkHubPresentationDeps) {
releaseView = typeof release === 'function' ? release : undefined;
view.webContents.once('destroyed', releaseViewRegistration);
installMainWindowPermissionPolicy(view.webContents, entry.url);
- view.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
- view.webContents.on('will-navigate', (event) => event.preventDefault());
+ // Keep remote pages out of the WorkHub renderer while preserving the
+ // user-facing assistant-link contract used by the main Desktop window.
+ // WorkHub is a local conversation surface, not the embedded browser.
+ view.webContents.setWindowOpenHandler(({ url }) => {
+ if (isExternalUrl(url)) void shell.openExternal(url);
Review Comment:
[P3] `void shell.openExternal(url)` with no `.catch` — the repo has both idioms, and the safer one is one call away.
`shell.openExternal` returns a promise that rejects when the OS has no handler for the URL. `browser/controller.ts:159` guards it — `void shell.openExternal(safe).catch(() => {});` — while `main-window.ts:468` and `:483` do not, and this PR follows the unguarded one. I found no `process.on('unhandledRejection')` anywhere under `apps/desktop/src/main`.
I am not claiming this crashes: I cannot run Electron here, so I did not determine what its main process does with an unhandled rejection, and the behaviour differs across Node/Electron versions and flags. The point is narrower — two call sites in the same codebase disagree about whether this promise needs a catch, this PR adds a third on the unguarded side, and `.catch(() => {})` costs nothing either way.
Both new call sites are on lines 152 and 157.
<details><summary>简体中文</summary>
`void shell.openExternal(url)` 没有 `.catch` —— 仓库里两种写法都有,而更稳妥的那种只差一次调用。
`shell.openExternal` 在系统没有对应 handler 时会 reject。`browser/controller.ts:159` 做了保护(`void shell.openExternal(safe).catch(() => {})`),而 `main-window.ts:468` 与 `:483` 没有,本 PR 跟的是没保护的那种。我在 `apps/desktop/src/main` 下没有找到任何 `process.on('unhandledRejection')`。
**我不是在断言这会崩**:这里起不来 Electron,我没有确定它的主进程如何处理未捕获的 rejection,而且这个行为随 Node/Electron 版本与启动参数而变。我想说的更窄:同一个代码库里两处调用点对"这个 promise 要不要 catch"意见不一致,本 PR 在没保护的那一侧又加了第三处,而 `.catch(() => {})` 无论如何都不花什么代价。
两处新增调用点在第 152、157 行。
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(desktop): open WorkHub external links [maka]
Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks commented on code in PR #5446:
URL: https://github.com/apache/maka/pull/5446#discussion_r4034917078
##########
apps/desktop/src/main/workhub-presentation.ts:
##########
@@ -144,8 +145,17 @@ export function createWorkHubPresentation(deps: WorkHubPresentationDeps) {
releaseView = typeof release === 'function' ? release : undefined;
view.webContents.once('destroyed', releaseViewRegistration);
installMainWindowPermissionPolicy(view.webContents, entry.url);
- view.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
- view.webContents.on('will-navigate', (event) => event.preventDefault());
+ // Keep remote pages out of the WorkHub renderer while preserving the
+ // user-facing assistant-link contract used by the main Desktop window.
+ // WorkHub is a local conversation surface, not the embedded browser.
+ view.webContents.setWindowOpenHandler(({ url }) => {
+ if (isExternalUrl(url)) void shell.openExternal(url);
+ return { action: 'deny' };
+ });
+ view.webContents.on('will-navigate', (event, url) => {
Review Comment:
Fixed in f60fd3c14d16a98162a22a497e12d948c741d79c. The WorkHub `will-navigate` handler now reads `contents.getURL()` and returns before `preventDefault()` when the target equals the current URL, matching the main-window behavior for the initial Vite dev-server or packaged entry load. The regression test now covers a same-URL `http://localhost:5173/` navigation.
##########
apps/desktop/src/main/workhub-presentation.ts:
##########
@@ -144,8 +145,17 @@ export function createWorkHubPresentation(deps: WorkHubPresentationDeps) {
releaseView = typeof release === 'function' ? release : undefined;
view.webContents.once('destroyed', releaseViewRegistration);
installMainWindowPermissionPolicy(view.webContents, entry.url);
- view.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
- view.webContents.on('will-navigate', (event) => event.preventDefault());
+ // Keep remote pages out of the WorkHub renderer while preserving the
+ // user-facing assistant-link contract used by the main Desktop window.
+ // WorkHub is a local conversation surface, not the embedded browser.
+ view.webContents.setWindowOpenHandler(({ url }) => {
+ if (isExternalUrl(url)) void shell.openExternal(url);
Review Comment:
Fixed in f60fd3c14d16a98162a22a497e12d948c741d79c. Both allowlisted `shell.openExternal` calls now attach `.catch(() => {})`, so an unavailable OS handler cannot create an unhandled rejection in the main process.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(desktop): open WorkHub external links [maka]
Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #5446:
URL: https://github.com/apache/maka/pull/5446#discussion_r4034893934
##########
apps/desktop/src/main/workhub-presentation.ts:
##########
@@ -144,8 +145,17 @@ export function createWorkHubPresentation(deps: WorkHubPresentationDeps) {
releaseView = typeof release === 'function' ? release : undefined;
view.webContents.once('destroyed', releaseViewRegistration);
installMainWindowPermissionPolicy(view.webContents, entry.url);
- view.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
- view.webContents.on('will-navigate', (event) => event.preventDefault());
+ // Keep remote pages out of the WorkHub renderer while preserving the
+ // user-facing assistant-link contract used by the main Desktop window.
+ // WorkHub is a local conversation surface, not the embedded browser.
+ view.webContents.setWindowOpenHandler(({ url }) => {
+ if (isExternalUrl(url)) void shell.openExternal(url);
+ return { action: 'deny' };
+ });
+ view.webContents.on('will-navigate', (event, url) => {
Review Comment:
**Addendum — downgrading my own P3 above.**
The parallel review line reports, from a probe on Electron 43.4.1 with these listeners in production order, that a user-initiated same-frame `<a href>` emits `will-frame-navigate` first; the existing listener calls `preventDefault()` there, and `will-navigate` never fires. If that holds, this whole branch is unreachable for link navigations, and my "same-URL hit hands the dev renderer to the system browser" scenario cannot occur through it either — `will-frame-navigate` fires for the main frame too, so it would consume a scripted `location` change or a dev-server reload before this listener sees it.
So treat my note above as subordinate to theirs: same line, same root cause, and their fix — handling allowed main-frame URLs in `will-frame-navigate` while continuing to deny subframes — resolves both. If you do move the logic there, the same-URL guard from `main-window.ts:477` is still worth carrying across, because at that point the branch becomes reachable.
I could not run Electron here, so I did not reproduce their ordering result; I am deferring to it on the evidence they published, not confirming it.
One piece I did check independently, because their severity rests on it: assistant Markdown external links do carry `target="_blank"`. `MarkdownLink` in `packages/ui/src/markdown-body.tsx:339` renders safe external schemes as `<AstryxLink href isExternalLink>`, and Astryx's `Link` maps `isExternalLink` to `target="_blank"` with `rel="noopener noreferrer"` (`computeTargetAndRel`). So the case #5445 reports goes through `setWindowOpenHandler`, which this PR does fix — the unreachable branch is a dormant fallback rather than the user-visible path. That supports calling it P3 rather than anything higher.
<details><summary>简体中文</summary>
**补充 —— 下调我自己上面那条 P3。**
并行评审线基于 Electron 43.4.1 的实测报告:在生产的监听器注册顺序下,用户点击同框架 `<a href>` 会**先**触发 `will-frame-navigate`,既有监听器在那里 `preventDefault()`,`will-navigate` 根本不会触发。若成立,这整个分支对链接导航就是不可达的,我说的"同 URL 命中把 dev 渲染器丢给系统浏览器"也同样走不到 —— `will-frame-navigate` 对主框架也会触发,脚本改 `location` 或 dev server 重载同样会先被它吃掉。
所以请把我上面那条视为从属于他们那条:同一行、同一个根因,而他们的修法(在 `will-frame-navigate` 里处理被允许的主框架 URL,同时继续拒绝子框架)可以一并解决。**如果真的把逻辑挪过去,`main-window.ts:477` 那条同 URL 早退仍然值得一并带过去** —— 因为那时这个分支才真正变得可达。
我这里起不来 Electron,没有复现他们的顺序结论;我是**依据他们公布的证据让位,不是确认它**。
有一点我独立核过,因为他们的定级建立在它之上:助手 Markdown 的外链**确实带 `target="_blank"`**。`packages/ui/src/markdown-body.tsx:339` 的 `MarkdownLink` 把安全外部 scheme 渲染成 `<AstryxLink href isExternalLink>`,而 Astryx 的 `Link` 把 `isExternalLink` 映射为 `target="_blank"` + `rel="noopener noreferrer"`。所以 #5445 报的那个场景走的是 `setWindowOpenHandler`,本 PR 确实修好了它 —— 不可达的那个分支是休眠的兜底,不是用户可见路径。这支持把它定为 P3 而不是更高。
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(desktop): open WorkHub external links [maka]
Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #5446:
URL: https://github.com/apache/maka/pull/5446#discussion_r4034859840
##########
apps/desktop/src/main/workhub-presentation.ts:
##########
@@ -144,8 +145,17 @@ export function createWorkHubPresentation(deps: WorkHubPresentationDeps) {
releaseView = typeof release === 'function' ? release : undefined;
view.webContents.once('destroyed', releaseViewRegistration);
installMainWindowPermissionPolicy(view.webContents, entry.url);
- view.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
- view.webContents.on('will-navigate', (event) => event.preventDefault());
+ // Keep remote pages out of the WorkHub renderer while preserving the
+ // user-facing assistant-link contract used by the main Desktop window.
+ // WorkHub is a local conversation surface, not the embedded browser.
+ view.webContents.setWindowOpenHandler(({ url }) => {
+ if (isExternalUrl(url)) void shell.openExternal(url);
+ return { action: 'deny' };
+ });
+ view.webContents.on('will-navigate', (event, url) => {
Review Comment:
[P3] Route safe same-frame links from the event that actually fires
With Electron 43.4.1 and these listeners registered in production order, a user-initiated same-frame `<a href="/target">` emitted `will-frame-navigate` first; this listener called `preventDefault()`, and `will-navigate` never fired. The OS handoff therefore remained absent. The same probe confirmed that a `target="_blank"` link does reach `setWindowOpenHandler`, so the reported Markdown case is fixed, but this fallback is currently unreachable.
The new test manually emits `will-navigate` without exercising the existing frame listener, so it cannot catch this interaction. Please handle allowed main-frame URLs in `will-frame-navigate` (while continuing to deny subframes), or otherwise ensure that listener does not consume the navigation before `will-navigate`, and cover the real event sequence.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org