Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCentralized plugin cleanup on load failure/non-registration, added plugin-scoped timer controls and safer timer goroutine flow, bumped two indirect Go module versions, and added tests verifying timers, hooks, and visualizers are removed when plugin load fails. Changes
Sequence Diagram(s)sequenceDiagram
participant Manager
participant Plugin
participant LuaState
participant TimerGoroutine
Manager->>Plugin: create Plugin instance
Manager->>LuaState: L.DoFile(path) (holds p.mu)
LuaState-->>Plugin: executes script (may register timers/hooks/visualizer)
LuaState-->>Manager: register calls (hooks, visPlugs, visMap, timers)
alt DoFile succeeds and plugin registers
Manager->>Plugin: release p.mu (normal lifecycle)
else DoFile fails or plugin doesn't register
Manager->>Manager: cleanupPlugin(p)
Manager->>TimerGoroutine: stopPlugin(p) (remove timer entries)
TimerGoroutine-->>TimerGoroutine: timers check tm.take/tm.active and exit without invoking callbacks
Manager->>Manager: remove hooks, visPlugs, visMap entries
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@luaplugin/luaplugin_test.go`:
- Around line 108-159: Add a new test case in
TestLoadPluginCleanupStopsPendingTimers that exercises recurring timers via
cliamp.timer.every so the tm.active(id) bail-out path is covered: extend the
test's cases slice with a case (e.g., name "every") whose code uses
cliamp.timer.every(0.01, function() cliamp.fs.write(%q, "fired") end) followed
by cliamp.sleep(0.05) (mirroring the existing after-case), and run it in the
same t.Run flow (expecting no plugin for the no-register path or using expectErr
where appropriate) so the test asserts the recurring-timer callback is not
invoked after cleanup. Ensure the new case uses the same path formatting and
post-check (os.Stat) as the other cases.
In `@luaplugin/luaplugin.go`:
- Around line 220-236: The slices m.hooks and m.visPlugs currently reuse backing
arrays via hooks[:0] and m.visPlugs[:0], leaving removed *luaHook and *luaVis
pointers in the unused tail and preventing GC; update the removal code to zero
out the dropped tail elements before reassigning (for each original slice
iterate the old range after filtering and set remaining slots to nil or
explicitly clear entries in the old slice) so that removed luaHook/luaVis values
and the failed plugin p are not retained; reference m.hooks, hooks, *luaHook,
m.visPlugs, vis and *luaVis when making the change.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: afba1601-be5a-4938-b82a-162832cfb932
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (4)
go.modluaplugin/api_timer.goluaplugin/luaplugin.goluaplugin/luaplugin_test.go
Fixes two races found by running
go test -race1st:
luaplugin: timer callbacks can enter the same Lua VM concurrently with plugin loading, sogopher-luasees unsynchronized access to one*lua.LState. Fixed by plugin loading now holding the same mutex that timer callbacks use, so the Lua VM can’t be entered concurrently during startup. Cleanup also stops a plugin’s timers so callbacks can’t fire after failed or skipped loads.Test output:
2nd:
ui/model: there is a race in the oto v3.3.x (coming from beep). oto v3.4.0 does not have this issue. So, fix was just a bump. I have also opened a PR to beep to bump oto gopxl/beep#222Test output:
Summary by CodeRabbit
Chores
Bug Fixes
Tests