diff --git a/src/components/__tests__/PromptList.test.tsx b/src/components/__tests__/PromptList.test.tsx new file mode 100644 index 0000000..a4cafcc --- /dev/null +++ b/src/components/__tests__/PromptList.test.tsx @@ -0,0 +1,50 @@ +import { describe, expect, it } from "vitest"; +import { render, screen } from "@testing-library/react"; +import { PromptList } from "../PromptList"; +import mockedPrompts from "@/mocks/msw/fixtures/GetMessages.json"; +import { MemoryRouter } from "react-router-dom"; + +describe("PromptList", () => { + it("should render correct prompt", () => { + render( + + + , + ); + expect( + screen.getByRole("link", { + name: /server\.py do you see any security issue\?/i, + }), + ).toBeVisible(); + }); + + it("should render default prompt value when missing question", async () => { + const conversationTimestamp = "2025-01-02T14:19:58.024100Z"; + render( + + + , + ); + + expect( + screen.getByRole("link", { + name: `Prompt ${conversationTimestamp}`, + }), + ).toBeVisible(); + }); +}); diff --git a/src/mocks/msw/fixtures/GetAlerts.json b/src/mocks/msw/fixtures/GetAlerts.json new file mode 100644 index 0000000..7c4024b --- /dev/null +++ b/src/mocks/msw/fixtures/GetAlerts.json @@ -0,0 +1,30 @@ +[ + { + "conversation": { + "question_answers": [ + { + "question": { + "message": "```/Users/giuseppe/workspace/codegate/src/codegate/server.py\nimport traceback\n\nimport structlog\nfrom fastapi import APIRouter, FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom fastapi.responses import JSONResponse\nfrom starlette.middleware.errors import ServerErrorMiddleware\n\nfrom codegate import __description__, __version__\nfrom codegate.dashboard.dashboard import dashboard_router\nfrom codegate.pipeline.factory import PipelineFactory\nfrom codegate.providers.anthropic.provider import AnthropicProvider\nfrom codegate.providers.llamacpp.provider import LlamaCppProvider\nfrom codegate.providers.ollama.provider import OllamaProvider\nfrom codegate.providers.openai.provider import OpenAIProvider\nfrom codegate.providers.registry import ProviderRegistry\nfrom codegate.providers.vllm.provider import VLLMProvider\n\nlogger = structlog.get_logger(\"codegate\")\n\n\nasync def custom_error_handler(request, exc: Exception):\n \"\"\"This is a Middleware to handle exceptions and log them.\"\"\"\n # Capture the stack trace\n extracted_traceback = traceback.extract_tb(exc.__traceback__)\n # Log only the last 3 items of the stack trace. 3 is an arbitrary number.\n logger.error(traceback.print_list(extracted_traceback[-3:]))\n return JSONResponse({\"error\": str(exc)}, status_code=500)\n\n\ndef init_app(pipeline_factory: PipelineFactory) -> FastAPI:\n \"\"\"Create the FastAPI application.\"\"\"\n app = FastAPI(\n title=\"CodeGate\",\n description=__description__,\n version=__version__,\n )\n app.add_middleware(\n CORSMiddleware,\n allow_origins=[\"*\"],\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n )\n # Apply error handling middleware\n app.add_middleware(ServerErrorMiddleware, handler=custom_error_handler)\n\n # Create provider registry\n registry = ProviderRegistry(app)\n\n # Register all known providers\n registry.add_provider(\n \"openai\",\n OpenAIProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"anthropic\",\n AnthropicProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"llamacpp\",\n LlamaCppProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"vllm\",\n VLLMProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"ollama\",\n OllamaProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n\n # Create and add system routes\n system_router = APIRouter(tags=[\"System\"])\n\n @system_router.get(\"/health\")\n async def health_check():\n return {\"status\": \"healthy\"}\n\n app.include_router(system_router)\n app.include_router(dashboard_router)\n\n return app\n\n```\n\nserver.py do you see any security issue?", + "timestamp": "2025-01-03T09:10:00.689177Z", + "message_id": "0445530c-9288-4591-b48a-4fdc2f0aec6c" + }, + "answer": { + "message": "Yes, there are several security issues in the provided `server.py` code. Here are the main ones:\n\n1. **CORS Configuration**:\n ```python\n app.add_middleware(\n CORSMiddleware,\n allow_origins=[\"*\"],\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n )\n ```\n - Allowing all origins (`allow_origins=[\"*\"]`) and methods (`allow_methods=[\"*\"]`) can expose your server to Cross-Site Request Forgery (CSRF) attacks and other security vulnerabilities. It's recommended to restrict these settings to only the origins and methods that your application needs to support.\n\n2. **Error Handling Middleware**:\n ```python\n async def custom_error_handler(request, exc: Exception):\n \"\"\"This is a Middleware to handle exceptions and log them.\"\"\"\n # Capture the stack trace\n extracted_traceback = traceback.extract_tb(exc.__traceback__)\n # Log only the last 3 items of the stack trace. 3 is an arbitrary number.\n logger.error(traceback.print_list(extracted_traceback[-3:]))\n return JSONResponse({\"error\": str(exc)}, status_code=500)\n ```\n - Exposing detailed error messages in the response can be dangerous, as it can provide attackers with information that can be used to exploit vulnerabilities. It's better to log the error details and return a generic error message to the client.\n\n3. **Handling Exceptions**:\n - The `custom_error_handler` function logs the traceback and returns the exception message directly to the client. This can expose sensitive information about the server's internal state. It's better to log the error and return a generic message.\n\n4. **Provider Configuration**:\n - The providers are configured with the same pipeline processors. This might not be a security issue in itself, but it's important to ensure that the pipeline processors are secure and correctly configured.\n\n5. **Logging**:\n - The `logger.error` function is used to log the error traceback. Ensure that the logging configuration is set up correctly to prevent logging sensitive information to insecure destinations.\n\nHere is a revised version of the code with some of these issues addressed:\n\n```python\nimport traceback\n\nimport structlog\nfrom fastapi import APIRouter, FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom fastapi.responses import JSONResponse\nfrom starlette.middleware.errors import ServerErrorMiddleware\n\nfrom codegate import __description__, __version__\nfrom codegate.dashboard.dashboard import dashboard_router\nfrom codegate.pipeline.factory import PipelineFactory\nfrom codegate.providers.anthropic.provider import AnthropicProvider\nfrom codegate.providers.llamacpp.provider import LlamaCppProvider\nfrom codegate.providers.ollama.provider import OllamaProvider\nfrom codegate.providers.openai.provider import OpenAIProvider\nfrom codegate.providers.registry import ProviderRegistry\nfrom codegate.providers.vllm.provider import VLLMProvider\n\nlogger = structlog.get_logger(\"codegate\")\n\n\nasync def custom_error_handler(request, exc: Exception):\n \"\"\"This is a Middleware to handle exceptions and log them.\"\"\"\n # Capture the stack trace\n extracted_traceback = traceback.extract_tb(exc.__traceback__)\n # Log only the last 3 items of the stack trace. 3 is an arbitrary number.\n logger.error(traceback.print_list(extracted_traceback[-3:]))\n return JSONResponse({\"error\": \"An internal server error occurred\"}, status_code=500)\n\n\ndef init_app(pipeline_factory: PipelineFactory) -> FastAPI:\n \"\"\"Create the FastAPI application.\"\"\"\n app = FastAPI(\n title=\"CodeGate\",\n description=__description__,\n version=__version__,\n )\n app.add_middleware(\n CORSMiddleware,\n allow_origins=[\"https://example.com\"], # Restrict to specific origins\n allow_credentials=True,\n allow_methods=[\"GET\", \"POST\"], # Restrict to specific methods\n allow_headers=[\"*\"],\n )\n # Apply error handling middleware\n app.add_middleware(ServerErrorMiddleware, handler=custom_error_handler)\n\n # Create provider registry\n registry = ProviderRegistry(app)\n\n # Register all known providers\n registry.add_provider(\n \"openai\",\n OpenAIProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"anthropic\",\n AnthropicProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"llamacpp\",\n LlamaCppProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"vllm\",\n VLLMProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"ollama\",\n OllamaProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n\n # Create and add system routes\n system_router = APIRouter(tags=[\"System\"])\n\n @system_router.get(\"/health\")\n async def health_check():\n return {\"status\": \"healthy\"}\n\n app.include_router(system_router)\n app.include_router(dashboard_router)\n\n return app\n```\n\nIn this revised version, the CORS middleware is restricted to specific origins and methods, and the error handler returns a generic error message to the client.", + "timestamp": "2025-01-03T09:09:34.359269Z", + "message_id": "68e7c9bc-9afa-4240-8eba-621eaae4a2a0" + } + } + ], + "provider": "vllm", + "type": "chat", + "chat_id": "chatcmpl-eebad2bd68434c7c947d10754a204ea4", + "conversation_timestamp": "2025-01-03T09:10:00.689177Z" + }, + "alert_id": "0445530c-9288-4591-b48a-4fdc2f0aec6c", + "code_snippet": null, + "trigger_string": "`\n\n", + "trigger_type": "code-comment", + "trigger_category": "info", + "timestamp": "2025-01-03T09:10:00.689177Z" + } +] \ No newline at end of file diff --git a/src/mocks/msw/fixtures/GetMessages.json b/src/mocks/msw/fixtures/GetMessages.json new file mode 100644 index 0000000..8e8b115 --- /dev/null +++ b/src/mocks/msw/fixtures/GetMessages.json @@ -0,0 +1,306 @@ +[ + { + "question_answers": [ + { + "question": { + "message": "```/Users/giuseppe/workspace/codegate/src/codegate/server.py\nimport traceback\n\nimport structlog\nfrom fastapi import APIRouter, FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom fastapi.responses import JSONResponse\nfrom starlette.middleware.errors import ServerErrorMiddleware\n\nfrom codegate import __description__, __version__\nfrom codegate.dashboard.dashboard import dashboard_router\nfrom codegate.pipeline.factory import PipelineFactory\nfrom codegate.providers.anthropic.provider import AnthropicProvider\nfrom codegate.providers.llamacpp.provider import LlamaCppProvider\nfrom codegate.providers.ollama.provider import OllamaProvider\nfrom codegate.providers.openai.provider import OpenAIProvider\nfrom codegate.providers.registry import ProviderRegistry\nfrom codegate.providers.vllm.provider import VLLMProvider\n\nlogger = structlog.get_logger(\"codegate\")\n\n\nasync def custom_error_handler(request, exc: Exception):\n \"\"\"This is a Middleware to handle exceptions and log them.\"\"\"\n # Capture the stack trace\n extracted_traceback = traceback.extract_tb(exc.__traceback__)\n # Log only the last 3 items of the stack trace. 3 is an arbitrary number.\n logger.error(traceback.print_list(extracted_traceback[-3:]))\n return JSONResponse({\"error\": str(exc)}, status_code=500)\n\n\ndef init_app(pipeline_factory: PipelineFactory) -> FastAPI:\n \"\"\"Create the FastAPI application.\"\"\"\n app = FastAPI(\n title=\"CodeGate\",\n description=__description__,\n version=__version__,\n )\n app.add_middleware(\n CORSMiddleware,\n allow_origins=[\"*\"],\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n )\n # Apply error handling middleware\n app.add_middleware(ServerErrorMiddleware, handler=custom_error_handler)\n\n # Create provider registry\n registry = ProviderRegistry(app)\n\n # Register all known providers\n registry.add_provider(\n \"openai\",\n OpenAIProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"anthropic\",\n AnthropicProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"llamacpp\",\n LlamaCppProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"vllm\",\n VLLMProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"ollama\",\n OllamaProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n\n # Create and add system routes\n system_router = APIRouter(tags=[\"System\"])\n\n @system_router.get(\"/health\")\n async def health_check():\n return {\"status\": \"healthy\"}\n\n app.include_router(system_router)\n app.include_router(dashboard_router)\n\n return app\n\n```\n\nserver.py do you see any security issue?", + "timestamp": "2025-01-03T09:09:33.743797Z", + "message_id": "a1549789-b610-4999-9907-f8f010c2f3b7" + }, + "answer": { + "message": "Yes, there are several security issues in the provided `server.py` code. Here are the main ones:\n\n1. **CORS Configuration**:\n ```python\n app.add_middleware(\n CORSMiddleware,\n allow_origins=[\"*\"],\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n )\n ```\n - Allowing all origins (`allow_origins=[\"*\"]`) and methods (`allow_methods=[\"*\"]`) can expose your server to Cross-Site Request Forgery (CSRF) attacks and other security vulnerabilities. It's recommended to restrict these settings to only the origins and methods that your application needs to support.\n\n2. **Error Handling Middleware**:\n ```python\n async def custom_error_handler(request, exc: Exception):\n \"\"\"This is a Middleware to handle exceptions and log them.\"\"\"\n # Capture the stack trace\n extracted_traceback = traceback.extract_tb(exc.__traceback__)\n # Log only the last 3 items of the stack trace. 3 is an arbitrary number.\n logger.error(traceback.print_list(extracted_traceback[-3:]))\n return JSONResponse({\"error\": str(exc)}, status_code=500)\n ```\n - Exposing detailed error messages in the response can be dangerous, as it can provide attackers with information that can be used to exploit vulnerabilities. It's better to log the error details and return a generic error message to the client.\n\n3. **Handling Exceptions**:\n - The `custom_error_handler` function logs the traceback and returns the exception message directly to the client. This can expose sensitive information about the server's internal state. It's better to log the error and return a generic message.\n\n4. **Provider Configuration**:\n - The providers are configured with the same pipeline processors. This might not be a security issue in itself, but it's important to ensure that the pipeline processors are secure and correctly configured.\n\n5. **Logging**:\n - The `logger.error` function is used to log the error traceback. Ensure that the logging configuration is set up correctly to prevent logging sensitive information to insecure destinations.\n\nHere is a revised version of the code with some of these issues addressed:\n\n```python\nimport traceback\n\nimport structlog\nfrom fastapi import APIRouter, FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom fastapi.responses import JSONResponse\nfrom starlette.middleware.errors import ServerErrorMiddleware\n\nfrom codegate import __description__, __version__\nfrom codegate.dashboard.dashboard import dashboard_router\nfrom codegate.pipeline.factory import PipelineFactory\nfrom codegate.providers.anthropic.provider import AnthropicProvider\nfrom codegate.providers.llamacpp.provider import LlamaCppProvider\nfrom codegate.providers.ollama.provider import OllamaProvider\nfrom codegate.providers.openai.provider import OpenAIProvider\nfrom codegate.providers.registry import ProviderRegistry\nfrom codegate.providers.vllm.provider import VLLMProvider\n\nlogger = structlog.get_logger(\"codegate\")\n\n\nasync def custom_error_handler(request, exc: Exception):\n \"\"\"This is a Middleware to handle exceptions and log them.\"\"\"\n # Capture the stack trace\n extracted_traceback = traceback.extract_tb(exc.__traceback__)\n # Log only the last 3 items of the stack trace. 3 is an arbitrary number.\n logger.error(traceback.print_list(extracted_traceback[-3:]))\n return JSONResponse({\"error\": \"An internal server error occurred\"}, status_code=500)\n\n\ndef init_app(pipeline_factory: PipelineFactory) -> FastAPI:\n \"\"\"Create the FastAPI application.\"\"\"\n app = FastAPI(\n title=\"CodeGate\",\n description=__description__,\n version=__version__,\n )\n app.add_middleware(\n CORSMiddleware,\n allow_origins=[\"https://example.com\"], # Restrict to specific origins\n allow_credentials=True,\n allow_methods=[\"GET\", \"POST\"], # Restrict to specific methods\n allow_headers=[\"*\"],\n )\n # Apply error handling middleware\n app.add_middleware(ServerErrorMiddleware, handler=custom_error_handler)\n\n # Create provider registry\n registry = ProviderRegistry(app)\n\n # Register all known providers\n registry.add_provider(\n \"openai\",\n OpenAIProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"anthropic\",\n AnthropicProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"llamacpp\",\n LlamaCppProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"vllm\",\n VLLMProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n registry.add_provider(\n \"ollama\",\n OllamaProvider(\n pipeline_processor=pipeline_factory.create_input_pipeline(),\n fim_pipeline_processor=pipeline_factory.create_fim_pipeline(),\n output_pipeline_processor=pipeline_factory.create_output_pipeline(),\n fim_output_pipeline_processor=pipeline_factory.create_fim_output_pipeline(),\n ),\n )\n\n # Create and add system routes\n system_router = APIRouter(tags=[\"System\"])\n\n @system_router.get(\"/health\")\n async def health_check():\n return {\"status\": \"healthy\"}\n\n app.include_router(system_router)\n app.include_router(dashboard_router)\n\n return app\n```\n\nIn this revised version, the CORS middleware is restricted to specific origins and methods, and the error handler returns a generic error message to the client.", + "timestamp": "2025-01-03T09:09:34.359269Z", + "message_id": "68e7c9bc-9afa-4240-8eba-621eaae4a2a0" + } + } + ], + "provider": "vllm", + "type": "chat", + "chat_id": "chatcmpl-eebad2bd68434c7c947d10754a204ea4", + "conversation_timestamp": "2025-01-03T09:09:33.743797Z" + }, + { + "question_answers": [ + { + "question": { + "message": "\n\n```tsx src/App.tsx (23-29)\n const { prompts, loading, fetchPrompts } = usePromptsStore();\n useSse();\n\n const test = \"REDACTED<$lCzMsqxUWElmZqd/qX4llR3pqsrBJVxkt6SB6WXXKKhYG37ZnscxPawjfZmgPVoSpcSR975hOIE2s/6iVr2JETpVdwdaG4hAYlzJ4tteJg==>\";\n const breadcrumb = useBreadcrumb();\n\n\n```\nPlease explain the cause of this error and how to solve it: 'test' is declared but its value is never read.", + "timestamp": "2025-01-02T13:42:48.721165Z", + "message_id": "031cf7a3-1ce6-435d-bbee-0f939b30cc20" + }, + "answer": { + "message": "The error message \"'test' is declared but its value is never read\" indicates that the variable `test` is defined in your code, but it is never used anywhere. This can lead to confusion for other developers reading the code and might indicate that the intended functionality has not been implemented.\n\n### Cause of the Error\n\n1. **Unused Variable**: The variable `test` is declared but not used in the rest of the code within the `App` component. This can be a result of incomplete implementation or a placeholder that was meant to be used later but was forgotten.\n\n### How to Solve It\n\nYou have a few options to resolve this issue:\n\n1. **Remove the Unused Variable**:\n - If the variable is not needed, you can safely remove it to clean up the code and eliminate the warning.\n\n ```tsx\n const { prompts, loading, fetchPrompts } = usePromptsStore();\n useSse();\n\n const breadcrumb = useBreadcrumb();\n\n useEffect(() => {\n fetchPrompts();\n }, [fetchPrompts]);\n ```\n\n2. **Use the Variable**:\n - If the variable is intended to be used, ensure that it is utilized somewhere in the component. For example, you could log it for debugging purposes or use it in some part of the application logic.\n\n ```tsx\n const { prompts, loading, fetchPrompts } = usePromptsStore();\n useSse();\n\n const test = \"REDACTED<$lCzMsqxUWElmZqd/qX4llR3pqsrBJVxkt6SB6WXXKKhYG37ZnscxPawjfZmgPVoSpcSR975hOIE2s/6iVr2JETpVdwdaG4hAYlzJ4tteJg==>\";\n const breadcrumb = useBreadcrumb();\n\n useEffect(() => {\n console.log(test); // Example usage\n fetchPrompts();\n }, [fetchPrompts]);\n ```\n\n3. **Suppress the Warning (Not Recommended)**:\n - If you are sure that the variable is intentionally unused and do not want to remove it, you can suppress the warning. However, this is generally not recommended as it can lead to oversight of real issues.\n\n ```tsx\n // @ts-ignore\n const test = \"REDACTED<$lCzMsqxUWElmZqd/qX4llR3pqsrBJVxkt6SB6WXXKKhYG37ZnscxPawjfZmgPVoSpcSR975hOIE2s/6iVr2JETpVdwdaG4hAYlzJ4tteJg==>\";\n const breadcrumb = useBreadcrumb();\n ```\n\n### Best Practices\n\n- **Keep Code Clean**: Regularly clean up unused variables to maintain a clean and understandable codebase.\n- **Use Linters**: Utilize tools like ESLint to automatically detect and flag unused variables, helping you maintain code quality.\n\nBy addressing this issue, you can improve the maintainability and readability of your code.", + "timestamp": "2025-01-02T13:42:49.361714Z", + "message_id": "a542408b-d0bc-4f6f-8b71-64c93c1e388a" + } + } + ], + "provider": "vllm", + "type": "chat", + "chat_id": "chatcmpl-7d87679de7ed41639eb91d8ebbaa6f72", + "conversation_timestamp": "2025-01-02T13:42:48.721165Z" + }, + { + "question_answers": [ + { + "question": { + "message": "```/Users/giuseppe/workspace/codegate-ui/src/App.tsx\nimport { Header } from \"./components/Header\";\nimport { PromptList } from \"./components/PromptList\";\nimport { useEffect } from \"react\";\nimport { Dashboard } from \"./components/Dashboard\";\nimport { Routes, Route, Link } from \"react-router-dom\";\nimport { Chat } from \"./components/Chat\";\nimport { usePromptsStore } from \"./hooks/usePromptsStore\";\nimport { Sidebar } from \"./components/Sidebar\";\nimport { useSse } from \"./hooks/useSse\";\nimport { Help } from \"./components/Help\";\nimport { Certificates } from \"./components/Certificates\";\nimport { CertificateSecurity } from \"./components/CertificateSecurity\";\nimport {\n Breadcrumb,\n BreadcrumbList,\n BreadcrumbItem,\n BreadcrumbSeparator,\n BreadcrumbPage,\n} from \"./components/ui/breadcrumb\";\nimport { useBreadcrumb } from \"./hooks/useBreadcrumb\";\n\nfunction App() {\n const { prompts, loading, fetchPrompts } = usePromptsStore();\n useSse();\n\n const test = \"REDACTED<$4g3iWc/V3YD6pAXIeA43M197ostjpL3XZuDbJuxTN+jG1Mcjv6cMFcC73SsIDzECoWSuZqSYGkrWe5vQqbheaJbDlocBrPZMkgQWkcP8gw==>\";\n const breadcrumb = useBreadcrumb();\n\n useEffect(() => {\n fetchPrompts();\n }, [fetchPrompts]);\n\n return (\n
\n \n \n \n
\n
\n\n
\n \n \n \n Dashboard\n \n {breadcrumb && (\n <>\n \n \n \n {breadcrumb}\n \n \n \n )}\n \n \n
\n\n
\n \n } />\n } />\n } />\n } />\n }\n />\n \n
\n
\n
\n );\n}\n\nexport default App;\n\n```\n\nApp.tsx could you review?", + "timestamp": "2025-01-02T13:40:18.343146Z", + "message_id": "33b28648-c3a8-4f52-a110-e59a19dc6fab" + }, + "answer": { + "message": "**CodeGate Security Analysis**\n\n### Security Vulnerabilities and Potential Risks\n\n1. **Unsanitized User Input and Cross-Site Scripting (XSS)**\n - The `breadcrumb` variable, which is derived from user interaction, is directly rendered within the `` component. If the `breadcrumb` contains user-controlled data, it could be vulnerable to XSS attacks if not properly sanitized.\n\n2. **Potential Sensitive Data Exposure**\n - The `test` variable contains a string that begins with \"REDACTED\", indicating it may contain sensitive information. Ensure that such strings are not exposed or logged in a manner that could lead to data breaches.\n\n3. **Lack of Authentication and Authorization**\n - The code does not include any authentication or authorization mechanisms. This could allow unauthorized users to access sensitive components like `/certificates` and `/certificates/security`.\n\n4. **Security of Sensitive Components**\n - Components like `CertificateSecurity` and `Certificates` might handle sensitive information. Ensure that these components implement proper security measures to protect the data they handle.\n\n### Best Practices for Secure Implementation\n\n1. **Sanitize and Encode User Input**\n - Always sanitize and encode user inputs to prevent XSS attacks. Use libraries like `DOMPurify` to sanitize HTML content.\n\n2. **Implement Authentication and Authorization**\n - Integrate a robust authentication system (e.g., OAuth, JWT) to ensure that only authorized users can access sensitive routes and components.\n\n3. **Protect Sensitive Data**\n - Ensure that any sensitive data, such as certificates and security-related information, is encrypted both at rest and in transit. Use HTTPS for all communications.\n\n4. **Regular Security Audits and Testing**\n - Conduct regular security audits and penetration testing to identify and fix vulnerabilities in the application.\n\n### Recommendations for Security Improvements\n\n1. **Sanitize Breadcrumb Data**\n - Modify the `BreadcrumbPage` component to sanitize the `breadcrumb` data before rendering it. For example:\n ```jsx\n \n {DOMPurify.sanitize(breadcrumb)}\n \n ```\n\n2. **Implement Authentication**\n - Use a library like `react-router-dom` with authentication middleware to protect routes. For example:\n ```jsx\n \n \n \n }\n />\n ```\n\n3. **Secure Components**\n - Ensure that components like `CertificateSecurity` and `Certificates` implement proper security measures, such as input validation, encryption, and access controls.\n\n4. **Review and Secure Dependencies**\n - Regularly review and update dependencies to ensure they are secure and free from known vulnerabilities. Use tools like `npm audit` to identify and fix vulnerabilities.\n\n### References to Relevant Security Standards or Guidelines\n\n- **OWASP Top Ten**: A list of the most critical security risks to web applications, including XSS and injection flaws.\n- **OWASP Security Testing Guide**: Provides detailed guidance on how to test for various security vulnerabilities.\n- **NIST Cybersecurity Framework**: Offers a comprehensive set of guidelines for managing and reducing cybersecurity risks.\n\nBy addressing these security considerations, you can significantly enhance the security posture of your application.", + "timestamp": "2025-01-02T13:40:18.881023Z", + "message_id": "82b89210-811a-478d-9229-e45bd3d60913" + } + } + ], + "provider": "vllm", + "type": "chat", + "chat_id": "chatcmpl-92720293078e459e9d65be5298a9dae6", + "conversation_timestamp": "2025-01-02T13:40:18.343146Z" + }, + { + "question_answers": [ + { + "question": { + "message": "hello", + "timestamp": "2025-01-02T13:39:39.656516Z", + "message_id": "1273fc1a-43e7-42c3-82b0-0057858d9b98" + }, + "answer": { + "message": "Hello! How can I assist you today?", + "timestamp": "2025-01-02T13:39:40.159594Z", + "message_id": "24aa2eec-f5bc-4275-8e30-a8f68d3f3002" + } + } + ], + "provider": "vllm", + "type": "chat", + "chat_id": "chatcmpl-40c88006b69940dab2d454175ff4c533", + "conversation_timestamp": "2025-01-02T13:39:39.656516Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/src/App.tsx b/src/App.tsx\n// index fafa5bf..46b5fbd 100644\n// --- a/src/App.tsx\n// +++ b/src/App.tsx\n// @@ -22,6 +22,8 @@ import { useBreadcrumb } from \"./hooks/useBreadcrumb\";\n// function App() {\n// const { prompts, loading, fetchPrompts } = usePromptsStore();\n// useSse();\n// +\n// + cosnt test = REDACTED<$u0UEa5CGkrHrKv9oWKNC/aUuzW/D1d0ULifi+LvgIaGefP/xzkPr73YSZpciPs1YUAfjgcx35E3X81EwaKw4C68LTZuOXBBHEzZokLNZbg==>\n// const breadcrumb = useBreadcrumb();\n// \n// useEffect(() => {\n// src/App.tsx\nimport { useEffect } from \"react\";\nimport { Dashboard } from \"./components/Dashboard\";\nimport { Routes, Route, Link } from \"react-router-dom\";\nimport { Chat } from \"./components/Chat\";\nimport { usePromptsStore } from \"./hooks/usePromptsStore\";\nimport { Sidebar } from \"./components/Sidebar\";\nimport { useSse } from \"./hooks/useSse\";\nimport { Help } from \"./components/Help\";\nimport { Certificates } from \"./components/Certificates\";\nimport { CertificateSecurity } from \"./components/CertificateSecurity\";\nimport {\n Breadcrumb,\n BreadcrumbList,\n BreadcrumbItem,\n BreadcrumbSeparator,\n BreadcrumbPage,\n} from \"./components/ui/breadcrumb\";\nimport { useBreadcrumb } from \"./hooks/useBreadcrumb\";\n\nfunction App() {\n const { prompts, loading, fetchPrompts } = usePromptsStore();\n useSse();\n\n cosnt test = 'REDACTED<$m2fVY6C1zlk0swockzeQM/vDxL0h6im+Ber6vzYFFplvdR7dncAecjH18/Wptj0h3lQu7xCKxCFfCXxn7qe0clMZisPnRvohJOS/+W6P/m0++N/asPFkZnhJ3YPS>'\n const breadcrumb = useBreadcrumb();\n\n useEffect(() => {\n fetchPrompts();\n }, [fetchPrompts]);\n\n return (\n
\n \n \n \n
\n
\n\n
\n \n \n \n Dashboard\n \n {breadcrumb && (\n <>\n \n <|fim_middle|>", + "timestamp": "2025-01-02T13:40:06.097504Z", + "message_id": "ccf1c87a-4846-4d81-b69f-f882f1971cf7" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "ccf1c87a-4846-4d81-b69f-f882f1971cf7", + "conversation_timestamp": "2025-01-02T13:40:06.097504Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|im_start|>user\n```tsx\nimport { Header } from \"./components/Header\";\nimport { PromptList } from \"./components/PromptList\";\nimport { useEffect } from \"react\";\nimport { Dashboard } from \"./components/Dashboard\";\nimport { Routes, Route, Link } from \"react-router-dom\";\nimport { Chat } from \"./components/Chat\";\nimport { usePromptsStore } from \"./hooks/usePromptsStore\";\nimport { Sidebar } from \"./components/Sidebar\";\nimport { useSse } from \"./hooks/useSse\";\nimport { Help } from \"./components/Help\";\nimport { Certificates } from \"./components/Certificates\";\nimport { CertificateSecurity } from \"./components/CertificateSecurity\";\nimport {\n Breadcrumb,\n BreadcrumbList,\n BreadcrumbItem,\n BreadcrumbSeparator,\n BreadcrumbPage,\n} from \"./components/ui/breadcrumb\";\nimport { useBreadcrumb } from \"./hooks/useBreadcrumb\";\n\nfunction App() {\n const { prompts, loading, fetchPrompts } = usePromptsStore();\n useSse();\n\n const test = \"REDACTED<$lAJek6QoLZgSKq3z4ybqMVFOCtiHQtP8hbBzWeQysFQoGwwNrEghIPnFCsXY985bpTjx4ZIiBzx11E1yM3ybbUzoxG/W4TrUPzM4aHAjIg==>\";\n const breadcrumb = useBreadcrumb();\n\n useEffect(() => {\n fetchPrompts();\n }, [fetchPrompts]);\n\n return (\n
\n \n \n \n
\n
\n\n
\n \n \n \n Dashboard\n \n {breadcrumb && (\n <>\n \n \n \n {breadcrumb}\n \n \n \n )}\n \n \n
\n\n
\n \n } />\n } />\n } />\n } />\n }\n />\n \n
\n
\n
\n );\n}\n\nexport default App;\n\n\n```\n\nPlease rewrite the entire code block above in order to satisfy the following request: \"The following code was suggested as an edit:\n```\n// @ts-ignore\nconst test = \"REDACTED<$gGYIqfbrVCHST8Xn/yfGtFDfQQ3Kn6mQ9t1+YrUCKYxNEiRYb4u9BQmxZkOQE5I+9UZRasD0/bY3m00v4OSo+PI6Zzn97RSVNJgM47nUlQ==>\";\nconst breadcrumb = useBreadcrumb();\n```\nPlease apply it to the previous code.\". You should rewrite the entire code block without leaving placeholders, even if the code is the same as before.<|im_end|>\n<|im_start|>assistant\nSure! Here's the entire rewritten code block:\n```tsx\n", + "timestamp": "2025-01-02T14:19:58.024100Z", + "message_id": "b97fbe59-0e34-4b98-8f2f-41332ebc059a" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "b97fbe59-0e34-4b98-8f2f-41332ebc059a", + "conversation_timestamp": "2025-01-02T14:19:58.024100Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/package.json b/package.json\n// index 3b62d87..4774c65 100644\n// --- a/package.json\n// +++ b/package.json\n// @@ -21,7 +21,6 @@\n// \"@radix-ui/react-switch\": \"^1.1.1\",\n// \"@radix-ui/react-tooltip\": \"^1.1.6\",\n// \"@types/prismjs\": \"^1.26.5\",\n// - \"@types/react-copy-to-clipboard\": \"^5.0.7\",\n// \"@types/react-syntax-highlighter\": \"^15.5.13\",\n// \"class-variance-authority\": \"^0.7.1\",\n// \"clsx\": \"^2.1.1\",\n// @@ -29,7 +28,6 @@\n// \"lucide-react\": \"^0.462.0\",\n// \"prismjs\": \"^1.29.0\",\n// \"react\": \"^18.3.1\",\n// - \"react-copy-to-clipboard\": \"^5.1.0\",\n// \"react-dom\": \"^18.3.1\",\n// \"react-markdown\": \"^9.0.1\",\n// \"react-router-dom\": \"^7.0.2\",\n// @@ -61,4 +59,4 @@\n// \"typescript-eslint\": \"^8.15.0\",\n// \"vite\": \"^6.0.1\"\n// }\n// -}\n// +}\n// \\ No newline at end of file\n// diff --git a/src/components/CopyToClipboard.tsx b/src/components/CopyToClipboard.tsx\n// new file mode 100644\n// index 0000000..682af0c\n// --- /dev/null\n// +++ b/src/components/CopyToClipboard.tsx\n// @@ -0,0 +1,31 @@\n// +import clsx from \"clsx\";\n// +import { ClipboardCopy } from \"lucide-react\";\n// +\n// +export function CopyToClipboard({\n// + text,\n// + className,\n// +}: {\n// + className?: string;\n// + text: string;\n// +}) {\n// + const copyToClipboard = async () => {\n// + try {\n// + await navigator.clipboard.writeText(text);\n// + } catch {}\n// + };\n// +\n// + return (\n// + \n// + \n// + \n// + );\n// +}\n// Path: Untitled.txt\n// navigator.clipboard.writeText\n// components/CopyToClipboard.tsx\nimport clsx from \"clsx\";\nimport { ClipboardCopy } from \"lucide-react\";\n\nexport function CopyToClipboard({\n text,\n className,\n}: {\n className?: string;\n text: string;\n}) {\n const copyToClipboard = async () => {\n try {\n await navigator.clipboard.writeText(text);\n } catch {}\n };\n\n return (\n hover:bg-gray-700/70 \n transition-opacity duration-200 \n opacity-0 group-hover:opacity-100`,\n className\n )}\n >\n \n \n );\n}\n<|fim_middle|>", + "timestamp": "2025-01-02T15:00:12.114817Z", + "message_id": "27318899-9e9b-4dfa-9e61-f482dcd24e54" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "27318899-9e9b-4dfa-9e61-f482dcd24e54", + "conversation_timestamp": "2025-01-02T15:00:12.114817Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>\n// components/Markdown.tsx\nimport remarkGfm from \"remark-gfm\";\nimport ReactMarkdown from \"react-markdown\";\nimport { Prism as SyntaxHighlighter } from \"react-syntax-highlighter\";\nimport { oneDark } from \"react-syntax-highlighter/dist/esm/styles/prism\";\nimport { cn } from \"@/lib/utils\";\nimport { CopyToClipboard } from \"./CopyToClipboard\";\n\ninterface Props {\n children: string;\n className?: string;\n}\n\nconst customStyle = {\n ...oneDark,\n 'pre[class*=\"language-\"]': {\n ...oneDark['pre[class*=\"language-\"]'],\n whiteSpace: \"pre-wrap\",\n background: \"#re<|fim_suffix|>\",\n padding: \"1.5rem\",\n borderRadius: \"0.5rem\",\n margin: \"1.5rem 0\",\n fontSize: \"10px\",\n width: \"80%\", // Ensure the block takes full width\n position: \"relative\",\n },\n};\n\nexport function Markdown({ children, className = \"\" }: Props) {\n return (\n <|fim_middle|>", + "timestamp": "2025-01-02T17:01:41.579128Z", + "message_id": "4ea5d1df-c724-49f7-a132-d19e092b52c8" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "4ea5d1df-c724-49f7-a132-d19e092b52c8", + "conversation_timestamp": "2025-01-02T17:01:41.579128Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// Path: Untitled.txt\n// 1a1b26\n// components/Markdown.tsx\n // whiteSpace: \"pre-wrap\",\n // background: \"#1a1b26\",\n // padding: \"1.5rem\",\n // borderRadius: \"0.5rem\",\n // margin: \"1.5rem 0\",\n // fontSize: \"10px\",\n // width: \"80%\", // Ensure the block takes full width\n // position: \"relative\",\n // },\n};\n\nexport function Markdown({ children, className = \"\" }: Props) {\n return (\n \n 1a1b26\",\n // fontSize: \"10x\",\n // whiteSpace: \"pre-wrap\",\n // padding: \"1.5rem\",\n // borderRadius: \"0.5rem\",\n // margin: \"1.5rem 0\",\n // position: \"relative\", // Critical for clipboard positioning\n // width: \"100%\", // Ensure full width of parent container\n // boxSizing: \"border-box\", // Prevent padding overflow\n },\n }}\n language={match[1]}\n PreTag=\"div\"\n className=\"rounded-lg overflow-hidden shadow-lg text-sm\"\n showLineNumbers={false}\n wrapLines\n {...props}\n ><|fim_middle|>", + "timestamp": "2025-01-02T17:08:08.428889Z", + "message_id": "203fe119-0e58-43b5-a863-73f30f73d272" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "203fe119-0e58-43b5-a863-73f30f73d272", + "conversation_timestamp": "2025-01-02T17:08:08.428889Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>\n// components/Markdown.tsx\n}\n\nconst customStyle = {\n ...oneDark,\n 'pre[class*=\"language-\"]': {\n ...oneDark['pre[class*=\"language-\"]'],\n whiteSpace: \"pre-wrap\",\n // background: \"#1a1b26\",\n padding: \"1.5rem\",\n borderRadius: \"0.5rem\",\n margin: \"1.5rem 0\",\n fontSize: \"10px\",\n width: \"80%\", // Ensure the block takes full width\n position: \"relative\",\n },\n};\n\nexport function Markdown({ children, className = \"\" }: Props) {\n return (\n \n \"\n showLineNumbers={false}\n wrapLines\n {...props}\n >\n {String(children).replace(/\\n$/, \"\")}\n \n \n
\n ) : (\n ", + "timestamp": "2025-01-02T17:20:32.921469Z", + "message_id": "d81ca662-84ae-4114-9041-6d640c547bb9" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "d81ca662-84ae-4114-9041-6d640c547bb9", + "conversation_timestamp": "2025-01-02T17:20:32.921469Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// Path: Untitled.txt\n// showLineNumbers\n// components/Markdown.tsx\n background: \"none\",\n padding: \"0\",\n borderRadius: \"0\",\n fontSize: \"inherit\",\n color: \"inherit\",\n display: \"inline\",\n },\n 'pre[class*=\"language-\"]': {\n ...oneDark['pre[class*=\"language-\"]'],\n whiteSpace: \"pre-wrap\",\n background: \"#1a1b26\",\n padding: \"1.5rem\",\n borderRadius: \"0.5rem\",\n margin: \"1.5rem 0\",\n fontSize: \"10px\",\n width: \"80%\",\n position: \"relative\",\n },\n};\nexport function Markdown({ children, className = \"\" }: Props) {\n return (\n \n ={{\n ...customStyle,\n 'pre[class*=\"language-\"]': {\n ...oneDark['pre[class*=\"language-\"]'],\n background: \"#1a1b26\",\n padding: \"1.5rem\",\n borderRadius: \"0.5rem\",\n margin: \"1.5rem 0\",\n width: \"100%\",\n position: \"relative\",\n boxSizing: \"border-box\",\n },\n }}\n language={match[1]}\n PreTag=\"div\"\n className=\"rounded-lg overflow-hidden shadow-lg text-sm\"\n wrapLines\n {...props}\n >\n {String(children).replace(/\\n$/, \"\")}\n <|fim_middle|>", + "timestamp": "2025-01-02T17:25:40.052416Z", + "message_id": "bb2ab808-1ce7-4937-9d79-0d773dcb7111" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "bb2ab808-1ce7-4937-9d79-0d773dcb7111", + "conversation_timestamp": "2025-01-02T17:25:40.052416Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/package.json b/package.json\n// index 42ed9d9..6b1ddde 100644\n// --- a/package.json\n// +++ b/package.json\n// @@ -25,6 +25,7 @@\n// \"class-variance-authority\": \"^0.7.1\",\n// \"clsx\": \"^2.1.1\",\n// \"date-fns\": \"^4.1.0\",\n// + \"highlight.js\": \"^11.11.1\",\n// \"lucide-react\": \"^0.462.0\",\n// \"prismjs\": \"^1.29.0\",\n// \"react\": \"19.0.0\",\n// components/Markdown.tsx\nimport hljs from \"highlight.js\";\n\ninterface Props {\n children: string;\n className?: string;\n}\nconsole.log({ oneDark });\nconst customStyle = {\n ...oneDark,\n 'code[class*=\"language-\"]': {\n ...oneDark['code[class*=\"language-\"]'],\n background: \"none\",\n },\n 'pre[class*=\"language-\"]': {\n ...oneDark['pre[class*=\"language-\"]'],\n whiteSpace: \"pre-wrap\",\n background: \"#1a1b26\",\n padding: \"1.5rem\",\n borderRadius: \"0.5rem\",\n margin: \"1.5rem 0\",\n fontSize: \"10px\",\n width: \"80%\",\n position: \"relative\",\n },\n};\nexport function Markdown({ children, className = \"\" }: Props) {\n \n return (\n ).language;\n console.log({ detectedLanguage });\n const match = /language-(\\w+)/.exec(className || \"\");\n const inline = !match;\n return !inline ? (\n
\n ", + "timestamp": "2025-01-03T10:22:01.721847Z", + "message_id": "9b522dca-a54e-4356-9692-d5be66f051cc" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "9b522dca-a54e-4356-9692-d5be66f051cc", + "conversation_timestamp": "2025-01-03T10:22:01.721847Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/package.json b/package.json\n// index 42ed9d9..6b1ddde 100644\n// --- a/package.json\n// +++ b/package.json\n// @@ -25,6 +25,7 @@\n// \"class-variance-authority\": \"^0.7.1\",\n// \"clsx\": \"^2.1.1\",\n// \"date-fns\": \"^4.1.0\",\n// + \"highlight.js\": \"^11.11.1\",\n// \"lucide-react\": \"^0.462.0\",\n// \"prismjs\": \"^1.29.0\",\n// \"react\": \"19.0.0\",\n// Path: Untitled.txt\n// a11yDark\n// components/Markdown.tsx\nconst customStyle = {\n ...oneDark,\n 'code[class*=\"language-\"]': {\n ...oneDark['code[class*=\"language-\"]'],\n background: \"none\",\n },\n 'pre[class*=\"language-\"]': {\n ...oneDark['pre[class*=\"language-\"]'],\n whiteSpace: \"pre-wrap\",\n background: \"#1a1b26\",\n padding: \"1.5rem\",\n borderRadius: \"0.5rem\",\n margin: \"1.5rem 0\",\n fontSize: \"10px\",\n width: \"80%\",\n position: \"relative\",\n },\n};\nexport function Markdown({ children, className = \"\" }: Props) {\n return (\n \n return (\n <>\n \n {String(children).replace(/\\n$/, \"\")}<|fim_middle|>", + "timestamp": "2025-01-03T10:59:20.862404Z", + "message_id": "b21cb89e-f5f0-4cbe-95a6-7407bf59199d" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "b21cb89e-f5f0-4cbe-95a6-7407bf59199d", + "conversation_timestamp": "2025-01-03T10:59:20.862404Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/package.json b/package.json\n// index 42ed9d9..6b1ddde 100644\n// --- a/package.json\n// +++ b/package.json\n// @@ -25,6 +25,7 @@\n// \"class-variance-authority\": \"^0.7.1\",\n// \"clsx\": \"^2.1.1\",\n// \"date-fns\": \"^4.1.0\",\n// + \"highlight.js\": \"^11.11.1\",\n// \"lucide-react\": \"^0.462.0\",\n// \"prismjs\": \"^1.29.0\",\n// \"react\": \"19.0.0\",\n// components/Markdown.tsx\n children: string;\n className?: string;\n}\nconsole.log({ oneDark });\nconst customStyle = {\n ...oneDark,\n 'code[class*=\"language-\"]': {\n ...oneDark['code[class*=\"language-\"]'],\n background: \"none\",\n },\n 'pre[class*=\"language-\"]': {\n ...oneDark['pre[class*=\"language-\"]'],\n whiteSpace: \"pre-wrap\",\n background: \"#1a1b26\",\n padding: \"1.5rem\",\n borderRadius: \"0.5rem\",\n margin: \"1.5rem 0\",\n fontSize: \"10px\",\n width: \"80%\",\n position: \"relative\",\n },\n};\nexport function Markdown({ children, className = \"\" }: Props) {\n return (\n >\n \n {String(children).replace(/\\n$/, \"\")}\n <|fim_middle|>", + "timestamp": "2025-01-03T11:05:21.749423Z", + "message_id": "a5bd2d58-4339-4bbd-a5b0-8f65ff758b46" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "a5bd2d58-4339-4bbd-a5b0-8f65ff758b46", + "conversation_timestamp": "2025-01-03T11:05:21.749423Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/package.json b/package.json\n// index 42ed9d9..6b1ddde 100644\n// --- a/package.json\n// +++ b/package.json\n// @@ -25,6 +25,7 @@\n// \"class-variance-authority\": \"^0.7.1\",\n// \"clsx\": \"^2.1.1\",\n// \"date-fns\": \"^4.1.0\",\n// + \"highlight.js\": \"^11.11.1\",\n// \"lucide-react\": \"^0.462.0\",\n// \"prismjs\": \"^1.29.0\",\n// \"react\": \"19.0.0\",\n// diff --git a/src/components/ui/chat/chat-bubble.tsx b/src/components/ui/chat/chat-bubble.tsx\n// index b9d20ec..1be8760 100644\n// --- a/src/components/ui/chat/chat-bubble.tsx\n// +++ b/src/components/ui/chat/chat-bubble.tsx\n// @@ -107,7 +107,7 @@ const ChatBubbleMessage = React.forwardRef<\n// const customStyle = {\n ...oneDark,\n 'code[class*=\"language-\"]': {\n ...oneDark['code[class*=\"language-\"]'],\n background: \"none\",\n },\n 'pre[class*=\"language-\"]': {\n ...oneDark['pre[class*=\"language-\"]'],\n whiteSpace: \"pre-wrap\",\n background: \"#1a1b26\",\n padding: \"1.5rem\",\n borderRadius: \"0.5rem\",\n margin: \"1.5rem 0\",\n fontSize: \"10px\",\n width: \"80%\",\n position: \"relative\",\n },\n};\nexport function Markdown({ children, className = \"\" }: Props) {\n return (\n ", + "timestamp": "2025-01-03T11:32:56.031157Z", + "message_id": "63dee5cb-444e-484c-8259-83be0ea073ac" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "63dee5cb-444e-484c-8259-83be0ea073ac", + "conversation_timestamp": "2025-01-03T11:32:56.031157Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/package.json b/package.json\n// index 42ed9d9..6b1ddde 100644\n// --- a/package.json\n// +++ b/package.json\n// @@ -25,6 +25,7 @@\n// \"class-variance-authority\": \"^0.7.1\",\n// \"clsx\": \"^2.1.1\",\n// \"date-fns\": \"^4.1.0\",\n// + \"highlight.js\": \"^11.11.1\",\n// \"lucide-react\": \"^0.462.0\",\n// \"prismjs\": \"^1.29.0\",\n// \"react\": \"19.0.0\",\n// diff --git a/src/components/ui/chat/chat-bubble.tsx b/src/components/ui/chat/chat-bubble.tsx\n// index b9d20ec..1be8760 100644\n// --- a/src/components/ui/chat/chat-bubble.tsx\n// +++ b/src/components/ui/chat/chat-bubble.tsx\n// @@ -107,7 +107,7 @@ const ChatBubbleMessage = React.forwardRef<\n// \n} from \"react-syntax-highlighter\";\nimport { oneDark } from \"react-syntax-highlighter/dist/esm/styles/prism\";\nimport { cn } from \"@/lib/utils\";\nimport { CopyToClipboard } from \"./CopyToClipboard\";\nimport hljs from \"highlight.js\";\n\nconst LANGUAGES_SUBSET_DETECTION = [\n \"bash\",\n \"c\",\n \"cpp\",\n \"csharp\",\n \"css\",\n \"elixir\",\n \"go\",\n \"groovy\",\n \"haskell\",\n \"html\",\n \"java\",\n \"javascript\",\n \"json\",\n \"kotlin\",\n \"lua\",\n \"markdown\",\n \"perl\",\n \"php\",<|fim_middle|>", + "timestamp": "2025-01-03T11:56:42.129289Z", + "message_id": "cd2f0343-5b65-4848-a694-79acb3e4de7b" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "cd2f0343-5b65-4848-a694-79acb3e4de7b", + "conversation_timestamp": "2025-01-03T11:56:42.129289Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/package.json b/package.json\n// index 42ed9d9..6b1ddde 100644\n// --- a/package.json\n// +++ b/package.json\n// @@ -25,6 +25,7 @@\n// \"class-variance-authority\": \"^0.7.1\",\n// \"clsx\": \"^2.1.1\",\n// \"date-fns\": \"^4.1.0\",\n// + \"highlight.js\": \"^11.11.1\",\n// \"lucide-react\": \"^0.462.0\",\n// \"prismjs\": \"^1.29.0\",\n// \"react\": \"19.0.0\",\n// diff --git a/src/components/ui/chat/chat-bubble.tsx b/src/components/ui/chat/chat-bubble.tsx\n// index b9d20ec..1be8760 100644\n// --- a/src/components/ui/chat/chat-bubble.tsx\n// +++ b/src/components/ui/chat/chat-bubble.tsx\n// @@ -107,7 +107,7 @@ const ChatBubbleMessage = React.forwardRef<\n// /prism\";\nimport { cn } from \"@/lib/utils\";\nimport { CopyToClipboard } from \"./CopyToClipboard\";\n// import hljs from \"highlight.js\";\n\nconst LANGUAGES_SUBSET_DETECTION = [\n \"bash\",\n \"c\",\n \"cpp\",\n \"csharp\",\n \"css\",\n \"elixir\",\n \"go\",\n \"groovy\",\n \"haskell\",\n \"html\",\n \"java\",\n \"javascript\",\n \"json\",\n \"kotlin\",\n \"lua\",\n \"markdown\",\n \"perl\",\n \"php\",\n \"python\",\n \"ruby\",\n \"rust\",\n \"scala\",\n \"sql\",\n \"swift\",\n \"typescript\",<|fim_middle|>", + "timestamp": "2025-01-03T12:10:18.944843Z", + "message_id": "52bf2933-2a34-4d78-8368-9fccb26da0a2" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "52bf2933-2a34-4d78-8368-9fccb26da0a2", + "conversation_timestamp": "2025-01-03T12:10:18.944843Z" + }, + { + "question_answers": [ + { + "question": { + "message": "<|fim_prefix|>// diff --git a/package.json b/package.json\n// index 42ed9d9..6b1ddde 100644\n// --- a/package.json\n// +++ b/package.json\n// @@ -25,6 +25,7 @@\n// \"class-variance-authority\": \"^0.7.1\",\n// \"clsx\": \"^2.1.1\",\n// \"date-fns\": \"^4.1.0\",\n// + \"highlight.js\": \"^11.11.1\",\n// \"lucide-react\": \"^0.462.0\",\n// \"prismjs\": \"^1.29.0\",\n// \"react\": \"19.0.0\",\n// diff --git a/src/components/ui/chat/chat-bubble.tsx b/src/components/ui/chat/chat-bubble.tsx\n// index b9d20ec..1be8760 100644\n// --- a/src/components/ui/chat/chat-bubble.tsx\n// +++ b/src/components/ui/chat/chat-bubble.tsx\n// @@ -107,7 +107,7 @@ const ChatBubbleMessage = React.forwardRef<\n// \n return (\n
\n ", + "timestamp": "2025-01-03T14:47:23.644901Z", + "message_id": "b57a9d41-c022-4e72-9b80-e96eed86a6ba" + }, + "answer": null + } + ], + "provider": "vllm", + "type": "fim", + "chat_id": "b57a9d41-c022-4e72-9b80-e96eed86a6ba", + "conversation_timestamp": "2025-01-03T14:47:23.644901Z" + } +] \ No newline at end of file diff --git a/src/mocks/msw/handlers.ts b/src/mocks/msw/handlers.ts index 7711de4..1b17d7f 100644 --- a/src/mocks/msw/handlers.ts +++ b/src/mocks/msw/handlers.ts @@ -1,12 +1,12 @@ import { http, HttpResponse } from "msw"; +import mockedPrompts from "@/mocks/msw/fixtures/GetMessages.json"; +import mockedAlerts from "@/mocks/msw/fixtures/GetAlerts.json"; export const handlers = [ - http.get("https://example.com/user", () => { - // ...and respond to them using this JSON response. - return HttpResponse.json({ - id: "c7b3d8e0-5e0b-4b0f-8b3a-3b9f4b3d3b3d", - firstName: "John", - lastName: "Maverick", - }); + http.get("*/dashboard/messages", () => { + return HttpResponse.json(mockedPrompts); + }), + http.get("*/dashboard/alerts", () => { + return HttpResponse.json(mockedAlerts); }), ];