Add support for themes #380
Conversation
|
This is a comment left during a code review. Comment: All color accessor functions (e.g. The old How can I resolve this? If you propose a fix, please make it concise. |
|
The cleanest fix is a single helper that takes the read lock, then have all accessor functions use it: func palette() *Palette {
modeMu.RLock()
p := currentPalette
modeMu.RUnlock()
return p
}Then update every accessor to call func Background() color.Color { return lipgloss.Color(palette().Primary.Background) }
func Foreground() color.Color { return lipgloss.Color(palette().Primary.Foreground) }
func White() color.Color { return lipgloss.Color(palette().Normal.White) }
func Gray() color.Color { return lipgloss.Color(palette().Normal.Black) }
func Pink() color.Color { return lipgloss.Color(palette().Bright.Red) }
// ... and so on for all accessors
func ProgressStart() color.Color { return lipgloss.Color(palette().Bright.Red) }
func ProgressEnd() color.Color { return lipgloss.Color(palette().Bright.Magenta) }This works because reading the pointer under Alternatively, you could use Tip: You can customize Greptile's behavior for this repo with |
|
This is a comment left during a code review. Comment:
func SetDarkMode(isDark bool) {
modeMu.Lock()
changed := isDarkMode != isDark
isDarkMode = isDark
if isDark {
currentPalette = &defaultDark
} else {
currentPalette = &defaultLight
}
modeMu.Unlock()
// ...
}How can I resolve this? If you propose a fix, please make it concise. |
|
The fix is to update One caveat: this resets to the default palette even when a custom theme is active (e.g., user toggles dark/light mode while a |
187e8b9 to
9419311
Compare
|
Update: CI seems to be happy now. |
|
@SuperCoolPencil I think I have added what I want to the PR. Some things which potentially can be improved:
On an unrelated note imo there could be docs/info on installation and usage of gotestsum/golangci-lint on a local machine for development purposes. Been wanting to contribute code to this cool project for a while. |
|
Hey @bladeacer Thanks for the PR! I'm out of town this weekend but i"ll try to review this asap. Noticed some merge conflicts, would really appreciate if you could resolve them Awesomeee |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
@SuperCoolPencil , I have fixed the merge conflicts. |
…or color constants to functions
…tion with file extension support
… color definitions, and clean up theme configuration files
…ry selection logic, and optimize graph gradient rendering
…ng across the TUI
…ts box styling and visibility thresholds
…to TOML files when selecting themes
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
Testing latest changes the theme path file picker does not have a default path, and pressing enter does not select the toml file. |
|
Hey @bladeacer I'm so sorry for not seeing your comments, I'm just trying to integrate some changes. Yeah, pressing enter doesnt currently select it. Thanks for reporting that. I'll fix it up. Really good work on the PR, all the changes are well thought out. If I had a few suggestions it would be
|
Thanks for the head's up :D
The approach I took to that was assuming the user could either supply a single The explicit light dark block are for the aforementioned purpose, being optional by providing a sane fallback when it is not provided. |
…ings documentation
…improve hex parsing error handling
|
@SuperCoolPencil lgtm. |
|
Awesome! Thank you so much for contributing! OSS needs more contributors like you :) |
Resolves #328 .
Note the merge conflict and details discussed in #328 .
Greptile Summary
This PR adds a TOML-based theming system with four bundled themes (Catppuccin, Gruvbox, Nord, Surge), a multi-location path resolver, light/dark variant selection per theme, a
RegisterThemeChangeHookmechanism so styles rebuild on palette swap, and a GoReleaser packaging script forthemes.zip. The previously reported critical issues — data race oncurrentPalette,SetDarkModenot updating the palette,ThemeConfigstruct tag mismatch, and the merge-conflict artifact — have all been resolved in this revision.Confidence Score: 5/5
Safe to merge; all remaining findings are P2 style/documentation issues with no impact on runtime correctness.
All previously flagged P0/P1 issues (data race, palette not updated on mode change, TOML struct mismatch, merge artifact) are resolved. The three remaining comments are minor: a wrong inline step-number comment, an undocumented Palette.Dark field, and a missing light-variant test. None affect current behavior.
internal/tui/colors/colors.go and colors_test.go for the minor documentation and test-coverage gaps noted above.
Important Files Changed
Comments Outside Diff (8)
internal/tui/view_settings.go, line 856-866 (link)resetSettingToDefaultdoesn't handletheme_pathWhen the user presses the reset key on the
theme_pathsetting,resetSettingToDefaultfalls through without resetting it (nocase "theme_path"in the General switch). The path remains unchanged andApplyThemeis not called (it's only called whensettingKey == "theme"), so the custom theme stays active even after a reset.Add the missing case:
Prompt To Fix With AI
internal/tui/view_settings.go, line 861-865 (link)theme_pathreset is a no-opresetSettingToDefaulthandles every new General setting excepttheme_path. Pressing the reset key on "Theme File" silently does nothing — the path is never cleared andApplyThemeis never re-invoked. There is also noif settingKey == "theme_path"branch inupdate_settings.go's reset handler (line 186) to re-apply the theme after clearing the path.And in
update_settings.goafter line 188, add:Prompt To Fix With AI
internal/tui/update_settings.go, line 178-190 (link)theme_pathleaves the UI on the old custom themeWhen the user presses the reset key on the
theme_pathsetting,resetSettingToDefaultclearsThemePathto"", butApplyThemeis only called whensettingKey == "theme". The palette is therefore never reloaded, so the custom theme remains visually active even though the setting now says it's cleared.Prompt To Fix With AI
internal/tui/update_settings.go, line 178-189 (link)theme_pathdoesn't re-apply the themeAfter
resetSettingToDefaultclearsThemePathto"",ApplyThemeis only called whensettingKey == "theme", not whensettingKey == "theme_path". The in-memoryLoadThemestate still points at the old custom palette, so the UI continues rendering with the custom theme until a restart — the reset has no visible effect.Prompt To Fix With AI
internal/tui/update_settings.go, line 191-203 (link)theme_pathdoesn't re-apply the themeresetSettingToDefaultclearsm.Settings.General.ThemePathto"", butApplyThemeis only called whensettingKey == "theme". Resetting the path leaves the custom palette active in memory — the user sees no change until they restart the app.Prompt To Fix With AI
internal/tui/update_filepicker.go, line 63-65 (link)handleFilePickerGotoHome()callsnewFilepicker(defaultDir)which creates a picker withDirAllowed=true, FileAllowed=false(the defaults innewFilepicker). ForFilePickerOriginThemethis leaves the picker in directory-only mode, so after pressing H no.tomlfile can ever be selected.updateBatchFilePickerhandles the same edge case explicitly (lines 96–98 in the same file):The theme branch here should do the same:
Prompt To Fix With AI
internal/tui/update_settings.go, line 198-210 (link)theme_pathleaves UI with stale paletteWhen the user presses Reset on the
theme_pathsetting, the field is cleared to""byresetSettingToDefault, butApplyThemeis never called. ThecurrentPalettepointer in thecolorspackage continues pointing at the custom theme's data, so the UI remains visually themed even though the setting now reads empty. By contrast, resettingtheme(line 207) does callApplyTheme. The same call needs to be added fortheme_path:Prompt To Fix With AI
internal/config/paths.go, line 121-125 (link)EnsureDirsGetThemesDir()is defined and used as the default browse location when opening the file picker fortheme_path(inupdate_settings.go), but it is absent from thedirsslice inEnsureDirs. On a fresh install,config.GetThemesDir()always returns a non-empty path, so thebrowseDir == ""fallback inupdate_settings.gonever fires, and the filepicker is pointed at a directory that doesn't yet exist — resulting in a broken/empty file picker for users trying to browse for a theme.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (15): Last reviewed commit: "feat: add theme packaging script and inc..." | Re-trigger Greptile
Context used: