fix(tui): keep backgrounded subagents spinning
This commit is contained in:
parent
e2bca216a2
commit
72ec09cf74
1 changed files with 25 additions and 15 deletions
|
|
@ -1719,18 +1719,23 @@ function ToolPart(props: { part: SessionMessageAssistantTool }) {
|
||||||
const ctx = use()
|
const ctx = use()
|
||||||
const data = useData()
|
const data = useData()
|
||||||
const display = createMemo(() => toolDisplay(props.part.name))
|
const display = createMemo(() => toolDisplay(props.part.name))
|
||||||
const runningShell = createMemo(
|
const activeBackgroundWork = createMemo(() => {
|
||||||
() => {
|
if (props.part.state.status === "pending") return false
|
||||||
if (display() !== "shell" || props.part.state.status === "pending") return false
|
if (display() === "shell") {
|
||||||
const shellID = stringValue(props.part.state.structured.shellID)
|
const shellID = stringValue(props.part.state.structured.shellID)
|
||||||
return Boolean(shellID && data.shell.get(shellID))
|
return Boolean(shellID && data.shell.get(shellID))
|
||||||
},
|
}
|
||||||
)
|
if (display() === "subagent") {
|
||||||
|
const sessionID = stringValue(props.part.state.structured.sessionID) ?? stringValue(props.part.state.structured.sessionId)
|
||||||
|
return Boolean(sessionID && data.session.status(sessionID) === "running")
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
// Hide tool if showDetails is false and tool completed successfully
|
// Hide tool if showDetails is false and tool completed successfully
|
||||||
const shouldHide = createMemo(() => {
|
const shouldHide = createMemo(() => {
|
||||||
if (ctx.showDetails()) return false
|
if (ctx.showDetails()) return false
|
||||||
if (runningShell()) return false
|
if (activeBackgroundWork()) return false
|
||||||
if (props.part.state.status !== "completed") return false
|
if (props.part.state.status !== "completed") return false
|
||||||
if (display() === "shell") return false
|
if (display() === "shell") return false
|
||||||
return true
|
return true
|
||||||
|
|
@ -1755,9 +1760,6 @@ function ToolPart(props: { part: SessionMessageAssistantTool }) {
|
||||||
get part() {
|
get part() {
|
||||||
return props.part
|
return props.part
|
||||||
},
|
},
|
||||||
get runningShell() {
|
|
||||||
return runningShell()
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -1788,7 +1790,7 @@ function ToolPart(props: { part: SessionMessageAssistantTool }) {
|
||||||
<Edit {...toolprops} />
|
<Edit {...toolprops} />
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={display() === "subagent"}>
|
<Match when={display() === "subagent"}>
|
||||||
<Task {...toolprops} />
|
<Subagent {...toolprops} />
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={display() === "apply_patch"}>
|
<Match when={display() === "apply_patch"}>
|
||||||
<ApplyPatch {...toolprops} />
|
<ApplyPatch {...toolprops} />
|
||||||
|
|
@ -1816,7 +1818,6 @@ type ToolProps = {
|
||||||
tool: string
|
tool: string
|
||||||
output?: string
|
output?: string
|
||||||
part: SessionMessageAssistantTool
|
part: SessionMessageAssistantTool
|
||||||
runningShell?: boolean
|
|
||||||
}
|
}
|
||||||
function GenericTool(props: ToolProps) {
|
function GenericTool(props: ToolProps) {
|
||||||
const { theme } = useTheme()
|
const { theme } = useTheme()
|
||||||
|
|
@ -2062,7 +2063,11 @@ function Shell(props: ToolProps) {
|
||||||
return request?.source?.type === "tool" && request.source.callID === props.part.id
|
return request?.source?.type === "tool" && request.source.callID === props.part.id
|
||||||
})
|
})
|
||||||
const color = createMemo(() => (permission() ? theme.warning : theme.text))
|
const color = createMemo(() => (permission() ? theme.warning : theme.text))
|
||||||
const isRunning = createMemo(() => props.part.state.status === "running" || props.runningShell === true)
|
const isRunning = createMemo(() => {
|
||||||
|
if (props.part.state.status === "running") return true
|
||||||
|
const shellID = stringValue(props.metadata.shellID)
|
||||||
|
return Boolean(shellID && data.shell.get(shellID))
|
||||||
|
})
|
||||||
const command = createMemo(() => stringValue(props.input.command))
|
const command = createMemo(() => stringValue(props.input.command))
|
||||||
const output = createMemo(() => {
|
const output = createMemo(() => {
|
||||||
if (props.part.state.status === "pending") return ""
|
if (props.part.state.status === "pending") return ""
|
||||||
|
|
@ -2225,15 +2230,20 @@ function WebSearch(props: ToolProps) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Task(props: ToolProps) {
|
function Subagent(props: ToolProps) {
|
||||||
const { navigate } = useRoute()
|
const { navigate } = useRoute()
|
||||||
|
const data = useData()
|
||||||
const sessionID = createMemo(() => stringValue(props.metadata.sessionID) ?? stringValue(props.metadata.sessionId))
|
const sessionID = createMemo(() => stringValue(props.metadata.sessionID) ?? stringValue(props.metadata.sessionId))
|
||||||
const description = createMemo(() => stringValue(props.input.description))
|
const description = createMemo(() => stringValue(props.input.description))
|
||||||
|
const isRunning = createMemo(() => {
|
||||||
|
const id = sessionID()
|
||||||
|
return props.part.state.status === "running" || Boolean(id && data.session.status(id) === "running")
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InlineTool
|
<InlineTool
|
||||||
icon={props.part.state.status === "completed" ? "✓" : "│"}
|
icon={isRunning() ? "│" : props.part.state.status === "completed" ? "✓" : "│"}
|
||||||
spinner={props.part.state.status === "running"}
|
spinner={isRunning()}
|
||||||
complete={description()}
|
complete={description()}
|
||||||
pending="Delegating..."
|
pending="Delegating..."
|
||||||
part={props.part}
|
part={props.part}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue