opencode-session-turns 0.1.0 → 0.1.1
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/README.md +43 -48
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
# opencode-session-turns
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
conversation, listing **every user turn** of the current session. Hover the rail
|
|
5
|
-
to reveal the turns; click one to jump straight to that message.
|
|
3
|
+
**OpenCode Desktop 插件:在会话右缘列出每一轮的「用户提问」,悬停展开,点击即刻跳转到那一条消息。**
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
An OpenCode Desktop plugin that adds a slim rail on the right edge of the
|
|
6
|
+
conversation, listing every user turn of the current session. Hover to expand;
|
|
7
|
+
click a turn to jump straight to that message.
|
|
8
|
+
|
|
9
|
+
适用 OpenCode Desktop 2.2.6(以预构建的 `./gui-experimental` 包形式加载)。
|
|
9
10
|
|
|
10
11
|
```
|
|
11
|
-
┌─
|
|
12
|
-
│ 09:14 #1
|
|
13
|
-
│ 09:22 #2
|
|
14
|
-
│ 09:35 #3
|
|
12
|
+
┌─ 会话轮次 (12) ─────────────┐
|
|
13
|
+
│ 09:14 #1 帮我看看这个报错… │
|
|
14
|
+
│ 09:22 #2 那改成异步呢? │
|
|
15
|
+
│ 09:35 #3 继续 │
|
|
15
16
|
│ ... │
|
|
16
17
|
└─────────────────────────────┘
|
|
17
18
|
```
|
|
18
19
|
|
|
19
|
-
##
|
|
20
|
+
## 功能
|
|
20
21
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
- `/turns
|
|
22
|
+
- 列出当前会话的每一轮用户提问(从会话消息接口分页拉取,`type=user`)。
|
|
23
|
+
- 鼠标移到窗口右缘的细条上自动展开,移开自动收起。
|
|
24
|
+
- 点击任意一轮,**跳转到对应消息**——包括很久以前、尚未渲染的历史轮次。
|
|
25
|
+
- 自动高亮当前视口所在的轮次。
|
|
26
|
+
- 斜杠命令 `/turns`、快捷键 `⌘⌥R`(Windows/Linux 为 `Ctrl+Alt+R`)展开轮次条。
|
|
26
27
|
|
|
27
|
-
##
|
|
28
|
+
## 安装
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
installs it from npm on startup:
|
|
30
|
+
把包名加入 `opencode.json` 的 `plugins` 列表,OpenCode 启动时会自动从 npm 安装:
|
|
31
31
|
|
|
32
32
|
```json
|
|
33
33
|
{
|
|
@@ -35,51 +35,46 @@ installs it from npm on startup:
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
然后重启 OpenCode Desktop(GUI bundle 在窗口启动时加载)。
|
|
39
39
|
|
|
40
|
-
##
|
|
40
|
+
## 使用
|
|
41
41
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
42
|
+
- 把鼠标移到会话右侧的细条上展开;
|
|
43
|
+
- 或按 `⌘⌥R` / 输入 `/turns` 展开;
|
|
44
|
+
- 点击某一轮即可跳到那条消息。
|
|
45
45
|
|
|
46
|
-
##
|
|
46
|
+
## 实现原理(为什么并不简单)
|
|
47
47
|
|
|
48
|
-
OpenCode Desktop 2.2.6
|
|
48
|
+
OpenCode Desktop 2.2.6 有几个必须绕开的陷阱:
|
|
49
49
|
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
host parse `/index.html` as a route and throw a fatal `Unrecognised route!`.
|
|
56
|
-
- The GUI SDK exposes **no** `scrollToMessage()` / `navigate()` API
|
|
57
|
-
(`ctx.router` is read-only).
|
|
50
|
+
- 时间线是**虚拟渲染**的:只有视口附近的行动态挂载,远端轮次不在 DOM 里。
|
|
51
|
+
- 桌面端使用**内存路由**:`window.location` 始终停在 `oc://renderer/index.html`,
|
|
52
|
+
与真实路由解耦。直接往 `window.location` 写 `#message-<id>` 或派发 `popstate`,
|
|
53
|
+
会让宿主把 `/index.html` 当成路由解析并抛出致命的 `Unrecognised route!`(会崩)。
|
|
54
|
+
- GUI SDK **没有** `scrollToMessage()` / `navigate()` 这类公开 API(`ctx.router` 只读)。
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
因此本插件的做法是:
|
|
60
57
|
|
|
61
|
-
1.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
plugin keeps toggling the hash to an already-loaded turn and back to the
|
|
69
|
-
target, pulling one page at a time until the target row mounts.
|
|
58
|
+
1. 用 `ctx.router.path()` 取到真实路由(合法的 `/server/…/session/…` 路径);
|
|
59
|
+
2. 伪造一个 `<a href="<路由>#message-<id>">` 并派发冒泡 click。宿主在 `document`
|
|
60
|
+
上注册的链接拦截器(Solid Router 的 `create` 钩子)会把它交给**内存 router 的
|
|
61
|
+
navigate()**,从而驱动宿主自己的游标状态机加载历史并定位到该行——全程不碰
|
|
62
|
+
`window.location`。
|
|
63
|
+
3. 宿主每次 seek 只向前加载**约一页(~5 轮)**历史,所以插件会交替把 hash 指向
|
|
64
|
+
「已加载的最早一轮」和目标,逐页把历史翻出来,直到目标行挂载。
|
|
70
65
|
|
|
71
|
-
|
|
66
|
+
已挂载的行则直接用本地滚动,瞬时定位。
|
|
72
67
|
|
|
73
|
-
##
|
|
68
|
+
## 构建
|
|
74
69
|
|
|
75
70
|
```sh
|
|
76
71
|
npm install
|
|
77
72
|
npm run build # -> dist/gui-experimental.cjs
|
|
78
73
|
```
|
|
79
74
|
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
改完源码后重新构建,并在 OpenCode Desktop 里 Reload 插件
|
|
76
|
+
(Settings → Extensions → Plugins → Reload)或重启应用。
|
|
82
77
|
|
|
83
|
-
##
|
|
78
|
+
## 许可证
|
|
84
79
|
|
|
85
80
|
MIT © meiyx7
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-session-turns",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "OpenCode Desktop
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "OpenCode Desktop 插件:在会话右缘列出每一轮用户提问,点击即可跳转到对应消息。A right-edge rail of user turns; click one to jump to that message.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "meiyx7",
|