Skip to content

fix(weather-editor): weather data on game load#2268

Merged
alandtse merged 11 commits into
community-shaders:devfrom
SkrubbySkrubInAShrub:fix/weather-editor-load-on-game-start
May 3, 2026
Merged

fix(weather-editor): weather data on game load#2268
alandtse merged 11 commits into
community-shaders:devfrom
SkrubbySkrubInAShrub:fix/weather-editor-load-on-game-start

Conversation

@SkrubbySkrubInAShrub
Copy link
Copy Markdown
Collaborator

@SkrubbySkrubInAShrub SkrubbySkrubInAShrub commented May 2, 2026

fixes bug introduced in 790044b that caused weather editor data to be loaded only after the weather editor menu was opened. This leads to no overrides being applied until the menu is opened.

Summary by CodeRabbit

  • Improvements

    • Editor resources now preload selectively for faster responsiveness when appropriate.
    • Settings UI ensures the weather presets list is loaded, improving reliability.
    • Widget loading notifications are suppressed by default to reduce unnecessary alerts.
    • Editor open/toggle behavior and hotkey handling improved for more consistent operation.
  • Chores

    • Version bumped to 2-0-1.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 2, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Weather editor now caches discovery of widget .json files to decide whether to preload resources; widget loading gained an opt-out for user notifications; editor open/toggle routes were centralized to ensure data is loaded before opening; menu hotkey uses the new toggle; version bumped.

Changes

Weather editor + Widget loading

Layer / File(s) Summary
Data Shape / Constants
src/WeatherEditor/Widget.h
Added static constexpr std::string_view folder-name constants and static constexpr std::array kSaveFolderNames; changed Widget::Load signature to Load(bool showNotification = true).
Core Implementation
src/WeatherEditor/Widget.cpp
Widget::Load(bool showNotification) implemented; all user-facing notifications are gated on showNotification while parsing/reset behavior remains unchanged.
Batch Initialization
src/WeatherEditor/WeatherUtils.h
WidgetFactory::PopulateWidgets calls widget->Load(false) to suppress notifications during bulk population.
Editor Discovery / Preload Logic
src/Features/WeatherEditor.h, src/Features/WeatherEditor.cpp
Added cached widget-JSON discovery (HasWidgetJsonFiles() with s_checkedWidgetJsonFiles/s_hasWidgetJsonFiles), ShouldPreloadEditorResources(), and EnsureWeatherListLoaded().
Window Control
src/Features/WeatherEditor.h, src/Features/WeatherEditor.cpp
Added OpenEditorWindow() and ToggleEditorWindow() which validate EditorWindow::CanBeOpen() and call EnsureDataLoaded() when opening. DrawSettings() now calls EnsureWeatherListLoaded() and uses OpenEditorWindow() for the Open Editor action. Prepass() only calls EnsureDataLoaded() when ShouldPreloadEditorResources() is true.
Input Wiring
src/Menu.cpp
Weather editor hotkey now calls WeatherEditor::ToggleEditorWindow() and treats locked/playmode as ExitPreviewMode() when applicable.
Metadata
features/Weather Editor/Shaders/Features/WeatherEditor.ini
Bumped [Info] Version from 2-0-0 to 2-0-1.

Sequence Diagram(s)

sequenceDiagram
    participant Prepass as WeatherEditor::Prepass()
    participant Checker as WeatherEditor::HasWidgetJsonFiles()
    participant Window as EditorWindow
    participant Loader as WeatherEditor::EnsureDataLoaded()
    participant Factory as WidgetFactory::PopulateWidgets()
    participant Widget as Widget::Load(showNotification)

    Prepass->>Window: EditorWindow::CanBeOpen()?
    Prepass->>Checker: HasWidgetJsonFiles()?
    alt ShouldPreloadEditorResources() true
        Prepass->>Loader: EnsureDataLoaded()
        Loader-->>Prepass: resources initialized
    end
    Prepass->>Factory: PopulateWidgets()
    Factory->>Widget: widget->Load(false)
    Widget-->>Factory: initialized (notifications suppressed)
    Factory-->>Prepass: widgets ready
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • alandtse
  • davo0411

Poem

🐰
I hop through folders, sniff for json light,
Quiet loads at dusk so screens stay polite,
A window waits until the data's whole,
Widgets wake softly with notifications low,
I twitch—editor opens on a careful night.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.70% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title describes the main objective—fixing weather editor data loading on game start—which is clearly reflected in the PR's description, objectives, and code changes that conditionally preload weather data.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get your free trial and get 200 agent minutes per Slack user (a $50 value).


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/WeatherEditor/Widget.cpp (1)

93-145: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

showNotification is not consistently honored in error branches.

Load(false) suppresses success/no-file messages, but open/invalid/parse/unexpected-error paths still show notifications. In preload flows, a batch of bad files can still spam toasts.

