dsh-yazi 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DECISIONS.md +36 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/client.js +36 -8
- package/hero.png +0 -0
- package/package.json +2 -1
- package/src/client/main.js +7 -0
- package/src/client/terminal.js +29 -8
package/DECISIONS.md
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
# DECISIONS
|
|
2
2
|
|
|
3
3
|
<!-- APPEND-ONLY LOG: 新条目插入到此行之后 -->
|
|
4
|
+
## DEC-029 2026-11-28 Yazi 视图挂载时主动聚焦终端(修复切 tab 后键盘无响应)
|
|
5
|
+
|
|
6
|
+
用户报告:切到 Yazi 标签后 yazi 不接收键盘,必须先用鼠标点一下面板。根因不是 WebSocket 或 PTY,
|
|
7
|
+
而是浏览器焦点:`mountYaziTerminal` 只调用 `term.open(stage)`,而 xterm 的 `open()` 不会移动焦点。
|
|
8
|
+
|
|
9
|
+
- **实测证据**:用 Playwright + 真 Chrome 跑同一段 xterm 代码,先让一个 composer 类元素持有焦点再
|
|
10
|
+
`open()`,`document.activeElement` 仍是那个元素;此时敲 `abc`,字符全部落进 composer
|
|
11
|
+
(`oldTyped: "|composer:abc"`)。改成 `open()` 后显式 `term.focus()`,焦点落到
|
|
12
|
+
`.xterm-helper-textarea`,`abc` 进入终端且 composer 保持空(`composerUntouched: true`)。
|
|
13
|
+
- **为什么之前"点一下就好"**:鼠标点击落在 xterm 的 helper textarea 上,是浏览器默认行为替我们做了
|
|
14
|
+
这件事。焦点本来就没有交给终端,点击只是补上了缺失的那一步。
|
|
15
|
+
- **为什么必须挂载时聚焦**:DSH 的 `conversation.view` 槽位用 `{ only: viewId }` 渲染(见
|
|
16
|
+
dsh-client-ui-renderer),切走即卸载、切回即重新挂载。所以"只在 ready 后聚焦一次"会漏掉
|
|
17
|
+
第二次切回;挂在挂载路径上才与卸载/挂载的节奏一致。
|
|
18
|
+
- **在 greeting 之前聚焦,不等到 ready**:终端对象在 `open()` 后就接受按键,早聚焦可以避免
|
|
19
|
+
yazi 还在绘制时敲的键落进 composer。已有测试断言 greeting 不会二次聚焦。
|
|
20
|
+
- **`autoFocus` 是参数而非硬编码**:默认 `true`,传 `false` 可挂载但不抢焦点。这样"切过去只是想
|
|
21
|
+
看 yazi 状态、不想打字"的场景仍有出口,也让测试能分别验证两条路径。
|
|
22
|
+
- **`focus()` 收敛为一个函数**:原先返回对象里的内联 `focus` 与新增的挂载路径会各写一份,合并成
|
|
23
|
+
模块内 `focus()`,并统一加 `disposed` 守卫——否则 dispose 后调用会对已销毁的终端操作。
|
|
24
|
+
- **测试**:新增 5 条(挂载即聚焦、greeting 不二次聚焦、dispose 后不聚焦、`autoFocus: false`
|
|
25
|
+
不抢焦点、视图确实传 `autoFocus: true` 的产物断言)。先跑确认 3 条 focus 用例因行为缺失而红,
|
|
26
|
+
改后 194 条全绿(`make check`)。
|
|
27
|
+
- 版本不变(补丁级修复,随下次发布)。
|
|
28
|
+
|
|
29
|
+
## DEC-028 2026-11-27 统一 README hero 图约定:hero.png(PNG / 根目录 / README 引用 / files 收录)
|
|
30
|
+
|
|
31
|
+
用户要求把 hero 图统一到约定:文件名恰好为 `hero.png`、PNG 格式、位于仓库根目录、由 README.md 与 README.zh.md 以 `./hero.png` 引用,并收录进 package.json 的 `files`。
|
|
32
|
+
|
|
33
|
+
- **用 `git mv` 而非删除+新增**:`git mv hero-yazi.png hero.png` 保留文件历史,避免产生「删旧建新」的假象,符合同类资源替换(DEC-020 图标换 WebP)一贯做法。
|
|
34
|
+
- **格式与位置**:原文件已是合法 PNG(1536×656、8-bit RGB,PNG magic bytes `89 50 4E 47 0D 0A 1A 0A`),无需转码;仅改名为 `hero.png` 并留在仓库根目录。
|
|
35
|
+
- **引用点**:README.md 与 README.zh.md 的 hero 图引用都从 `./hero-yazi.png` 改为 `./hero.png`,alt 文案保持 `dsh-yazi hero` 不变(中立且简单)。全仓 grep 确认只有这两处引用 hero 图。
|
|
36
|
+
- **随包发布**:package.json 的 `files` 数组新增 `hero.png`(放在 `icon.webp` 之后),确保 npm 包内带上这张图,README 在 registry 上的图片链接可用。
|
|
37
|
+
- **测试先行**:新增 `test/hero.test.js`(4 条),断言 hero.png 存在且带 PNG magic bytes、旧名 hero-yazi.png 已消失、两份 README 都引用 `./hero.png` 且不出现旧名、package.json 收录 `hero.png` 且不收录旧名。改前先跑确认 4 条全红(行为缺失,非环境问题),改后全绿。
|
|
38
|
+
- 测试:`make test`(node --test)全部通过。
|
|
39
|
+
|
|
4
40
|
## DEC-027 2026-11-27 ⛔️ 进入 worktree 后 yazi 仍打开工作区路径(取代: DEC-004 的解析顺序)
|
|
5
41
|
|
|
6
42
|
用户报告:会话当场处于 worktree 时,yazi 打开的是 worktree 目录,这是错的,应该打开工作区自身的路径。
|
package/README.md
CHANGED
package/README.zh.md
CHANGED
package/client.js
CHANGED
|
@@ -547,11 +547,16 @@ function reportDiagnostic(phase, detail) {
|
|
|
547
547
|
* { type: 'error', kind }
|
|
548
548
|
* { type: 'closed' }
|
|
549
549
|
* @param options.win Window-like object (defaults to `window`).
|
|
550
|
-
* @
|
|
550
|
+
* @param options.autoFocus
|
|
551
|
+
* Take the keyboard on mount. Defaults to true: DSH renders a view without
|
|
552
|
+
* moving focus into it, so without this the panel is visible but deaf until
|
|
553
|
+
* the user clicks it. Pass false to mount without stealing focus.
|
|
554
|
+
* @returns {{ dispose: Function, resize: Function, kill: Function, send: Function, focus: Function }}
|
|
551
555
|
*/
|
|
552
556
|
function mountYaziTerminal(options) {
|
|
553
557
|
const { stage, bundle, query, notify } = options
|
|
554
558
|
const win = options.win ?? window
|
|
559
|
+
const autoFocus = options.autoFocus !== false
|
|
555
560
|
const { Terminal, FitAddon } = bundle
|
|
556
561
|
// assets.js supplies the reporter in the built bundle; a unit test may load
|
|
557
562
|
// this file alone, so the reference is guarded rather than assumed.
|
|
@@ -705,6 +710,28 @@ function mountYaziTerminal(options) {
|
|
|
705
710
|
|
|
706
711
|
const inputSubscription = term.onData((data) => send({ t: 'in', d: data }))
|
|
707
712
|
|
|
713
|
+
/**
|
|
714
|
+
* Give the keyboard to the terminal.
|
|
715
|
+
*
|
|
716
|
+
* xterm's `focus()` targets its hidden helper textarea, which is what makes
|
|
717
|
+
* keystrokes reach the PTY. DSH itself never moves focus into a view it just
|
|
718
|
+
* rendered, so this is the panel's own job — the shortcut path and the mount
|
|
719
|
+
* path both end up here.
|
|
720
|
+
*/
|
|
721
|
+
function focus() {
|
|
722
|
+
if (disposed) return
|
|
723
|
+
try {
|
|
724
|
+
term.focus?.()
|
|
725
|
+
} catch {
|
|
726
|
+
// A disposed terminal has nothing to focus.
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// Take the keyboard as soon as the panel exists rather than waiting for the
|
|
731
|
+
// greeting: typing while yazi is still painting should not be dropped, and
|
|
732
|
+
// the browser only routes keys to a focused element.
|
|
733
|
+
if (autoFocus) focus()
|
|
734
|
+
|
|
708
735
|
if (typeof win.ResizeObserver === 'function') {
|
|
709
736
|
observer = new win.ResizeObserver(scheduleFit)
|
|
710
737
|
observer.observe(stage)
|
|
@@ -716,13 +743,7 @@ function mountYaziTerminal(options) {
|
|
|
716
743
|
return {
|
|
717
744
|
resize: scheduleFit,
|
|
718
745
|
send,
|
|
719
|
-
focus
|
|
720
|
-
try {
|
|
721
|
-
term.focus?.()
|
|
722
|
-
} catch {
|
|
723
|
-
// A disposed terminal has nothing to focus.
|
|
724
|
-
}
|
|
725
|
-
},
|
|
746
|
+
focus,
|
|
726
747
|
kill() {
|
|
727
748
|
send({ t: 'kill' })
|
|
728
749
|
},
|
|
@@ -868,6 +889,13 @@ window.__ModuleLoader__.load({
|
|
|
868
889
|
// No cwd hint: the Host reads the session's workspace itself. A
|
|
869
890
|
// hint from here would be the live directory, i.e. the worktree.
|
|
870
891
|
query: { sid: sessionId },
|
|
892
|
+
// Selecting the Yazi tab mounts this view, and DSH moves no focus
|
|
893
|
+
// into a view it just rendered — so without this the panel showed
|
|
894
|
+
// yazi but ignored the keyboard until the user clicked it. Safe to
|
|
895
|
+
// take focus here: this effect only runs while the panel is the
|
|
896
|
+
// selected view, so the composer it might otherwise steal from is
|
|
897
|
+
// not on screen.
|
|
898
|
+
autoFocus: true,
|
|
871
899
|
notify(event) {
|
|
872
900
|
if (event.type === 'connecting') return
|
|
873
901
|
if (event.type === 'ready') {
|
package/hero.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-yazi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Adds a Yazi tab to the navigation bar that runs the local yazi file manager in a real PTY inside the main panel.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"cordis.patch.yml",
|
|
19
19
|
"locale/*.json",
|
|
20
20
|
"icon.webp",
|
|
21
|
+
"hero.png",
|
|
21
22
|
"README.md",
|
|
22
23
|
"DECISIONS.md"
|
|
23
24
|
],
|
package/src/client/main.js
CHANGED
|
@@ -114,6 +114,13 @@ window.__ModuleLoader__.load({
|
|
|
114
114
|
// No cwd hint: the Host reads the session's workspace itself. A
|
|
115
115
|
// hint from here would be the live directory, i.e. the worktree.
|
|
116
116
|
query: { sid: sessionId },
|
|
117
|
+
// Selecting the Yazi tab mounts this view, and DSH moves no focus
|
|
118
|
+
// into a view it just rendered — so without this the panel showed
|
|
119
|
+
// yazi but ignored the keyboard until the user clicked it. Safe to
|
|
120
|
+
// take focus here: this effect only runs while the panel is the
|
|
121
|
+
// selected view, so the composer it might otherwise steal from is
|
|
122
|
+
// not on screen.
|
|
123
|
+
autoFocus: true,
|
|
117
124
|
notify(event) {
|
|
118
125
|
if (event.type === 'connecting') return
|
|
119
126
|
if (event.type === 'ready') {
|
package/src/client/terminal.js
CHANGED
|
@@ -18,11 +18,16 @@
|
|
|
18
18
|
* { type: 'error', kind }
|
|
19
19
|
* { type: 'closed' }
|
|
20
20
|
* @param options.win Window-like object (defaults to `window`).
|
|
21
|
-
* @
|
|
21
|
+
* @param options.autoFocus
|
|
22
|
+
* Take the keyboard on mount. Defaults to true: DSH renders a view without
|
|
23
|
+
* moving focus into it, so without this the panel is visible but deaf until
|
|
24
|
+
* the user clicks it. Pass false to mount without stealing focus.
|
|
25
|
+
* @returns {{ dispose: Function, resize: Function, kill: Function, send: Function, focus: Function }}
|
|
22
26
|
*/
|
|
23
27
|
function mountYaziTerminal(options) {
|
|
24
28
|
const { stage, bundle, query, notify } = options
|
|
25
29
|
const win = options.win ?? window
|
|
30
|
+
const autoFocus = options.autoFocus !== false
|
|
26
31
|
const { Terminal, FitAddon } = bundle
|
|
27
32
|
// assets.js supplies the reporter in the built bundle; a unit test may load
|
|
28
33
|
// this file alone, so the reference is guarded rather than assumed.
|
|
@@ -176,6 +181,28 @@ function mountYaziTerminal(options) {
|
|
|
176
181
|
|
|
177
182
|
const inputSubscription = term.onData((data) => send({ t: 'in', d: data }))
|
|
178
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Give the keyboard to the terminal.
|
|
186
|
+
*
|
|
187
|
+
* xterm's `focus()` targets its hidden helper textarea, which is what makes
|
|
188
|
+
* keystrokes reach the PTY. DSH itself never moves focus into a view it just
|
|
189
|
+
* rendered, so this is the panel's own job — the shortcut path and the mount
|
|
190
|
+
* path both end up here.
|
|
191
|
+
*/
|
|
192
|
+
function focus() {
|
|
193
|
+
if (disposed) return
|
|
194
|
+
try {
|
|
195
|
+
term.focus?.()
|
|
196
|
+
} catch {
|
|
197
|
+
// A disposed terminal has nothing to focus.
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Take the keyboard as soon as the panel exists rather than waiting for the
|
|
202
|
+
// greeting: typing while yazi is still painting should not be dropped, and
|
|
203
|
+
// the browser only routes keys to a focused element.
|
|
204
|
+
if (autoFocus) focus()
|
|
205
|
+
|
|
179
206
|
if (typeof win.ResizeObserver === 'function') {
|
|
180
207
|
observer = new win.ResizeObserver(scheduleFit)
|
|
181
208
|
observer.observe(stage)
|
|
@@ -187,13 +214,7 @@ function mountYaziTerminal(options) {
|
|
|
187
214
|
return {
|
|
188
215
|
resize: scheduleFit,
|
|
189
216
|
send,
|
|
190
|
-
focus
|
|
191
|
-
try {
|
|
192
|
-
term.focus?.()
|
|
193
|
-
} catch {
|
|
194
|
-
// A disposed terminal has nothing to focus.
|
|
195
|
-
}
|
|
196
|
-
},
|
|
217
|
+
focus,
|
|
197
218
|
kill() {
|
|
198
219
|
send({ t: 'kill' })
|
|
199
220
|
},
|