dsh-phone-linking
Use this computer's DeepSeek Harness from an iPhone — and in landscape get the desktop layout, not a squeezed phone page.
A DeepSeek Harness (DSH) plugin in two halves:
- Host half — a small gateway the plugin owns. It listens on
0.0.0.0:8790, proxies the real GUI from its loopback origin, and optionally starts acloudflaredquick tunnel so the phone does not have to be on the same Wi-Fi. - Client half — a browser layer that activates on a phone in landscape: keyboard lift, safe-area insets, touch-sized controls, no stuck hover tooltips, and a landscape settings page.
Nothing about dsh web startup is changed, and no router configuration is needed.
中文说明见下方 怎么用。English summary above, full docs in Chinese below.
What it actually fixes
The stock web UI is responsive, but it targets a desktop browser in a narrow window:
| Symptom on an iPhone | What this plugin does |
|---|---|
Soft keyboard covers the composer, because the shell is height:100% of the layout viewport |
Shrinks html/body/#root to visualViewport.height while the keyboard is open, and hides the ambient dock so the input stays visible |
| Text runs under the notch / Dynamic Island in landscape, and under the status bar in a Home Screen app | Adds viewport-fit=cover to the served shell plus env(safe-area-inset-*) padding |
| Tapping an input zooms the page | Forces 16px on textarea / input / [contenteditable] |
| Some icon buttons are ~28px | 40px minimum targets on icon buttons, panel toggles, rail fish, new-session |
| Hover tooltips linger after a tap | Hides [role="tooltip"] and the resize handle on touch |
| Sidebar is a 56px rail below 1024px, so landscape is a sliver | Expands the sidebar to the desktop column once per landscape entry |
| Nothing installable to the Home Screen as a full-screen app | Rewrites the shell with apple-mobile-web-app-status-bar-style, so "Add to Home Screen" opens edge-to-edge |
Install
The plugin installs as a bundle (host half + client half + locale + icon). It is not on npm; install from a clone.
Clone this repo somewhere permanent — the profile installs a link, so do not delete or move the folder afterwards.
git clone https://github.com/zdddrszj985/dsh-Phone-Linking.gitInstall the bundle through DSH itself, pointing at the cloned folder:
- GUI: 设置 → 插件 → 从本地目录安装, choose the cloned folder, or
- ask your DSH agent to call the plugin manager's
install_bundlewith the absolute path, or - CLI: add the folder to the profile with
dsh plugin add link:<absolute path>, then add the package namedsh-phone-linkingtodsh.profile.bundlesin the profile'spackage.json.
Restart DeepSeek Harness once. The gateway binds its listener at plugin mount time, so the host half only appears after a start.
Open 设置 → 手机横屏. The first card is the LAN address, the 6-digit code, and the pairing state. Scan-free: open the copied link on the phone.
Requires DSH ≥ 0.2.1 (uses connection.requestRejection, webServer.getOrigin, and the slot API).
怎么用
- 电脑上打开 设置 → 手机横屏,最上面那张卡就是局域网地址、6 位访问码,以及配对状态。
- iPhone 用 Safari 打开那个地址,输入访问码(或者用「复制免密链接」把带令牌的链接发给自己,进一次就记住一年)。
- 进入后点 Safari 的分享 →「添加到主屏幕」,以后从主屏幕进,横屏没有地址栏,底部也没有工具条。
- 横过来,打字——输入框会被顶到键盘上方。
设置卡上如果写「网关没在跑」,说明电脑端那半没加载:插件要处于启用状态,然后重启一次 DeepSeek Harness(电脑端代码只在启动时跑一次)。手机端代码是刷页面就生效的。
手机不在同一个 WiFi 时
设置卡里点 开启公网访问,等十秒左右会出现一个 https://…trycloudflare.com 地址,旁边有「复制免密链接」,发给手机打开即可,横屏层照样生效。
- 隧道是 cloudflared 的临时通道,每次开启地址都变,关掉就废;要固定地址得自己配一个 Cloudflare 账号的 named tunnel。
- 走公网进来照样要令牌或访问码,安全边界和局域网那条一样。
- 电脑待机、断网、关掉 DSH,隧道一起断。
- 找 cloudflared 的顺序:环境变量
DSH_CLOUDFLARED→ profile 里的node_modules/cloudflared/bin→$DSH_HOME→ 当前目录 → PATH。
为什么不是直接改官方监听地址
dsh web --host 只接受一个具体地址,写进 profile 之后就成了硬编码:换个 WiFi、IP 变了,DSH 可能连启动都起不来。插件的入口是插件自己管的,DSH 升级、换网、拔网线都不影响它。
和「远程访问」插件的关系
装了 @linxin666/dsh-remote-web-ui 的机器上,任何非本机回环来源都要先配对,否则工作区被一块「需要设备配对」挡住。这条通道在电脑上是回环请求,所以它自己会调那个插件的 /api/pair/issue + /api/pair/accept,把自己登记成一个正常设备——你在它的设备列表里会看到一条 DSH-iPhone-Gateway,那就是这条通道本身,随手撤销掉也可以(撤销后下次启动会重新登记)。没装那个插件时这一步自动跳过。
两个入口可以同时存在:它的二维码/隧道适合在外网连,这个插件的局域网入口延迟低、不用过隧道。手机从哪个入口进来,横屏层都生效。
安全边界
- 入口只监听
0.0.0.0:<port>,同一局域网内的设备能连;不点「开启公网访问」时公网连不到。 - 进来要带一个 48 字节随机令牌(首次由链接带入,存成一年有效的 HttpOnly Cookie),或者输 6 位访问码;访问码连错 8 次锁 10 分钟。
- 令牌和访问码存在
$DSH_HOME/iphone-desk.json(0600)。想作废旧链接就点「作废旧链接」,想换码就点「换一个」。手机自己的 Cookie 会一直保留到那台手机清缓存。 - 手机看到的会话 Cookie 是电脑进程内换来的,令牌本身不出现在任何页面里。
- 电脑端状态接口只听回环,并且只对
http://127.0.0.1:<GUI 端口>这一个来源开放 CORS,别的网页读不到。
配置
| 项 | 默认 | 说明 |
|---|---|---|
DSH_IPHONE_PORT |
8790 |
网关监听端口。改了以后设置页读不到状态(它读 8790),但手机照旧用新端口 |
DSH_CLOUDFLARED |
自动查找 | cloudflared 可执行文件路径 |
DSH_IPHONE_PAIR_COOKIE |
dsh_pair |
与远程访问插件对接时用的设备 Cookie 名 |
状态文件:$DSH_HOME/iphone-desk.json(令牌、访问码、配对设备、隧道路由开关);日志:$DSH_HOME/iphone-desk.log。
排查
- 手机上打不开:先确认手机和电脑在同一个 WiFi;不在同一个 WiFi 就点「开启公网访问」。Windows 防火墙第一次拦的时候要选「允许」(专用网络)。
- 公网地址打不开:隧道还在「正在建立」就再等几秒;报错就点「重试」。地址每次开启都会变,别用手上的旧地址。
- 打不开、但电脑上本地能开:看看是不是公司网络开了客户端隔离。
- 横屏没变化:地址后面加
?dsh-iphone-desk=force强制启用看样式变不变;不变说明页面里没加载到客户端代码,刷新一次。 - 电脑上想看效果:浏览器打开
http://127.0.0.1:<端口>/?dsh-iphone-desk=force,把窗口拉成又矮又宽。
结构
index.js 电脑端:网关、代理、令牌/访问码、配对、隧道
client.js 手机端:横屏判断、键盘、安全区、触控密度、设置卡
cordis.patch.yml 一行 insert,插件挂到 profile
locale/{zh,en}.json 标题、描述、详情页
docs/DETAIL.md 实现细节(代理为什么这么写、控制面为什么不在 webServer 上)
test/ 两个自检脚本:node test/host-check.cjs / client-check.cjs
测试
node test/host-check.cjs # 17+ 项:状态接口、CORS、令牌/访问码、隧道接口
node test/client-check.cjs # 21 项:横屏判定、键盘开关、设置项、强制开关
两个脚本都用假的 DOM/ctx 跑真实模块,不需要起 DSH,也不会碰到真实的 $DSH_HOME(host 那个会自己建临时目录)。
License
MIT © zdddrszj985
No comments yet. Be the first to write one.