✨ feat(web,sidecar,shared,sdk): Bash 手动转后台——运行中命令可由用户一键转入后台 - #856
Merged
Conversation
前台等待期内(15s 自动转后台预算之前)的 durable Bash 命令按 toolUseId 注册进 SDK 注册表;web 工具卡片对运行中的 Bash 显示"转入后台"按钮,经 agent:promote-shell-background RPC 触发 promote:原工具调用立即收到 后台回执(backgroundedByUser: true),命令与完成通知链路由既有 promoteToBackground 接管。跨会话/未知 toolUseId 拒绝,fail-closed。 - sdk: raceForeground helper 挂接手动晋升 promise;注意 Promise.race 会把 undefined 经 Promise.resolve 立即兑现,manualPromotion 缺省时 必须从 race 中剔除,否则前台等待被 0ms 击穿(已钉测试) - sidecar: bash-handlers 薄转发层 + zod schema + 注册 - web: 运行中 Bash 卡片"转入后台"按钮(ui/Button,失败 toast 降级) Constraint: 仅 durable 路径可手动转后台——direct 路径(独立 SDK 调用方)无 job 记录,注册表不覆盖 Constraint: 基于 feat/background-bash-semantics(#854)堆叠,合并需先入前者 Rejected: 按 jobId 而非 toolUseId 定位 | 命令运行中回执未产生,UI 拿不到 jobId Rejected: promote 后保留原前台等待继续等 done | 转后台语义就是立即归还回合 Tested: bash.test.ts 55 pass(含手动 promote 全链路:未知 id/跨会话拒绝、回执、完成通知一次性) Tested: @lume/agent-sdk、@lume/shared、@lume/web typecheck 通过;sidecar 存量 typecheck 错误在 main 已存在(obsidian vault-facade.test)
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
功能
借鉴 ZCode 的"用户手动后台化"能力:当一个 Bash 命令正在前台运行(还没到 15s 自动转后台预算)时,工具卡片上出现**「转入后台」**按钮,点击后命令立即转入后台继续执行,原工具调用立刻返回后台回执,回合恢复响应。
链路
实现要点
task.job存在才注册);direct 路径(独立 SDK 调用方)不支持,fail-closed。Promise.race会把undefined经Promise.resolve立即兑现——manualPromotion缺省时绝不能混入 race 数组,否则前台等待被 0ms 击穿、所有前台命令直接落入自动转后台(已由改写前 8 个失败用例实证,现钉在 raceForeground helper 注释里)。Command was moved to the background by user: <task_id>,_meta.task.backgroundedByUser: true供 UI/模型区分三种后台入口(显式/自动/手动)。测试
bash.test.ts55 pass / 2 env-skip:手动 promote 全链路(未知 id 拒绝、跨会话拒绝、回执、ProcessOutput收尾、task_started恰好一次)@lume/agent-sdk/@lume/shared/@lume/webtypecheck 通过