Skip to content

feat: InferPage visual & functional improvements#122

Open
Madzionator wants to merge 19 commits intomainfrom
feature/infra-page-update
Open

feat: InferPage visual & functional improvements#122
Madzionator wants to merge 19 commits intomainfrom
feature/infra-page-update

Conversation

@Madzionator
Copy link
Collaborator

@Madzionator Madzionator commented Feb 20, 2026

Visual improvements

  • Redesigned main chat layout (Home.razor) - new structure, spacing and component organization
  • Updated navigation bar with backend type indicator tag showing current BackendType (e.g. Local, DeepSeek, OpenAI)
  • Refreshed color scheme with accent color aligned to MaIN library branding; replaced eval-based theme access with dedicated ThemeManager for consistent theme application across components
  • Updated scroll to be "smarter" - follow output unless user scrolled up

Functional improvements

  • Added file attachment support in chat
  • Added cancel/stop generation button
  • Added show/hide reasoning toggle button
  • Updated backend type configuration - use BackendType enum for backend config and UI

Bug fixes

  • Fixed progressive token streaming for file-based chat messages
  • Fixed browser-level theme persistence - selected theme is now correctly remembered across page reloads

Refactoring

  • Cleaned up Program.cs - simplified and reorganized service registration, removed redundant configuration boilerplate
  • Extracted reusable helper methods to MaIN.Domain/Extensions.cs to reduce code duplication across services
  • Refactored OpenAiCompatibleService and LLMService internals - added CancellationToken propagation through the chat message processing pipeline, enabling proper cancellation of in-flight requests

After update 2:

Functional improvements

  • Added basic support for unregistered models – instead of throwing an exception, the system now attempts to send requests to the provided model name (foundation for future extended model settings support)
  • Extended file attachment handling with drag & drop and copy & paste support (including images)
  • Separated image files from other attachments – image preview is now displayed instead of file name (both on upload and in sent message details)
  • Improved image generation feature – fixed previous issues and enhanced overall reliability and behavior

Bug fixes

  • Fixed image handling in OpenAiCompatibleService – images are now sent through a dedicated path, bypassing Kernel Memory and OCR; image understanding is delegated directly to the AI model

Refactor backend selection to use BackendType everywhere and simplify API key handling. Added Extensions.GetApiKeyVariable to map backends to env vars; Program now sets Utils.BackendType from the CLI arg, prompts for missing API keys (and marks Utils.HasApiKey), and only registers MaIN services when a non-self backend is selected. Utils was simplified: removed per-backend booleans, added BackendType, HasApiKey, IsLocal helper and moved Reason flag. UI updates: NavBar shows backend and model badges (with color/display name logic including "Local Ollama"), and Home.razor now branches on BackendType and uses Utils.IsLocal for MessageType. Also trimmed launchSettings applicationUrl.
Introduce a small JS themeManager in App.razor that bootstraps theme on page load (reads localStorage, parses JSON, and sets documentElement data-theme for dark mode) and exposes save/load helpers. Replace prior eval-based localStorage/document access in NavBar.razor and Home.razor with calls to themeManager.load, and update component logic to derive UI mode/accent color from the returned value. This centralizes theme persistence, avoids using eval, and provides safer parsing and fallbacks.
Remove the old BackendType extension and centralize API key metadata in LLMApiRegistry (moved to MaIN.Domain.Models.Concrete). Program.cs now looks up the registry entry for each BackendType to read ApiKeyEnvName instead of calling GetApiKeyVariable. Updated numerous LLM and image service files (and McpService) to reference the new namespace. This change consolidates API key configuration and removes the duplicated extension method.
Add multi-image support and extract image bytes from uploaded files for LLM services; improve model ID/instance handling and model selection flow.

- Message: replace single byte[] Image with List<byte[]> Images and keep a backward-compatible Image getter/setter.
- Chat: preserve raw ModelId string, safely try to resolve model instance (no throws), and sync ModelInstance with internal id field.
- Home.razor: unify model resolution into a local variable and choose GenericLocalModel/GenericCloudModel when registry lookup fails.
- AnthropicService & OpenAiCompatibleService: add ExtractImageFromFiles to load image file bytes into Message.Images, remove consumed file entries, update HasImages/BuildMessageContent to iterate images, and extend image type detection (HEIC/HEIF, AVIF and more extensions).

These changes enable passing uploaded images to compatible LLM backends while maintaining backward compatibility and preventing exceptions when models are missing.
wisedev-pstach
wisedev-pstach previously approved these changes Feb 24, 2026
Add client-side support for image attachments: show inline thumbnails for selected images, history image previews, paste handling, dismiss buttons, and update input/send logic to include images alongside files. Introduce _selectedImages and ImageExtensions, update MessageExt to store AttachedImages, and ensure proper disposal of image streams. Add CSS for image-preview and history-image-preview styling. On the service side, route messages that include images through a SearchAsync + context-enhanced chat flow (streaming and non-streaming) and adjust token handling/return values accordingly.
Introduce image-generation capability across the app: add IImageGenerationModel and HasImageGeneration on AIModel; mark cloud models (DALL·E3, new gpt-image-1 and grok-2-image) as image generators. Update UI to render generated images with download and copy-to-clipboard actions (Home.razor changes, CopyImageToClipboard interop + editor.js). Improve visual/model detection in Utils to use ModelRegistry with a fallback set of known image-generation IDs. Increase SignalR hub max message size to 10MB (Program.cs) to allow larger image transfers and add CSS for generated image layout and controls.
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