Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/copilot-instructions-src.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Source Code (`src/`) - JavaScript/TypeScript

## Architecture Overview

This directory contains the React Native JavaScript/TypeScript code that defines the UI and business logic.

### Key Components

**App Foundation**
- `App.tsx` - Root component, provides StylesContext, SettingsContext, and PopupsContext
- `Styles.tsx` - Theme system with dark mode support
- `Popups.tsx` - Shared popup infrastructure

**Chat System**
- `ChatSession.tsx` - Manages chat history and ChatElement list (readonly context)
- `Chat.tsx` - Scrolling message list with FeedbackContext and ChatScrollContext
- `ChatSession.tsx` exports `AutomatedChatSession` for pre-populated demos

**AI Integration**
- `AiQuery.tsx` - Drives OpenAI queries, converts prompts to responses
- `AiResponse.tsx` - Renders AI responses with markdown/code blocks
- `HumanQuery.tsx` - Displays user prompts with edit/copy buttons
- `OpenAI.tsx` - Handles OpenAI API calls and response parsing

**UI Components**
- `Controls.tsx` - Reusable controls (Attribution, ConsentSwitch, FluentTextInput, FlyoutMenu, MarkdownWithRules, SwitchWithLabel, ImageSelection)
- `FluentControls.tsx` - Windows-styled controls
- `CodeBlock.tsx` - Syntax highlighting with copy support
- `Settings.tsx` - Settings dialog for API keys and preferences
- `Feedback.tsx` - Feedback collection for AI responses
- `About.tsx` - About dialog
- `WelcomeMessage.tsx` - First-run experience
- `Picker.tsx` - Custom picker control

**Features**
- `TrialMode.tsx` - Trial API key and usage tracking
- `Speech.tsx` - Text-to-speech integration

**Native Modules**
- `NativeVersionInfo.ts` - Turbo module for app/build version
- `NativeSpeech.ts` - Turbo module for Windows speech synthesis

## Making Changes

### State Management
- Settings flow through SettingsContext (API keys, models, preferences)
- Chat history is read-only via ChatHistoryContext
- Updates to chat happen through ChatSession component's state

### Adding New Features
1. If adding UI: Create component in Controls.tsx or new file
2. If adding settings: Update Settings.tsx and SettingsContext in App.tsx
3. If adding AI capability: Extend OpenAI.tsx handlers

### Common Patterns
- Use StylesContext for theming (never hardcode colors)
- Use React.useContext() to access app contexts
- Follow existing component structure in Controls.tsx
- Keep components focused on single responsibility

## Testing JavaScript Changes

```bash
# Start Metro bundler for fast iteration
npx react-native start

# Lint your changes
yarn lint

# Fix auto-fixable issues
yarn lint --fix
```

JavaScript changes can be developed on any platform. Windows is only required for building the native app.
79 changes: 79 additions & 0 deletions .github/copilot-instructions-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Windows Native Code (`windows/`)

## Overview

This directory contains the Windows-specific native code for React Native Windows (RNW). The app is built as a C++/WinRT UWP application.

## Structure

- `artificialChat/` - Main application project
- `*.cpp/h` - C++ source and headers
- `*.vcxproj` - Visual Studio project files
- `AutolinkedNativeModules.*` - Auto-generated RNW module linking
- `pch.h/cpp` - Precompiled headers

- `artificialChat.Package/` - MSIX packaging project for Windows Store deployment
- `artificialChat.sln` - Visual Studio solution file

## Native Modules

The app includes custom Turbo Modules for Windows-specific features:

### VersionInfo Module
- **Spec**: `codegen/NativeVersionInfoSpec.g.h`
- **Implementation**: `windows/artificialChat/VersionInfo.h`
- **Purpose**: Exposes app version and build version to JavaScript
- **Constants**: `appVersion`, `buildVersion`

### Speech Module
- **Spec**: `codegen/NativeSpeechSpec.g.h`
- **Implementation**: `windows/artificialChat/Speech.h`
- **Purpose**: Text-to-speech using Windows Speech Synthesis
- **Methods**: `speak()`, `getVoices()`, `setVoice()`

## Building Windows App

**Prerequisites**: Windows OS with Visual Studio and MSBuild components

```powershell
# Install RNW dependencies (run once, elevated PowerShell)
node_modules/react-native-windows/Scripts/rnw-dependencies.ps1
```

```bash
# Debug build (default)
yarn windows

# Release build
yarn windows --release

# Specify architecture
yarn windows --arch x64
yarn windows --arch x86
```

**Build times**: 5-30 minutes for first build, 2-10 minutes for incremental changes

## Modifying Native Code

### Adding New Native Module
1. Create spec file in `codegen/` directory
2. Implement module in `windows/artificialChat/`
3. Register in `AutolinkedNativeModules.g.cpp` (auto-generated)
4. Export from JavaScript in `src/Native*.ts`

### Debugging
- Open `windows/artificialChat.sln` in Visual Studio
- Set breakpoints in C++ code
- Press F5 to build and debug

### Common Issues
- **Build fails**: Ensure RNW dependencies script has been run
- **Missing MSBuild**: Install Visual Studio with C++ workload
- **Linking errors**: Clean and rebuild solution

## Platform Limitations

- Windows builds only work on Windows OS
- Linux/macOS cannot compile or run Windows native code
- JavaScript development (Metro bundler) works cross-platform
Loading