chore(ext): react misc
This commit is contained in:
@@ -82,7 +82,8 @@ export function useAgent(): UseAgentResult {
|
|||||||
|
|
||||||
const execute = useCallback(async (task: string) => {
|
const execute = useCallback(async (task: string) => {
|
||||||
const agent = agentRef.current
|
const agent = agentRef.current
|
||||||
if (!agent) return
|
console.log('Fire task:', task, agent)
|
||||||
|
if (!agent) throw new Error('Agent not initialized')
|
||||||
|
|
||||||
setCurrentTask(task)
|
setCurrentTask(task)
|
||||||
setHistory([])
|
setHistory([])
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { EmptyState, Logo, StatusDot } from './components/misc'
|
|||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [showConfig, setShowConfig] = useState(false)
|
const [showConfig, setShowConfig] = useState(false)
|
||||||
const [task, setTask] = useState('')
|
const [inputValue, setInputValue] = useState('')
|
||||||
const historyRef = useRef<HTMLDivElement>(null)
|
const historyRef = useRef<HTMLDivElement>(null)
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
||||||
|
|
||||||
@@ -32,17 +32,16 @@ export default function App() {
|
|||||||
const handleSubmit = useCallback(
|
const handleSubmit = useCallback(
|
||||||
(e?: React.FormEvent) => {
|
(e?: React.FormEvent) => {
|
||||||
e?.preventDefault()
|
e?.preventDefault()
|
||||||
if (!task.trim() || status === 'running') return
|
if (!inputValue.trim() || status === 'running') return
|
||||||
|
|
||||||
const taskToExecute = task.trim()
|
const taskToExecute = inputValue.trim()
|
||||||
setTask('')
|
setInputValue('')
|
||||||
|
|
||||||
console.log('[SidePanel] Executing task:', taskToExecute)
|
|
||||||
execute(taskToExecute).catch((error) => {
|
execute(taskToExecute).catch((error) => {
|
||||||
console.error('[SidePanel] Failed to execute task:', error)
|
console.error('[SidePanel] Failed to execute task:', error)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[task, status, execute]
|
[inputValue, status, execute]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleStop = useCallback(() => {
|
const handleStop = useCallback(() => {
|
||||||
@@ -120,8 +119,8 @@ export default function App() {
|
|||||||
<InputGroupTextarea
|
<InputGroupTextarea
|
||||||
ref={textareaRef}
|
ref={textareaRef}
|
||||||
placeholder="Describe your task... (Enter to send)"
|
placeholder="Describe your task... (Enter to send)"
|
||||||
value={task}
|
value={inputValue}
|
||||||
onChange={(e) => setTask(e.target.value)}
|
onChange={(e) => setInputValue(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
disabled={isRunning}
|
disabled={isRunning}
|
||||||
className="text-xs pr-12 min-h-10"
|
className="text-xs pr-12 min-h-10"
|
||||||
@@ -141,7 +140,7 @@ export default function App() {
|
|||||||
size="icon-sm"
|
size="icon-sm"
|
||||||
variant="default"
|
variant="default"
|
||||||
onClick={() => handleSubmit()}
|
onClick={() => handleSubmit()}
|
||||||
disabled={!task.trim()}
|
disabled={!inputValue.trim()}
|
||||||
className="size-7"
|
className="size-7"
|
||||||
>
|
>
|
||||||
<Send className="size-3" />
|
<Send className="size-3" />
|
||||||
|
|||||||
Reference in New Issue
Block a user