Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

PR #676 removed NeighboringFilesQuery from the Playlist model, breaking subtitle auto-detection for videos. CompositeTrackPickerViewModel could no longer access the file query needed to search for subtitle files matching the video filename in the same directory.

Changes

Pass NeighboringFilesQuery through message pipeline:

  • Add NeighboringFilesQuery property to PlaylistCurrentItemChangedMessage
  • Update MediaListViewModel to include _neighboringFilesQuery when sending the message
  • Modify CompositeTrackPickerViewModel.GetSubtitlesForFile() to accept and use the query from the message

Restore original subtitle detection logic:

// When query is available, filter neighboring files for matching subtitles
if (neighboringFilesQuery != null)
{
    IReadOnlyList<StorageFile> files = await neighboringFilesQuery.GetFilesAsync(0, 50);
    subtitles = files.Where(f =>
            f.IsSupportedSubtitle() && f.Name.StartsWith(
                Path.GetFileNameWithoutExtension(sourceFile.Name),
                StringComparison.OrdinalIgnoreCase))
        .ToArray();
}

This reuses the existing query from the playlist rather than creating a new one, matching pre-#676 behavior while maintaining the architectural improvements.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • crl.godaddy.com
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/Screenbox/.codeql-scratch/dbs/csharp/working/3256F08C1671F9FA0FA5343B5C71D01D/missingpackages_workingdir --packages /home/REDACTED/work/Screenbox/.codeql-scratch/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /home/REDACTED/work/Screenbox/.codeql-scratch/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • ocsp.godaddy.com
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/Screenbox/.codeql-scratch/dbs/csharp/working/3256F08C1671F9FA0FA5343B5C71D01D/missingpackages_workingdir --packages /home/REDACTED/work/Screenbox/.codeql-scratch/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /home/REDACTED/work/Screenbox/.codeql-scratch/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>cannot load subtitles automatically</issue_title>
<issue_description>Describe the bug
I name the subtitle files the same as video files. But when I open the video files, subtitles cannot load automatically, even if I set the option --sub-autodetect-fuzzy = (I tried 0 to 2)

Screenshots

This is how I name the file.

Image

This is how it shows.

Image

Environment

  • OS: Windows 11 26200.7171
  • App Version: 0.17.0.0
    </issue_description>

<agent_instructions>This is a regression introduced in #676 that removed the logic that allow CompositeTrackPickerViewModel to get the current active NeighboringFilesQuery. The Playlist instance returned by PlaylistRequestMessage no longer has a reference to a NeighboringFilesQuery anymore. It's probably better to include the current NeighboringFilesQuery in the PlaylistCurrentItemChangedMessage.

StorageFileQueryResult? query = Messenger.Send<PlaylistRequestMessage>().Response.NeighboringFilesQuery;
            if (query != null)
            {
                try
                {
                    IReadOnlyList<StorageFile> files = await query.GetFilesAsync(0, 50);
                    subtitles = files.Where(f =>
                            f.IsSupportedSubtitle() && f.Name.StartsWith(
                                Path.GetFileNameWithoutExtension(sourceFile.Name),
                                StringComparison.OrdinalIgnoreCase))
                        .ToList();
                }
                catch (Exception e)
                {
                    LogService.Log(e);
                }
            }
```</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@huynhsontung</author><body>
Sorry for the late response, but this was certainly a regression in v0.17.0, created from huynhsontung/Screenbox#676. The `CompositeTrackPickerViewModel` no longer had access to the neighbouring file query that was used to check for available subtitle files in the same folder. App version 0.16.x should not have this issue.</body></comment_new>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 3, 2025 05:33
…ssage to fix subtitle auto-loading

Co-authored-by: huynhsontung <31434093+huynhsontung@users.noreply.github.com>
Co-authored-by: huynhsontung <31434093+huynhsontung@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with automatic subtitle loading for video files Fix subtitle auto-loading regression from PR #676 Dec 3, 2025
Copilot AI requested a review from huynhsontung December 3, 2025 05:40
@huynhsontung huynhsontung changed the title Fix subtitle auto-loading regression from PR #676 fix: subtitle auto-loading regression from PR #676 Dec 4, 2025
@huynhsontung huynhsontung marked this pull request as ready for review December 4, 2025 06:55
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Dec 4, 2025
@huynhsontung huynhsontung merged commit c64efe1 into main Dec 13, 2025
4 checks passed
@huynhsontung huynhsontung deleted the copilot/fix-subtitle-loading-issue branch December 13, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot load subtitles automatically

2 participants