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.
Files changed (2) hide show
  1. package/README.md +43 -48
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,33 +1,33 @@
1
1
  # opencode-session-turns
2
2
 
3
- An **OpenCode Desktop** plugin that adds a slim rail on the right edge of the
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
- > Works on OpenCode Desktop 2.2.6. The rail is a GUI plugin, loaded from the
8
- > prebuilt `./gui-experimental` bundle.
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
- ┌─ Session turns (12) ────────┐
12
- │ 09:14 #1 Fix this error… │
13
- │ 09:22 #2 What about async?│
14
- │ 09:35 #3 Continue │
12
+ ┌─ 会话轮次 (12) ─────────────┐
13
+ │ 09:14 #1 帮我看看这个报错… │
14
+ │ 09:22 #2 那改成异步呢? │
15
+ │ 09:35 #3 继续 │
15
16
  │ ... │
16
17
  └─────────────────────────────┘
17
18
  ```
18
19
 
19
- ## Features
20
+ ## 功能
20
21
 
21
- - Lists every user turn of the current session (paged from the session API).
22
- - Hover the right-edge rail to expand; move away to collapse.
23
- - Click a turn to jump to its message — including turns far back in history.
24
- - Highlights the turn currently in view.
25
- - `/turns` slash command and `⌘⌥R` (`Ctrl+Alt+R`) to reveal the rail.
22
+ - 列出当前会话的每一轮用户提问(从会话消息接口分页拉取,`type=user`)。
23
+ - 鼠标移到窗口右缘的细条上自动展开,移开自动收起。
24
+ - 点击任意一轮,**跳转到对应消息**——包括很久以前、尚未渲染的历史轮次。
25
+ - 自动高亮当前视口所在的轮次。
26
+ - 斜杠命令 `/turns`、快捷键 `⌘⌥R`(Windows/Linux 为 `Ctrl+Alt+R`)展开轮次条。
26
27
 
27
- ## Install
28
+ ## 安装
28
29
 
29
- Add the package name to the `plugins` list in your `opencode.json`; OpenCode
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
- Restart OpenCode Desktop (the GUI bundle is loaded at window startup).
38
+ 然后重启 OpenCode Desktop(GUI bundle 在窗口启动时加载)。
39
39
 
40
- ## Usage
40
+ ## 使用
41
41
 
42
- - Move the mouse to the thin rail on the right edge of the conversation.
43
- - Or press `⌘⌥R` / run `/turns` to reveal it.
44
- - Click a turn to jump to that message.
42
+ - 把鼠标移到会话右侧的细条上展开;
43
+ - 或按 `⌘⌥R` / 输入 `/turns` 展开;
44
+ - 点击某一轮即可跳到那条消息。
45
45
 
46
- ## How it works (and why it is not trivial)
46
+ ## 实现原理(为什么并不简单)
47
47
 
48
- OpenCode Desktop 2.2.6 has some sharp edges that a GUI plugin has to respect:
48
+ OpenCode Desktop 2.2.6 有几个必须绕开的陷阱:
49
49
 
50
- - The timeline is **virtualized**: only rows near the viewport are mounted, so
51
- distant turns are not in the DOM.
52
- - The desktop app uses a **memory history** for routing. `window.location`
53
- stays at `oc://renderer/index.html` and is decoupled from the real route.
54
- Writing `#message-<id>` to `window.location` (or firing `popstate`) makes the
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
- So this plugin:
56
+ 因此本插件的做法是:
60
57
 
61
- 1. Picks the real route from `ctx.router.path()` (a valid
62
- `/server/…/session/…` path).
63
- 2. Fakes a click on an `<a href="<route>#message-<id>">`. The host's own
64
- document-level link interceptor turns that into a **memory-router navigate**,
65
- which drives the host's cursor machine to page in history and seek to the
66
- row — without touching `window.location`.
67
- 3. The host only pages in about **one history page (~5 turns) per seek**, so the
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
- Rows that are already mounted are scrolled locally for an instant jump.
66
+ 已挂载的行则直接用本地滚动,瞬时定位。
72
67
 
73
- ## Build
68
+ ## 构建
74
69
 
75
70
  ```sh
76
71
  npm install
77
72
  npm run build # -> dist/gui-experimental.cjs
78
73
  ```
79
74
 
80
- After changing the source, rebuild and reload the plugin in OpenCode Desktop
81
- (Settings → Extensions → Plugins → Reload) or restart the app.
75
+ 改完源码后重新构建,并在 OpenCode Desktop 里 Reload 插件
76
+ (Settings → Extensions → Plugins → Reload)或重启应用。
82
77
 
83
- ## License
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.0",
4
- "description": "OpenCode Desktop plugin: a right-edge rail listing every user turn of the current session; click a turn to jump to that message.",
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",