diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b608e88..0744f896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.14.0](https://github.com/stacklok/codegate-ui/compare/v0.13.1...v0.14.0) (2025-02-07) + + +### Features + +* show alert detail in the conversation page ([#277](https://github.com/stacklok/codegate-ui/issues/277)) ([8154d3e](https://github.com/stacklok/codegate-ui/commit/8154d3e9c8082f6aac0fc2914621dd99f8f71936)) + ## [0.13.1](https://github.com/stacklok/codegate-ui/compare/v0.13.0...v0.13.1) (2025-02-07) diff --git a/package-lock.json b/package-lock.json index 4ddf4a85..5260ba41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vite-project", - "version": "0.13.1", + "version": "0.14.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vite-project", - "version": "0.13.1", + "version": "0.14.0", "dependencies": { "@hey-api/client-fetch": "^0.7.1", "@monaco-editor/react": "^4.6.0", diff --git a/package.json b/package.json index 7aa7d0ae..22be71a1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vite-project", "private": true, - "version": "0.13.1", + "version": "0.14.0", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/AlertDetail.tsx b/src/components/AlertDetail.tsx new file mode 100644 index 00000000..10de3054 --- /dev/null +++ b/src/components/AlertDetail.tsx @@ -0,0 +1,55 @@ +import { AlertConversation } from "@/api/generated"; +import { isAlertMalicious } from "@/features/alerts/lib/is-alert-malicious"; +import { isAlertSecret } from "@/features/alerts/lib/is-alert-secret"; +import { Markdown } from "./Markdown"; + +type MaliciousPkgType = { + name: string; + type: string; + status: string; + description: string; +}; + +export function AlertDetail({ alert }: { alert: AlertConversation }) { + if (alert.trigger_string === null) return "N/A"; + if (isAlertSecret(alert) && typeof alert.trigger_string === "string") { + return ( +
+ {alert.trigger_string} +
+ ); + } + + if (isAlertMalicious(alert) && typeof alert.trigger_string === "object") { + const maliciousPkg = alert.trigger_string as MaliciousPkgType; + + return ( +
+ +   + + {maliciousPkg.type}/{maliciousPkg.name} + + {maliciousPkg.status && ( + <> +
+ {maliciousPkg.status} + + )} + {maliciousPkg.description && ( + <> +
+ {" "} + {maliciousPkg.description} + + )} +
+ ); + } + return null; +} diff --git a/src/routes/route-chat.tsx b/src/routes/route-chat.tsx index 30f1b5f3..6cda4069 100644 --- a/src/routes/route-chat.tsx +++ b/src/routes/route-chat.tsx @@ -8,11 +8,14 @@ import { ChatBubbleMessage, } from "@/components/ui/chat/chat-bubble"; import { Markdown } from "@/components/Markdown"; -import { Breadcrumb, Breadcrumbs } from "@stacklok/ui-kit"; +import { Breadcrumb, Breadcrumbs, Card, CardBody } from "@stacklok/ui-kit"; import { BreadcrumbHome } from "@/components/BreadcrumbHome"; +import { useQueryGetWorkspaceAlertTable } from "@/features/alerts/hooks/use-query-get-workspace-alerts-table"; +import { AlertDetail } from "@/components/AlertDetail"; export function RouteChat() { const { id } = useParams(); + const { data = [] } = useQueryGetWorkspaceAlertTable(); const { data: prompts } = useQueryGetWorkspaceMessages(); const chat = prompts?.find((prompt) => prompt.chat_id === id); @@ -28,6 +31,13 @@ export function RouteChat() { chat.conversation_timestamp, ); + // we have an issue on BE, we received duplicated alerts + const alertDetail = data.filter((alert) => + alert.conversation.question_answers.some( + (item) => item.question.message_id === id, + ), + )[0]; + return ( <> @@ -36,6 +46,14 @@ export function RouteChat() {
+ {alertDetail && ( + + + + + + )} + {(chat?.question_answers ?? []).map(({ question, answer }, index) => (