Skip to content

Add Procrastinate sample app#729

Open
StephaneDelcroix wants to merge 3 commits into
dotnet:mainfrom
StephaneDelcroix:add-procrastinate-sample
Open

Add Procrastinate sample app#729
StephaneDelcroix wants to merge 3 commits into
dotnet:mainfrom
StephaneDelcroix:add-procrastinate-sample

Conversation

@StephaneDelcroix

@StephaneDelcroix StephaneDelcroix commented Dec 19, 2025

Copy link
Copy Markdown

Summary

This PR adds Procrastinate, a fun anti-productivity app that demonstrates several advanced .NET MAUI features including MEAI (Microsoft.Extensions.AI) integration.

MEAI Features Demonstrated

  • IChatClient — On-device AI via AppleIntelligenceChatClient (iOS/macOS)
  • IChatClient — Cloud AI via OpenAI-compatible adapter (Groq/Llama)
  • IEmbeddingGeneratorNLEmbeddingGenerator for quality scoring of generated excuses
  • Multi-Agent Pipeline — 3-agent chain (Researcher→Writer→Editor) with reasoning panel
  • BYOM (Bring Your Own Model) — Any OpenAI-compatible endpoint (Ollama, LM Studio, etc.)
  • Embedded ONNX Model — In-process OnnxRuntimeGenAI with HuggingFace model download
  • Hybrid AI Switching — Settings UI to switch between local/cloud/pipeline/custom/embedded modes

Other Features Demonstrated

  • Shell Navigation — Tab-based navigation with 5 main pages
  • Localization — Full translation in 7 languages (English, French, Spanish, Portuguese, Dutch, Czech, Ukrainian)
  • Custom Theming — Nord color palette with dark/light theme support
  • Mini-Games — 9 games including TicTacToe with AI opponent (via IChatClient)
  • XAML Source Generator — Uses MauiXamlInflator=SourceGen
  • Plugin.Maui.Audio — Sound effects for Simon Says game
  • SecureStorage — API keys stored securely (Keychain/EncryptedSharedPrefs)

Hackday Challenge Levels Covered

  • 🟢 Basic: Local AI via AppleIntelligenceChatClient + cloud AI via Groq
  • 🟡 Advanced: Hybrid model switching, NLEmbedding quality scoring, BYOM endpoints
  • 🟠 Agent Framework: 3-agent pipeline with reasoning display
  • 🔴 Freestyle: Embedded ONNX model (Phi-3 Mini) running entirely on-device

Original Repository

https://github.com/StephaneDelcroix/procrastinate

Testing

# iOS (requires .NET 10 SDK + dotnet10 nightly feed)
dotnet build -f net10.0-ios

# Android
dotnet build -f net10.0-android

# macOS
dotnet build -f net10.0-maccatalyst

StephaneDelcroix and others added 3 commits December 19, 2025 08:42
A fun anti-productivity app demonstrating:
- Shell navigation with tabs
- AI integration (Groq Cloud & Apple Intelligence via native xcframework)
- Multi-language localization (6 languages)
- Nord color palette theming
- 9 mini-games including AI-powered Tic Tac Toe
- XAML Source Generator usage
- Native iOS interop with Swift framework
Replace custom FMWrapper native bridge with Microsoft.Extensions.AI (MEAI):
- On-device AI via AppleIntelligenceChatClient (IChatClient)
- Cloud AI via OpenAI-compatible IChatClient (Groq)
- NLEmbeddingGenerator for quality scoring
- 3-agent pipeline excuse generator (Researcher→Writer→Editor)
- BYOM (Bring Your Own Model) with any OpenAI-compatible endpoint
- Embedded ONNX model support via OnnxRuntimeGenAI
- Agent reasoning panel with collapsible UI
- API keys stored in SecureStorage
- Thread-safe ONNX client, cached embeddings, friendly error messages

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@StephaneDelcroix

Copy link
Copy Markdown
Author

🔄 Updated: Full MEAI Migration + Advanced AI Features

This PR has been updated with a complete migration from the custom FMWrapper native bridge to Microsoft.Extensions.AI (MEAI). Changes include:

Core Migration

  • Replaced ~200 lines of P/Invoke/Swift bridge code with IChatClient abstraction
  • On-device: AppleIntelligenceChatClient from Microsoft.Maui.Essentials.AI
  • Cloud: OpenAI.OpenAIClient.AsIChatClient() targeting Groq (OpenAI-compatible)
  • Registered via DI in MauiProgram.cs

Advanced Features

  • NLEmbedding Quality ScoringIEmbeddingGenerator cosine similarity against golden excuses, with retry on low quality
  • BYOM — Custom endpoint support for Ollama, LM Studio, vLLM, etc.
  • 3-Agent Pipeline — Researcher→Writer→Editor chain with collapsible reasoning panel showing each agent's output
  • Embedded ONNXOnnxRuntimeGenAI for in-process Phi-3 Mini (download from HuggingFace)

Code Quality (from multi-model code review)

  • Thread-safe ONNX client singleton with lock + active inference counter
  • API keys migrated to SecureStorage (Keychain/EncryptedSharedPrefs)
  • Cached golden embeddings, epsilon-guarded cosine similarity
  • UI callback cleanup in OnDisappearing to prevent page leaks
  • Atomic downloads with .tmp rename, concurrency guard via SemaphoreSlim
  • Friendly error messages instead of raw exception text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants