Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(chat): the model picker shows after Turn on Talk without a reload
trohitgca0144e1e4af
diff --git a/client/src/features/chat/data/chatContext.ts b/client/src/features/chat/data/chatContext.tsindex be4aac68..67a1a528 100644--- a/client/src/features/chat/data/chatContext.ts+++ b/client/src/features/chat/data/chatContext.ts@@ -11,6 +11,7 @@import { useQuery } from '@tanstack/react-query';import { z } from 'zod';import { useWebSocketActions } from '@/contexts/WebSocketContext';+import { queryKeys } from '@/lib/queryConfig';export interface ChatCommand {command: string;@@ -67,7 +68,7 @@ export function parseChatContext(reply: unknown): ChatContext {export function useChatContext(sessionId: string) {const { sendRequest, isReady } = useWebSocketActions();return useQuery<ChatContext, Error>({- queryKey: ['chatContext', sessionId],+ queryKey: queryKeys.chatContext.bySession(sessionId).queryKey,enabled: isReady && Boolean(sessionId),staleTime: 60_000,queryFn: async () => {diff --git a/client/src/hooks/__tests__/useWorkflowOpsListener.test.ts b/client/src/hooks/__tests__/useWorkflowOpsListener.test.tsindex ba55750d..2c960cc5 100644--- a/client/src/hooks/__tests__/useWorkflowOpsListener.test.ts+++ b/client/src/hooks/__tests__/useWorkflowOpsListener.test.ts@@ -19,6 +19,7 @@ import { renderHook, act } from '@testing-library/react';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import type { Node, Edge } from 'reactflow';+import { queryKeys } from '../../lib/queryConfig';import { useSavedGraphSync, useWorkflowOpsListener } from '../useWorkflowOpsListener';import { WORKFLOWS_QUERY_KEY } from '../useWorkflowsQuery';import { nodeParamsQueryKey } from '../useNodeParamsQuery';@@ -198,4 +199,16 @@ describe('useSavedGraphSync', () => {expect(storeMock.adoptSavedOperations).not.toHaveBeenCalled();expect(queryClient.getQueryData(nodeParamsQueryKey('7:duckduckgoSearch:1'))).toBeUndefined();});++ it('refetches what the workflow’s chat offers once the server saved a change to it', () => {+ // Before Turn on Talk the employee took no model choice.+ queryClient.setQueryData(queryKeys.chatContext.bySession('7').queryKey, { commands: [], attachments: true, web: false, modelChoice: false, maxAttachments: 6 });+ queryClient.setQueryData(queryKeys.chatContext.bySession('8').queryKey, { commands: [], attachments: true, web: false, modelChoice: false, maxAttachments: 6 });+ renderHook(() => useSavedGraphSync(), { wrapper });++ push({ workflow_id: '7', operations: SAVED, persisted: true });++ expect(queryClient.getQueryState(queryKeys.chatContext.bySession('7').queryKey)?.isInvalidated).toBe(true);+ expect(queryClient.getQueryState(queryKeys.chatContext.bySession('8').queryKey)?.isInvalidated).toBe(false);+ });});diff --git a/client/src/hooks/useWorkflowOpsListener.ts b/client/src/hooks/useWorkflowOpsListener.tsindex 8bdbeb85..5ddca228 100644--- a/client/src/hooks/useWorkflowOpsListener.ts+++ b/client/src/hooks/useWorkflowOpsListener.ts@@ -14,7 +14,9 @@* into the app store's copy of the workflow the editor holds, on either* screen, and puts their parameter rows in the parameter cache. Without it* a workflow left open in Dev while Home is showing keeps its old graph,- * and the editor's next save replaces the server's additions.+ * and the editor's next save replaces the server's additions. It also+ * refetches what the workflow's chat offers, which its saved graph decides:+ * after Turn on Talk the employee takes the model picker's choice.*/import { useEffect } from 'react';@@ -23,6 +25,7 @@ import { toast } from 'sonner';import { useQueryClient } from '@tanstack/react-query';import { useWebSocket, useWebSocketActions, type NodeParameters } from '../contexts/WebSocketContext';+import { queryKeys } from '../lib/queryConfig';import { useAppStore } from '../store/useAppStore';import {addSavedEdges,@@ -109,5 +112,6 @@ export function useSavedGraphSync(): void {}));}useAppStore.getState().adoptSavedOperations(raw.workflow_id, ops);+ void queryClient.invalidateQueries({ queryKey: queryKeys.chatContext.bySession(raw.workflow_id).queryKey });}), [addEventListener, queryClient]);}diff --git a/client/src/lib/queryConfig.ts b/client/src/lib/queryConfig.tsindex 3b6eef9e..12e401ae 100644--- a/client/src/lib/queryConfig.ts+++ b/client/src/lib/queryConfig.ts@@ -81,6 +81,17 @@ const chatThread = createQueryKeys('chatThread', {bySession: (sessionId: string) => [sessionId],});+/**+ * What one chat session's message box offers (`get_chat_context`; session+ * id = the workflow id): its commands, attachments, Web, and whether the+ * employee takes the model picker's choice. The workflow's saved graph+ * decides it, so useSavedGraphSync invalidates it when the server saves a+ * change to that graph (Turn on Talk, the Agent Builder).+ */+const chatContext = createQueryKeys('chatContext', {+ bySession: (sessionId: string) => [sessionId],+});+/*** Merged factory. Consumers call e.g.* queryKeys.credentialValues.byProvider(id).queryKey@@ -88,4 +99,4 @@ const chatThread = createQueryKeys('chatThread', {* queryKeys.credentialValues._def* for partial-match invalidation across the namespace.*/-export const queryKeys = mergeQueryKeys(credentialValues, compactionStats, chatThread);+export const queryKeys = mergeQueryKeys(credentialValues, compactionStats, chatThread, chatContext);diff --git a/docs-internal/chat_protocol.md b/docs-internal/chat_protocol.mdindex a8fed37c..a7d102b0 100644--- a/docs-internal/chat_protocol.md+++ b/docs-internal/chat_protocol.md@@ -650,7 +650,9 @@ picker: each node keeps its model.when it can't answer (`available: false` with its `reason`).- **`capabilities.model_choice`** (`get_chat_context`) is whether the employee applies a choice: its answering agentruns as an AgentWorkflow (`AGENT_WORKFLOW_TYPES`, with `TEMPORAL_AGENT_WORKFLOW_ENABLED` on). A Claude Code or- RLM agent never does, so the client shows no picker for it.+ RLM agent never does, so the client shows no picker for it. The saved graph decides it, so the client refetches+ the context (`queryKeys.chatContext`) when the server saves a change to that graph (`workflow_ops_apply` with+ `persisted`, handled by `useSavedGraphSync`): after Turn on Talk the picker shows without a reload.## Branches