feat: simplify navigation, make reload work (#4498)
This commit is contained in:
@@ -49,12 +49,16 @@ export function useAgent(): UseAgentReturn {
|
||||
const [agentState, setAgentState] = useState<AgentState>(AgentState.UNINITIALIZED);
|
||||
const [sessionId, setSessionId] = useState<string | null>(null);
|
||||
const initPromiseRef = useRef<Promise<ChatType> | null>(null);
|
||||
const [recipeFromAppConfig, setRecipeFromAppConfig] = useState<Recipe | null>(
|
||||
(window.appConfig.get('recipe') as Recipe) || null
|
||||
);
|
||||
|
||||
const { getExtensions, addExtension, read } = useConfig();
|
||||
|
||||
const resetChat = useCallback(() => {
|
||||
setSessionId(null);
|
||||
setAgentState(AgentState.UNINITIALIZED);
|
||||
setRecipeFromAppConfig(null);
|
||||
}, []);
|
||||
|
||||
const agentIsInitialized = agentState === AgentState.INITIALIZED;
|
||||
@@ -112,7 +116,7 @@ export function useAgent(): UseAgentReturn {
|
||||
: await startAgent({
|
||||
body: {
|
||||
working_dir: window.appConfig.get('GOOSE_WORKING_DIR') as string,
|
||||
recipe: initContext.recipeConfig,
|
||||
recipe: recipeFromAppConfig ?? initContext.recipeConfig,
|
||||
},
|
||||
throwOnError: true,
|
||||
});
|
||||
@@ -179,7 +183,7 @@ export function useAgent(): UseAgentReturn {
|
||||
initPromiseRef.current = initPromise;
|
||||
return initPromise;
|
||||
},
|
||||
[getExtensions, addExtension, read, agentIsInitialized, sessionId]
|
||||
[agentIsInitialized, sessionId, read, recipeFromAppConfig, getExtensions, addExtension]
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -29,7 +29,7 @@ export const useRecipeManager = (chat: ChatType, recipeConfig?: Recipe | null) =
|
||||
const finalRecipeConfig = chat.recipeConfig;
|
||||
|
||||
useEffect(() => {
|
||||
if (!chatContext?.setRecipeConfig) return;
|
||||
if (!chatContext) return;
|
||||
|
||||
// If we have a recipe from navigation state, persist it
|
||||
if (recipeConfig && !chatContext.chat.recipeConfig) {
|
||||
|
||||
Reference in New Issue
Block a user