Mayank2027 commited on
Commit
08f7d5d
·
verified ·
1 Parent(s): 28961c6

Update frontend/src/components/AgentPanel.tsx

Browse files
frontend/src/components/AgentPanel.tsx CHANGED
@@ -1,12 +1,15 @@
1
  import React, { useState } from 'react';
 
2
 
3
  const AgentPanel: React.FC<{ projectPath: string }> = ({ projectPath }) => {
4
  const [prompt, setPrompt] = useState('');
5
  const [output, setOutput] = useState('');
6
  const [running, setRunning] = useState(false);
 
7
 
8
  const run = async () => {
9
  setRunning(true);
 
10
  setOutput('');
11
  try {
12
  const resp = await fetch('/api/agent/run', {
@@ -28,6 +31,7 @@ const AgentPanel: React.FC<{ projectPath: string }> = ({ projectPath }) => {
28
  } catch (e) {}
29
  }
30
  }
 
31
  } catch (e) {
32
  setOutput('Error: ' + e);
33
  }
@@ -35,19 +39,34 @@ const AgentPanel: React.FC<{ projectPath: string }> = ({ projectPath }) => {
35
  };
36
 
37
  return (
38
- <div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
39
- <div style={{ padding: 8, borderBottom: '1px solid #333' }}>
 
40
  <textarea
41
- style={{ width: '100%', height: 60, background: '#2d2d2d', color: 'white' }}
42
  value={prompt}
43
  onChange={e => setPrompt(e.target.value)}
44
- placeholder="E.g., Create a REST API in Python..."
45
  />
46
- <button onClick={run} disabled={running} style={{ marginTop: 4, background: '#007acc', padding: '4px 12px', borderRadius: 4 }}>
47
- {running ? 'Running...' : 'Execute Agent'}
 
 
 
 
 
 
 
 
 
 
48
  </button>
49
  </div>
50
- <div style={{ flex: 1, overflowY: 'auto', padding: 10, fontFamily: 'monospace', whiteSpace: 'pre-wrap' }}>{output}</div>
 
 
 
 
51
  </div>
52
  );
53
  };
 
1
  import React, { useState } from 'react';
2
+ import { FaRobot, FaSpinner, FaCheckCircle } from 'react-icons/fa';
3
 
4
  const AgentPanel: React.FC<{ projectPath: string }> = ({ projectPath }) => {
5
  const [prompt, setPrompt] = useState('');
6
  const [output, setOutput] = useState('');
7
  const [running, setRunning] = useState(false);
8
+ const [done, setDone] = useState(false);
9
 
10
  const run = async () => {
11
  setRunning(true);
12
+ setDone(false);
13
  setOutput('');
14
  try {
15
  const resp = await fetch('/api/agent/run', {
 
31
  } catch (e) {}
32
  }
33
  }
34
+ setDone(true);
35
  } catch (e) {
36
  setOutput('Error: ' + e);
37
  }
 
39
  };
40
 
41
  return (
42
+ <div style={{ height: '100%', display: 'flex', flexDirection: 'column', background: 'var(--bg-primary)' }}>
43
+ <div style={{ padding: 12, borderBottom: '1px solid var(--border)' }}>
44
+ <div style={{ marginBottom: 8, fontWeight: 600, fontSize: 13 }}><FaRobot /> AI Agent</div>
45
  <textarea
46
+ style={{ width: '100%', height: 60, background: 'var(--bg-tertiary)', color: 'var(--text-primary)', border: '1px solid var(--border)', borderRadius: 6, padding: 8, resize: 'vertical' }}
47
  value={prompt}
48
  onChange={e => setPrompt(e.target.value)}
49
+ placeholder="E.g., Create a REST API with CRUD endpoints..."
50
  />
51
+ <button onClick={run} disabled={running} style={{
52
+ marginTop: 8,
53
+ background: running ? 'var(--border)' : 'var(--accent)',
54
+ color: 'white',
55
+ padding: '6px 16px',
56
+ borderRadius: 6,
57
+ fontWeight: 600,
58
+ display: 'flex',
59
+ alignItems: 'center',
60
+ gap: 6
61
+ }}>
62
+ {running ? <><FaSpinner className="spin" /> Running...</> : <><FaRobot /> Execute Agent</>}
63
  </button>
64
  </div>
65
+ <div style={{ flex: 1, overflowY: 'auto', padding: 12, fontFamily: 'monospace', whiteSpace: 'pre-wrap', background: 'var(--bg-secondary)', borderRadius: '0 0 6px 6px' }}>
66
+ {done && <div style={{ color: 'var(--success)', marginBottom: 8 }}><FaCheckCircle /> Task completed</div>}
67
+ {output || (running ? 'Working...' : 'Output will appear here')}
68
+ </div>
69
+ <style>{`.spin { animation: spin 1s linear infinite; } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }`}</style>
70
  </div>
71
  );
72
  };