mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
reuse existing non-busy terminals
This commit is contained in:
parent
e35d69d124
commit
67786ada49
1 changed files with 13 additions and 1 deletions
|
|
@ -157,8 +157,10 @@ export class TerminalManager {
|
|||
}
|
||||
|
||||
async getOrCreateTerminal(cwd: string): Promise<TerminalInfo> {
|
||||
const terminals = TerminalRegistry.getAllTerminals()
|
||||
|
||||
// Find available terminal from our pool first (created for this task)
|
||||
const availableTerminal = TerminalRegistry.getAllTerminals().find((t) => {
|
||||
const matchingTerminal = terminals.find((t) => {
|
||||
if (t.busy) {
|
||||
return false
|
||||
}
|
||||
|
|
@ -168,11 +170,21 @@ export class TerminalManager {
|
|||
}
|
||||
return arePathsEqual(vscode.Uri.file(cwd).fsPath, terminalCwd.fsPath)
|
||||
})
|
||||
if (matchingTerminal) {
|
||||
this.terminalIds.add(matchingTerminal.id)
|
||||
return matchingTerminal
|
||||
}
|
||||
|
||||
// If no matching terminal exists, try to find any non-busy terminal
|
||||
const availableTerminal = terminals.find((t) => !t.busy)
|
||||
if (availableTerminal) {
|
||||
// Navigate back to the desired directory
|
||||
await this.runCommand(availableTerminal, `cd "${cwd}"`)
|
||||
this.terminalIds.add(availableTerminal.id)
|
||||
return availableTerminal
|
||||
}
|
||||
|
||||
// If all terminals are busy, create a new one
|
||||
const newTerminalInfo = TerminalRegistry.createTerminal(cwd)
|
||||
this.terminalIds.add(newTerminalInfo.id)
|
||||
return newTerminalInfo
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue