From c618174e60e4632d36d7352d83399508c72b2f42 Mon Sep 17 00:00:00 2001 From: soryu Date: Tue, 27 Jan 2026 11:04:20 +0000 Subject: Add Red Team CLI command and frontend UI (#39) * Add Red Team CLI command and frontend UI Backend additions: - Add `makima red-team notify` CLI command for red team tasks - Add RedTeamCommand enum with Notify subcommand - Add red_team API client module for notify endpoint - Add RedTeamNotifyArgs with severity, task, file, context options Frontend additions: - Add ContractCreateModal with red team toggle and prompt input - Update ContractDetail with red-team tab for notifications - Update ContractList with red team enabled badge - Add TypeScript types for RedTeamNotification and related interfaces Co-Authored-By: Claude Opus 4.5 * Add CSS styles for Red Team frontend components Add comprehensive styling for: - Contract list and detail containers - Red team badge styling with gradient backgrounds - Tab navigation with red team specific styling - Red team notifications panel with severity indicators - Contract creation modal form elements - Task badges for supervisor and red team roles Co-Authored-By: Claude Opus 4.5 * Fix missing local_only field in TUI CreateContractRequest Add the missing local_only field to the CreateContractRequest struct initialization in the TUI contract creation handler. Co-Authored-By: Claude Opus 4.5 * [WIP] Heartbeat checkpoint - 2026-01-27 03:07:28 UTC --------- Co-authored-by: Claude Opus 4.5 --- frontend/src/components/ContractCreateModal.tsx | 185 ++++++++++++++++++++++++ frontend/src/components/ContractDetail.tsx | 139 +++++++++++++++++- frontend/src/components/ContractList.tsx | 61 +++++--- 3 files changed, 363 insertions(+), 22 deletions(-) create mode 100644 frontend/src/components/ContractCreateModal.tsx (limited to 'frontend/src/components') diff --git a/frontend/src/components/ContractCreateModal.tsx b/frontend/src/components/ContractCreateModal.tsx new file mode 100644 index 0000000..e1d9732 --- /dev/null +++ b/frontend/src/components/ContractCreateModal.tsx @@ -0,0 +1,185 @@ +import React, { useState } from 'react' + +interface ContractCreateModalProps { + isOpen: boolean + onClose: () => void + onCreated: () => void +} + +interface CreateContractForm { + name: string + description: string + contractType: string + redTeamEnabled: boolean + redTeamPrompt: string +} + +export function ContractCreateModal({ isOpen, onClose, onCreated }: ContractCreateModalProps) { + const [form, setForm] = useState({ + name: '', + description: '', + contractType: 'simple', + redTeamEnabled: false, + redTeamPrompt: '', + }) + const [loading, setLoading] = useState(false) + const [error, setError] = useState(null) + + if (!isOpen) return null + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault() + setLoading(true) + setError(null) + + try { + const response = await fetch('/api/v1/contracts', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + name: form.name, + description: form.description || undefined, + contract_type: form.contractType, + red_team_enabled: form.redTeamEnabled, + red_team_prompt: form.redTeamEnabled && form.redTeamPrompt ? form.redTeamPrompt : undefined, + }), + }) + + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + throw new Error(errorData.message || `Failed to create contract: ${response.statusText}`) + } + + // Reset form and close modal + setForm({ + name: '', + description: '', + contractType: 'simple', + redTeamEnabled: false, + redTeamPrompt: '', + }) + onCreated() + onClose() + } catch (err) { + setError(err instanceof Error ? err.message : 'Unknown error') + } finally { + setLoading(false) + } + } + + return ( +
+
e.stopPropagation()}> +
+

Create Contract

+ +
+ +
+
+ {error && ( +
+ {error} +
+ )} + +
+

Contract Details

+ +
+ +
+ +
+