From 56a126dbc2efbc4ceeb5a80d7860516aa0c962ed Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 15 Jan 2026 21:18:55 +0000 Subject: [PATCH] fix: silence unused variable warnings in aiChat.ts --- .../src/components/AI/Chat/QuestionCard.tsx | 145 ++++++++++++++++++ .../src/components/AI/Chat/index.tsx | 14 +- frontend-modern/src/stores/aiChat.ts | 10 +- 3 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 frontend-modern/src/components/AI/Chat/QuestionCard.tsx diff --git a/frontend-modern/src/components/AI/Chat/QuestionCard.tsx b/frontend-modern/src/components/AI/Chat/QuestionCard.tsx new file mode 100644 index 000000000..72e4158de --- /dev/null +++ b/frontend-modern/src/components/AI/Chat/QuestionCard.tsx @@ -0,0 +1,145 @@ +import { Component, Show, For, createSignal } from 'solid-js'; +import type { PendingQuestion } from './types'; + +interface QuestionCardProps { + question: PendingQuestion; + onAnswer: (answers: Array<{ id: string; value: string }>) => void; + onSkip: () => void; +} + +export const QuestionCard: Component = (props) => { + // Store answers for each question + const [answers, setAnswers] = createSignal>({}); + + const handleInputChange = (questionId: string, value: string) => { + setAnswers((prev) => ({ ...prev, [questionId]: value })); + }; + + const handleSelectOption = (questionId: string, value: string) => { + setAnswers((prev) => ({ ...prev, [questionId]: value })); + }; + + const handleSubmit = () => { + const answerArray = props.question.questions.map((q) => ({ + id: q.id, + value: answers()[q.id] || '', + })); + props.onAnswer(answerArray); + }; + + const isValid = () => { + // Check all questions have answers + return props.question.questions.every((q) => { + const answer = answers()[q.id]; + return answer && answer.trim() !== ''; + }); + }; + + return ( +
+ {/* Header */} +
+
+ + + +
+ Question from AI +
+ + {/* Questions */} +
+ + {(q) => ( +
+

+ {q.question} +

+ + + handleInputChange(q.id, e.currentTarget.value)} + class="w-full px-3 py-2 text-sm border border-blue-200 dark:border-blue-700 rounded-lg bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder="Type your answer..." + disabled={props.question.isAnswering} + /> + + + +
+ + {(option) => ( + + )} + +
+
+
+ )} +
+ + {/* Actions */} +
+ + +
+
+
+ ); +}; diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx index b39d6113d..9d78697ff 100644 --- a/frontend-modern/src/components/AI/Chat/index.tsx +++ b/frontend-modern/src/components/AI/Chat/index.tsx @@ -6,7 +6,7 @@ import { logger } from '@/utils/logger'; import { useChat } from './hooks/useChat'; import { ChatMessages } from './ChatMessages'; import { PROVIDER_DISPLAY_NAMES, getProviderFromModelId, groupModelsByProvider } from '../aiChatUtils'; -import type { PendingApproval, ModelInfo } from './types'; +import type { PendingApproval, PendingQuestion, ModelInfo } from './types'; const MODEL_LEGACY_STORAGE_KEY = 'pulse:ai_chat_model'; const MODEL_SESSION_STORAGE_KEY = 'pulse:ai_chat_models_by_session'; @@ -342,6 +342,16 @@ export const AIChat: Component = (props) => { } }; + // Question handlers + const handleAnswerQuestion = async (messageId: string, question: PendingQuestion, answers: Array<{ id: string; value: string }>) => { + await chat.answerQuestion(messageId, question.questionId, answers); + }; + + const handleSkipQuestion = (messageId: string, questionId: string) => { + // Just remove from UI - skipping a question + chat.updateQuestion(messageId, questionId, { removed: true }); + }; + const toggleModelSelector = () => { const next = !showModelSelector(); setShowModelSelector(next); @@ -597,6 +607,8 @@ export const AIChat: Component = (props) => { messages={chat.messages()} onApprove={handleApprove} onSkip={handleSkip} + onAnswerQuestion={handleAnswerQuestion} + onSkipQuestion={handleSkipQuestion} emptyState={{ title: 'Start a conversation', subtitle: 'Ask about your infrastructure, diagnose issues, or get help.', diff --git a/frontend-modern/src/stores/aiChat.ts b/frontend-modern/src/stores/aiChat.ts index 5fc5eb3d8..6f588d1dc 100644 --- a/frontend-modern/src/stores/aiChat.ts +++ b/frontend-modern/src/stores/aiChat.ts @@ -99,9 +99,9 @@ const [aiEnabled, setAiEnabled] = createSignal(null); // null = // Session management state const [currentSessionId, setCurrentSessionId] = createSignal(loadOrCreateSessionId()); const [sessionTitle, setSessionTitle] = createSignal(''); -const [sessions, setSessions] = createSignal([]); -const [syncEnabled, _setSyncEnabled] = createSignal(true); -const [isSyncing, setIsSyncing] = createSignal(false); +const [_sessions, _setSessions] = createSignal([]); +const [_syncEnabled, _setSyncEnabled] = createSignal(true); +const [_isSyncing, _setIsSyncing] = createSignal(false); // Debounce timer for saving let saveDebounceTimer: ReturnType | null = null; @@ -170,12 +170,12 @@ export const aiChatStore = { // Get all sessions (for session picker) get sessions() { - return sessions(); + return _sessions(); }, // Check if syncing get syncing() { - return isSyncing(); + return _isSyncing(); }, // Check if a specific item is in context