feat(ext): rerun tasks from history

This commit is contained in:
adonis
2026-03-19 23:54:08 +08:00
parent ba242d3a1b
commit 0bc47a997d
3 changed files with 87 additions and 20 deletions

View File

@@ -56,19 +56,27 @@ export default function App() {
}
}, [history, activity])
const handleSubmit = useCallback(
(e?: React.SyntheticEvent) => {
e?.preventDefault()
if (!inputValue.trim() || status === 'running') return
const runTask = useCallback(
(task: string) => {
const normalizedTask = task.trim()
if (!normalizedTask || status === 'running') return
const taskToExecute = inputValue.trim()
setInputValue('')
setView({ name: 'chat' })
execute(taskToExecute).catch((error) => {
execute(normalizedTask).catch((error) => {
console.error('[SidePanel] Failed to execute task:', error)
})
},
[inputValue, status, execute]
[execute, status]
)
const handleSubmit = useCallback(
(e?: React.SyntheticEvent) => {
e?.preventDefault()
runTask(inputValue)
},
[inputValue, runTask]
)
const handleStop = useCallback(() => {
@@ -103,12 +111,21 @@ export default function App() {
<HistoryList
onSelect={(id) => setView({ name: 'history-detail', sessionId: id })}
onBack={() => setView({ name: 'chat' })}
onRerun={runTask}
rerunDisabled={status === 'running'}
/>
)
}
if (view.name === 'history-detail') {
return <HistoryDetail sessionId={view.sessionId} onBack={() => setView({ name: 'history' })} />
return (
<HistoryDetail
sessionId={view.sessionId}
onBack={() => setView({ name: 'history' })}
onRerun={runTask}
rerunDisabled={status === 'running'}
/>
)
}
// --- Chat view ---