Skip to content

Conversation

@xrlzu
Copy link
Member

@xrlzu xrlzu commented Oct 22, 2025

PixPin_2025-10-22_16-42-03

@pcl-ce-automation pcl-ce-automation bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: L PR 大小评估:大型 labels Oct 22, 2025
@pynickle pynickle requested a review from Copilot October 24, 2025 04:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds search and sort functionality to the instance saves management page. The implementation includes a search box for filtering saves by name, sort options (by filename, creation time, or modification time), and a file system watcher to automatically refresh the saves list when changes occur.

Key Changes:

  • Added search functionality with fuzzy matching for save names
  • Implemented three sorting methods: filename, creation time, and modification time
  • Added FileSystemWatcher for automatic refresh on file system changes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
PageInstanceSaves.xaml.vb Implements search/sort logic, FileSystemWatcher integration, and UI refresh handling
PageInstanceSaves.xaml Adds search box UI component and sort button to the interface

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


Private Sub OnFileSystemChanged(sender As Object, e As FileSystemEventArgs)
RunInUi(Sub()
Threading.Thread.Sleep(100)
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Thread.Sleep in a UI callback can block the UI thread. Consider using a debounce mechanism with a timer instead to batch multiple rapid file system changes and avoid potential UI freezes.

Copilot uses AI. Check for mistakes.
End If
Try
If IsSearching Then
PanListBack.Title = $"搜索结果 ({_searchResult?.Count})"
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential issue: _searchResult?.Count will return Nothing (null) when _searchResult is Nothing, which will display as empty string in the title. Use _searchResult?.Count.GetValueOrDefault(0) or handle the null case explicitly to always show a number.

Suggested change
PanListBack.Title = $"搜索结果 ({_searchResult?.Count})"
PanListBack.Title = $"搜索结果 ({_searchResult?.Count.GetValueOrDefault(0)})"

Copilot uses AI. Check for mistakes.
If IsSearching Then
Dim queryList As New List(Of SearchEntry(Of String))
For Each saveFolder In saveFolders
Dim folderName = GetFolderNameFromPath(saveFolder)
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function GetFolderNameFromPath is called but not defined in this file. Verify that this function exists and is accessible, otherwise this will cause a compilation error.

Copilot uses AI. Check for mistakes.
fileSystemWatcher.Dispose()
End If

fileSystemWatcher = New FileSystemWatcher()
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing validation: if WorldPath doesn't exist or is invalid, this will throw an ArgumentException. Add a check using Directory.Exists(WorldPath) before setting the Path property.

Suggested change
fileSystemWatcher = New FileSystemWatcher()
fileSystemWatcher = New FileSystemWatcher()
If Not Directory.Exists(WorldPath) Then Directory.CreateDirectory(WorldPath)

Copilot uses AI. Check for mistakes.
searchSource.Add(New KeyValuePair(Of String, Double)(folderName, 1))
queryList.Add(New SearchEntry(Of String) With {.Item = saveFolder, .SearchSource = searchSource})
Next
_searchResult = Search(queryList, SearchBox.Text, MaxBlurCount:=6, MinBlurSimilarity:=0.35).Select(Function(r) r.Item).ToList()
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search operation executes on every TextChanged event, which could cause performance issues with large save lists. Consider implementing debouncing to delay search execution until the user stops typing.

Copilot uses AI. Check for mistakes.
@xrlzu xrlzu closed this Oct 26, 2025
@pcl-ce-automation pcl-ce-automation bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: XS PR 大小评估:微型 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: L PR 大小评估:大型 labels Oct 26, 2025
@xrlzu
Copy link
Member Author

xrlzu commented Oct 26, 2025

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS PR 大小评估:微型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant