( text: string, images?: string[], mode?: string, providerProfile?: string, )
| 1508 | } |
| 1509 | |
| 1510 | public async submitUserMessage( |
| 1511 | text: string, |
| 1512 | images?: string[], |
| 1513 | mode?: string, |
| 1514 | providerProfile?: string, |
| 1515 | ): Promise<void> { |
| 1516 | try { |
| 1517 | text = (text ?? "").trim() |
| 1518 | images = images ?? [] |
| 1519 | |
| 1520 | if (text.length === 0 && images.length === 0) { |
| 1521 | return |
| 1522 | } |
| 1523 | |
| 1524 | const provider = this.providerRef.deref() |
| 1525 | |
| 1526 | if (provider) { |
| 1527 | if (mode) { |
| 1528 | await provider.setMode(mode) |
| 1529 | } |
| 1530 | |
| 1531 | if (providerProfile) { |
| 1532 | await provider.setProviderProfile(providerProfile) |
| 1533 | |
| 1534 | // Update this task's API configuration to match the new profile |
| 1535 | // This ensures the parser state is synchronized with the selected model |
| 1536 | const newState = await provider.getState() |
| 1537 | if (newState?.apiConfiguration) { |
| 1538 | this.updateApiConfiguration(newState.apiConfiguration) |
| 1539 | } |
| 1540 | } |
| 1541 | |
| 1542 | this.emit(RooCodeEventName.TaskUserMessage, this.taskId) |
| 1543 | |
| 1544 | // Handle the message directly instead of routing through the webview. |
| 1545 | // This avoids a race condition where the webview's message state hasn't |
| 1546 | // hydrated yet, causing it to interpret the message as a new task request. |
| 1547 | this.handleWebviewAskResponse("messageResponse", text, images) |
| 1548 | } else { |
| 1549 | console.error("[Task#submitUserMessage] Provider reference lost") |
| 1550 | } |
| 1551 | } catch (error) { |
| 1552 | console.error("[Task#submitUserMessage] Failed to submit user message:", error) |
| 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | async handleTerminalOperation(terminalOperation: "continue" | "abort") { |
| 1557 | if (terminalOperation === "continue") { |
no test coverage detected