refactor(extension): split Lua manager#66
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughSplits the extension manager into source discovery, loader with injected ChangesExtension Manager Refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #66 +/- ##
==========================================
+ Coverage 62.35% 62.64% +0.28%
==========================================
Files 185 188 +3
Lines 17852 17910 +58
==========================================
+ Hits 11132 11220 +88
+ Misses 5622 5591 -31
- Partials 1098 1099 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/extension/manager_dispatch.go`:
- Around line 13-27: The ExecuteCommand implementation may call into Lua after
the context is already canceled; add an early context-cancellation guard (check
ctx.Err()) immediately after verifying the command exists and before invoking
callLua so you return the context error without running extension code; apply
the same pattern wherever similar logic exists (e.g., other manager methods that
call callLua or call extension.function) to check ctx.Err() before executing any
extension code.
In `@internal/extension/manager_loader.go`:
- Around line 143-153: If DoFile or PCall fails, existing registrations from the
partially-initialized luaExtension remain pointing at a closed runtime; call a
rollback routine on the Manager to remove those registrations before closing the
runtime and returning. Add a method like Manager.unregisterRuntime(rt
*luaExtension) that locks the manager and deletes entries in manager.commands
and manager.tools using rt.commands and rt.tools (and removes any
handlers/keymaps tied to rt), then invoke
manager.unregisterRuntime(extensionRuntime) immediately on any error path
(before calling extensionRuntime.state.Close() and returning) for both the
DoFile failure and the PCall/setup failure paths (and similarly for the later
failure paths referenced around 157-159).
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c3ffb770-3fc5-4368-b352-587b00eefa5a
📒 Files selected for processing (4)
internal/extension/manager.gointernal/extension/manager_dispatch.gointernal/extension/manager_loader.gointernal/extension/manager_sources.go
💤 Files with no reviewable changes (1)
- internal/extension/manager.go
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/extension/manager_test.go (1)
598-600: ⚡ Quick winTighten failure-path assertions to avoid false-positive passes.
Both rollback tests only assert that an error exists. Please assert a stable substring that proves the intended failure path (
loadvssetup) so unrelated failures don’t satisfy the test.Proposed diff
- err := manager.LoadFile(context.Background(), extensionPath) - require.Error(t, err) + err := manager.LoadFile(context.Background(), extensionPath) + require.ErrorContains(t, err, "extension: load") + require.ErrorContains(t, err, "boom") @@ - err := manager.LoadPaths(context.Background(), []string{extensionRoot}) - require.Error(t, err) + err := manager.LoadPaths(context.Background(), []string{extensionRoot}) + require.ErrorContains(t, err, "extension: setup") + require.ErrorContains(t, err, "boom")Also applies to: 629-631
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/extension/manager_test.go` around lines 598 - 600, The tests currently only check that manager.LoadFile(...) returns an error and manager.Commands() is empty, which can hide unrelated failures; update the assertions to assert that the returned error contains a stable substring indicating the intended failure path (e.g., assert.ErrorContains(t, err, "load failed" or the exact load-specific message from LoadFile for the first test, and similarly assert.ErrorContains(t, err, "setup failed" or the setup-specific message for the second test), and keep the assert.Empty(t, manager.Commands()) checks; apply the same change to the other occurrence referenced (the block around the lines noted for 629-631) so both rollback tests validate a specific failure path rather than any error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/extension/manager_test.go`:
- Around line 598-600: The tests currently only check that manager.LoadFile(...)
returns an error and manager.Commands() is empty, which can hide unrelated
failures; update the assertions to assert that the returned error contains a
stable substring indicating the intended failure path (e.g.,
assert.ErrorContains(t, err, "load failed" or the exact load-specific message
from LoadFile for the first test, and similarly assert.ErrorContains(t, err,
"setup failed" or the setup-specific message for the second test), and keep the
assert.Empty(t, manager.Commands()) checks; apply the same change to the other
occurrence referenced (the block around the lines noted for 629-631) so both
rollback tests validate a specific failure path rather than any error.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bba51c09-6439-4102-8bf4-3fde4c2feadc
📒 Files selected for processing (4)
internal/extension/manager.gointernal/extension/manager_dispatch.gointernal/extension/manager_loader.gointernal/extension/manager_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
- internal/extension/manager.go
- internal/extension/manager_dispatch.go
- internal/extension/manager_loader.go
|



Summary\n- split the Lua extension manager into focused loader, dispatch, and source files\n- keep public Manager API and behavior unchanged\n\n## Validation\n- mise exec -- go test ./internal/extension\n- mise exec -- task ci