workspace: fix test registry pollution, rename to managed-projects.json, slug-based entries - #81
Merged
Conversation
…test paths - Rename registry.json -> managed-projects.json (FilePathConstants, GlobalPaths) - Add Slug property to WorkspaceRegistryEntry for direct slug lookup - Add WorkspacePaths-based WorkspaceService constructor with injectable registryFilePath so tests never touch the real global registry - Add CreateProject(slug, name) short overload deriving codebasePath from paths - RegisterEntry deduplicates by path (OrdinalIgnoreCase) and stores slug - App.xaml.cs: update RegistryFile -> ManagedProjectsFile reference - WorkspaceServiceTests: IDisposable cleanup + temp registry path - ConsistencyCheckServiceTests: temp registry path - ProductionReadinessIntegrationTests: temp registry, named params for CreateProject - ConsistencyUiAndDetectionIntegrationTests: temp registry path - ProjectSettingsViewModelTests: temp registry + explicit codebasePath overload Fixes stale temp-dir entries accumulating in the real registry from test runs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
DecisionsViewModelTests: - Id.Value.ShouldBe() to avoid Shouldly IEnumerable<char> ambiguity on DecisionId - Add missing IAgentInboxService arg to DecisionChatService constructor - Fix CS4014: capture ShouldNotBeNull() result before await ProjectSettingsViewModelTests: - AgentExecutorName.AnthropicValue (string const) -> AgentExecutorName.Anthropic (typed) for all ModelDescriptor constructors and GetModelsForExecutor() calls - Arg.Any<string>() -> Arg.Any<AgentExecutorName>() for IModelRegistry mock setup - AgentTemplatesService(_paths) -> AgentTemplatesService(_templatesDir) (add _templatesDir field) - _paths.Root = _rootPath/.ai-dev so CreateProject(codebasePath:_rootPath) aligns with what WorkspacePaths expects (paths must match .ai-dev structure) ai-dev.ui.winui.csproj: - Scope PublishReadyToRun and PublishTrimmed to actual publish operations only (add ' != ''' condition) so building the test project in Release doesn't trigger NETSDK1094/NETSDK1102 ILLink errors Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ix DI ambiguity WorkspaceService had two constructors after the registry refactor, making the DI container throw 'ambiguous constructors' when both WorkspacePaths and ActiveWorkspaceHolder were resolvable (both registered by callers + AddAiDevCore). Fixes: - Remove ActiveWorkspaceHolder and WorkspacePaths registrations from AddAiDevCore (callers own these registrations, as they did before the refactor) - Merge WorkspaceService into a single constructor: WorkspaceService(WorkspacePaths, AtomicFileWriter, ActiveWorkspaceHolder? = null, string? registryFilePath = null, ILogger? = null) - Register WorkspaceService via explicit factory in AddAiDevCore, using GetRequiredService<WorkspacePaths> and GetService<ActiveWorkspaceHolder> (null in API context; real holder in WinUI context) All tests now pass (625 unit + 60 integration + 10 WinUI) and registry.json is never modified by any test run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
auleewilliams
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running tests was polluting the real user registry (
%LOCALAPPDATA%\AiDevStudio\registry.json) with stale "Demo Project" entries from temp directories. Every call toWorkspaceService.CreateProject→RegisterPathwrote to the production registry file, so repeated test runs accumulated junk entries visible in the WinUI app.Changes
Core: registry isolation
WorkspaceService— added optionalstring? registryFilePathparameter andEffectiveRegistryFileproperty. When non-null, all registry reads/writes use this path instead of the global one. Tests pass a temp path; production DI path is unaffected.CoreServiceExtensions.AddAiDevCore— removedActiveWorkspaceHolder/WorkspacePathsfrom the shared DI registration (hosts register those themselves); uses an explicit factory forWorkspaceServiceto avoid DI constructor ambiguity in .NET 10.Core: registry refactor
FilePathConstants— renamed constant toManagedProjectsFileName = "managed-projects.json"GlobalPaths—ManagedProjectsFileproperty replacesRegistryFile; filename is nowmanaged-projects.jsonWorkspaceRegistryEntry— addedSlugproperty so each entry stores{ path, slug }WorkspaceService—RegisterPath→RegisterEntry(path, slug); stores both fieldsTests: full isolation
All test classes now use a temp registry path — no test will ever write to the real user registry:
WorkspaceServiceTestsIDisposable, temp_registryPath, passed to constructorConsistencyCheckServiceTestsProductionReadinessIntegrationTestsGlobalPaths.RegistryFile→ temp pathConsistencyUiAndDetectionIntegrationTestsProjectSettingsViewModelTestsWorkspacePathsroot alignment,AgentExecutorNametyped propertiesDecisionsViewModelTestsIAgentInboxServicearg,.Value.ShouldBe()forDecisionId, CS4014 fixWinUI: csproj hygiene
PublishReadyToRun/PublishTrimmedto publish-only targets to avoid spurious build warningsApp.xaml.csto referenceGlobalPaths.ManagedProjectsFileResult