mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-15 02:42:45 +08:00
feat(a2ui): Implement A2UI backend with question handling and WebSocket support
- Added A2UITypes for defining question structures and answers. - Created A2UIWebSocketHandler for managing WebSocket connections and message handling. - Developed ask-question tool for interactive user questions via A2UI. - Introduced platformUtils for platform detection and shell command handling. - Centralized TypeScript types in index.ts for better organization. - Implemented compatibility checks for hook templates based on platform requirements.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// ========================================
|
||||
// A2UI Card Component Renderer
|
||||
// ========================================
|
||||
// Maps A2UI Card component to shadcn/ui Card
|
||||
|
||||
import React from 'react';
|
||||
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/Card';
|
||||
import type { ComponentRenderer } from '../../core/A2UIComponentRegistry';
|
||||
import { resolveTextContent } from '../A2UIRenderer';
|
||||
import type { CardComponent } from '../../core/A2UITypes';
|
||||
|
||||
interface A2UICardProps {
|
||||
component: CardComponent;
|
||||
state: Record<string, unknown>;
|
||||
onAction: (actionId: string, params: Record<string, unknown>) => void | Promise<void>;
|
||||
resolveBinding: (binding: { path: string }) => unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* A2UI Card Component Renderer
|
||||
* Container component with optional title and description
|
||||
*/
|
||||
export const A2UICard: ComponentRenderer = ({ component, state, onAction, resolveBinding }) => {
|
||||
const cardComp = component as CardComponent;
|
||||
const { Card: cardConfig } = cardComp;
|
||||
|
||||
// Resolve title and description
|
||||
const title = cardConfig.title ? resolveTextContent(cardConfig.title, resolveBinding) : undefined;
|
||||
const description = cardConfig.description ? resolveTextContent(cardConfig.description, resolveBinding) : undefined;
|
||||
|
||||
return (
|
||||
<Card>
|
||||
{(title || description) && (
|
||||
<CardHeader>
|
||||
{title && <CardTitle>{title}</CardTitle>}
|
||||
{description && <CardDescription>{description}</CardDescription>}
|
||||
</CardHeader>
|
||||
)}
|
||||
<CardContent>
|
||||
{cardConfig.content.map((childComp, index) => {
|
||||
// For nested components, we would typically use the registry
|
||||
// But for simplicity in this renderer, we just render a placeholder
|
||||
const childType = Object.keys(childComp)[0];
|
||||
return (
|
||||
<div key={index} data-component-type={childType}>
|
||||
{/* Nested components would be rendered here via A2UIRenderer */}
|
||||
{childType}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user