@xiangyixie/dsh-superagent 0.15.0 → 0.15.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/CHANGELOG.md CHANGED
@@ -8,6 +8,19 @@ along with the next code release. A doc-only version leaves `lib/` and `bin/`
8
8
  byte-identical to the version before it, and the pinned install line in the
9
9
  README is updated to the version being released.
10
10
 
11
+ ## 0.15.1 — 2026-11-16
12
+
13
+ ### 变化
14
+
15
+ - **调度板挪到右侧,收得起来。** 会话调度从对话正文里搬出来,成了右侧常驻栏,点栏
16
+ 上箭头收起、再点展开。收起状态记在浏览器里,刷新或重开页面还是你上次选的样子;窄
17
+ 到 720px 时默认收起,展开是浮在对话上方,不会把正文挤成一条缝。
18
+ - **一个会话一张方卡。** 卡片按网格排列,一张卡就是一个会话:上面写这个会话现在是
19
+ 在跑、排队、等你决定、等审批,还是完成、失败、空闲;下面直接写跑了几条任务线、
20
+ 并行几路、有没有排队,以及现在在跑什么工具。点卡片进入详情,能看到这个会话里的
21
+ 每条任务线、每个步骤的状态、耗时,以及哪一步在等哪一步。数据仍只读宿主的会话列表
22
+ 和现有 run 记录,没有另造状态或第二套队列。
23
+
11
24
  ## 0.15.0 — 2026-11-16
12
25
 
13
26
  ### 变化
package/README.en.md CHANGED
@@ -36,12 +36,12 @@ Three steps. The desktop app and the CLI install the same plugin; each step says
36
36
 
37
37
  ### 1. Install
38
38
 
39
- Desktop: **Plugins** → **Add plugin** → enter `@xiangyixie/dsh-superagent@0.15.0` → install.
39
+ Desktop: **Plugins** → **Add plugin** → enter `@xiangyixie/dsh-superagent@0.15.1` → install.
40
40
 
41
41
  CLI:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.15.0
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.15.1
45
45
  ```
46
46
 
47
47
  **Restart DSH** afterwards — plugins are loaded once at host startup. You can also add the [plugin index](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json) on the **Discover** page for one-click installs; upgrades are always remove-then-add.
@@ -1666,7 +1666,7 @@ appears to "hang" until the ignored-abort child returns.
1666
1666
 
1667
1667
  | What you see | What it means | What to do |
1668
1668
  | --- | --- | --- |
1669
- | `superagent_*` tools do not exist | The bundle row is not mounted, or the host refused to load the plugin. | Run `--dump-config` and check for the `@xiangyixie/dsh-superagent` block; reinstall with `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.15.0` and read the host log for `[dsh-superagent]` lines. |
1669
+ | `superagent_*` tools do not exist | The bundle row is not mounted, or the host refused to load the plugin. | Run `--dump-config` and check for the `@xiangyixie/dsh-superagent` block; reinstall with `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.15.1` and read the host log for `[dsh-superagent]` lines. |
1670
1670
  | `Cannot find module .../lib/control.js` (or `watch.js` / `report.js` / `wizard.js`), or `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` in the host log | The copy in that profile is incomplete — an `add` that was interrupted leaves a partial extraction. From 0.14.3 the entry point names the missing file itself. The published package is not the cause: every version ships all thirty-four `lib/` files. | Delete the plugin's directory under the profile's `node_modules` (scoped `@xiangyixie/dsh-superagent`, or unscoped `dsh-superagent` from an older tarball install) and run the same `add` command again, with the version number. Do not copy files in by hand. |
1671
1671
  | `[error] the model provider rejected the API key` | The key env var is missing in the process that started the host. | Export `DEEPSEEK_API_KEY` (the default route) or the variable your route names, then restart `dsh`. |
1672
1672
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | The profile's route has no credential in the environment. | Set the env var named for that route and restart. The error line names the route, so use that, not this page. |
package/README.md CHANGED
@@ -36,12 +36,12 @@ dsh-superagent 把这件事接过去:你说一句目标,它负责拆、负
36
36
 
37
37
  ### 1. 装
38
38
 
39
- 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.15.0` → 安装。
39
+ 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.15.1` → 安装。
40
40
 
41
41
  命令行:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.15.0
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.15.1
45
45
  ```
46
46
 
47
47
  装完**重启 DSH**(插件只在宿主启动时加载一次)。也可以从「发现」页添加[插件索引](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json)一键安装;升级一律先 `remove` 再 `add`。
@@ -1090,7 +1090,7 @@ SHA-256)。`--format html` 把同样的内容写成一个自包含
1090
1090
 
1091
1091
  | 你看到的 | 含义 | 怎么办 |
1092
1092
  | --- | --- | --- |
1093
- | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.15.0` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1093
+ | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.15.1` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1094
1094
  | `Cannot find module .../lib/control.js`(或 `watch.js` / `report.js` / `wizard.js`),或宿主日志里的 `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` | 那个 profile 里的副本不完整——被中断的 `add` 会留下残缺的解包结果。0.14.3 起的入口会直接点名缺哪个文件。已发布的包不是原因:每个版本都带全部三十四个 `lib/` 文件。 | 删掉 profile 的 `node_modules` 下该插件的目录(带 scope 的 `@xiangyixie/dsh-superagent`,或旧 tarball 安装留下的无 scope 的 `dsh-superagent`),再用同一条 `add` 命令重装,并带上版本号。不要手工拷贝文件进去。 |
1095
1095
  | `[error] the model provider rejected the API key` | 启动宿主的那个进程里缺 key 环境变量。 | 导出 `DEEPSEEK_API_KEY`(默认路由)或你那条路由声明的变量,然后重启 `dsh`。 |
1096
1096
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | profile 的路由在环境里没有凭据。 | 设置该路由对应的环境变量并重启。错误行里写了路由名,以它为准,不要照本文。 |
package/README.zh.md CHANGED
@@ -36,12 +36,12 @@ dsh-superagent 把这件事接过去:你说一句目标,它负责拆、负
36
36
 
37
37
  ### 1. 装
38
38
 
39
- 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.15.0` → 安装。
39
+ 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.15.1` → 安装。
40
40
 
41
41
  命令行:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.15.0
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.15.1
45
45
  ```
46
46
 
47
47
  装完**重启 DSH**(插件只在宿主启动时加载一次)。也可以从「发现」页添加[插件索引](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json)一键安装;升级一律先 `remove` 再 `add`。
@@ -1090,7 +1090,7 @@ SHA-256)。`--format html` 把同样的内容写成一个自包含
1090
1090
 
1091
1091
  | 你看到的 | 含义 | 怎么办 |
1092
1092
  | --- | --- | --- |
1093
- | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.15.0` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1093
+ | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.15.1` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1094
1094
  | `Cannot find module .../lib/control.js`(或 `watch.js` / `report.js` / `wizard.js`),或宿主日志里的 `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` | 那个 profile 里的副本不完整——被中断的 `add` 会留下残缺的解包结果。0.14.3 起的入口会直接点名缺哪个文件。已发布的包不是原因:每个版本都带全部三十四个 `lib/` 文件。 | 删掉 profile 的 `node_modules` 下该插件的目录(带 scope 的 `@xiangyixie/dsh-superagent`,或旧 tarball 安装留下的无 scope 的 `dsh-superagent`),再用同一条 `add` 命令重装,并带上版本号。不要手工拷贝文件进去。 |
1095
1095
  | `[error] the model provider rejected the API key` | 启动宿主的那个进程里缺 key 环境变量。 | 导出 `DEEPSEEK_API_KEY`(默认路由)或你那条路由声明的变量,然后重启 `dsh`。 |
1096
1096
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | profile 的路由在环境里没有凭据。 | 设置该路由对应的环境变量并重启。错误行里写了路由名,以它为准,不要照本文。 |
package/lib/console.js CHANGED
@@ -1171,6 +1171,17 @@ export function createConsole({
1171
1171
  return
1172
1172
  }
1173
1173
 
1174
+ if (leaf === 'schedules' && parts.length === 3) {
1175
+ if (method !== 'GET') throw new WorkbenchError(405, 'only GET is allowed here', { id: 'method-not-allowed' })
1176
+ try {
1177
+ const sessions = typeof host.listSchedules === 'function' ? await host.listSchedules() : []
1178
+ send(res, 200, { ok: true, data: { sessions, currentSessionId, reason: null } })
1179
+ } catch (error) {
1180
+ send(res, 200, { ok: true, data: { sessions: [], currentSessionId, reason: messageOf(error) } })
1181
+ }
1182
+ return
1183
+ }
1184
+
1174
1185
  if (leaf === 'session' && parts.length === 4 && parts[3] === 'switch') {
1175
1186
  if (method !== 'POST') throw new WorkbenchError(405, 'only POST is allowed here', { id: 'method-not-allowed' })
1176
1187
  const body = await readJson(req)
package/lib/index.js CHANGED
@@ -3881,6 +3881,27 @@ export function apply(ctx, config) {
3881
3881
  })))
3882
3882
  },
3883
3883
 
3884
+ /**
3885
+ * Session list plus the run rows the sidebar needs. The rows are the same
3886
+ * runView the message stream uses; the sidebar only groups them per
3887
+ * session, it does not keep a queue of its own.
3888
+ */
3889
+ async listSchedules() {
3890
+ const sessions = await this.listSessions()
3891
+ const all = await store.list().catch(() => [])
3892
+ const bySession = new Map()
3893
+ for (const run of all) {
3894
+ if (!run || typeof run.parentSessionId !== 'string') continue
3895
+ const list = bySession.get(run.parentSessionId) ?? []
3896
+ list.push(run)
3897
+ bySession.set(run.parentSessionId, list)
3898
+ }
3899
+ return sessions.map(session => ({
3900
+ ...session,
3901
+ rows: (bySession.get(session.sessionId) ?? []).slice(-8).map(run => runView(run)),
3902
+ }))
3903
+ },
3904
+
3884
3905
  /**
3885
3906
  * One conversation's log, newest page first and then walked back to the
3886
3907
  * first turn. The controller reads cold sessions too, so a conversation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiangyixie/dsh-superagent",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "长周期自主执行插件:一个目标拆成可并行的子任务,交付一份合并报告,重启后仍可继续。",
5
5
  "author": "Admire (LittleChenLiya)",
6
6
  "type": "module",
@@ -627,55 +627,114 @@
627
627
  .step.failed .sdot { background: var(--red); }
628
628
  .lane-progress-text { margin-top: 5px; color: var(--faint); font-size: 10.5px; }
629
629
 
630
- /* ---- schedule board: what runs now, what waits, on one time axis ---- */
631
- .schedule-wrap { flex: none; padding: 0 22px 10px; max-height: 38vh; overflow: auto; }
632
- .schedule-wrap[hidden] { display: none; }
633
- .sched {
634
- margin: 0 0 10px; padding: 9px 10px 10px;
635
- border: 1px solid var(--line-soft); border-radius: 10px; background: #0c1217;
636
- }
637
- .sched-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; margin-bottom: 7px; }
638
- .sched-title { color: var(--muted); font-size: 11px; font-weight: 600; }
639
- .sched-facts { color: var(--faint); font-size: 10.5px; }
640
- .sched-axis { margin-left: auto; color: var(--faint); font: 10px var(--mono); white-space: nowrap; }
641
- .sched-run { min-width: 0; padding: 6px 0 2px; border-top: 1px dashed var(--line-soft); }
642
- .sched-run:first-of-type { border-top: 0; padding-top: 0; }
643
- .sched-run-head { display: flex; align-items: center; gap: 7px; min-width: 0; margin-bottom: 4px; }
644
- .sched-goal {
645
- flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
646
- color: var(--muted); font-size: 11.5px;
630
+ /* ---- schedule rail: one square card per conversation, steps on tap ---- */
631
+ .sched-rail {
632
+ position: fixed; top: 58px; right: 0; bottom: 0; z-index: 19;
633
+ width: 320px; display: flex; flex-direction: column;
634
+ border-left: 1px solid var(--line); background: #0d1317;
635
+ box-shadow: -18px 0 50px rgba(0, 0, 0, .32);
636
+ transition: transform .18s ease-out;
637
+ }
638
+ .rail-toggle {
639
+ position: absolute; left: 0; top: 10px; z-index: 2;
640
+ width: 27px; height: 27px; padding: 0;
641
+ border: 1px solid var(--line); border-left: 0; border-radius: 0 7px 7px 0;
642
+ background: #162027; color: var(--muted); font-size: 14px; line-height: 1;
643
+ }
644
+ .rail-toggle:hover { color: var(--text); background: #1c2831; }
645
+ .rail-strip { display: none; }
646
+ body.rail-collapsed .sched-rail { transform: translateX(calc(100% - 34px)); }
647
+ body.rail-collapsed .rail-main { visibility: hidden; }
648
+ body.rail-collapsed .rail-strip {
649
+ display: flex; flex-direction: column; align-items: center; gap: 8px;
650
+ height: 100%; padding: 46px 0 16px;
651
+ }
652
+ .rail-strip-text {
653
+ writing-mode: vertical-rl; letter-spacing: .18em;
654
+ color: var(--muted); font-size: 10.5px;
647
655
  }
648
- .sched-time { flex: none; color: var(--faint); font: 10px var(--mono); white-space: nowrap; }
649
- .sched-row {
650
- display: grid; grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
651
- gap: 8px; align-items: center; min-width: 0; padding: 2px 0;
656
+ .rail-count {
657
+ min-width: 18px; padding: 1px 4px; border-radius: 9px; text-align: center;
658
+ background: rgba(246, 193, 119, .16); color: var(--amber); font-size: 10px;
659
+ }
660
+ .rail-count[hidden] { display: none; }
661
+ .rail-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
662
+ .rail-head {
663
+ display: flex; align-items: baseline; gap: 8px; padding: 13px 14px 9px 20px;
664
+ border-bottom: 1px solid var(--line-soft);
652
665
  }
653
- .sched-label {
666
+ .rail-head strong { font-size: 12px; }
667
+ .rail-facts { color: var(--faint); font-size: 10.5px; }
668
+ .rail-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px 20px 20px; }
669
+ .rail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
670
+ .rail-card {
671
+ position: relative; aspect-ratio: 1 / 1; min-width: 0; overflow: hidden;
672
+ display: flex; flex-direction: column; gap: 3px;
673
+ padding: 8px 9px; border: 1px solid var(--line-soft); border-radius: 10px;
674
+ background: #10171c; color: var(--text); text-align: left;
675
+ }
676
+ .rail-card:hover { border-color: #35464f; background: #131c22; }
677
+ .rail-card.current { border-color: #3a5a52; background: #101b1a; }
678
+ .rail-card.k-attention, .rail-card.k-approval { border-color: rgba(246, 193, 119, .42); background: rgba(246, 193, 119, .05); }
679
+ .rail-card.k-failed { border-color: rgba(255, 123, 114, .32); }
680
+ .rail-card.k-done { border-color: rgba(99, 214, 164, .22); }
681
+ .rail-card-top { display: flex; align-items: center; gap: 5px; min-width: 0; }
682
+ .rail-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: #3a4a55; }
683
+ .rail-dot.running { background: var(--amber); animation: blink 1.1s infinite; }
684
+ .rail-dot.attention, .rail-dot.approval { background: var(--amber); }
685
+ .rail-dot.done { background: var(--green); }
686
+ .rail-dot.failed { background: var(--red); }
687
+ .rail-state {
654
688
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
655
- color: var(--muted); font-size: 10.5px;
689
+ color: var(--muted); font-size: 10px;
690
+ }
691
+ .rail-when { margin-left: auto; flex: none; color: var(--faint); font: 9.5px var(--mono); }
692
+ .rail-title {
693
+ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
694
+ color: var(--text); font-size: 11.5px; line-height: 1.35; word-break: break-word;
695
+ }
696
+ .rail-now {
697
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
698
+ color: var(--amber); font-size: 9.5px;
699
+ }
700
+ .rail-now.idle { color: var(--faint); }
701
+ .rail-meta {
702
+ margin-top: auto; display: flex; flex-wrap: wrap; gap: 1px 6px;
703
+ color: var(--faint); font-size: 9.5px; line-height: 1.4;
704
+ }
705
+ .rail-meta b { color: var(--muted); font-weight: 600; }
706
+ .rail-empty { margin: 0; color: var(--faint); font-size: 11px; line-height: 1.6; }
707
+ .rail-back {
708
+ display: inline-flex; align-items: center; gap: 4px; margin: 0 0 9px; padding: 0;
709
+ border: 0; background: transparent; color: var(--muted); font-size: 11px;
710
+ }
711
+ .rail-back:hover { color: var(--text); }
712
+ .rail-detail-head { margin-bottom: 10px; }
713
+ .rail-detail-title {
714
+ margin: 0 0 4px; font-size: 12.5px; line-height: 1.4; word-break: break-word;
715
+ }
716
+ .rail-detail-facts { color: var(--faint); font-size: 10.5px; line-height: 1.55; }
717
+ .rail-run {
718
+ margin-bottom: 8px; padding: 8px 9px; border-radius: 9px;
719
+ border: 1px solid var(--line-soft); background: #0e1418;
720
+ }
721
+ .rail-run:last-child { margin-bottom: 0; }
722
+ .rail-run-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
723
+ .rail-run-goal {
724
+ flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
725
+ color: var(--muted); font-size: 11px;
726
+ }
727
+ .rail-elapsed { flex: none; color: var(--faint); font: 9.5px var(--mono); white-space: nowrap; }
728
+ .rail-steps { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
729
+ .rail-steps .step { font-size: 10.5px; }
730
+ .rail-step-text { min-width: 0; word-break: break-word; }
731
+ .rail-step-note { color: var(--faint); }
732
+ .rail-step-dur { flex: none; margin-left: auto; color: var(--faint); font: 9.5px var(--mono); white-space: nowrap; }
733
+ .rail-note { margin: 0 0 8px; color: var(--faint); font-size: 10.5px; }
734
+ /* Wide screens give the rail its own column; narrow ones overlay it below. */
735
+ @media (min-width: 721px) {
736
+ body.rail-open .stage { padding-right: 338px; }
656
737
  }
657
- .sched-label .n { color: var(--faint); font-family: var(--mono); margin-right: 4px; }
658
- .sched-note { color: var(--faint); font-size: 10px; }
659
- .sched-track {
660
- position: relative; height: 9px; min-width: 0;
661
- border-radius: 999px; background: #131c22; overflow: hidden;
662
- }
663
- .sched-bar {
664
- position: absolute; top: 0; bottom: 0; min-width: 2px; border-radius: 999px;
665
- background: #3a4a55;
666
- }
667
- .sched-bar.running { background: var(--amber); }
668
- .sched-bar.completed { background: var(--green); }
669
- .sched-bar.failed, .sched-bar.cancelled { background: var(--red); }
670
- .sched-bar.waiting {
671
- left: 0; right: 0; background: transparent;
672
- border: 1px dashed rgba(246, 193, 119, .45);
673
- }
674
- .sched-bar.pending { left: 0; right: 0; background: #1d272e; }
675
- .sched-bar.skipped { left: 0; right: 0; background: repeating-linear-gradient(90deg, #2a3740 0 6px, transparent 6px 11px); }
676
- .sched-empty { color: var(--faint); font-size: 10.5px; padding: 2px 0 3px; }
677
- .sched-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; color: var(--faint); font-size: 10px; }
678
- .sched-legend i { display: inline-block; width: 7px; height: 7px; margin-right: 3px; border-radius: 2px; vertical-align: -1px; }
679
738
 
680
739
  .summary {
681
740
  margin-top: 10px; padding: 10px 11px; border-radius: 10px;
@@ -750,13 +809,11 @@
750
809
  .brand div span { display: none; }
751
810
  .hint { display: none; }
752
811
  .messages { padding: 16px 14px 22px; }
753
- .schedule-wrap { padding: 0 14px 10px; max-height: 44vh; }
754
- /* One column per step: the label sits above its bar, so a narrow screen
755
- keeps the order and the durations instead of squeezing both sideways. */
756
- .sched-row { grid-template-columns: minmax(0, 1fr); gap: 3px; }
757
- .sched-label { white-space: normal; overflow: visible; text-overflow: clip; }
758
- .sched-axis { margin-left: 0; }
759
- .sched-goal { white-space: normal; }
812
+ /* The rail floats over the thread instead of squeezing it into a column. */
813
+ .sched-rail { width: min(320px, calc(100vw - 42px)); box-shadow: -26px 0 60px rgba(0, 0, 0, .55); }
814
+ .rail-head { padding-left: 16px; }
815
+ .rail-body { padding-left: 14px; }
816
+ .rail-grid { gap: 7px; }
760
817
  }
761
818
  </style>
762
819
  </head>
@@ -796,7 +853,6 @@
796
853
  </div>
797
854
  <div id="typing" class="typing" hidden><span></span><span></span><span></span><em id="typingText" style="font-style:normal;margin-left:3px">运行中</em></div>
798
855
  </div>
799
- <section id="scheduleWrap" class="schedule-wrap" aria-label="调度" hidden></section>
800
856
  <div id="messages" class="messages" aria-live="polite"></div> <form id="composer" class="composer" autocomplete="off">
801
857
  <div class="composer-box">
802
858
  <textarea id="input" rows="1" placeholder="要做什么…" disabled></textarea>
@@ -879,7 +935,22 @@
879
935
  </form>
880
936
  </div>
881
937
 
882
- <div id="toasts" class="toasts" aria-live="polite"></div>
938
+ <div id="toasts" class="toasts" aria-live="polite"></div>
939
+
940
+ <aside id="schedRail" class="sched-rail" aria-label="会话调度">
941
+ <button id="railToggle" class="rail-toggle" type="button" aria-label="收起调度" title="收起调度">›</button>
942
+ <div class="rail-strip" aria-hidden="true">
943
+ <span class="rail-strip-text">调度</span>
944
+ <b id="railCount" class="rail-count">0</b>
945
+ </div>
946
+ <div class="rail-main">
947
+ <div class="rail-head">
948
+ <strong>会话</strong>
949
+ <span id="railFacts" class="rail-facts"></span>
950
+ </div>
951
+ <div id="railBody" class="rail-body"></div>
952
+ </div>
953
+ </aside>
883
954
 
884
955
  <dialog id="wizardDialog">
885
956
  <div class="wiz-head">
@@ -912,8 +983,7 @@
912
983
 
913
984
  const TOKEN_KEY = 'dsh-superagent-console-token'
914
985
  const $ = id => document.getElementById(id)
915
- const messagesEl = $('messages')
916
- const scheduleWrapEl = $('scheduleWrap')
986
+ const messagesEl = $('messages')
917
987
  const inputEl = $('input')
918
988
  const sendEl = $('send')
919
989
  const composerEl = $('composer')
@@ -952,6 +1022,11 @@
952
1022
  const noticeCountEl = $('noticeCount')
953
1023
  const noticePanelEl = $('noticePanel')
954
1024
  const noticeListEl = $('noticeList')
1025
+ const railToggleEl = $('railToggle')
1026
+ const railBodyEl = $('railBody')
1027
+ const railFactsEl = $('railFacts')
1028
+ const railCountEl = $('railCount')
1029
+ const RAIL_KEY = 'dsh-superagent-rail-collapsed'
955
1030
 
956
1031
  // Upload rules mirror the server's: the page refuses early with a readable
957
1032
  // sentence, and the server refuses again because a page is not a gate.
@@ -990,7 +1065,11 @@
990
1065
  preset: null,
991
1066
  laneEls: new Map(),
992
1067
  runAnchors: new Map(),
993
- scheduleSig: '',
1068
+ schedules: [],
1069
+ schedulesNote: null,
1070
+ schedulesBusy: false,
1071
+ railDetail: null,
1072
+ railSig: '',
994
1073
  attentionSeen: new Set(),
995
1074
  approvals: new Map(),
996
1075
  sessions: [],
@@ -1655,53 +1734,102 @@
1655
1734
  }
1656
1735
  }
1657
1736
 
1658
- // ---------- schedule board ----------
1737
+ // ---------- schedule rail ----------
1659
1738
  //
1660
- // The board is a projection of the run records the host already writes: run
1661
- // status, each step's status/startedAt/finishedAt, the waitingOn keys the
1662
- // graph scheduler sets, and the run's own maxParallel/queue. Nothing here
1663
- // invents a second queue or recomputes progress.
1739
+ // The right-hand rail is a projection of what the host already writes: its
1740
+ // own conversation list plus the run records on disk (status, each step's
1741
+ // startedAt/finishedAt/waitingOn, the run's maxParallel and queue). Nothing
1742
+ // here invents a second queue or recomputes progress.
1664
1743
 
1665
1744
  function timeOf(value) {
1666
1745
  const ms = typeof value === 'number' ? value : Date.parse(value)
1667
1746
  return Number.isFinite(ms) ? ms : null
1668
1747
  }
1669
1748
 
1670
- function scheduleAxis(runs) {
1671
- let start = Infinity
1672
- let end = 0
1673
- for (const run of runs) {
1674
- const created = timeOf(run.createdAt)
1675
- if (created !== null) {
1676
- start = Math.min(start, created)
1677
- end = Math.max(end, created)
1678
- }
1679
- for (const subtask of Array.isArray(run.subtasks) ? run.subtasks : []) {
1680
- const began = timeOf(subtask.startedAt)
1681
- if (began !== null) {
1682
- start = Math.min(start, began)
1683
- end = Math.max(end, began)
1684
- }
1685
- const ended = timeOf(subtask.finishedAt)
1686
- if (ended !== null) end = Math.max(end, ended)
1687
- }
1688
- const finished = timeOf(run.finishedAt)
1689
- if (finished !== null) end = Math.max(end, finished)
1749
+ /** The live session reads STATE.runs; every other card reads the host list. */
1750
+ function railRows(session) {
1751
+ const rows = session.sessionId === STATE.sessionId && STATE.runs.length > 0
1752
+ ? STATE.runs
1753
+ : Array.isArray(session.rows) ? session.rows : []
1754
+ return rows.slice(0, 8)
1755
+ }
1756
+
1757
+ function railApprovals(sessionId) {
1758
+ if (sessionId !== STATE.sessionId) return 0
1759
+ let count = 0
1760
+ for (const entry of STATE.approvals.values()) if (!entry.decided) count += 1
1761
+ return count
1762
+ }
1763
+
1764
+ function railFactsOf(session) {
1765
+ const rows = railRows(session)
1766
+ const steps = rows.flatMap(run => (Array.isArray(run.subtasks) ? run.subtasks : []))
1767
+ const active = rows.filter(run => !isTerminal(run.status) && run.status !== 'queued')
1768
+ const queued = rows.filter(run => run.status === 'queued')
1769
+ const running = steps.filter(step => step.status === 'running')
1770
+ const waiting = steps.filter(step => step.status === 'waiting')
1771
+ const cap = rows.reduce((best, run) => Math.max(best, Number(run.limits?.maxParallel) || 0), 0)
1772
+ const attention = rows.reduce((sum, run) => sum + (Array.isArray(run.attention) ? run.attention.length : 0), 0)
1773
+ const approvals = railApprovals(session.sessionId)
1774
+ const latest = rows.reduce((best, run) => {
1775
+ const at = timeOf(run.createdAt) ?? 0
1776
+ return at > best.at ? { at, run } : best
1777
+ }, { at: -1, run: null }).run
1778
+ return { rows, steps, active, queued, running, waiting, cap, attention, approvals, latest }
1779
+ }
1780
+
1781
+ /** Card state, in the order a person would want to know about it. */
1782
+ function railStatusOf(session, facts) {
1783
+ if (facts.approvals > 0) return { kind: 'approval', text: '等审批', dot: 'approval' }
1784
+ if (facts.attention > 0) return { kind: 'attention', text: '等你决定', dot: 'attention' }
1785
+ if (facts.active.length > 0) return { kind: 'running', text: '在跑', dot: 'running' }
1786
+ if (facts.queued.length > 0) return { kind: 'queued', text: '排队', dot: '' }
1787
+ if (session.running === true && facts.rows.length === 0) return { kind: 'running', text: '在跑', dot: 'running' }
1788
+ const latest = facts.latest
1789
+ if (latest) {
1790
+ if (latest.status === 'completed') return { kind: 'done', text: '完成', dot: 'done' }
1791
+ if (latest.status === 'cancelled') return { kind: 'failed', text: '已取消', dot: 'failed' }
1792
+ if (isTerminal(latest.status)) return { kind: 'failed', text: '失败', dot: 'failed' }
1690
1793
  }
1691
- if (!Number.isFinite(start)) start = Date.now()
1692
- const live = runs.some(run => !isTerminal(run.status))
1693
- const right = Math.max(end, live ? Date.now() : 0, start + 1000)
1694
- return { start, end: right, live }
1695
- }
1696
-
1697
- function scheduleStats(runs) {
1698
- const active = runs.filter(run => !isTerminal(run.status) && run.status !== 'queued')
1699
- const queued = runs.filter(run => run.status === 'queued')
1700
- const steps = runs.flatMap(run => (Array.isArray(run.subtasks) ? run.subtasks : []))
1701
- const running = steps.filter(subtask => subtask.status === 'running').length
1702
- const waiting = steps.filter(subtask => subtask.status === 'waiting').length
1703
- const cap = runs.reduce((best, run) => Math.max(best, Number(run.limits?.maxParallel) || 0), 0)
1704
- return { active, queued, running, waiting, cap }
1794
+ return { kind: 'idle', text: '空闲', dot: '' }
1795
+ }
1796
+
1797
+ function railTitleOf(session) {
1798
+ if (typeof session.title === 'string' && session.title) return session.title
1799
+ if (typeof session.first === 'string' && session.first) return session.first
1800
+ if (session.sessionId === STATE.sessionId) return '当前会话'
1801
+ const rows = Array.isArray(session.rows) ? session.rows : []
1802
+ if (session.blank && rows.length === 0) return '空会话'
1803
+ return shortId(session.sessionId) || '会话'
1804
+ }
1805
+
1806
+ function railFactsLine(facts) {
1807
+ const parts = [`${facts.rows.length} 条任务线`]
1808
+ if (facts.running.length > 0) parts.push(`并行 ${facts.running.length}${facts.cap > 0 ? `/${facts.cap}` : ''}`)
1809
+ if (facts.waiting.length > 0) parts.push(`等前一步 ${facts.waiting.length}`)
1810
+ if (facts.queued.length > 0) parts.push(`排队 ${facts.queued.length}`)
1811
+ return parts.join(' · ')
1812
+ }
1813
+
1814
+ /** One short sentence about the thing that needs attention right now. */
1815
+ function railNowOf(session, facts, status) {
1816
+ if (status.kind === 'approval') return `有 ${facts.approvals} 个工具调用等你批`
1817
+ if (status.kind === 'attention') return `有 ${facts.attention} 个问题等你回`
1818
+ if (facts.active.length > 0) {
1819
+ const tools = [...new Set(facts.active.flatMap(run => runningToolsOf(run)))]
1820
+ if (tools.length > 0) return `工具 ${tools.slice(0, 2).join('、')}`
1821
+ const step = facts.active[0].subtasks?.find(item => item.status === 'running')
1822
+ return step ? stepLabel(step) : currentAction(facts.active[0])
1823
+ }
1824
+ const queued = facts.queued[0]
1825
+ if (queued) {
1826
+ const queue = queued.queue || {}
1827
+ return queue.position ? `排第 ${queue.position}${queue.of ? ` / ${queue.of}` : ''}` : '排队,等前面的跑完'
1828
+ }
1829
+ if (facts.rows.length === 0) return session.running ? '这一轮刚开始' : '还没有任务线'
1830
+ if (status.kind === 'done') return '这一轮已结束'
1831
+ if (status.kind === 'failed') return '没走通,点开看步骤'
1832
+ return '没有在跑的'
1705
1833
  }
1706
1834
 
1707
1835
  function stepTitleOf(run, key) {
@@ -1709,152 +1837,234 @@
1709
1837
  return hit ? stepLabel(hit) : String(key)
1710
1838
  }
1711
1839
 
1712
- function scheduleBar(subtask, run, axis) {
1713
- const began = timeOf(subtask.startedAt) ?? timeOf(run.startedAt) ?? timeOf(run.createdAt)
1714
- if (began === null) return null
1715
- const ended = timeOf(subtask.finishedAt) ?? (subtask.status === 'running' ? Date.now() : null)
1716
- if (ended === null) return null
1717
- const span = Math.max(1000, axis.end - axis.start)
1718
- const left = Math.max(0, Math.min(99, ((began - axis.start) / span) * 100))
1719
- const width = Math.max(1.2, Math.min(100 - left, ((ended - began) / span) * 100))
1720
- return { left, width }
1840
+ function stepDuration(step) {
1841
+ const start = timeOf(step.startedAt)
1842
+ if (start === null) return ''
1843
+ const end = timeOf(step.finishedAt) ?? (step.status === 'running' ? Date.now() : null)
1844
+ if (end === null) return ''
1845
+ return formatClock(end - start)
1721
1846
  }
1722
1847
 
1723
- function scheduleRow(run, subtask, axis) {
1724
- const row = el('div', 'sched-row')
1725
- const label = el('div', 'sched-label')
1726
- label.title = stepLabel(subtask)
1727
- label.append(el('span', 'n', subtask.key || String(subtask.index ?? '·')))
1728
- label.append(document.createTextNode(stepLabel(subtask)))
1848
+ function railClock(run) {
1849
+ const node = el('span', 'rail-elapsed', laneElapsed(run))
1850
+ const start = timeOf(run.createdAt)
1851
+ if (start !== null) node.dataset.start = String(start)
1852
+ const finish = timeOf(run.finishedAt)
1853
+ if (finish !== null) node.dataset.finish = String(finish)
1854
+ return node
1855
+ }
1856
+
1857
+ function railStep(run, step) {
1858
+ const row = el('div', `step ${step.status || 'pending'}`)
1859
+ row.append(el('span', 'sdot'))
1860
+ const text = el('span', 'rail-step-text', stepLabel(step))
1729
1861
  const notes = []
1730
- if (subtask.status === 'running' && subtask.tool) notes.push(`工具 ${subtask.tool}`)
1731
- const waits = Array.isArray(subtask.waitingOn) ? subtask.waitingOn : []
1862
+ if (step.status === 'running' && step.tool) notes.push(`工具 ${step.tool}`)
1863
+ const waits = Array.isArray(step.waitingOn) ? step.waitingOn : []
1732
1864
  if (waits.length > 0) notes.push(`等「${waits.map(key => stepTitleOf(run, key)).join('」「')}」`)
1733
- else if (subtask.status === 'waiting') notes.push('等前一步')
1734
- if (subtask.status === 'skipped') notes.push('跳过')
1735
- if (notes.length > 0) label.append(el('span', 'sched-note', ` · ${notes.join(' · ')}`))
1736
- row.append(label)
1737
-
1738
- const track = el('div', 'sched-track')
1739
- const range = scheduleBar(subtask, run, axis)
1740
- const status = subtask.status || 'pending'
1741
- const bar = el('i', `sched-bar ${status}`)
1742
- if (range) {
1743
- bar.style.left = `${range.left}%`
1744
- bar.style.width = `${range.width}%`
1745
- if (status === 'running') {
1746
- const began = timeOf(subtask.startedAt) ?? timeOf(run.startedAt) ?? timeOf(run.createdAt)
1747
- if (began !== null) bar.dataset.start = String(began)
1748
- }
1749
- }
1750
- track.append(bar)
1751
- row.append(track)
1865
+ else if (step.status === 'waiting') notes.push('等前一步')
1866
+ if (step.status === 'skipped') notes.push('跳过')
1867
+ if (notes.length > 0) text.append(el('span', 'rail-step-note', ` · ${notes.join(' · ')}`))
1868
+ row.append(text)
1869
+ const duration = stepDuration(step)
1870
+ if (duration) row.append(el('span', 'rail-step-dur', duration))
1752
1871
  return row
1753
1872
  }
1754
1873
 
1755
- function scheduleElement(runs) {
1756
- const stats = scheduleStats(runs)
1757
- const axis = scheduleAxis(runs)
1758
- const box = el('div', 'sched')
1759
- box.dataset.axisStart = String(axis.start)
1760
- box.dataset.live = axis.live ? '1' : ''
1761
-
1762
- const head = el('div', 'sched-head')
1763
- head.append(el('span', 'sched-title', '调度'))
1764
- const facts = []
1765
- if (stats.running > 0) facts.push(`并行 ${stats.running}${stats.cap > 0 ? `/${stats.cap}` : ''} 步`)
1766
- if (stats.active.length > 0) facts.push(`${stats.active.length} 条任务线在跑`)
1767
- if (stats.waiting > 0) facts.push(`${stats.waiting} 步等前一步`)
1768
- if (stats.queued.length > 0) facts.push(`${stats.queued.length} 条排队`)
1769
- if (facts.length === 0) facts.push(runs.every(run => isTerminal(run.status)) ? '这一轮已结束' : '还没有步骤在跑')
1770
- head.append(el('span', 'sched-facts', facts.join(' · ')))
1771
- head.append(el('span', 'sched-axis', formatClock(axis.end - axis.start)))
1874
+ function railRun(run) {
1875
+ const box = el('div', 'rail-run')
1876
+ const head = el('div', 'rail-run-head')
1877
+ head.append(el('span', `status-pill ${statusClass(run.status)}`, laneStatusText(run)))
1878
+ const goal = el('span', 'rail-run-goal', run.goal || '这条任务线')
1879
+ goal.title = run.goal || ''
1880
+ head.append(goal)
1881
+ head.append(railClock(run))
1772
1882
  box.append(head)
1773
1883
 
1774
- for (const run of runs) {
1775
- const section = el('div', 'sched-run')
1776
- const runHead = el('div', 'sched-run-head')
1777
- runHead.append(el('span', 'sched-goal', run.goal || '这条任务线'))
1778
- runHead.append(el('span', `status-pill ${statusClass(run.status)}`, laneStatusText(run)))
1779
- if (run.status === 'queued') {
1780
- const queue = run.queue || {}
1781
- runHead.append(el('span', 'sched-time', queue.position
1782
- ? `排第 ${queue.position}${queue.of ? ` / ${queue.of}` : ''}`
1783
- : '排队中'))
1784
- } else {
1785
- runHead.append(el('span', 'sched-time', laneElapsed(run)))
1786
- }
1787
- section.append(runHead)
1788
-
1789
- const subtasks = Array.isArray(run.subtasks) ? run.subtasks : []
1790
- if (subtasks.length === 0) {
1791
- section.append(el('div', 'sched-empty', run.status === 'queued'
1792
- ? '等前面的任务线跑完再开始'
1793
- : run.status === 'planning' ? '拆步骤中,还没有步骤时间' : '还没有步骤记录'))
1794
- } else {
1795
- for (const subtask of subtasks.slice(0, 10)) section.append(scheduleRow(run, subtask, axis))
1796
- if (subtasks.length > 10) section.append(el('div', 'sched-empty', `还有 ${subtasks.length - 10} 个步骤`))
1797
- }
1798
- box.append(section)
1884
+ const steps = Array.isArray(run.subtasks) ? run.subtasks : []
1885
+ if (steps.length === 0) {
1886
+ box.append(el('p', 'rail-note', run.status === 'queued'
1887
+ ? '等前面的任务线跑完再开始'
1888
+ : run.status === 'planning' ? '拆步骤中,还没有步骤时间' : '还没有步骤记录'))
1889
+ return box
1799
1890
  }
1800
-
1801
- const legend = el('div', 'sched-legend')
1802
- for (const [kind, text] of [
1803
- ['running', '在跑'],
1804
- ['waiting', '等前一步'],
1805
- ['completed', '完成'],
1806
- ['failed', '失败'],
1807
- ]) {
1808
- const item = el('span')
1809
- const dot = el('i')
1810
- dot.style.background = kind === 'running' ? 'var(--amber)'
1811
- : kind === 'completed' ? 'var(--green)'
1812
- : kind === 'failed' ? 'var(--red)' : 'transparent'
1813
- if (kind === 'waiting') dot.style.border = '1px dashed rgba(246, 193, 119, .55)'
1814
- item.append(dot, document.createTextNode(text))
1815
- legend.append(item)
1816
- }
1817
- box.append(legend)
1891
+ const queue = run.queue || {}
1892
+ if (run.status === 'queued' && queue.position) {
1893
+ box.append(el('p', 'rail-note', `排队第 ${queue.position}${queue.of ? ` / ${queue.of}` : ''}`))
1894
+ }
1895
+ const list = el('div', 'rail-steps')
1896
+ for (const step of steps.slice(0, 12)) list.append(railStep(run, step))
1897
+ if (steps.length > 12) list.append(el('p', 'rail-note', `还有 ${steps.length - 12} 个步骤`))
1898
+ box.append(list)
1818
1899
  return box
1819
1900
  }
1820
1901
 
1821
- /** One board for every line the host is still working on. */
1822
- function renderSchedule() {
1823
- const runs = STATE.runs.filter(run => !isTerminal(run.status))
1824
- if (runs.length === 0) {
1825
- scheduleWrapEl.hidden = true
1826
- if (STATE.scheduleSig !== '') {
1827
- STATE.scheduleSig = ''
1828
- scheduleWrapEl.replaceChildren()
1829
- }
1902
+ function railDetailBody(session) {
1903
+ const facts = railFactsOf(session)
1904
+ const status = railStatusOf(session, facts)
1905
+ const wrap = el('div', 'rail-detail')
1906
+ const back = el('button', 'rail-back', '← 全部会话')
1907
+ back.type = 'button'
1908
+ back.addEventListener('click', () => {
1909
+ STATE.railDetail = null
1910
+ renderRail()
1911
+ })
1912
+ wrap.append(back)
1913
+
1914
+ const head = el('div', 'rail-detail-head')
1915
+ head.append(el('div', 'rail-detail-title', railTitleOf(session)))
1916
+ head.append(el('div', 'rail-detail-facts', [
1917
+ status.text, railFactsLine(facts), `更新 ${timeLabel(session.updatedAt) || '—'}`,
1918
+ ].join(' · ')))
1919
+ wrap.append(head)
1920
+
1921
+ if (facts.rows.length === 0) {
1922
+ wrap.append(el('p', 'rail-empty', session.running
1923
+ ? '这一轮刚开始,还没有任务线记录。'
1924
+ : '这个会话还没有任务线。'))
1925
+ return wrap
1926
+ }
1927
+ for (const run of [...facts.rows].reverse()) wrap.append(railRun(run))
1928
+ return wrap
1929
+ }
1930
+
1931
+ function railCard(session) {
1932
+ const facts = railFactsOf(session)
1933
+ const status = railStatusOf(session, facts)
1934
+ const card = el('button', `rail-card k-${status.kind}${session.sessionId === STATE.sessionId ? ' current' : ''}`)
1935
+ card.type = 'button'
1936
+
1937
+ const top = el('div', 'rail-card-top')
1938
+ top.append(el('span', `rail-dot ${status.dot}`.trim()))
1939
+ top.append(el('span', 'rail-state', status.text))
1940
+ top.append(el('span', 'rail-when', timeLabel(session.updatedAt) || '—'))
1941
+ card.append(top)
1942
+
1943
+ const title = el('div', 'rail-title', railTitleOf(session))
1944
+ title.title = title.textContent
1945
+ card.append(title)
1946
+
1947
+ card.append(el('div', `rail-now${status.kind === 'idle' || status.kind === 'done' ? ' idle' : ''}`,
1948
+ railNowOf(session, facts, status)))
1949
+
1950
+ const meta = el('div', 'rail-meta')
1951
+ meta.append(el('span', '', `${facts.rows.length} 条`))
1952
+ meta.append(el('span', '', `并行 ${facts.running.length}`))
1953
+ if (facts.queued.length > 0) meta.append(el('span', '', `排队 ${facts.queued.length}`))
1954
+ card.append(meta)
1955
+
1956
+ card.addEventListener('click', () => {
1957
+ STATE.railDetail = session.sessionId
1958
+ renderRail()
1959
+ })
1960
+ return card
1961
+ }
1962
+
1963
+ function railSignature() {
1964
+ const rows = STATE.schedules.map(session => {
1965
+ const facts = railFactsOf(session)
1966
+ return [
1967
+ session.sessionId,
1968
+ session.updatedAt ?? '',
1969
+ session.running ? 'on' : '',
1970
+ session.title || session.first || '',
1971
+ facts.approvals,
1972
+ facts.attention,
1973
+ facts.rows.map(run => `${run.id}:${laneSignature(run)}`).join(','),
1974
+ ].join(':')
1975
+ })
1976
+ return [STATE.railDetail || '', STATE.schedulesNote || '', rows.join('|')].join('#')
1977
+ }
1978
+
1979
+ function renderRail() {
1980
+ const sessions = STATE.schedules
1981
+ const detail = sessions.find(session => session.sessionId === STATE.railDetail)
1982
+ if (STATE.railDetail && !detail) STATE.railDetail = null
1983
+ let running = 0
1984
+ let waiting = 0
1985
+ for (const session of sessions) {
1986
+ const kind = railStatusOf(session, railFactsOf(session)).kind
1987
+ if (kind === 'running' || kind === 'queued') running += 1
1988
+ else if (kind === 'attention' || kind === 'approval') waiting += 1
1989
+ }
1990
+ const busy = running + waiting
1991
+ railCountEl.textContent = String(busy)
1992
+ railCountEl.hidden = busy === 0
1993
+ const headParts = [`${sessions.length} 个会话`]
1994
+ if (running > 0) headParts.push(`在跑 ${running}`)
1995
+ if (waiting > 0) headParts.push(`等你 ${waiting}`)
1996
+ railFactsEl.textContent = sessions.length === 0 ? '' : headParts.join(' · ')
1997
+
1998
+ const signature = railSignature()
1999
+ if (signature === STATE.railSig) return
2000
+ STATE.railSig = signature
2001
+
2002
+ if (sessions.length === 0) {
2003
+ railBodyEl.replaceChildren(el('p', 'rail-empty', STATE.schedulesNote
2004
+ ? `读不到会话列表:${STATE.schedulesNote}`
2005
+ : STATE.mode === 'chat' ? '读取会话…' : '还不能读取会话。'))
1830
2006
  return
1831
2007
  }
1832
- const signature = runs.map(run => [
1833
- run.id, laneSignature(run), run.queue?.position ?? '', run.queue?.waiting ? 'queued' : '',
1834
- ].join(':')).join('#')
1835
- if (signature === STATE.scheduleSig) return
1836
- STATE.scheduleSig = signature
1837
- scheduleWrapEl.hidden = false
1838
- scheduleWrapEl.replaceChildren(scheduleElement(runs))
1839
- }
1840
-
1841
- /** Running bars grow with the clock between run frames. */
1842
- function tickSchedule() {
1843
- const now = Date.now()
1844
- for (const box of document.querySelectorAll('.sched')) {
1845
- const start = Number(box.dataset.axisStart)
1846
- if (!Number.isFinite(start)) continue
1847
- for (const bar of box.querySelectorAll('.sched-bar[data-start]')) {
1848
- const began = Number(bar.dataset.start)
1849
- if (!Number.isFinite(began)) continue
1850
- const span = Math.max(1000, now - start)
1851
- const left = Math.max(0, Math.min(99, ((began - start) / span) * 100))
1852
- const width = Math.max(1.2, Math.min(100 - left, ((now - began) / span) * 100))
1853
- bar.style.left = `${left}%`
1854
- bar.style.width = `${width}%`
1855
- }
1856
- const label = box.querySelector('.sched-axis')
1857
- if (label && box.dataset.live === '1') label.textContent = formatClock(now - start)
2008
+ railBodyEl.replaceChildren(detail ? railDetailBody(detail) : railGridOf(sessions))
2009
+ }
2010
+
2011
+ function railGridOf(sessions) {
2012
+ const grid = el('div', 'rail-grid')
2013
+ for (const session of sessions) grid.append(railCard(session))
2014
+ return grid
2015
+ }
2016
+
2017
+ /** Elapsed clocks inside the open card detail keep ticking between polls. */
2018
+ function tickRailClocks() {
2019
+ for (const node of railBodyEl.querySelectorAll('.rail-elapsed[data-start]')) {
2020
+ const started = Number(node.dataset.start)
2021
+ if (!Number.isFinite(started)) continue
2022
+ const finished = node.dataset.finish ? Number(node.dataset.finish) : Date.now()
2023
+ if (!Number.isFinite(finished)) continue
2024
+ node.textContent = formatClock(finished - started)
2025
+ }
2026
+ }
2027
+
2028
+ let railTimer = 0
2029
+ function queueRail() {
2030
+ if (railTimer) return
2031
+ railTimer = setTimeout(() => {
2032
+ railTimer = 0
2033
+ renderRail()
2034
+ }, 120)
2035
+ }
2036
+
2037
+ function setRail(collapsed, { persist = true } = {}) {
2038
+ document.body.classList.toggle('rail-collapsed', collapsed)
2039
+ document.body.classList.toggle('rail-open', !collapsed)
2040
+ railToggleEl.textContent = collapsed ? '‹' : '›'
2041
+ railToggleEl.setAttribute('aria-label', collapsed ? '展开调度' : '收起调度')
2042
+ railToggleEl.title = collapsed ? '展开调度' : '收起调度'
2043
+ if (persist) {
2044
+ try { localStorage.setItem(RAIL_KEY, collapsed ? '1' : '0') } catch {}
2045
+ }
2046
+ }
2047
+
2048
+ /** A stored choice wins; otherwise a narrow screen starts collapsed. */
2049
+ function restoreRail() {
2050
+ let stored = null
2051
+ try { stored = localStorage.getItem(RAIL_KEY) } catch {}
2052
+ if (stored === '1' || stored === '0') setRail(stored === '1', { persist: false })
2053
+ else setRail(window.innerWidth <= 720, { persist: false })
2054
+ }
2055
+
2056
+ async function loadSchedules() {
2057
+ if (STATE.schedulesBusy || !STATE.token) return
2058
+ STATE.schedulesBusy = true
2059
+ try {
2060
+ const data = await api('/api/console/schedules')
2061
+ STATE.schedules = Array.isArray(data?.sessions) ? data.sessions : []
2062
+ STATE.schedulesNote = data?.reason || null
2063
+ } catch (error) {
2064
+ STATE.schedulesNote = messageOf(error)
2065
+ } finally {
2066
+ STATE.schedulesBusy = false
2067
+ renderRail()
1858
2068
  }
1859
2069
  }
1860
2070
 
@@ -2237,19 +2447,6 @@
2237
2447
  next.focus()
2238
2448
  try { next.setSelectionRange(next.value.length, next.value.length) } catch {}
2239
2449
  }
2240
- if (artifacts.length > 0) {
2241
- const chips = el('div', 'artifacts')
2242
- for (const artifact of artifacts) chips.append(artifactElement(artifact))
2243
- item.append(chips)
2244
- }
2245
- item.addEventListener('click', event => {
2246
- if (event.target.closest('a')) return
2247
- drawerClose()
2248
- entry.message.el?.scrollIntoView({ block: 'center', behavior: 'smooth' })
2249
- entry.message.el?.classList.add('flash')
2250
- setTimeout(() => entry.message.el?.classList.remove('flash'), 1200)
2251
- })
2252
- historyListEl.append(item)
2253
2450
  }
2254
2451
  renderAdvancedRuns()
2255
2452
  for (const id of [...STATE.cancelRequested]) {
@@ -2257,7 +2454,7 @@
2257
2454
  if (!run || isTerminal(run.status)) STATE.cancelRequested.delete(id)
2258
2455
  }
2259
2456
  syncStopAll()
2260
- renderSchedule()
2457
+ queueRail()
2261
2458
  renderHistory()
2262
2459
  }
2263
2460
 
@@ -2802,8 +2999,10 @@
2802
2999
  if (frame.sessionId && frame.sessionId !== STATE.sessionId) {
2803
3000
  setSession(frame.sessionId)
2804
3001
  STATE.approvals.clear()
3002
+ STATE.railDetail = null
2805
3003
  clearMessages()
2806
3004
  renderEmpty()
3005
+ loadSchedules()
2807
3006
  }
2808
3007
  break
2809
3008
  case 'stream.snapshot':
@@ -2843,6 +3042,7 @@
2843
3042
  seatApproval(approval)
2844
3043
  refreshNotices({ toastNew: true })
2845
3044
  pushToast('有工具调用等你决定。', 'warn')
3045
+ queueRail()
2846
3046
  } else if (frame.action === 'auto') {
2847
3047
  pushToast(`已放行 ${frame.toolName || '这个工具'},本会话内不再询问。`, 'ok')
2848
3048
  } else if ((frame.action === 'decided' || frame.action === 'expired') && frame.id) {
@@ -2855,6 +3055,7 @@
2855
3055
  : frame.outcome === 'rejected' ? 'reject' : 'cancelled'
2856
3056
  settleApprovalNode(entry)
2857
3057
  refreshNotices()
3058
+ queueRail()
2858
3059
  }
2859
3060
  }
2860
3061
  break
@@ -3104,6 +3305,7 @@
3104
3305
  refreshNotices()
3105
3306
  if (STATE.messages.length === 0) renderEmpty()
3106
3307
  loadTools()
3308
+ loadSchedules()
3107
3309
  wizardLoad({ probe: false, auto: true })
3108
3310
  }
3109
3311
 
@@ -3820,6 +4022,7 @@
3820
4022
  setSession(data.sessionId)
3821
4023
  STATE.approvals.clear()
3822
4024
  STATE.cancelRequested.clear()
4025
+ STATE.railDetail = null
3823
4026
  clearMessages()
3824
4027
  STATE.runs = []
3825
4028
  renderLanes()
@@ -3827,6 +4030,7 @@
3827
4030
  renderEmpty()
3828
4031
  renderTools(null)
3829
4032
  loadTools()
4033
+ loadSchedules()
3830
4034
  pushToast('已开始新对话。', 'ok')
3831
4035
  connectEvents()
3832
4036
  } catch (error) {
@@ -3969,11 +4173,19 @@
3969
4173
 
3970
4174
  newChatEl.addEventListener('click', newConversation)
3971
4175
  stopAllEl.addEventListener('click', stopAllRuns)
4176
+ railToggleEl.addEventListener('click', () => {
4177
+ setRail(!document.body.classList.contains('rail-collapsed'))
4178
+ })
4179
+ restoreRail()
4180
+ renderRail()
3972
4181
  setInterval(() => {
3973
4182
  tickLaneClocks()
3974
- tickSchedule()
4183
+ tickRailClocks()
3975
4184
  updateApprovalClocks()
3976
4185
  }, 1000)
4186
+ setInterval(() => {
4187
+ if (STATE.mode === 'chat') loadSchedules()
4188
+ }, 5000)
3977
4189
  $('historyOpen').addEventListener('click', () => drawerOpen('history'))
3978
4190
  $('advancedOpen').addEventListener('click', () => drawerOpen('advanced'))
3979
4191
  for (const button of document.querySelectorAll('[data-close]')) {