AI Troubleshooter Component
Relevant source files
The following files were used as context for generating this wiki page:
The AI Troubleshooter component analyzes Android kernel build logs to identify issues and suggest solutions. It specifically targets problems related to LineageOS 23.2 and SM8550 device architectures, helping developers debug KMI/GKI compatibility issues and failed patch hooks.
Sources: README.md:11-13, src/components/dashboard/AITroubleshooter.tsx:40
In its current implementation, the component operates as a mock assistant to support static Android APK exports. It simulates AI analysis without requiring a backend server, providing feedback on log data passed from the main dashboard.
Sources: src/ai/flows/ai-build-troubleshooting-assistant.ts:1-5, src/app/page.tsx:495-499
Component Architecture and Data Flow
The AITroubleshooter is a React client component that manages the state of analysis and displays results to the user. It receives logsText as a prop from the parent dashboard, which it sends to the aiBuildTroubleshootingAssistant flow for processing.
Sources: src/components/dashboard/AITroubleshooter.tsx:1-17
Analysis Workflow
The following diagram illustrates the data flow from the user interface to the AI logic.
The workflow begins when the user triggers the analysis button. The component updates its internal state to show a loading spinner, invokes the AI flow, and then renders the returned summary, errors, and solutions.
Sources: src/components/dashboard/AITroubleshooter.tsx:18-31
Sequence of Interaction
This sequence diagram shows the interaction between the UI component and the mock AI flow.
The UI waits for a promise resolution from the AI flow, which includes a simulated 2-second delay to mimic processing time.
Sources: src/ai/flows/ai-build-troubleshooting-assistant.ts:38-51, src/components/dashboard/AITroubleshooter.tsx:23-24
Data Structures
The system uses specific TypeScript types and schemas to define the input and output for the troubleshooting logic.
Input Schema
| Field | Type | Description |
|---|---|---|
buildLog | string | The raw text output from the kernel build process. |
deviceInfo | object | Optional metadata including model, codename, GKI, and KMI versions. |
Sources: src/ai/flows/ai-build-troubleshooting-assistant.ts:7-20
Output Schema
| Field | Type | Description |
|---|---|---|
summary | string | A high-level explanation of the build status or identified problems. |
identifiedErrors | array | A list of specific error strings (e.g., "E01"). |
suggestedSolutions | array | Actionable steps to resolve the identified errors. |
Sources: src/ai/flows/ai-build-troubleshooting-assistant.ts:22-31
Implementation Details
UI Integration
The component is integrated into the main application dashboard via a tabbed interface. It utilizes a ScrollArea to handle large amounts of log analysis data and displays errors with specific color coding (red for errors, primary/green for solutions).
Sources: src/app/page.tsx:495-499, src/components/dashboard/AITroubleshooter.tsx:55-103
Mock Logic for Static Export
Because the application is designed to be exported as a static Android APK using Capacitor, the AI functionality is currently mocked.
export async function aiBuildTroubleshootingAssistant(
input: AiBuildTroubleshootingAssistantInput
): Promise<AiBuildTroubleshootingAssistantOutput> {
return new Promise((resolve) => {
setTimeout(() => {
resolve({
summary: "Simulated AI analysis for static export mode...",
identifiedErrors: ["Cannot reach AI server locally without backend."],
suggestedSolutions: ["Provide a remote AI endpoint..."]
});
}, 2000);
});
}
Sources: src/ai/flows/ai-build-troubleshooting-assistant.ts:33-53
Dependencies and Environment
The AI module is built using Genkit and supports development-time execution via specific npm scripts.
- Genkit: Used for AI flow orchestration (
@genkit-ai/google-genai). - Scripts:
npm run genkit:devstarts the Genkit development environment usingsrc/ai/dev.ts. - Icons: Uses
lucide-reacticons such asSparkles,Bot, andAlertCirclefor visual status cues.
Sources: package.json:13-14, 31, src/ai/dev.ts:1-4, src/components/dashboard/AITroubleshooter.tsx:6
The AI Troubleshooter provides a critical debugging layer for kernel developers by consolidating build log information and presenting it through a structured analysis interface.