Skip to content

Adds better Local translation - #679

Merged
TheJoeFin merged 7 commits into
audiofrom
LAF-Translate
Aug 23, 2026
Merged

TheJoeFin merged 7 commits into
audiofrom
LAF-Translate

Conversation

@TheJoeFin

Copy link
Copy Markdown
Owner

PR Classification

Implements support for unlocking Windows AI language model (Phi Silica) as a Limited Access Feature, refactors translation logic, and improves translation reliability and error handling.

PR Summary

Adds build-time and runtime support for LAF unlock, replaces the translation implementation with a new Windows AI-based approach, and enhances error reporting and resource management.

  • Updates CI workflows and build scripts to inject LAF secrets via new MSBuild properties and environment variables.
  • Refactors translation logic: removes old code from WindowsAiUtilities, introduces WinAiTranslator for batching and streaming translations, and adds LanguageHeuristics for fast detection.
  • Updates GrabFrame and EditTextWindow to use the new translator, batch word boxes, and provide improved user feedback on translation failures.
  • Cleans up resource management with explicit model lifecycle methods and removes obsolete concurrency logic.
  • Adds documentation for configuring LAF environment variables.

TheJoeFin and others added 7 commits August 22, 2026 11:15
Replaces WindowsAiUtilities/TextRewriter-based translation with new WinAiTranslator, managing on-device Phi Silica model and LAF unlock. Adds batched and streaming translation, improved error handling, and user feedback. Moves language heuristics to LanguageHeuristics.cs. Project now supports LAF tokens via build/env vars. Updates all translation entry points for new API. Cleans up old logic, adds LimitedAccessFeatureUtilities, and improves UI batching and resource management.
Enables secure injection of Windows AI Language Model (LAF) unlock tokens via LAF_TOKEN and LAF_PUBLISHER_ID environment variables, sourced from GitHub Actions secrets in Release.yml and buildDev.yml, and passed to MSBuild publish steps. Updates Text-Grab.csproj to default LafToken and LafPublisherId from environment variables for local and CI builds. Adds Configuring-LAF-Environment-Variables.md to document setup and usage, stressing token secrecy. Builds without secrets still succeed but omit on-device text AI features.
Refactored all Windows AI language model logic into WinAiLanguageModel for shared creation, availability checks, and inference queuing. Standardized error and result handling with WinAiFailure and WinAiGenerationResult. Updated WinAiTranslator, WindowsAiUtilities, and regex extraction to use the shared model and new result types. Improved error reporting in EditTextWindow and clarified documentation throughout.
Added "Summarize as Meeting Notes" to EditTextWindow with UI and handler. Implemented WinAiMeetingNotes utility for splitting, summarizing, and merging long text using Windows AI (Phi Silica). Added unit tests for text splitting. Refactored response cleaning to shared CleanResponse method in WinAiLanguageModel. Updated docs and comments. Improved error handling and user feedback for meeting notes generation.
When the out-of-process Windows AI runtime connection is lost (e.g., "The RPC server is unavailable"), the code now disposes and recreates the language model, retries the request once, and only fails if restart fails. This logic is centralized in `WinAiLanguageModel.GenerateAsync` and `RunWithModelAsync`, using a new `IsConnectionLost` helper. The unlock cache in `LimitedAccessFeatureUtilities` is reset on restart to avoid caching transient failures. All AI features now use the shared model and recovery logic. Public APIs allow manual model restarts. Exception handling distinguishes recoverable from unrecoverable errors, and error messages are clarified.
Wires the existing "New Window with Selected Text" action to Ctrl+N
so it doesn't require the menu, and shows the shortcut in the menu item.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Previously these AI actions overwrote the source text in place. Now
the source stays untouched and the generated result opens in a new
Edit Text window, matching the existing "open in new window" pattern.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@TheJoeFin
TheJoeFin merged commit 9a8e12d into audio Aug 23, 2026
@TheJoeFin
TheJoeFin deleted the LAF-Translate branch August 23, 2026 15:25
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.

1 participant