From fddd206cfee1245d5de166db3a49a1df634c0fa4 Mon Sep 17 00:00:00 2001 From: DevMando Date: Fri, 17 Jul 2026 01:35:01 -0700 Subject: [PATCH] Add custom chat background image with live preview; reorganize Appearance page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users can pick a background image shown behind the transcript in every tab, with an opacity slider that fades only the image — text keeps full contrast. The image is copied into local app data and served to the WebView through a mandocode.userdata virtual host; image and opacity persist in ui-settings.json and apply to open tabs live via the existing theme-script pipeline. The Appearance page gains a preview card (theme colors + image + sample chat lines) and is reorganized into Win11-style collapsible sections with current values on the headers. Also guards the opacity handlers behind an _appearanceReady flag: their XAML defaults fire during InitializeComponent and previously saved default settings over the user's file at every launch. --- .../Controls/ChatTabView.xaml.cs | 12 ++ src/MandoCode.Desktop/MainWindow.xaml | 107 +++++++++++++++--- src/MandoCode.Desktop/MainWindow.xaml.cs | 79 ++++++++++++- .../Services/ThemeManager.cs | 80 ++++++++++++- .../Services/TranscriptHtmlBuilder.cs | 10 ++ 5 files changed, 268 insertions(+), 20 deletions(-) diff --git a/src/MandoCode.Desktop/Controls/ChatTabView.xaml.cs b/src/MandoCode.Desktop/Controls/ChatTabView.xaml.cs index c2c7fc8..345b8ea 100644 --- a/src/MandoCode.Desktop/Controls/ChatTabView.xaml.cs +++ b/src/MandoCode.Desktop/Controls/ChatTabView.xaml.cs @@ -218,6 +218,18 @@ public async Task InitializeAsync() } catch { } + // User-data host: serves the chat background image (see ThemeManager.SetChatBackground). + // Missing folder just means no background renders. + try + { + Directory.CreateDirectory(ThemeManager.UserDataFolder); + core.SetVirtualHostNameToFolderMapping( + "mandocode.userdata", + ThemeManager.UserDataFolder, + Microsoft.Web.WebView2.Core.CoreWebView2HostResourceAccessKind.Allow); + } + catch { } + core.NavigateToString(TranscriptHtmlBuilder.BaseDocument(ThemeManager.Current)); } catch (Exception ex) diff --git a/src/MandoCode.Desktop/MainWindow.xaml b/src/MandoCode.Desktop/MainWindow.xaml index f51fcf5..469d52c 100644 --- a/src/MandoCode.Desktop/MainWindow.xaml +++ b/src/MandoCode.Desktop/MainWindow.xaml @@ -414,25 +414,28 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +