feat: watch background commands, open their output and stop them
A command the agent detached keeps running after its tool call returns; the chat now shows it above the composer: one row per command with its clock and a stop, folded under "正在执行 N 条命令" when there are several, with a subagent tag for a child session's command. Tapping a row opens the live output in a sheet (a page a second from shell.output, tail kept), following the tail with a way back to the newest line. The tool row that started it carries a 后台 tag and shows the same output when expanded, falling back to the completion note once the shell is gone; a command stopped from the app says so instead of showing the Shell.NotFoundError it leaves behind. The list comes from opencode's own shell jobs (experimental/job, descendants included), so a foreground command never appears, and an older server falls back to the shell list narrowed by the detached calls in the transcript. Stopping confirms, removes the shell, and leaves the model a note that the stop was the user's, as the first-party client does. 0.4.14 (414).
This commit is contained in:
1 parent
809e0a747a
commit
c4de5e84d8
11 files changed
+1749
-7
No files matched your search
@@ -5,6 +5,23 @@
|
||||
|
||||
---
|
||||
|
||||
## 0.4.14 后台任务:状态条、实时输出与停止(分支 `flutter`)
|
||||
|
||||
| 项 | 结果 |
|
||||
| --- | --- |
|
||||
| 状态条 | 输入框上方新增后台任务条(在运行状态胶囊之下):1 条时直接显示命令、计时、`停止`;多条折叠成「正在执行 N 条命令」,默认 N ≤ 3 展开;子代理会话的任务标「子代理」 |
|
||||
| 输出 | 点状态条任意一行打开底部弹层:完整命令、运行状态与计时、实时输出(1 秒轮询 `GET /api/shell/:id/output`,cursor 续读、尾部 256KB 封顶)、自动跟随与「回到最新」、复制、停止 |
|
||||
| 工具行 | 起后台命令的 `bash` 行带「后台」标签;展开后显示「后台输出」预览(最后 8 行,仅展开时轮询)+「查看全部」+「停止」 |
|
||||
| 数据来源 | 首选 `GET /api/experimental/job?sessionID=…&descendants=true&status=running` 里的 `kind=shell`(opencode 自己的后台记录:`shellID`、`command`、`sessionID`、`time.started`,覆盖子会话,不会混入前台命令);老服务端 404 时退回 `GET /api/shell` + 转录里 `{status:running, shellID}` 的标记 |
|
||||
| 停止 | 确认框「停止这个任务?」→ `DELETE /api/shell/:id` → 向启动它的会话写一条 synthetic 说明(“用户停止了这条后台命令,随后的 Shell.NotFoundError 不是失败,不要因此重跑”,与上游口径一致),然后刷新列表 |
|
||||
| 结束后 | 命令结束后,工具行与弹层不再轮询,改用会话里 synthetic `<background-result kind="shell" …>` 的最终输出(shell 被删除后仍能看);如果是用户在 App 里停的,显示「用户停止了这条命令。」而不是 Shell.NotFoundError |
|
||||
| 刷新 | 打开会话立即刷新,之后 3 秒一次;会话消息变化时也刷新(新任务立刻出现);服务端无该接口时停止轮询 |
|
||||
| 测试 | 新增 `test/shell_jobs_test.dart`:后台标记识别(前台命令不算)、转录/任务/外壳列表解析、输出页、完成说明与停止标记、计时格式、停止说明,以及状态条 1 条/2 条/多条折叠的布局;80 项全过 |
|
||||
| 验证 | 模拟器(真实任务):`sleep 900` 单条任务条 → 第二条命令变为「正在执行 2 条命令」+ 两条行;弹层实时输出(每秒 tick);弹层内「停止」→ 确认 → 任务与 shell 消失、模型收到 synthetic 停止说明;工具行「后台」标签 + 展开后的最终输出/「用户停止了这条命令。」 |
|
||||
| 版本 | **0.4.14(code 414)** |
|
||||
|
||||
---
|
||||
|
||||
## 0.4.13 相对路径与生成图片的行内展示(分支 `flutter`)
|
||||
|
||||
| 项 | 结果 |
|
||||
|
||||
Reference in new issue
Block a user