CmdPal: Update WebSearch extension history immediately (#41398)

## Summary of the Pull Request

This PR ensures that the list of recent searches in the Web Search
extension is updated immediately after a new item is added or when
settings controlling the number of items are changed.

- Refactors the Web Search extension history to keep it in memory after
being loaded at startup
- Adds an event to notify subscribers when the history changes  
- Implements `IDisposable` to ensure that `WebSearchListPage`
unsubscribes from the event
- Moves responsibility for creating all list items to single class
(`WebSearchListPage`)
- Updated unit tests
- 
## PR Checklist

- [x] Closes: #40548
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end-user-facing strings can be localized
- [x] **Dev docs:** nothing
- [x] **New binaries:** none
- [x] **Documentation updated:** nope

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
This commit is contained in:
Jiří Polášek
2025-09-03 20:47:33 +02:00
committed by GitHub
parent 347c3f1efa
commit 7d8f64cf3c
10 changed files with 342 additions and 208 deletions

View File

@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -9,11 +10,13 @@ namespace Microsoft.CmdPal.Ext.WebSearch.Helpers;
public interface ISettingsInterface
{
event EventHandler? HistoryChanged;
public bool GlobalIfURI { get; }
public uint HistoryItemCount { get; }
public int HistoryItemCount { get; }
public List<ListItem> LoadHistory();
public IReadOnlyList<HistoryItem> HistoryItems { get; }
public void SaveHistory(HistoryItem historyItem);
public void AddHistoryItem(HistoryItem historyItem);
}