Skip to content

Commit

Permalink
detail bug in schedule agent and naming of new run in edit agent (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
namansleeps authored Aug 12, 2023
1 parent e90b59b commit cf869a2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
10 changes: 3 additions & 7 deletions gui/pages/Content/Agents/ActivityFeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,16 @@ export default function ActivityFeed({selectedRunId, selectedView, setFetchedDat
</div>}
</div>
}
{feeds.length < 1 && !agent?.is_running && !agent?.is_scheduled ?
(isLoading ?
<div style={{display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh'}}>
<ClipLoader/>
</div>
: <div style={{
{feeds.length < 1 && !agent?.is_running && !agent?.is_scheduled &&
<div style={{
color: 'white',
fontSize: '14px',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
textAlign: 'center',
width: '100%'
}}>The Agent is not scheduled</div>) : null
}}>The Agent is not scheduled</div>
}
</div>
{feedContainerRef.current && feedContainerRef.current.scrollTop >= 1200 &&
Expand Down
4 changes: 3 additions & 1 deletion gui/pages/Content/Agents/AgentCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,9 @@ export default function AgentCreate({
setEditButtonClicked(true);
agentData.agent_id = editAgentId;
const name = agentData.name
agentData.name = "New Run"
const adjustedDate = new Date((new Date()).getTime() + 6*24*60*60*1000 - 1*60*1000);
const formattedDate = `${adjustedDate.getDate()} ${['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][adjustedDate.getMonth()]} ${adjustedDate.getFullYear()} ${adjustedDate.getHours().toString().padStart(2, '0')}:${adjustedDate.getMinutes().toString().padStart(2, '0')}`;
agentData.name = "Run " + formattedDate
addAgentRun(agentData)
.then((response) => {
if(response){
Expand Down
4 changes: 3 additions & 1 deletion gui/pages/Content/Agents/AgentSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ export default function AgentSchedule({
const {schedule_id} = response.data;
toast.success('Scheduled successfully!', {autoClose: 1800});
setCreateModal();
EventBus.emit('refreshDate', {});
EventBus.emit('reFetchAgents', {});
setTimeout(() => {
EventBus.emit('refreshDate', {});
}, 1000)
})
.catch(error => {
console.error('Error:', error);
Expand Down
1 change: 1 addition & 0 deletions gui/pages/Content/Agents/AgentWorkspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
toast.success('Schedule stopped successfully!', {autoClose: 1800});
setCreateStopModal(false);
EventBus.emit('reFetchAgents', {});
setAgentScheduleDetails(null)
}
})
.catch((error) => {
Expand Down
8 changes: 6 additions & 2 deletions gui/pages/Content/Agents/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Details({agentDetails1, runCount, agentScheduleDetails,
const [showConstraints, setShowConstraints] = useState(false);
const [showInstructions, setShowInstructions] = useState(false);
const [filteredInstructions, setFilteredInstructions] = useState([]);
const [scheduleText, setScheduleText] = useState('Agent is not Scheduled');
const [scheduleText, setScheduleText] = useState('');
const [agentDetails, setAgentDetails] = useState(null)
const info_text = {
marginLeft: '7px',
Expand Down Expand Up @@ -37,6 +37,10 @@ export default function Details({agentDetails1, runCount, agentScheduleDetails,
}, [agentDetails1]);

useEffect(() => {
if(!agentScheduleDetails){
setScheduleText('')
return
}
if (agent?.is_scheduled) {
if (agentScheduleDetails?.recurrence_interval !== null) {
if ((agentScheduleDetails?.expiry_runs === -1 || agentScheduleDetails?.expiry_runs == null) && agentScheduleDetails?.expiry_date !== null) {
Expand Down Expand Up @@ -191,7 +195,7 @@ export default function Details({agentDetails1, runCount, agentScheduleDetails,
<div><Image width={15} height={15} src="/images/info.svg" alt="info-icon"/></div>
<div style={info_text}>Stop after {agentDetails.max_iterations} iterations</div>
</div>}
{agent?.is_scheduled && <div className={styles.agent_info_box}>
{agent?.is_scheduled && scheduleText && <div className={styles.agent_info_box}>
<div><Image width={15} height={15} src="/images/event_repeat.svg" alt="info-icon"/></div>
<div style={info_text}>{scheduleText}</div>
</div>}
Expand Down

0 comments on commit cf869a2

Please sign in to comment.