Skip to content

WorkIQ MCP auth: re-consent UX and failure-mode polish (#441)#446

Merged
rockfordlhotka merged 1 commit into
mainfrom
workiq-phase5
May 23, 2026
Merged

WorkIQ MCP auth: re-consent UX and failure-mode polish (#441)#446
rockfordlhotka merged 1 commit into
mainfrom
workiq-phase5

Conversation

@rockfordlhotka
Copy link
Copy Markdown
Member

Summary

Phase 5 of the WorkIQ integration (design/workiq-phase5-plan.md). Builds on #442/#443/#444. Closes three failure-mode gaps:

  • Actionable auth_required tool error. MsalUiRequiredException and friends used to fall into the generic "execution failed, retryable" bucket, so the LLM blindly retried. New FindReauthRequired walker + catch clause in McpBridgeService produces ToolError { Code=auth_required, IsRetryable=false } with a message that names the Blazor Reconnect/Connect button.
  • Hide WorkIQ tools while auth is unhealthy. New WorkIqHealthTracker singleton flips on cache writes / silent-refresh failures, emits a structured log on every transition, and raises HealthChanged. The bridge subscribes and republishes the tool list with workiq-* servers removed (or re-added) so patrols and chat sessions started during the unhealthy window never call them. Direct calls still get the auth_required error from above.
  • Blazor double-click guards. WorkIqConnect.razor and WorkIqReconnectBanner.razor gain _starting / _reconnecting bools + disabled attributes so a fast second click can't kick off a parallel device-code flow that clobbers the first one's success state.

Also adds deploy/workiq-setup.md with the re-consent flow and scheduled-tasks-during-expiry sections (a stub Phase 4 can extend with its own initial-setup material).

Test plan

  • dotnet build RockBot.slnx clean (only pre-existing CA1416 / NU190x warnings)
  • dotnet test RockBot.slnx — all new tests pass (9 WorkIqHealthTrackerTests + 7 MsalToolErrorMappingTests)
  • Full suite green except one pre-existing Windows file-move flake in RepairTicketApplyPassTests.TimeoutBackoff_PassesEscalatingBudgets_ToVerifier that passes in isolation (unrelated to this PR)
  • Smoke against the live cluster: revoke the WorkIQ cache, confirm banner appears, confirm the next chat reply returns the auth_required text, confirm patrol logs stop trying workiq tools, reconnect, confirm tools come back within ~1 second
  • Verify a deliberate double-click on Connect / Reconnect in the Blazor UI is a no-op

Note: the Blazor button guards live purely in the .razor (no bUnit in the project); the plan explicitly permitted the UI-only guard.

🤖 Generated with Claude Code

Phase 5 of the WorkIQ integration. Closes three failure-mode gaps left
after Phases 1-4:

- Surface MsalUiRequiredException as an actionable auth_required tool
  error so the LLM stops retrying and returns a clear "reconnect M365"
  message. New FindReauthRequired walker + BuildReauthRequiredMessage
  helper in McpBridgeService, with a catch clause placed before the
  existing FindAuthChallenge catch.
- Add WorkIqHealthTracker singleton that flips healthy/unhealthy on
  cache writes and silent-refresh failures, emits a structured log on
  every transition, and raises HealthChanged so the bridge can hide
  workiq-* tools from the published tool list while auth is broken.
  Patrols and chat sessions started during the unhealthy window never
  see those tools and stop generating execution_failed noise.
- Double-click guards on the Blazor Connect and Reconnect buttons so a
  fast second click can't kick off a parallel device-code flow that
  would clobber the first one's success state.

Adds deploy/workiq-setup.md with the re-consent flow and scheduled-
tasks-during-expiry sections (stub for Phase 4 to extend).

Tests: 9 WorkIqHealthTrackerTests + 7 MsalToolErrorMappingTests, all
passing. Blazor button guards live purely in the UI layer per the plan
(no bUnit in the project; component-level guard is acknowledged-fine).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rockfordlhotka rockfordlhotka merged commit 796ff62 into main May 23, 2026
2 checks passed
@rockfordlhotka rockfordlhotka deleted the workiq-phase5 branch May 23, 2026 20:21
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.

1 participant