mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Merge pull request #552 from RooVetGit/fix_multiple_terminals_created
Fix multiple terminals created
This commit is contained in:
5
.changeset/friendly-bottles-kneel.md
Normal file
5
.changeset/friendly-bottles-kneel.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"roo-cline": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix issue where the terminal management system was creating unnecessary new terminals (thanks @evan-fannin!)
|
||||||
@@ -161,8 +161,10 @@ export class TerminalManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getOrCreateTerminal(cwd: string): Promise<TerminalInfo> {
|
async getOrCreateTerminal(cwd: string): Promise<TerminalInfo> {
|
||||||
|
const terminals = TerminalRegistry.getAllTerminals()
|
||||||
|
|
||||||
// Find available terminal from our pool first (created for this task)
|
// 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) {
|
if (t.busy) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -173,11 +175,21 @@ export class TerminalManager {
|
|||||||
}
|
}
|
||||||
return arePathsEqual(vscode.Uri.file(cwd).fsPath, terminalCwd.fsPath)
|
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) {
|
if (availableTerminal) {
|
||||||
|
// Navigate back to the desired directory
|
||||||
|
await this.runCommand(availableTerminal, `cd "${cwd}"`)
|
||||||
this.terminalIds.add(availableTerminal.id)
|
this.terminalIds.add(availableTerminal.id)
|
||||||
return availableTerminal
|
return availableTerminal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If all terminals are busy, create a new one
|
||||||
const newTerminalInfo = TerminalRegistry.createTerminal(cwd)
|
const newTerminalInfo = TerminalRegistry.createTerminal(cwd)
|
||||||
this.terminalIds.add(newTerminalInfo.id)
|
this.terminalIds.add(newTerminalInfo.id)
|
||||||
return newTerminalInfo
|
return newTerminalInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user