Repository navigation
feat(assistant): add send preferences and preserve the CLI during steering - #1042
Conversation
|
修复 bug:引导(steer)当前回复时,会话原来用的 CLI 和执行机器保不住。之前 Codex/Cursor 会话一引导,裸模型 ID 会被当成 CodeBuddy 处理,结果报「请先配置 CodeBuddy Key」。另外 followSteer 没把 Executor 和 ExecutionTarget 传下去,后续这一轮可能跑到云端,而不是原来绑定的执行机器。 |
|
PR #1042 代码评审结论 修复 bug:引导(steer)当前回复时,会话原来用的 CLI 和执行机器保不住。之前 Codex/Cursor 会话一引导,裸模型 ID 会被当成 CodeBuddy 处理,结果报「请先配置 CodeBuddy Key」。另外 followSteer 没把 Executor 和 ExecutionTarget 传下去,后续这一轮可能跑到云端,而不是原来绑定的执行机器。
位置:internal/httpapi/assistant_generation.go:539 go effort := firstNonEmpty(body.Effort, session.Effort) 我写了一个临时测试复现(已删除):先用 claude-opus-5.5 + max 开一轮,生成中换成 gpt-6-sol 并选「默认」,然后引导: 本 PR:返回 400,模型 gpt-6-sol 不支持思考强度 "max" 建议:直接用 body.Effort 做校验并写进 steer;同时让 followSteer 能把空值当成「默认」,不要再用 firstNonEmpty 去恢复旧值。再补一个「换模型 + 默认 effort」的测试用例。 建议(不阻塞合并) |
Robert0622
left a comment
There was a problem hiding this comment.
用 DeepSeek V4.1 Flash 实测生成中插话并按默认推理强度续跑通过。补充回归发现同文案插话会丢失新附件,已标在代码行。
| Model: session.Model, | ||
| Effort: session.Effort, | ||
| ApprovalMode: steer.ApprovalMode, | ||
| Messages: session.Messages, |
There was a problem hiding this comment.
[P2] 连续发送相同文字时保留插话的新附件
开启「立即发送」后,若上一轮尚未产出可保存的回复,commitTurnTranscript 仅凭文字相同就会跳过新消息。本地用相同文字和两个不同文件复测,续跑用的对话记录只剩第一个文件。建议以插话请求的唯一标识去重,确保本次消息的附件和引用随续跑一起保存。
Robert0622
left a comment
There was a problem hiding this comment.
用 DeepSeek V4.1 Flash 复测了相同文字、更换附件后立即发送,两条用户消息和各自的附件均正确保留。双标签页对同一轮连续插话时,已接受的消息仍可能丢失,见行内评论。
| ActorName: user.LoginName, | ||
| TriggerID: rand.Text(), | ||
| } | ||
| if err := h.repo.SteerAssistantGeneration(ownerID, g.SessionID, g.ID, steer); err != nil { |
There was a problem hiding this comment.
[P2] 保留已接受的插话,避免后续请求覆盖
我把同一轮生成留在运行中,模拟两个标签页先后发送不同插话。两个 POST 都返回 HTTP 200,续跑后的会话只保存了第二条。SteerAssistantGeneration 会直接覆盖待处理的 Steer,而发送成功的前端已经从队列移除了第一条。请在同一事务内检查是否已有待处理插话,并保留第二条待发送,或返回明确冲突让前端保留它。
Robert0622
left a comment
There was a problem hiding this comment.
上一轮的双标签页覆盖已修复。第二次插话返回 HTTP 409,第一条保留,SQLite 和独立 Docker MySQL 并发复测通过。DeepSeek V4.1 Flash 的正常插话续跑通过。补充复测发现回复收尾时接受的插话仍可能丢失,见行内评论。
| return fmt.Errorf("生成已结束或不存在") | ||
| } | ||
| g := decodeGeneration(row) | ||
| if g.Steer != nil { |
There was a problem hiding this comment.
[P2] 收尾时保留已经接受的插话
executeGeneration 最后一次读取 Steer 后,生成在数据库里仍是 running。这时第一条插话可返回 HTTP 200。最终 checkpoint 会把这条插话写进已完成的生成记录,worker 手里的 steer 仍为空,消息没有进会话记录,也没有启动续跑。我固定该时序连续复测三次,结果一致。建议用同一事务协调结束状态与待处理插话。收尾先完成时返回已有的结束冲突,让前端排到下一轮。插话先被接受时,把它交给当前 worker 或持久派发流程处理。
Robert0622
left a comment
There was a problem hiding this comment.
复测通过。插话先被接受时,原回复和新消息会保存,随后启动续跑。收尾先锁定时返回 409,前端按已结束转入下一轮队列。HTTP 收尾和 SQLite、Docker MySQL 并发回归加 -race 重复通过,DeepSeek V4.1 Flash 的真实插话续跑通过。
What changed
Steering a running Codex or Cursor conversation could validate its model against CodeBuddy's catalog, replace it with the default, and fail the next turn's CLI consistency check. Resolve the CLI from the saved conversation and validate its model, credentials, runner login and reasoning effort before requesting cancellation. The follow-up retains the selected model, execution target and partial reply. Choosing Default uses the follow-up model's default reasoning effort. Repeating the same text with a new file or reference preserves the new message and its context even before the first reply produces output.
Add an AI assistant setting for messages sent during generation: Queue (the default) or Send immediately. The preference is saved per user and refreshes when settings are saved or the chat tab becomes visible. Immediate sends reuse steering. A validation or permission rejection pauses automatic sends and preserves the message. If the reply already ended, the message goes out on the next turn. A running reply can have one pending steer. A competing request gets a conflict and its message stays in that tab’s paused queue. Closing a turn and accepting a steer use the same generation row lock. The worker carries an accepted message into the transcript and starts its follow-up. A message that arrives after steering closes queues until the transcript has been saved.
Scope
Compatibility
assistant_preferences.steer_on_send, defaulting to false. Existing users keep queueing.migrations/036_assistant_steer_on_send.sql; no data migration or seed.design.md.Validation
All 16 GitHub checks for
b0cb4acpassed. Check results.Passed locally:
npm --prefix chatbot test— 56 files, 395 tests.npm --prefix chatbot run build.npm --prefix webtest run coverage— 87.53% line coverage (85% required).go test ./internal/httpapi ./internal/repo ./web -run 'TestAssistant|TestSteer|TestGeneration|TestStoppedGeneration|TestAppBundleFilesAreEmbeddedAndListed|TestAppJSParses|Hui|NoNativeDialogs' -count=1 -timeout=180s.go test -raceona8d7a41, including equal-text messages with different attachments and references and replay of an accepted steer.-raceruns ofTestAssistantGenerationCoordinatesSteering. The test covers competing requests, handing an accepted steer to the worker, and closing the current turn before the request arrives.b0cb4ac.go vet ./....python3 scripts/check-public.py.git diff --check.The broader local Go run (with the CI real-browser test exclusion) encountered host-specific failures in unrelated tests: Linux
/procassumptions in deploy tests, the macOS Unix socket path limit, and the local Gitsafe.bareRepository=explicitsetting. The deploy failures were also reproduced from an unchangedmainexport. The broad run also exceeded its local 180-second timeout; the focused regression and race tests above passed. See the PR checks for the full Linux CI result.Not run locally: real cloud CLI end-to-end validation, the Linux-only secret-scan script, and the Classic validation/install/e2e scripts (no Classic changes).
Safety