Skip to content

fix(open-external): support Termux (platform android) openers - #769

Open
240xu wants to merge 1 commit into
omdsh-dev:mainfrom
240xu:fix/termux-android-open-external
Open

240xu wants to merge 1 commit into
omdsh-dev:mainfrom
240xu:fix/termux-android-open-external

Conversation

@240xu

@240xu 240xu commented Sep 26, 2026

Copy link
Copy Markdown

问题

在 Termux(Android 上最主要的 Node 运行时,process.platform 为 'android')上,文件树右键「在资源管理器中显示」和自定义 URL scheme 打开静默失败:两个 command builder 都落到 default 分支调用 xdg-open,而 Termux 里根本没有这个命令(spawn 错误按设计吞掉,用户侧表现为点了没反应)。

修复

按文件既有的纯函数 + 平台可注入风格,各加一个 case 'android':

  • revealCommand:termux-open 打开父目录——Android 没有桌面文件管理器也没有 select 协议,与 Linux 分支同样走父目录的 KISS 路线,交给 Android 系统的打开方式选择器;
  • urlCommand:termux-open-url 分发 URL intent(termux-open 会先把 URL 路由到内容选择器,URL 专用入口更直接)。

验证

  • tsc --noEmit 通过
  • tests/open-external.spec.ts 新增 3 个 android 用例,13/13 通过(真机 Termux 环境实测运行)
  • eslint 对改动文件零告警
  • Termux 真机(TERMUX_VERSION=0.118,/data/data/com.termux/files/usr/bin/termux-open{,-url} 存在)上确认两个命令可用

On Termux — the dominant Node runtime that reports process.platform
'android' — both external-open actions fell through to xdg-open, which
does not exist there, so 'reveal in file manager' and custom-scheme URL
opens failed silently (the spawn error is swallowed by design).

- revealCommand: case 'android' → termux-open on the containing
  directory (no desktop file manager and no select protocol on Android;
  same parent-dir KISS as the Linux branch)
- urlCommand: case 'android' → termux-open-url (the URL intent
  dispatcher; termux-open would route URLs through the content chooser)

Command builders stay pure — the platform remains injectable and the new
branches are unit-tested like every other platform.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant