diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-18 08:17:00 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-18 08:17:00 +0300 |
| commit | 19994d378a3a6a1bd254e55fd4c14aec823dd811 (patch) | |
| tree | d891acfa43eeb235f63b15062e3261b6c71b8c3e /internal/gui | |
| parent | d689baaef4226a85fc050b5b8ac7bbb3746566af (diff) | |
feat: dynamic artistic styles with weekly regeneration
- Remove 42 hard-coded image generation styles
- Load styles from cache file (artistic_styles.txt)
- Generate styles via OpenAI API if file doesn't exist
- Regenerate styles automatically if older than one week
- Shuffle styles on each use to prevent LLM bias
- Fix bug where generated images appeared in wrong dialog
- Handle empty custom prompts properly
- Remove Bulgarian word references from image prompts
- Improve subject focus and visibility in prompts
- Add error handling when styles cannot be loaded
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/gui')
| -rw-r--r-- | internal/gui/app.go | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/internal/gui/app.go b/internal/gui/app.go index 6d520bc..46141d6 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -635,17 +635,26 @@ func (a *Application) onRegenerateImage() { // Use the text from translationEntry if currentTranslation is not set translation = strings.TrimSpace(a.translationEntry.Text) } - imageFile, err := a.generateImagesWithPrompt(a.currentWord, customPrompt, translation) + // Store the word we're generating for + wordForGeneration := a.currentWord + imageFile, err := a.generateImagesWithPrompt(wordForGeneration, customPrompt, translation) if err != nil { fyne.Do(func() { a.showError(fmt.Errorf("Image regeneration failed: %w", err)) }) } else { if imageFile != "" { - a.currentImage = imageFile - fyne.Do(func() { - a.imageDisplay.SetImages([]string{imageFile}) - }) + // Only update if we're still on the same word + a.mu.Lock() + if a.currentWord == wordForGeneration { + a.currentImage = imageFile + a.mu.Unlock() + fyne.Do(func() { + a.imageDisplay.SetImages([]string{imageFile}) + }) + } else { + a.mu.Unlock() + } } } @@ -686,17 +695,26 @@ func (a *Application) onRegenerateRandomImage() { // Use the text from translationEntry if currentTranslation is not set translation = strings.TrimSpace(a.translationEntry.Text) } - imageFile, err := a.generateImagesWithPrompt(a.currentWord, customPrompt, translation) + // Store the word we're generating for + wordForGeneration := a.currentWord + imageFile, err := a.generateImagesWithPrompt(wordForGeneration, customPrompt, translation) if err != nil { fyne.Do(func() { a.showError(fmt.Errorf("Random image generation failed: %w", err)) }) } else { if imageFile != "" { - a.currentImage = imageFile - fyne.Do(func() { - a.imageDisplay.SetImages([]string{imageFile}) - }) + // Only update if we're still on the same word + a.mu.Lock() + if a.currentWord == wordForGeneration { + a.currentImage = imageFile + a.mu.Unlock() + fyne.Do(func() { + a.imageDisplay.SetImages([]string{imageFile}) + }) + } else { + a.mu.Unlock() + } } } |
