@greatapps/greatagents-ui 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatapps/greatagents-ui",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Shared agents UI components for Great platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -81,15 +81,15 @@ export function createGagentsClient(config: GagentsClientConfig) {
81
81
  createAgent: (
82
82
  idAccount: number,
83
83
  body: Pick<Agent, "title"> &
84
- Partial<Pick<Agent, "prompt" | "photo" | "delay_typing" | "waiting_time">>,
84
+ Partial<Pick<Agent, "photo" | "delay_typing" | "waiting_time">>,
85
85
  ) => request<Agent>("POST", idAccount, "agents", body),
86
86
 
87
87
  updateAgent: (
88
88
  idAccount: number,
89
89
  id: number,
90
90
  body: Partial<
91
- Pick<Agent, "title" | "prompt" | "photo" | "delay_typing" | "waiting_time" | "active">
92
- >,
91
+ Pick<Agent, "title" | "photo" | "delay_typing" | "waiting_time" | "active">
92
+ > & { prompt?: string; change_notes?: string },
93
93
  ) => request<Agent>("PUT", idAccount, `agents/${id}`, body),
94
94
 
95
95
  deleteAgent: (idAccount: number, id: number) =>
@@ -10,7 +10,7 @@ import {
10
10
  DialogFooter,
11
11
  Button,
12
12
  Input,
13
- Textarea,
13
+
14
14
  Label,
15
15
  } from "@greatapps/greatauth-ui/ui";
16
16
  import { Loader2 } from "lucide-react";
@@ -34,7 +34,6 @@ export function AgentFormDialog({
34
34
  const updateAgent = useUpdateAgent(config);
35
35
 
36
36
  const [title, setTitle] = useState("");
37
- const [prompt, setPrompt] = useState("");
38
37
  const [photo, setPhoto] = useState("");
39
38
  const [delayTyping, setDelayTyping] = useState("");
40
39
  const [waitingTime, setWaitingTime] = useState("");
@@ -43,13 +42,11 @@ export function AgentFormDialog({
43
42
  useEffect(() => {
44
43
  if (agent) {
45
44
  setTitle(agent.title);
46
- setPrompt(agent.prompt || "");
47
45
  setPhoto(agent.photo || "");
48
46
  setDelayTyping(agent.delay_typing != null ? String(agent.delay_typing) : "");
49
47
  setWaitingTime(agent.waiting_time != null ? String(agent.waiting_time) : "");
50
48
  } else {
51
49
  setTitle("");
52
- setPrompt("");
53
50
  setPhoto("");
54
51
  setDelayTyping("");
55
52
  setWaitingTime("");
@@ -66,7 +63,6 @@ export function AgentFormDialog({
66
63
  const body: Record<string, unknown> = {
67
64
  title: title.trim(),
68
65
  };
69
- if (prompt.trim()) body.prompt = prompt.trim();
70
66
  if (photo.trim()) body.photo = photo.trim();
71
67
  if (delayTyping.trim()) body.delay_typing = Number(delayTyping);
72
68
  if (waitingTime.trim()) body.waiting_time = Number(waitingTime);
@@ -117,17 +113,6 @@ export function AgentFormDialog({
117
113
  disabled={isPending}
118
114
  />
119
115
  </div>
120
- <div className="space-y-2">
121
- <Label htmlFor="agent-prompt">Prompt do Sistema</Label>
122
- <Textarea
123
- id="agent-prompt"
124
- value={prompt}
125
- onChange={(e) => setPrompt(e.target.value)}
126
- placeholder="Instruções para o agente AI..."
127
- rows={6}
128
- disabled={isPending}
129
- />
130
- </div>
131
116
  <div className="grid grid-cols-2 gap-4">
132
117
  <div className="space-y-2">
133
118
  <Label htmlFor="agent-delay">Delay de Digitação (ms)</Label>
@@ -98,18 +98,33 @@ export function AgentPromptEditor({ config, agent }: AgentPromptEditorProps) {
98
98
  const { data: agentToolsData } = useAgentTools(config, agent.id);
99
99
  const { data: toolsData } = useTools(config);
100
100
 
101
+ const versions = (versionsData?.data || []) as PromptVersion[];
102
+ const sortedVersions = [...versions].sort(
103
+ (a, b) => new Date(b.datetime_add).getTime() - new Date(a.datetime_add).getTime(),
104
+ );
105
+ const currentVersion = sortedVersions.find((v) => v.is_current) || sortedVersions[0] || null;
106
+ const currentPromptContent = currentVersion?.prompt_content ?? "";
107
+
101
108
  const [trackedAgentId, setTrackedAgentId] = useState(agent.id);
102
- const [promptText, setPromptText] = useState(agent.prompt || "");
109
+ const [promptText, setPromptText] = useState(currentPromptContent);
110
+ const [promptInitialized, setPromptInitialized] = useState(false);
103
111
  const [changeNotes, setChangeNotes] = useState("");
104
112
  const [showPreview, setShowPreview] = useState(false);
105
113
  const [compareVersionId, setCompareVersionId] = useState<number | null>(null);
106
114
 
107
115
  const textareaRef = useRef<HTMLTextAreaElement>(null);
108
116
 
117
+ // Initialize prompt text from current version when data loads
118
+ if (!promptInitialized && currentPromptContent && !isLoading) {
119
+ setPromptText(currentPromptContent);
120
+ setPromptInitialized(true);
121
+ }
122
+
109
123
  // Reset prompt text when agent changes
110
124
  if (trackedAgentId !== agent.id) {
111
125
  setTrackedAgentId(agent.id);
112
- setPromptText(agent.prompt || "");
126
+ setPromptText(currentPromptContent);
127
+ setPromptInitialized(!!currentPromptContent);
113
128
  setCompareVersionId(null);
114
129
  }
115
130
 
@@ -142,13 +157,6 @@ export function AgentPromptEditor({ config, agent }: AgentPromptEditorProps) {
142
157
  }
143
158
  }
144
159
 
145
- const versions = versionsData?.data || [];
146
- const sortedVersions = [...versions].sort(
147
- (a: PromptVersion, b: PromptVersion) =>
148
- new Date(b.datetime_add).getTime() - new Date(a.datetime_add).getTime(),
149
- );
150
-
151
- const currentVersion = sortedVersions.length > 0 ? sortedVersions[0] : null;
152
160
  const compareVersion = sortedVersions.find((v) => v.id === compareVersionId);
153
161
 
154
162
  // Diff: always compare selected older version against current
@@ -21,7 +21,7 @@ export function AgentsPage({
21
21
  const [createOpen, setCreateOpen] = useState(false);
22
22
 
23
23
  return (
24
- <div className="flex flex-col gap-4 p-4">
24
+ <div className="flex flex-col gap-4 p-4 md:p-6">
25
25
  <div className="flex items-center justify-between">
26
26
  <div>
27
27
  <h1 className="text-xl font-semibold">{title}</h1>
@@ -25,7 +25,7 @@ export function CredentialsPage({
25
25
  const credentials = credentialsData?.data || [];
26
26
 
27
27
  return (
28
- <div className="flex flex-col gap-4 p-4">
28
+ <div className="flex flex-col gap-4 p-4 md:p-6">
29
29
  <div className="flex items-center justify-between">
30
30
  <div>
31
31
  <h1 className="text-xl font-semibold">{title}</h1>
@@ -21,7 +21,7 @@ export function ToolsPage({
21
21
  const [editTool, setEditTool] = useState<Tool | undefined>(undefined);
22
22
 
23
23
  return (
24
- <div className="flex flex-col gap-4 p-4">
24
+ <div className="flex flex-col gap-4 p-4 md:p-6">
25
25
  <div className="flex items-center justify-between">
26
26
  <div>
27
27
  <h1 className="text-xl font-semibold">{title}</h1>
@@ -9,7 +9,6 @@ export interface Agent {
9
9
  id: number;
10
10
  id_account: number;
11
11
  title: string;
12
- prompt: string | null;
13
12
  photo: string | null;
14
13
  external_token: string | null;
15
14
  openai_assistant_id: string | null;