{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/ChatController.php",
"offset": 144,
"limit": 90
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/ChatController.php",
"content": " \/**\n * Streaming message endpoint with SSE progress events\n *\/\n public function messageStream(string $uuid): void\n {\n $session = $this->getSessionUseCase->getSession($uuid);\n\n if ($session === null) {\n $this->sseError('Session nicht gefunden.');\n\n return;\n }\n\n $sessionId = $session->getId() ?? 0;\n $question = trim($_POST['message'] ?? '');\n $requestedModel = $_POST['model'] ?? $session->getModel();\n $model = $this->modelRegistry->isValid($requestedModel)\n ? $requestedModel\n : $this->modelRegistry->getDefaultChatModel();\n $sessionCollections = $session->getCollections();\n $collections = $_POST['collections'] ?? $sessionCollections;\n $contextLimit = (int) ($_POST['context_limit'] ?? $session->getContextLimit());\n $authorProfileId = (int) ($_POST['author_profile_id'] ?? $session->getAuthorProfileId() ?? 0);\n $systemPromptId = (int) ($_POST['system_prompt_id'] ?? $session->getSystemPromptId() ?? 1);\n $structureId = (int) ($_POST['structure_id'] ?? 0);\n $temperature = (float) ($_POST['temperature'] ?? $session->getTemperature());\n $maxTokens = (int) ($_POST['max_tokens'] ?? $session->getMaxTokens());\n\n if ($this->updateSessionUseCase->settingsHaveChanged($session, $model, $collections, $contextLimit, $authorProfileId, $temperature, $maxTokens)) {\n $this->updateSessionUseCase->updateSettings($sessionId, $model, $collections, $contextLimit, $authorProfileId, $temperature, $maxTokens);\n }\n\n if ($question === '') {\n $this->sseError('Bitte gib eine Frage ein.');\n\n return;\n }\n\n if (!empty($collections)) {\n $compatibility = $this->updateSessionUseCase->validateCollectionCompatibility($collections);\n if (!$compatibility['valid']) {\n $this->sseError('Collection-Fehler: ' . $compatibility['error']);\n\n return;\n }\n }\n\n $qualityCheck = isset($_POST['quality_check']) && $_POST['quality_check'] === '1';\n\n \/\/ Setup SSE headers - critical for streaming\n header('Content-Type: text\/event-stream; charset=utf-8');\n header('Cache-Control: no-cache, no-store, must-revalidate');\n header('Pragma: no-cache');\n header('Connection: keep-alive');\n header('X-Accel-Buffering: no');\n header('Content-Encoding: none');\n\n \/\/ Disable ALL output buffering\n if (function_exists('apache_setenv')) {\n apache_setenv('no-gzip', '1');\n }\n @ini_set('zlib.output_compression', '0');\n @ini_set('implicit_flush', '1');\n @ini_set('output_buffering', '0');\n while (ob_get_level()) {\n ob_end_clean();\n }\n ob_implicit_flush(true);\n\n \/\/ Send 4KB padding to force buffer flush (browsers need minimum bytes)\n echo ':' . str_repeat(' ', 4096) . \"\\n\\n\";\n flush();\n\n \/\/ Set progress callback - send padding after each event to force flush\n $this->streamingUseCase->setProgressCallback(function (string $step, string $message, ?int $durationMs) {\n $timestamp = (new \\DateTime())->format('H:i:s.v');\n $data = [\n 'ts' => $timestamp,\n 'step' => $step,\n 'msg' => $message,\n 'ms' => $durationMs,\n ];\n echo \"event: progress\\n\";\n echo 'data: ' . json_encode($data, JSON_UNESCAPED_UNICODE) . \"\\n\\n\";\n \/\/ Force buffer flush with padding (Apache\/proxy buffering workaround)\n echo ':' . str_repeat(' ', 4096) . \"\\n\";\n flush();\n });\n\n \/\/ Execute with streaming",
"numLines": 90,
"startLine": 144,
"totalLines": 478
}
}
}