fix(weather): support multiple widget instances - #490
Conversation
Previously, weather_popup and weather_widget were defined at module level, causing all widget instances to share the same popup and highlight state. This resulted in incorrect behavior when using multiple weather widgets (e.g., for different cities): - Clicking one widget would show another widget's popup - Clicking one widget would highlight another widget in the bar This fix moves weather_popup and weather_widget inside the worker() function, ensuring each widget instance has its own isolated state.
Rename `weather_widget` to `widget` inside worker() to avoid shadowing the module-level `weather_widget` variable on line 43. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename `widget` parameter to `w` in update_widget() to avoid shadowing the outer `widget` variable on line 169. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Ryuno-Ki
left a comment
There was a problem hiding this comment.
As I can see only some renames and a move of some codeblock I vote for rejecting it.
As expected, LLMs like Claude produce low-quality PRs.
| local ICONS_DIR = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/' | ||
|
|
||
| -- Create popup per widget instance to support multiple weather widgets | ||
| local weather_popup = awful.popup { |
There was a problem hiding this comment.
Why was this moved down?
There was a problem hiding this comment.
I think the goal is to create several popup instead of only one.
This is the real need, this move create scope issue and trigger other renaming.
The renaming is bad, for me this should be improved not rejected.
| } | ||
|
|
||
| local function update_widget(widget, stdout, stderr) | ||
| local function update_widget(w, stdout, stderr) |
There was a problem hiding this comment.
Why was the variable renamed?
There was a problem hiding this comment.
I think this is actually an improvement over the actual code.
Renaming the variable here prevents shadowing from the local widget variable from line 169. Making the widget line 169 local makes the main worker function a real constructor/factory/builder that creates new instances of the widget instead of using one shared (that gets overwritten by multiple call of the worker?).
|
Let me improve the naming
…On Wed, 28 Jan, 2026, 16:26 Aurélien Lajoie, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In weather-widget/weather.lua
<#490 (comment)>
:
> @@ -152,6 +140,20 @@ local function worker(user_args)
local timeout = args.timeout or 120
local ICONS_DIR = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/'
+
+ -- Create popup per widget instance to support multiple weather widgets
+ local weather_popup = awful.popup {
I think the goal is to create several popup instead of only one.
This is the real need, this move create scope issue and trigger other
renaming.
The renaming is bad, for me this should be improved not rejected.
—
Reply to this email directly, view it on GitHub
<#490 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAD4L57QPCNJBCAD6GGFNJD4JCIXTAVCNFSM6AAAAACTB4Z5TWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTOMJWGA2DKNZSHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Rename parameter 'w' to 'weather_icon' for better readability. This addresses review feedback about unclear variable naming while maintaining the fix for variable shadowing with the outer 'widget'. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
This PR fixes an issue where multiple weather widget instances share the same popup and highlight state, causing incorrect behavior.
Problem:
When using multiple weather widgets (e.g., for different cities), the following issues occur:
Root Cause:
weather_popupandweather_widgetwere defined at module level, so all widget instances created by callingweather_widget({...})shared the same popup and widget reference.Fix:
Move
weather_popupandweather_widgetdeclarations inside theworker()function, ensuring each widget instance has its own isolated state.Test plan
🤖 Generated with Claude Code