Skip to content

Commit a83a1ac

Browse files
authored
Merge pull request #50 from CopilotKit/fix/render-deployment
fix: improve Render deployment config for reliability
2 parents 5a0fe4c + 73a69ec commit a83a1ac

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function GET() {
2+
return Response.json({ status: "ok" });
3+
}

apps/app/src/components/generative-ui/save-template-overlay.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { useState, useCallback, useMemo, useRef, type ReactNode } from "react";
3+
import { useState, useCallback, useEffect, useMemo, type ReactNode } from "react";
44
import { useAgent } from "@copilotkit/react-core/v2";
55
import { SEED_TEMPLATES } from "@/components/template-library/seed-templates";
66

@@ -35,25 +35,29 @@ export function SaveTemplateOverlay({
3535
const [saveState, setSaveState] = useState<SaveState>("idle");
3636
const [templateName, setTemplateName] = useState("");
3737

38-
// Capture pending_template at mount time — it may be cleared by the agent later
38+
// Capture pending_template once — it may be cleared by the agent later.
39+
// Syncs external agent state into local state (legitimate effect-based setState).
3940
const pending = agent.state?.pending_template as { id: string; name: string } | null | undefined;
40-
const sourceRef = useRef<{ id: string; name: string } | null>(null);
41-
if (pending?.id && !sourceRef.current) {
42-
sourceRef.current = pending;
43-
}
41+
const [capturedSource, setCapturedSource] = useState<{ id: string; name: string } | null>(null);
42+
useEffect(() => {
43+
if (pending?.id) {
44+
// eslint-disable-next-line react-hooks/set-state-in-effect -- one-time capture of external agent state
45+
setCapturedSource((prev) => prev ?? pending);
46+
}
47+
}, [pending]);
4448

4549
// Check if this content matches an existing template:
4650
// 1. Exact HTML match (seed templates rendered as-is)
4751
// 2. Source template captured from pending_template (applied templates with modified data)
4852
const matchedTemplate = useMemo(() => {
4953
// First check source template from apply flow
50-
if (sourceRef.current) {
54+
if (capturedSource) {
5155
const allTemplates = [
5256
...SEED_TEMPLATES,
5357
...((agent.state?.templates as { id: string; name: string }[]) || []),
5458
];
55-
const source = allTemplates.find((t) => t.id === sourceRef.current!.id);
56-
if (source) return source;
59+
const found = allTemplates.find((t) => t.id === capturedSource.id);
60+
if (found) return found;
5761
}
5862
// Then check exact HTML match
5963
if (!html) return null;
@@ -64,7 +68,7 @@ export function SaveTemplateOverlay({
6468
...((agent.state?.templates as { id: string; name: string; html: string }[]) || []),
6569
];
6670
return allTemplates.find((t) => t.html && normalise(t.html) === norm) ?? null;
67-
}, [html, agent.state?.templates]);
71+
}, [html, agent.state?.templates, capturedSource]);
6872

6973
const handleSave = useCallback(() => {
7074
const name = templateName.trim() || title || "Untitled Template";

render.yaml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
services:
2-
# ── Agent (LangGraph Python) — private, not exposed to internet ──
3-
- type: pserv
2+
# ── Agent (LangGraph Python) — Docker required for langgraph-api image ──
3+
- type: web
44
name: open-generative-ui-agent
55
runtime: docker
66
plan: starter
77
dockerfilePath: docker/Dockerfile.agent
88
healthCheckPath: /ok
9+
scaling:
10+
minInstances: 1
11+
maxInstances: 3
12+
targetMemoryPercent: 80
13+
targetCPUPercent: 70
914
envVars:
1015
- key: OPENAI_API_KEY
1116
sync: false
@@ -18,17 +23,28 @@ services:
1823
- apps/agent/**
1924
- docker/Dockerfile.agent
2025

21-
# ── Frontend (Next.js) — public web service ──
26+
# ── Frontend (Next.js) — native Node runtime ──
2227
- type: web
2328
name: open-generative-ui-app
24-
runtime: docker
29+
runtime: node
2530
plan: starter
26-
dockerfilePath: docker/Dockerfile.app
31+
scaling:
32+
minInstances: 1
33+
maxInstances: 3
34+
targetMemoryPercent: 80
35+
targetCPUPercent: 70
36+
buildCommand: corepack enable && pnpm install --no-frozen-lockfile && pnpm --filter @repo/app build
37+
startCommand: pnpm --filter @repo/app start
38+
healthCheckPath: /api/health
2739
envVars:
40+
- key: NODE_VERSION
41+
value: "22"
42+
- key: SKIP_INSTALL_DEPS
43+
value: "true"
2844
- key: LANGGRAPH_DEPLOYMENT_URL
2945
fromService:
3046
name: open-generative-ui-agent
31-
type: pserv
47+
type: web
3248
property: hostport
3349
- key: LANGSMITH_API_KEY
3450
sync: false
@@ -44,4 +60,3 @@ services:
4460
- package.json
4561
- pnpm-lock.yaml
4662
- turbo.json
47-
- docker/Dockerfile.app

0 commit comments

Comments
 (0)