Suggested fix
 void Widget::Load(bool showNotification)
 {
+    auto notify = [&](const std::string& message, const ImVec4& color, float duration = 3.0f) {
+        if (showNotification) {
+            EditorWindow::GetSingleton()->ShowNotification(message, color, duration);
+        }
+    };
+
     std::string filePath = GetSaveFilePath();
@@
-        EditorWindow::GetSingleton()->ShowNotification(
-            std::format("Failed to open file for {}", GetEditorID()),
-            ImVec4(1.0f, 0.5f, 0.0f, 1.0f),
-            3.0f);
+        notify(std::format("Failed to open file for {}", GetEditorID()),
+               ImVec4(1.0f, 0.5f, 0.0f, 1.0f));
@@
-            EditorWindow::GetSingleton()->ShowNotification(
-                std::format("Invalid file for {} - resetting to vanilla", GetEditorID()),
-                ImVec4(1.0f, 0.5f, 0.0f, 1.0f),
-                3.0f);
+            notify(std::format("Invalid file for {} - resetting to vanilla", GetEditorID()),
+                   ImVec4(1.0f, 0.5f, 0.0f, 1.0f));
@@
-        EditorWindow::GetSingleton()->ShowNotification(
-            std::format("Parse error for {} - resetting to vanilla", GetEditorID()),
-            ImVec4(1.0f, 0.0f, 0.0f, 1.0f),
-            3.0f);
+        notify(std::format("Parse error for {} - resetting to vanilla", GetEditorID()),
+               ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
@@
-        EditorWindow::GetSingleton()->ShowNotification(
-            std::format("Error loading {} - resetting to vanilla", GetEditorID()),
-            ImVec4(1.0f, 0.0f, 0.0f, 1.0f),
-            3.0f);
+        notify(std::format("Error loading {} - resetting to vanilla", GetEditorID()),
+               ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/WeatherEditor/Widget.cpp` around lines 93 - 145, The error branches
currently always call EditorWindow::GetSingleton()->ShowNotification (open-fail,
null JSON, parse_error catch, std::exception catch) even when showNotification
is false; update each place that calls ShowNotification (in the open failure
block, after js.is_null(), inside the parse_error catch, and inside the
std::exception catch) to only invoke ShowNotification when showNotification is
true, leaving settingsFile.close(), logger calls, js = json(), and
LoadSettings() behavior unchanged; refer to the symbols settingsFile, js,
showNotification, GetEditorID(), and LoadSettings() to locate and modify the
calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Features/WeatherEditor.cpp`:
- Around line 96-98: The three static flags s_dataAvailable,
s_resourcesInitialized, and s_weathersLoaded are never cleared so the prepass
(if (s_dataAvailable && !s_resourcesInitialized && EditorWindow::CanBeOpen()) {
EnsureDataLoaded(); }) only runs once; add a Reset() method (or logic) that
clears those flags and call it on game transitions or when
EditorWindow::CanBeOpen() transitions from false→true so EnsureDataLoaded() can
run again—implement Reset() to set s_dataAvailable = s_resourcesInitialized =
s_weathersLoaded = false and invoke it from the appropriate lifecycle hook (or
inside the code path that detects EditorWindow::CanBeOpen() becoming true) so
the preload cycle is retriggered.

---

Outside diff comments:
In `@src/WeatherEditor/Widget.cpp`:
- Around line 93-145: The error branches currently always call
EditorWindow::GetSingleton()->ShowNotification (open-fail, null JSON,
parse_error catch, std::exception catch) even when showNotification is false;
update each place that calls ShowNotification (in the open failure block, after
js.is_null(), inside the parse_error catch, and inside the std::exception catch)
to only invoke ShowNotification when showNotification is true, leaving
settingsFile.close(), logger calls, js = json(), and LoadSettings() behavior
unchanged; refer to the symbols settingsFile, js, showNotification,
GetEditorID(), and LoadSettings() to locate and modify the calls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f051050-59a1-4c43-b3cf-7e4eae27f444

📥 Commits

Reviewing files that changed from the base of the PR and between e9ee125 and 90b0f44.

📒 Files selected for processing (4)
  • src/Features/WeatherEditor.cpp
  • src/WeatherEditor/WeatherUtils.h
  • src/WeatherEditor/Widget.cpp
  • src/WeatherEditor/Widget.h

Comment thread src/Features/WeatherEditor.cpp Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/WeatherEditor/Widget.cpp (1)

73-73: Add an issue-closing reference in the PR description.

Since this is a bug fix, consider adding a keyword like Fixes #<issue> / Closes #<issue> for traceability and auto-close behavior.

As per coding guidelines, "Issue References (if PR fixes bugs or implements features): Suggest adding appropriate GitHub keywords: 'Fixes #123' or 'Closes #123' for bug fixes."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/WeatherEditor/Widget.cpp` at line 73, The PR is missing an issue-closing
reference for this bug fix; update the PR description to include a GitHub
keyword such as "Fixes #<issue>" or "Closes #<issue>" so the issue auto-closes
when merged — mention the related function/class (Widget::Load) in the PR
description or body to provide context and ensure traceability.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/WeatherEditor/Widget.cpp`:
- Line 73: The PR is missing an issue-closing reference for this bug fix; update
the PR description to include a GitHub keyword such as "Fixes #<issue>" or
"Closes #<issue>" so the issue auto-closes when merged — mention the related
function/class (Widget::Load) in the PR description or body to provide context
and ensure traceability.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 07569dc5-4c37-495c-b3ef-f475a5b6353c

📥 Commits

Reviewing files that changed from the base of the PR and between 30ae141 and 94cb9b4.

📒 Files selected for processing (1)
  • src/WeatherEditor/Widget.cpp

@alandtse
Copy link
Copy Markdown
Collaborator

alandtse commented May 2, 2026

This needs to only happen if there are overrides detected. The weather load is slow and if a user doesn't need it, should be gated. Please confirm.

@SkrubbySkrubInAShrub
Copy link
Copy Markdown
Collaborator Author

This needs to only happen if there are overrides detected. The weather load is slow and if a user doesn't need it, should be gated. Please confirm.

Sure, I'll add a check for when overrides are detected.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Features/WeatherEditor.cpp`:
- Around line 39-55: The code sets s_checkedWidgetJsonFiles = true too early and
treats filesystem errors from std::filesystem::is_directory as "no folder",
which permanently suppresses future scans; update WeatherEditor.cpp so that
s_checkedWidgetJsonFiles is only set after a successful directory probe or after
all folders were scanned without encountering I/O errors, and treat
std::error_code failures from std::filesystem::is_directory and
directory_iterator as real errors (log and abort the scan but do not flip
s_checkedWidgetJsonFiles to true). Specifically, adjust the loop over
Widget::kSaveFolderNames and checks around
std::filesystem::is_directory(widgetSettingsPath, ec) and the directory_iterator
to only set s_hasWidgetJsonFiles/s_checkedWidgetJsonFiles after a confirmed
successful inspection (use the existing logger::warn with ec.message() on
failure) so a transient I/O/path error does not permanently mark the check as
completed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4dc4140d-6a6e-46d1-9739-676c0f07f105

📥 Commits

Reviewing files that changed from the base of the PR and between 94cb9b4 and d743a5e.

📒 Files selected for processing (5)
  • src/Features/WeatherEditor.cpp
  • src/Features/WeatherEditor.h
  • src/Menu.cpp
  • src/WeatherEditor/Widget.cpp
  • src/WeatherEditor/Widget.h

Comment thread src/Features/WeatherEditor.cpp Outdated
@SkrubbySkrubInAShrub
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 2, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

✅ A pre-release build is available for this PR:
Download

Copy link
Copy Markdown
Collaborator

@alandtse alandtse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted review (Claude Sonnet 4.6) — please verify before acting on this.

The overall gating is correct — EnsureDataLoaded() is only reached when HasWidgetJsonFiles() returns true, and s_resourcesInitialized makes the whole check a one-shot after that. No data loads for users without override files.

One bug in HasWidgetJsonFiles(): the three filesystem error paths return false without setting s_checkedWidgetJsonFiles = true, so on any filesystem error the function retries the full directory scan every Prepass() frame rather than caching the negative result.

// src/Features/WeatherEditor.cpp – all three error exits should be `continue` not `return false`

if (ec) {
    logger::warn("[WeatherEditor] Failed to inspect widget settings path '{}': {}", ...);
-   return false;
+   continue;  // skip this folder, check the rest; cache result at end of loop
}

Same for the entryEc check (line ~55) and the post-loop iterator ec check (line ~64). With continue in all three places, errors are tolerated per-folder/per-entry, the remaining folders are still checked, and s_checkedWidgetJsonFiles = true at line 70 correctly caches the final answer regardless of errors.

@alandtse alandtse changed the title fix(weather-editor): Weather data on game load fix(weather-editor): weather data on game load May 3, 2026
Replace `return false` with `continue` in the three filesystem error
paths so the scan tolerates per-folder/per-entry errors and still
caches the final result via `s_checkedWidgetJsonFiles = true` at the
end of the loop. Previously, any filesystem error caused Prepass() to
re-scan all widget folders every frame.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alandtse
Copy link
Copy Markdown
Collaborator

alandtse commented May 3, 2026

Nevermind, handled it directly so we can merge

@alandtse alandtse merged commit 1089a6f into community-shaders:dev May 3, 2026
11 checks passed
ParticleTroned added a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 15, 2026
Adapted for cs-1.4.11-PL-VR: keep saved editor/weather override loading and active-cell gating while preloading Weather Editor resources only when saved widget JSON exists.
ParticleTroned added a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 15, 2026
Adapted for cs-1.4.11-PL-VR: keep saved editor/weather override loading and active-cell gating while preloading Weather Editor resources only when saved widget JSON exists.
ParticleTroned added a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 16, 2026
Adapted for cs-1.4.11-PL-VR: keep saved editor/weather override loading and active-cell gating while preloading Weather Editor resources only when saved widget JSON exists.
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