You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
KeybindingManagerFactory.CreateManager(dataDirectory) shares DI-singleton profiles/commands across directories, leaking one directory's profiles into another's files #114
When a service provider is present, KeybindingManagerFactory.CreateManager(string dataDirectory) (Keybinding/Services/KeybindingManagerFactory.cs:~53-68) resolves the singletonICommandRegistry and IProfileManager, which are registered as singletons in Extensions/ServiceCollectionExtensions.cs:~43-44. Only the JsonKeybindingRepository is new per directory.
So every manager created for a different directory shares one in-memory set of profiles and commands.
Relatedly, CreateManager() with no arguments returns the DI singleton KeybindingManager, although its doc says "A new KeybindingManager instance".
Failure scenario (reproduced with a temporary MSTest)
An app that keeps per-user or per-workspace keybinding directories gets them cross-contaminated on the first save.
Suggested fix
In CreateManager(dataDirectory), always construct fresh state: new CommandRegistry() and new ProfileManager(), or simply new KeybindingManager(dataDirectory). Resolve from DI only for dependencies that are safe to share. Also either make CreateManager() return a new instance, or correct its doc.
Acceptance: managers created for two different directories don't see each other's profiles, and each directory's profiles.json contains only its own.
Priority: High. An app that keeps separate keybinding directories (per user or per workspace) has them cross-contaminated on the first save, and the wrong profiles are written to disk. That is silent, persistent data corruption, and it happens on an ordinary call sequence.
Area:KeybindingManagerFactory.CreateManager and the singleton registrations in ServiceCollectionExtensions
Suggested assignment: Keybinding maintainer, DI/factory area
Notes:new KeybindingManager(dataDirectory) is the smallest correct fix. The doc/behaviour mismatch on the parameterless CreateManager() is a second, cheaper fix. Correcting the doc avoids a behaviour change for DI consumers who rely on getting the singleton.
Activity
matt-edmondson commentedon Sep 26, 2026
Triage
KeybindingManagerFactory.CreateManagerand the singleton registrations inServiceCollectionExtensionsProfileManager. Related to Delegate profile/command JSON persistence to ktsu.AppDataStorage #93 (delegate persistence toktsu.AppDataStorage): whichever lands second should keep "fresh state per directory" as an invariant.SaveAsync) is in the same save path but does not touch the factory.Notes:
new KeybindingManager(dataDirectory)is the smallest correct fix. The doc/behaviour mismatch on the parameterlessCreateManager()is a second, cheaper fix. Correcting the doc avoids a behaviour change for DI consumers who rely on getting the singleton.Generated by Claude Code