Skip to content

Fix thread safety, redundant async/await, and section-count logic from review feedback#8

Merged
jongalloway merged 2 commits intofeat/copilot-sdk-dashboard-upgradesfrom
copilot/sub-pr-7
Feb 27, 2026
Merged

Fix thread safety, redundant async/await, and section-count logic from review feedback#8
jongalloway merged 2 commits intofeat/copilot-sdk-dashboard-upgradesfrom
copilot/sub-pr-7

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

Addresses five valid review comments on the metrics/structured-results PR.

Changes

  • CacheServiceCacheHits/Misses/Skips were plain auto-properties, unsafe for concurrent task access. Replaced with private int backing fields; writes use Interlocked.Increment, reads use Volatile.Read.

  • NewsletterService session hooks — Hooks were declared async solely to await Task.CompletedTask before returning. Dropped the async/await Task.CompletedTask pattern in favour of Task.FromResult<T?>.

// Before
OnErrorOccurred = async (input, invocation) => {
    logger.LogWarning(...);
    await Task.CompletedTask;
    return new ErrorOccurredHookOutput { ErrorHandling = "retry" };
},

// After
OnErrorOccurred = (input, invocation) => {
    logger.LogWarning(...);
    return Task.FromResult<ErrorOccurredHookOutput?>(new ErrorOccurredHookOutput { ErrorHandling = "retry" });
},
  • GenerateCopilotNewsletterAsync — Added explicit await Task.WhenAll(newsSectionTask, releaseSectionTask) before extracting results via await, making the concurrent intent clear and improving timing accuracy.

  • DoctorCommand — Removed a redundant second CopilotClient instantiation and ping; PrintCopilotStartupStatusAsync already creates a client, pings, and surfaces failures via warnings.

  • CountSections — Replaced unconditional +1 (assumed a welcome section always exists) with a scan of pre-heading lines; only counts a welcome section if non-whitespace content is actually present before the first ##/### heading.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…s, Task.WhenAll, remove duplicate ping, fix CountSections

Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance services with metrics and structured results Fix thread safety, redundant async/await, and section-count logic from review feedback Feb 26, 2026
@jongalloway jongalloway marked this pull request as ready for review February 27, 2026 01:13
@jongalloway jongalloway merged commit c01fe8e into feat/copilot-sdk-dashboard-upgrades Feb 27, 2026
1 check passed
@jongalloway jongalloway deleted the copilot/sub-pr-7 branch February 27, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants