diff --git a/app/api/psd-templates/route.ts b/app/api/psd-templates/route.ts
index a2336871a..6a8407fa0 100644
--- a/app/api/psd-templates/route.ts
+++ b/app/api/psd-templates/route.ts
@@ -174,7 +174,7 @@ export async function GET(request: NextRequest) {
} satisfies AgentPsdTemplateListResponse);
response.headers.set(
"Cache-Control",
- "private, max-age=60, stale-while-revalidate=300"
+ "private, no-store, max-age=0"
);
return response;
} catch (error) {
diff --git a/components/agents/AgentGenerationWorkspaceDarkV2.tsx b/components/agents/AgentGenerationWorkspaceDarkV2.tsx
index 7528e8af5..ae2969c34 100644
--- a/components/agents/AgentGenerationWorkspaceDarkV2.tsx
+++ b/components/agents/AgentGenerationWorkspaceDarkV2.tsx
@@ -4585,6 +4585,12 @@ export function AgentGenerationWorkspaceDarkV2({
);
+ const currentPsdWorkflowContext = getLatestWorkflowContext?.() ?? workflowContext;
+ const currentPsdBrandName = String(currentPsdWorkflowContext?.brand || "").trim();
+ const currentPsdFifthCategory = String(
+ currentPsdWorkflowContext?.fifthCategory || ""
+ ).trim();
+
return (
=> {
try {
- const response = await fetch(url, { cache: "default" });
+ const response = await fetch(url, { cache: "no-store" });
const payload = (await response
.json()
.catch(() => null)) as Partial | null;
@@ -511,6 +511,15 @@ function normalizeManagedBrandName(value?: string | null) {
return normalized;
}
+function matchesTemplateBrand(template: AgentPsdTemplate, brandName?: string | null) {
+ const normalizedBrandName = normalizeManagedBrandName(brandName).toLowerCase();
+ if (!normalizedBrandName) {
+ return true;
+ }
+
+ return normalizeManagedBrandName(template.brandName).toLowerCase() === normalizedBrandName;
+}
+
function getEffectiveTemplateCategoryTags(
template: AgentPsdTemplate,
activeCategoryTags: string[]
@@ -1449,14 +1458,21 @@ export function AgentPsdTemplateEditorDialog({
);
const templates = useMemo(
() =>
- allTemplates.filter((template) =>
- matchesTemplateSelectedCategories(
- template,
- normalizedSelectedCategoryNames,
- activeCategoryTags
- )
- ),
- [activeCategoryTags, allTemplates, normalizedSelectedCategoryNames]
+ allTemplates
+ .filter((template) => matchesTemplateBrand(template, normalizedBrandName))
+ .filter((template) =>
+ matchesTemplateSelectedCategories(
+ template,
+ normalizedSelectedCategoryNames,
+ activeCategoryTags
+ )
+ ),
+ [
+ activeCategoryTags,
+ allTemplates,
+ normalizedBrandName,
+ normalizedSelectedCategoryNames,
+ ]
);
const [selectedTemplateId, setSelectedTemplateId] = useState("");
const selectedTemplateDetailRequestUrl = useMemo(() => {