Fix scheduled recipe session params (#9553)
Signed-off-by: Angie Jones <jones.angie@gmail.com>
This commit is contained in:
@@ -468,27 +468,35 @@ async fn update_from_session(
|
|||||||
status: StatusCode::INTERNAL_SERVER_ERROR,
|
status: StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
})?;
|
})?;
|
||||||
if let Some(recipe) = session.recipe {
|
if let Some(recipe) = session.recipe {
|
||||||
match build_recipe_with_parameter_values(
|
if session.session_type == SessionType::Scheduled {
|
||||||
&recipe,
|
if let Some(prompt) = apply_recipe_to_agent(&agent, &recipe, true).await {
|
||||||
session.user_recipe_values.unwrap_or_default(),
|
agent
|
||||||
)
|
.extend_system_prompt("recipe".to_string(), prompt)
|
||||||
.await
|
.await;
|
||||||
{
|
}
|
||||||
Ok(Some(recipe)) => {
|
} else {
|
||||||
if let Some(prompt) = apply_recipe_to_agent(&agent, &recipe, true).await {
|
match build_recipe_with_parameter_values(
|
||||||
agent
|
&recipe,
|
||||||
.extend_system_prompt("recipe".to_string(), prompt)
|
session.user_recipe_values.unwrap_or_default(),
|
||||||
.await;
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(Some(recipe)) => {
|
||||||
|
if let Some(prompt) = apply_recipe_to_agent(&agent, &recipe, true).await {
|
||||||
|
agent
|
||||||
|
.extend_system_prompt("recipe".to_string(), prompt)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(None) => {
|
||||||
|
// Recipe has missing parameters
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
return Err(ErrorResponse {
|
||||||
|
message: e.to_string(),
|
||||||
|
status: StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(None) => {
|
|
||||||
// Recipe has missing parameters
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
return Err(ErrorResponse {
|
|
||||||
message: e.to_string(),
|
|
||||||
status: StatusCode::INTERNAL_SERVER_ERROR,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -758,27 +766,35 @@ async fn restart_agent_internal(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
if let Some(ref recipe) = session.recipe {
|
if let Some(ref recipe) = session.recipe {
|
||||||
match build_recipe_with_parameter_values(
|
if session.session_type == SessionType::Scheduled {
|
||||||
recipe,
|
if let Some(prompt) = apply_recipe_to_agent(&agent, recipe, true).await {
|
||||||
session.user_recipe_values.clone().unwrap_or_default(),
|
agent
|
||||||
)
|
.extend_system_prompt("recipe".to_string(), prompt)
|
||||||
.await
|
.await;
|
||||||
{
|
}
|
||||||
Ok(Some(recipe)) => {
|
} else {
|
||||||
if let Some(prompt) = apply_recipe_to_agent(&agent, &recipe, true).await {
|
match build_recipe_with_parameter_values(
|
||||||
agent
|
recipe,
|
||||||
.extend_system_prompt("recipe".to_string(), prompt)
|
session.user_recipe_values.clone().unwrap_or_default(),
|
||||||
.await;
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(Some(recipe)) => {
|
||||||
|
if let Some(prompt) = apply_recipe_to_agent(&agent, &recipe, true).await {
|
||||||
|
agent
|
||||||
|
.extend_system_prompt("recipe".to_string(), prompt)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(None) => {
|
||||||
|
// Recipe has missing parameters
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
return Err(ErrorResponse {
|
||||||
|
message: e.to_string(),
|
||||||
|
status: StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(None) => {
|
|
||||||
// Recipe has missing parameters
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
return Err(ErrorResponse {
|
|
||||||
message: e.to_string(),
|
|
||||||
status: StatusCode::INTERNAL_SERVER_ERROR,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export default function BaseChat({
|
|||||||
return initialMessage;
|
return initialMessage;
|
||||||
}, [initialMessage, recipe?.prompt, session?.user_recipe_values]);
|
}, [initialMessage, recipe?.prompt, session?.user_recipe_values]);
|
||||||
|
|
||||||
const canAutoSubmit = !recipe || hasNotAcceptedRecipe === false;
|
const canAutoSubmit = session?.session_type === 'scheduled' || !recipe || hasNotAcceptedRecipe === false;
|
||||||
|
|
||||||
useAutoSubmit({
|
useAutoSubmit({
|
||||||
sessionId,
|
sessionId,
|
||||||
@@ -208,7 +208,7 @@ export default function BaseChat({
|
|||||||
}, [messages]);
|
}, [messages]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!recipe || !isActiveSession) return;
|
if (!recipe || !isActiveSession || session?.session_type === 'scheduled') return;
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const accepted = await window.electron.hasAcceptedRecipeBefore(recipe);
|
const accepted = await window.electron.hasAcceptedRecipeBefore(recipe);
|
||||||
@@ -219,7 +219,7 @@ export default function BaseChat({
|
|||||||
setHasRecipeSecurityWarnings(scanResult.has_security_warnings);
|
setHasRecipeSecurityWarnings(scanResult.has_security_warnings);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}, [recipe, isActiveSession]);
|
}, [recipe, isActiveSession, session?.session_type]);
|
||||||
|
|
||||||
const handleRecipeAccept = async (accept: boolean) => {
|
const handleRecipeAccept = async (accept: boolean) => {
|
||||||
if (recipe && accept) {
|
if (recipe && accept) {
|
||||||
@@ -527,7 +527,7 @@ export default function BaseChat({
|
|||||||
</ChatInputCard>
|
</ChatInputCard>
|
||||||
</MainPanelLayout>
|
</MainPanelLayout>
|
||||||
|
|
||||||
{recipe && isActiveSession && (
|
{recipe && isActiveSession && session?.session_type !== 'scheduled' && (
|
||||||
<RecipeWarningModal
|
<RecipeWarningModal
|
||||||
isOpen={!!hasNotAcceptedRecipe}
|
isOpen={!!hasNotAcceptedRecipe}
|
||||||
onConfirm={() => handleRecipeAccept(true)}
|
onConfirm={() => handleRecipeAccept(true)}
|
||||||
@@ -541,7 +541,10 @@ export default function BaseChat({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{recipe?.parameters && recipe.parameters.length > 0 && !session?.user_recipe_values && (
|
{recipe?.parameters &&
|
||||||
|
recipe.parameters.length > 0 &&
|
||||||
|
!session?.user_recipe_values &&
|
||||||
|
session?.session_type !== 'scheduled' && (
|
||||||
<ParameterInputModal
|
<ParameterInputModal
|
||||||
parameters={recipe.parameters}
|
parameters={recipe.parameters}
|
||||||
onSubmit={setRecipeUserParams}
|
onSubmit={setRecipeUserParams}
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ export function useAutoSubmit({
|
|||||||
}, [sessionId]);
|
}, [sessionId]);
|
||||||
|
|
||||||
const hasUnfilledParameters = useCallback((session: Session) => {
|
const hasUnfilledParameters = useCallback((session: Session) => {
|
||||||
|
if (session.session_type === 'scheduled') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const recipe = session.recipe;
|
const recipe = session.recipe;
|
||||||
return recipe?.parameters && recipe.parameters.length > 0 && !session.user_recipe_values;
|
return recipe?.parameters && recipe.parameters.length > 0 && !session.user_recipe_values;
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user