| 362 | } |
| 363 | |
| 364 | void QuickRefactorHandler::handleLLMResponse( |
| 365 | const QString &response, const QJsonObject &request, bool isComplete) |
| 366 | { |
| 367 | if (request["id"].toString() != m_lastRequestId) { |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | if (isComplete) { |
| 372 | m_isRefactoringInProgress = false; |
| 373 | QString cleanedResponse = PluginLLMCore::ResponseCleaner::clean(response); |
| 374 | |
| 375 | RefactorResult result; |
| 376 | result.newText = cleanedResponse; |
| 377 | result.insertRange = m_currentRange; |
| 378 | result.success = true; |
| 379 | result.editor = m_currentEditor; |
| 380 | |
| 381 | LOG_MESSAGE("Refactoring completed successfully. New code to insert: "); |
| 382 | LOG_MESSAGE("---------- BEGIN REFACTORED CODE ----------"); |
| 383 | LOG_MESSAGE(cleanedResponse); |
| 384 | LOG_MESSAGE("----------- END REFACTORED CODE -----------"); |
| 385 | |
| 386 | emit refactoringCompleted(result); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | void QuickRefactorHandler::cancelRequest() |
| 391 | { |