Skip to content

Develop#3

Merged
Insality merged 6 commits intomainfrom
develop
Dec 22, 2025
Merged

Develop#3
Insality merged 6 commits intomainfrom
develop

Conversation

@Insality
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings December 22, 2025 16:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces significant refactoring to the event bus system to support entity-based event tracking, along with minor code style improvements and bug fixes.

  • Adds entity-based event lookup capabilities to the event bus for performance optimization
  • Changes event processing API from iterating individual events to batch processing
  • Standardizes string literal style and fixes variable reference

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
decore/internal/event_bus.lua Adds entity-based event tracking with events_by_entity and stash_by_entity maps; changes merge callback and process function signatures (breaking changes)
decore/internal/decore_utils.lua Standardizes string literal style from single to double quotes
decore/internal/decore_logger.lua Updates function documentation to remove unused second return value
decore/internal/decore_data.lua Fixes variable reference from decore_internal.logger to logger
decore/decore.lua Inlines TYPE_TABLE constant to simplify code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

---@field events table<string, table[]> The list of events group by event name. Array part of entities map is the order of entities event's triggers
---@field stash table<string, table[]> Events to be processed in PostWrap
---@field merge_callbacks table<string, fun(events: any[], new_event: any):boolean> The merge policy for events. If the merge policy returns true, the events are merged and not will be added as new event
---@field events table<string, any[]> The list of events group by event name. Array part of entities map is the order of entities event's triggers
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The documentation states "Array part of entities map is the order of entities event's triggers" which contains a grammatical error. It should be "entity's" (possessive singular) or "entities'" (possessive plural), but the phrase structure is unclear. Consider revising to clarify the meaning, such as "Array contains events in the order they were triggered for each entity".

Suggested change
---@field events table<string, any[]> The list of events group by event name. Array part of entities map is the order of entities event's triggers
---@field events table<string, any[]> The list of events grouped by event name. Array elements are ordered by the time the events were triggered

Copilot uses AI. Check for mistakes.
---@field events_by_entity table<string, table<entity, any[]>> Maps event_name -> entity -> array of events for fast lookup
---@field stash table<string, any[]> Events to be processed in PostWrap
---@field stash_by_entity table<string, table<entity, any[]>> Maps event_name -> entity -> array of events for stash (fast lookup)
---@field merge_callbacks table<string, fun(new_event: any, events: any[], entity_map: table<entity, any[]>):boolean> The merge policy for events. If the merge policy returns true, the events are merged and not will be added as new event
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The documentation states "the events are merged and not will be added as new event" which contains a grammatical error. The phrase "not will be" should be "will not be". Consider revising to "the events are merged and will not be added as a new event".

Suggested change
---@field merge_callbacks table<string, fun(new_event: any, events: any[], entity_map: table<entity, any[]>):boolean> The merge policy for events. If the merge policy returns true, the events are merged and not will be added as new event
---@field merge_callbacks table<string, fun(new_event: any, events: any[], entity_map: table<entity, any[]>):boolean> The merge policy for events. If the merge policy returns true, the events are merged and will not be added as a new event

Copilot uses AI. Check for mistakes.
Comment on lines +79 to 81
---@param merge_callback (fun(new_event: any, events: any[], entity_map: table<entity, any[]>):boolean)|nil The callback function to merge the events. Return true if the events were merged, false otherwise.
function M:set_merge_policy(event_name, merge_callback)
self.merge_callbacks[event_name] = merge_callback
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The merge callback signature has been changed from fun(events: any[], new_event: any) to fun(new_event: any, events: any[], entity_map: table<entity, any[]>). This is a breaking API change that will cause existing merge policy implementations to fail. The existing implementations in system/health/system_health.lua and system/transform/system_transform.lua use the old signature with only two parameters and will not work correctly with the new three-parameter call at line 41. Consider maintaining backward compatibility by checking the function's parameter count or providing migration guidance.

Suggested change
---@param merge_callback (fun(new_event: any, events: any[], entity_map: table<entity, any[]>):boolean)|nil The callback function to merge the events. Return true if the events were merged, false otherwise.
function M:set_merge_policy(event_name, merge_callback)
self.merge_callbacks[event_name] = merge_callback
---@param merge_callback (fun(new_event: any, events: any[], entity_map: table<entity, any[]>):boolean|fun(events: any[], new_event: any):boolean)|nil The callback function to merge the events. Return true if the events were merged, false otherwise.
function M:set_merge_policy(event_name, merge_callback)
if not merge_callback then
self.merge_callbacks[event_name] = nil
return
end
-- Maintain backward compatibility with legacy merge callbacks that use the
-- old signature: fun(events: any[], new_event: any)
local info = type(debug) == "table" and debug.getinfo and debug.getinfo(merge_callback, "u") or nil
if info and info.nparams == 2 then
-- Wrap legacy callback so it sees (events, new_event) in the expected order.
self.merge_callbacks[event_name] = function(new_event, events, entity_map)
-- entity_map is not available in the legacy signature and is ignored.
return merge_callback(events, new_event)
end
else
-- New-style or variadic callback; pass through as-is.
self.merge_callbacks[event_name] = merge_callback
end

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +69
if callback then
if context then
callback(context, events)
else
callback(events)
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The process function signature has been changed to pass the full array of events to the callback instead of calling it for each individual event. This is a breaking API change. The old API called callback(context, event) for each event in a loop, but the new API calls callback(context, events) once with the full array. Existing callback implementations like process_window_event and process_transform_event in system/camera/system_camera.lua expect individual events, not arrays, and will fail with this change. Consider maintaining backward compatibility or providing clear migration guidance.

Copilot uses AI. Check for mistakes.
@Insality Insality merged commit 038ac55 into main Dec 22, 2025
1 check passed
@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (d01efcf) to head (04e5944).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #3       +/-   ##
=======================================
- Coverage   52.60%    0   -52.61%     
=======================================
  Files          17    0       -17     
  Lines        1230    0     -1230     
=======================================
- Hits          647    0      -647     
+ Misses        583    0      -583     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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