Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/skills/add-extension-settings/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: >-

# Add Extension Settings

Add a settings page to your Command Palette extension using the built-in settings helpers. Settings are automatically persisted and restored by the extension host.
Add a settings page to your Command Palette extension using the built-in settings helpers. These helpers hold form values in memory; the extension must explicitly load and save them to persist choices across restarts.

## When to Use This Skill

Expand All @@ -23,7 +23,9 @@ Add a settings page to your Command Palette extension using the built-in setting

### Step 1: Create a Settings Manager

Create a new file `SettingsManager.cs`:
The following example illustrates wiring settings only; it is not a complete persistent settings manager. In this repository, extend the existing [CodexUsageDockSettingsPage](../../../CodexUsageDock/Pages/CodexUsageDockSettingsPage.cs) and use [LocalStorage](../../../CodexUsageDock/LocalStorage.cs). Load validated known keys after adding defaults but before subscribing to change events. Save on changes, report failures, and apply loaded choices before starting background work. Test a new instance against the same temporary file and a failed save followed by a retry.

For another extension, a minimal in-memory `SettingsManager.cs` starts as follows:

```csharp
using Microsoft.CommandPalette.Extensions;
Expand Down Expand Up @@ -142,7 +144,7 @@ internal sealed partial class MyPage : ListPage

## Key Points

- Settings are automatically persisted by the CmdPal host
- Persistence requires explicit load/save logic; exposing settings to CmdPal does not save them
- Use `SettingsChanged` event to react to changes in real-time
- Access values via `GetSetting<T>(id)` with the setting's string id
- Pass the settings manager to pages/commands that need configuration
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ Each entry links to the commit or pull request that introduced the change.

## [Unreleased]

## [0.6.1] - 2026-09-09

### Fixed

- Dock visibility, reset-time, refresh-interval, and adaptive-forecast settings now persist per Windows user and are applied before the first refresh. Failed saves are shown on the settings page. ([PR #17](https://github.com/TheBeems/CodexUsageDock/pull/17))
- The main status now identifies the most restrictive active quota window, including an exhausted weekly allowance. ([PR #17](https://github.com/TheBeems/CodexUsageDock/pull/17))
- Local fallback data now uses the newest valid quota event timestamp across active and archived sessions, preserves explicitly inactive windows, skips unreadable files, and shows measurement age in the Dock. ([PR #17](https://github.com/TheBeems/CodexUsageDock/pull/17))
- Live limits now update before optional token analysis finishes. Token scans are cancellable, cannot overlap, and cannot publish results for a superseded quota snapshot. ([PR #17](https://github.com/TheBeems/CodexUsageDock/pull/17))
- Text and chart forecasts now use the same most recent continuous measurement segment, pausing after gaps or stale data. ([PR #17](https://github.com/TheBeems/CodexUsageDock/pull/17))
- Invalid and null history entries no longer prevent startup. Local storage failures are reported, and deleting learned history reports success only after the cleared state is saved. ([PR #17](https://github.com/TheBeems/CodexUsageDock/pull/17))

### Changed

- Tests now require isolated temporary settings and history storage, preventing synthetic measurements from reaching the user's saved history. ([PR #17](https://github.com/TheBeems/CodexUsageDock/pull/17))
- Local storage paths and forecast analysis are shared helpers; local session readers consistently honor `CODEX_HOME`. ([PR #17](https://github.com/TheBeems/CodexUsageDock/pull/17))

## [0.6.0] - 2026-07-21

### Added
Expand Down Expand Up @@ -134,7 +150,8 @@ Each entry links to the commit or pull request that introduced the change.
- Initial release of the Windows Command Palette extension for viewing local Codex usage. [commit ac72fe5](https://github.com/TheBeems/CodexUsageDock/commit/ac72fe50fcd1af36f41cda896f1d792899573351)
- Automated release installer creation and smoke-test handling. [commit 64a3305](https://github.com/TheBeems/CodexUsageDock/commit/64a33058b7486dea12f026561c545b362eb2d622), [commit 21790a1](https://github.com/TheBeems/CodexUsageDock/commit/21790a1ea60a9bfec14ec578d77356c5576472fb)

[Unreleased]: https://github.com/TheBeems/CodexUsageDock/compare/eed6505c5fef9a4a6a5c39d6bd5bff619aa13f07...main
[Unreleased]: https://github.com/TheBeems/CodexUsageDock/compare/v0.6.1...main
[0.6.1]: https://github.com/TheBeems/CodexUsageDock/compare/v0.6.0...v0.6.1
[0.6.0]: https://github.com/TheBeems/CodexUsageDock/commit/eed6505c5fef9a4a6a5c39d6bd5bff619aa13f07
[0.5.3]: https://github.com/TheBeems/CodexUsageDock/commit/312dc394ff51648f1b063cd39afdfabaf33d8a3e
[0.5.2]: https://github.com/TheBeems/CodexUsageDock/releases/tag/v0.5.2
Expand Down
12 changes: 9 additions & 3 deletions CodexUsageDock.Tests/LocalCodexTokenUsageReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

namespace CodexUsageDock.Tests;

public sealed class LocalCodexTokenUsageReaderTests
public sealed class LocalCodexTokenUsageReaderTests : IDisposable
{
private readonly TestEnvironment _environment = new();

public void Dispose() => _environment.Dispose();

[Fact]
public async Task ReaderAggregatesActiveAndArchivedLogsAndDeduplicatesCopiedHistory()
{
Expand Down Expand Up @@ -141,12 +145,13 @@ public async Task ServicePublishesTokenUsageWithoutMakingAllowanceDependOnIt()
[new DailyTokenUsage(DateOnly.FromDateTime(now.Date), 123_456)],
now,
LocalTokenUsageStatus.Complete);
using var service = new CodexUsageService(
using var service = _environment.CreateService(
_ => Task.FromResult(snapshot),
() => snapshot,
localTokenUsageReader: (_, _, _, _) => Task.FromResult(expected));

await service.RefreshAsync();
await service.TokenRefreshTask;

Assert.Equal(UsageDataSource.AppServer, service.Current.Source);
Assert.Same(expected, service.CurrentTokenUsage);
Expand All @@ -163,12 +168,13 @@ public async Task ServiceKeepsAllowanceWhenTokenUsageReadFails()
Source = UsageDataSource.AppServer,
Error = null,
};
using var service = new CodexUsageService(
using var service = _environment.CreateService(
_ => Task.FromResult(snapshot),
() => snapshot,
localTokenUsageReader: (_, _, _, _) => Task.FromException<LocalTokenUsageSnapshot>(new IOException("test failure")));

await service.RefreshAsync();
await service.TokenRefreshTask;

Assert.Equal(UsageDataSource.AppServer, service.Current.Source);
Assert.Equal(LocalTokenUsageStatus.Unavailable, service.CurrentTokenUsage.Status);
Expand Down
Loading