Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
fix(chatbot): keep the picked model on steer, CLI sessions and regenerate
testerb30f400afacd
diff --git a/chatbot/src/App.jsx b/chatbot/src/App.jsxindex 9a70c4b9..644dae2f 100644--- a/chatbot/src/App.jsx+++ b/chatbot/src/App.jsx@@ -2329,7 +2329,7 @@ export default function App() {);if (stored) {closeDialog();- await chat.regenerate(stored);+ await chat.regenerate(stored, approval);}}}}diff --git a/chatbot/src/useChat.js b/chatbot/src/useChat.jsindex 55c9320c..1ca76ec1 100644--- a/chatbot/src/useChat.js+++ b/chatbot/src/useChat.js@@ -571,7 +571,13 @@ export function useChat() {.then((catalog) => {if (!current) return;setProviderCatalogs((old) => ({ ...old, [executor]: catalog }));- setModel((old) => (catalog.models || []).some((m) => m.id === old) ? old : preferredModel(catalog.models, executor));+ // An open conversation keeps the model it runs on: the catalog lists+ // bare IDs without the CLI prefix, and no gateway models.+ setModel((old) =>+ (catalog.models || []).some((m) => m.id === old) || (old && old === sessionRef.current?.model)+ ? old+ : preferredModel(catalog.models, executor),+ );}).catch((e) => current && setError(e.message));return () => {@@ -972,7 +978,9 @@ export function useChat() {return null;}}- async function regenerate(stored) {+ // approvalMode is the composer's current choice, so a regenerated reply+ // follows it like a new message does.+ async function regenerate(stored, approvalMode = "confirm") {try {submittingRef.current = true;setSubmitting(true);@@ -989,7 +997,7 @@ export function useChat() {model: chosen,effort: codeBuddy ? modelEffort(models.find((m) => m.id === chosen), stored.effort || "") : "",messages: stored.messages,- approvalMode: "confirm",+ approvalMode: ["confirm", "assisted", "auto"].includes(approvalMode) ? approvalMode : "confirm",});setGeneration(g);await refreshSessions();diff --git a/chatbot/src/useLocalConversations.js b/chatbot/src/useLocalConversations.jsindex d691ef8f..39968bf5 100644--- a/chatbot/src/useLocalConversations.js+++ b/chatbot/src/useLocalConversations.js@@ -270,8 +270,8 @@ export function useLocalConversations(real) {selectLocal(id);return forked;},- async regenerate(stored) {- if (!isLocalConversation(stored?.id)) return real.regenerate(stored);+ async regenerate(stored, approvalMode) {+ if (!isLocalConversation(stored?.id)) return real.regenerate(stored, approvalMode);selectLocal(stored.id);return complete(stored, [...stored.messages].reverse().find((message) => message.role === "user")?.content || stored.title);},diff --git a/chatbot/tests/hooks.test.jsx b/chatbot/tests/hooks.test.jsxindex 0ce4fc28..b6171343 100644--- a/chatbot/tests/hooks.test.jsx+++ b/chatbot/tests/hooks.test.jsx@@ -176,6 +176,40 @@ describe("conversation hooks", () => {}});+ test("regenerating after an edit follows the composer's approval mode", async () => {+ const { result } = renderHook(() => useChat());+ await waitFor(() => expect(result.current.ready).toBe(true));+ const stored = { id: "s1", projectId: "p1", model: "m1", messages: [{ role: "user", content: "修改" }] };+ await act(() => result.current.regenerate(stored, "assisted"));+ expect(writeMock).toHaveBeenLastCalledWith("/api/assistant/generations", expect.objectContaining({ approvalMode: "assisted" }));+ await act(() => result.current.regenerate(stored, "bogus"));+ expect(writeMock).toHaveBeenLastCalledWith("/api/assistant/generations", expect.objectContaining({ approvalMode: "confirm" }));+ });++ test("an open conversation on a CLI without a key keeps its model", async () => {+ localStorage.removeItem("loopforge.assistant.executor");+ const original = apiMock.getMockImplementation();+ const codexSession = {+ id: "s9", title: "Codex 会话", projectId: "p1", executor: "codex", model: "codex:gpt-5.6-sol", effort: "",+ updatedAt: "2026-01-01T00:00:00Z",+ messages: [{ role: "user", content: "hi" }, { role: "assistant", content: "ok", model: "codex:gpt-5.6-sol" }],+ };+ apiMock.mockImplementation(async (path, options) =>+ path === "/api/assistant/sessions/s9" ? structuredClone(codexSession) : original(path, options));+ try {+ history.replaceState({}, "", "/?session=s9");+ const { result } = renderHook(() => useChat());+ await waitFor(() => expect(result.current.session?.id).toBe("s9"));+ await waitFor(() => expect(apiMock).toHaveBeenCalledWith("/api/assistant/models?executor=codex"));+ await act(async () => {});+ expect(result.current.executor).toBe("codex");+ expect(result.current.model).toBe("codex:gpt-5.6-sol");+ } finally {+ apiMock.mockImplementation(original);+ localStorage.removeItem("loopforge.assistant.executor");+ }+ });+test("persists the draft sandbox selection when creating a conversation", async () => {history.replaceState({}, "", "/?projectId=p1");const { result } = renderHook(() => useChat());diff --git a/internal/httpapi/assistant_generation.go b/internal/httpapi/assistant_generation.goindex d2c32506..6533aa23 100644--- a/internal/httpapi/assistant_generation.go+++ b/internal/httpapi/assistant_generation.go@@ -506,7 +506,13 @@ func (h *assistantHandlers) steerGeneration(c *gin.Context) {}model = forced}- model = assistantAllowedModel(model, h.chatCatalog(c.Request.Context(), user))+ // A CodeBuddy model this instance has not listed yet refreshes the list+ // first, like a new turn, instead of silently becoming the default.+ catalog := h.chatCatalog(c.Request.Context(), user)+ if engine, _ := assistantModelEngine(model); engine == assistantEngineCodeBuddy {+ catalog = h.turnCatalog(c.Request.Context(), user, model)+ }+ model = assistantAllowedModel(model, catalog)if err := validateAssistantEffort(user, model, body.Effort); err != nil {c.JSON(400, gin.H{"error": err.Error()})returndiff --git a/internal/httpapi/assistant_transcript_test.go b/internal/httpapi/assistant_transcript_test.goindex b54241e9..f65bacd2 100644--- a/internal/httpapi/assistant_transcript_test.go+++ b/internal/httpapi/assistant_transcript_test.go@@ -260,3 +260,49 @@ func TestSteerContinuesFromPartialTranscript(t *testing.T) {time.Sleep(20 * time.Millisecond)}}++// A steer on a remembered CodeBuddy model this instance has not listed yet+// (another instance served the picker) refreshes the list instead of+// switching the rest of the turn to the default model.+func TestSteerRefreshesTheModelListBeforeFallingBack(t *testing.T) {+ h, user := workbenchFixture(t)+ stubCLIModelDiscovery(t)+ discoverCLIModels = func(context.Context, string, string) []string { return []string{"claude-opus-5.5"} }+ release := make(chan struct{})+ t.Cleanup(func() { close(release) })+ started := make(chan struct{})+ h.generate = func(ctx context.Context, _ string, _ domain.User) (string, error) {+ select {+ case <-started:+ default:+ close(started)+ }+ <-release+ return "", ctx.Err()+ }+ c, rec := workbenchContext(user, "POST", "/api/assistant/generations", bytes.NewBufferString(`{"projectId":"workbench","sessionId":"steer-model","messages":[{"role":"user","content":"先查项目"}]}`))+ h.startGeneration(c)+ if rec.Code != 202 {+ t.Fatalf("start: %d %s", rec.Code, rec.Body.String())+ }+ select {+ case <-started:+ case <-time.After(5 * time.Second):+ t.Fatal("generation never started")+ }+ // This instance has not seen the model list yet.+ cliModelMu.Lock()+ cliModelCache = map[string]cliModelEntry{}+ cliModelMu.Unlock()+ g, _ := h.repo.AssistantGeneration(user.ID, "steer-model")+ c, rec = workbenchContext(user, "POST", "/api/assistant/sessions/steer-model/generation/steer?generationId="+g.ID, bytes.NewBufferString(`{"content":"改查仓库","model":"claude-opus-5.5","approvalMode":"confirm"}`))+ c.Params = gin.Params{{Key: "id", Value: "steer-model"}}+ h.steerGeneration(c)+ if rec.Code != 200 {+ t.Fatalf("steer: %d %s", rec.Code, rec.Body.String())+ }+ current, _ := h.repo.AssistantGeneration(user.ID, "steer-model")+ if current.Steer == nil || current.Steer.Model != "claude-opus-5.5" {+ t.Fatalf("steer model = %+v, want claude-opus-5.5", current.Steer)+ }+}