Repository navigation
fix(tui): 底栏机器名只在远程工作区会话中显示(含悬停详情) - #98
Merged
Merged
Conversation
The footer field used to show whichever machine was persisted as current, so a local session still displayed the remote server name. The first attempt gated on `status().connected`, but the plugin auto-restores that machine at boot and probes it (lib/index.js), so `connected` is effectively always true. The field now follows the session's cwd: it is written only while the session the user is looking at resolves to a mirror under `$DSH_HOME/remote-workspaces`, and cleared for local sessions. The active session is the cwd the host hands to `provider.describe()` on every session switch (validated against live sessions), with session events as fallback; subagent sessions (`header.origin === 'subagent'`) are skipped. Hovering the field shows the full machine name, `user@host:port` and the remote path, clipped to one line for the current terminal width (CJK/emoji measured as two cells) and re-clipped on resize. The provider and the footer now share one mirror->machine matcher, including ssh-config aliases. A missing sessions service keeps the legacy behaviour; a failing one hides the field instead of reviving the stale name.
baiseraku
force-pushed
the
fix/tui-status-remote-only
branch
from
November 8, 2026 06:59
1589054 to
8f6a879
Compare
Contributor
Author
|
第一次 run 的 |
Owner
|
评审通过并已合入发布(v0.8.80)。几处做得特别好的点:cwd 三级采信 + describe 提示交叉校验、「读不到就隐藏而不是留旧名」的失败方向、500ms 合并刷新、CJK 宽度裁切、相同值不重写字段。一个非阻塞观察记下即可: |
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.
问题
在本地目录使用 dsh-tui 时,底栏一直显示远程机器名(例如
group/gpt-auto · 缓存 99.5% · shpc-116139-instance-… · DSH),让人以为当前会话是远程的。原因:
lib/tui/index.js的底栏字段只读machines.json的currentId,把「保存成 current 的机器」当成「正在用的机器」。第一版修复尝试按
api.status().connected判断,但插件启动时会 auto-restore 当前机器并echo探活(lib/index.js的 auto-restore 块),connected实际恒为 true,等于没改。方案
底栏改为跟随当前 TUI 会话的 cwd:只有它的 cwd 解析到
$DSH_HOME/remote-workspaces/<host>-<user>-<port>/<name>下的镜像时,才显示该镜像所属机器;本地会话清空字段。「当前会话」的判定顺序(TUI 一个进程可同时挂载多个会话):
provider.describe()的 cwd —— 只采信确实属于某个 live 会话的那个(session/*事件覆盖不到“切到已挂载会话”);user/message的会话;header.origin === 'subagent'的子代理会话一律排除(子代理也会进 store、也会发user/message,且可带独立 cwd)。session/created/session/disposed/user/message/ 终端 resize 触发 500ms 合并刷新。悬停详情(与其它底栏字段同一效果):完整机器名 ·
user@host:port· 远端路径。宿主只按 160 cells 截断 detail、再按可用宽度 wrap(不 truncate),所以插件自己按process.stdout.columns - 18裁成单行(状态行内宽columns-2,再给右侧 MiniWake/activity 预留),CJK / emoji 记 2 格,超宽以…结尾,并在 resize 后重裁。改动
lib/tui/index.js:会话判定 / 事件订阅 / 字段写入 / 宽度裁剪 / 卸载与竞态保护lib/tui/provider.js:describe()回传当前 cwd;导出matchMachineForMirror()供底栏与 provider 共用(含 ssh-config 别名机)lib/tui/format.js:displayWidth()/clipCells()lib/tui/i18n.js:悬停详情中英文案test/tui-install.test.js/test/tui-format.test.js:本地 / 远程 / 切换 / 子代理 / describe 提示 / 别名机 / 降级 / 去重 / 宽度用例docs/tui.md:状态行规则、悬停与宽度预算验证
npm test:1052 例 / 1043 通过 / 9 skip / 0 failnode check.mjs:OK…截断兼容性 / 限制
sessions服务(旧组合)时退回旧行为;有服务但读失败时隐藏,不显示过期机器名。provider.describe(cwd)(当前 dsh-tui 实现会调);没有这个调用的宿主上,退化为事件/输入驱动的近似判定。