[Bug] Headless tests: the data folder a test gives `MainWindowViewModel` does not reach its core, which reads the real per-user `settings.cfg`

Open
#475 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 5 days

@syntaki is already working on this.

Since Dec 1, 2026.

  • #476 by @syntaki — open

Assessment

This issue has not been assessed yet.

Description

What happened

MainWindowViewModel has a constructor for tests that takes a data folder. The view model's own paths go there, but the core it builds does not get the folder. That core looks up the real per-user Genie5 folder and loads the settings.cfg it finds there.

So a headless test that builds a core through the view model can depend on the settings of whoever runs it, and a test that connects would write its logs beside the real ones.

What you expected

The folder a test hands to the constructor should be the core's folder too.

Steps to reproduce

  1. Add this test to tests/Genie.App.HeadlessTests:

    [AvaloniaFact]
    public async Task The_core_a_test_builds_uses_the_tests_data_folder()
    {
        var dir = Path.Combine(Path.GetTempPath(), "genie_folder_" + Guid.NewGuid().ToString("N"));
        Directory.CreateDirectory(Path.Combine(dir, "Config"));
        File.WriteAllText(Path.Combine(dir, "Config", "settings.cfg"), "#config {prompt} {only-in-the-test-folder}\n");
        var vm = new MainWindowViewModel(startup: null, dataDirectoryOverride: dir);
    
        vm.Command.CommandText = "#echo hello";      // the first typed command builds the core
        vm.Command.SubmitCommand.Execute().Subscribe();
        Dispatcher.UIThread.RunJobs();
    
        var core = Assert.IsType<Genie.Core.GenieCore>(vm.Core);
        try
        {
            Assert.StartsWith(Path.GetFullPath(dir), Path.GetFullPath(core.Config.ConfigDir));
            Assert.Equal("only-in-the-test-folder", core.Config.GetSetting("prompt"));
        }
        finally { await core.DisposeAsync(); }
    }
    
  2. Run it. It fails: the core's ConfigDir is the per-user folder, not the test's.

The existing suite shows it too: dotnet test tests/Genie.App.HeadlessTests reads ~/.local/share/Genie5/Config/settings.cfg (its access time moves during the run). All 359 tests still pass with my settings, and the suite writes nothing there today.

Environment

  • OS + version: Ubuntu 26.04
  • Genie 5 version: main as of d1373a5 (5.0.1-beta.5)
  • Install type: built from source
  • Connection mode: not connected (the steps need no connection)

Logs / session capture

Failed Genie.App.HeadlessTests.ReportProbeTests.The_core_a_test_builds_uses_the_tests_data_folder [361 ms]
   Assert.StartsWith() Failure: String start does not match
String:         "~/.local/share/Genie5/Config"
Expected start: "/tmp/genie_folder_070faa89b2fc416d98edb97"···

Anything else

Cause, as far as I can read it:

  • The constructor passes dataDirectoryOverride to its own LocalDirectoryService only.
  • Where the core is built (new GenieCore(dataDirectoryOverride: …)), the argument is the connected profile's data directory or null. With null the core resolves the per-user folder itself.

The same is true of main as of d1373a5.

Workaround: a test can build its GenieCore directly with dataDirectoryOverride, when it does not need the view model.

I have a fix with tests (the constructor's folder is passed on to the core when the profile names none; a real start passes no folder and is unchanged), and a pull request follows.

Dominant language
C#
Stars
2
Forks
5
Avg merge
4d 3h
Merged PRs (30d)
22

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GenieClient/Genie5

All issues in GenieClient/Genie5

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.