Skip to content

fix: sign out doesn't work#1486

Merged
elibosley merged 3 commits intomainfrom
fix/sign-out
Jul 8, 2025
Merged

fix: sign out doesn't work#1486
elibosley merged 3 commits intomainfrom
fix/sign-out

Conversation

@elibosley
Copy link
Member

@elibosley elibosley commented Jul 8, 2025

Summary by CodeRabbit

  • Refactor

    • Improved handling of Connect account sign-in and sign-out with persistent mutation instances for better status updates and error reporting.
  • Chores

    • Expanded allowed command patterns in configuration for development, build, and testing tasks.
  • Tests

    • Enhanced mutation mocks in component tests to increase test reliability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 8, 2025

Walkthrough

The .claude/settings.local.json file is updated to allow additional Bash command patterns. In web/store/account.ts, Apollo GraphQL mutation handling for Connect sign-in and sign-out is refactored: mutations are now initialized once during store setup, with event handlers registered immediately, and invocation functions simplified to synchronous calls. Test files for components HeaderOsVersion and Registration are updated to mock useMutation with jest functions.

Changes

File(s) Change Summary
.claude/settings.local.json Expanded allowed Bash command patterns to include "pnpm codegen:", "pnpm dev:", "pnpm build:", "pnpm test:", "grep:", "pnpm type-check:", and "pnpm lint:*".
web/store/account.ts Refactored mutation setup for Connect sign-in/out: mutations initialized once, handlers registered at setup, invocation functions made synchronous. Function signatures updated.
web/test/components/HeaderOsVersion.test.ts, web/test/components/Registration.test.ts Added mock implementation for useMutation with mocked mutate, onDone, and onError methods.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AccountStore
    participant ApolloClient
    participant ErrorsStore

    User->>AccountStore: connectSignInMutation(payload)
    AccountStore->>ApolloClient: signInMutation(payload)
    ApolloClient-->>AccountStore: onDone/onError
    AccountStore->>ErrorsStore: report error (if any)
    AccountStore-->>User: update accountActionStatus

    User->>AccountStore: connectSignOutMutation()
    AccountStore->>ApolloClient: signOutMutation()
    ApolloClient-->>AccountStore: onDone/onError
    AccountStore->>ErrorsStore: report error (if any)
    AccountStore-->>User: update accountActionStatus
Loading

Suggested reviewers

  • pujitm

Poem

New commands join the Bash parade,
While mutations in the store are smartly laid.
One-time setup, handlers in line,
Synchronous calls—now things are fine!
With cleaner flow and actions tight,
The code marches on, ever light.
🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8ddf50 and 93db717.

📒 Files selected for processing (2)
  • .claude/settings.local.json (1 hunks)
  • web/store/account.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .claude/settings.local.json
  • web/store/account.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build API
  • GitHub Check: Build Web App
  • GitHub Check: Test API
  • GitHub Check: Build Unraid UI Library (Webcomponent Version)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
web/store/account.ts (1)

314-337: Ensure connectSignInMutation returns a Promise

The function is currently synchronous, but callers—including your tests—use await on it. Update it to return the underlying signInMutation Promise (or mark it async) so that await typedStore.connectSignInMutation() behaves as expected.

• Affected locations:
web/store/account.ts (definition of connectSignInMutation)
web/__test__/store/account.test.ts (lines with await typedStore.connectSignInMutation())

Suggested fix:

 const connectSignInMutation = () => {
   if (
     !connectSignInPayload.value ||
     (connectSignInPayload.value &&
       (!connectSignInPayload.value.apiKey ||
         !connectSignInPayload.value.email ||
         !connectSignInPayload.value.preferred_username))
   ) {
     accountActionStatus.value = 'failed';
-    return console.error('[connectSignInMutation] incorrect payload', connectSignInPayload.value);
+    // still synchronous error handling; tests only assert status
+    console.error('[connectSignInMutation] incorrect payload', connectSignInPayload.value);
+    return Promise.resolve();
   }

   accountActionStatus.value = 'updating';
-  signInMutation({
+  return signInMutation({
     input: {
       apiKey: connectSignInPayload.value.apiKey,
       userInfo: {
         email: connectSignInPayload.value.email,
         preferred_username: connectSignInPayload.value.preferred_username,
       },
     },
   });
 };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9624ca5 and e57c0c0.

📒 Files selected for processing (2)
  • .claude/settings.local.json (1 hunks)
  • web/store/account.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`web/store/**/*.{ts,js}`: Ensure Vue reactivity imports are added to store files (computed, ref, watchEffect)

web/store/**/*.{ts,js}: Ensure Vue reactivity imports are added to store files (computed, ref, watchEffect)

📄 Source: CodeRabbit Inference Engine (CLAUDE.md)

List of files the instruction was applied to:

  • web/store/account.ts
`**/*.{ts,tsx}`: TypeScript imports use .js extensions for ESM compatibility

**/*.{ts,tsx}: TypeScript imports use .js extensions for ESM compatibility

📄 Source: CodeRabbit Inference Engine (CLAUDE.md)

List of files the instruction was applied to:

  • web/store/account.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-graphql.mdc:0-0
Timestamp: 2025-06-30T14:51:12.348Z
Learning: Applies to web/**/*.mutation.ts : GraphQL mutations must be placed in `.mutation.ts` files
Learnt from: pujitm
PR: unraid/api#1211
File: web/codegen.ts:14-14
Timestamp: 2025-03-12T13:35:43.900Z
Learning: The JSON scalar type in web/codegen.ts was temporarily changed from 'string' to 'any' for compatibility with JsonForms integration. This change facilitates the implementation of the Connect settings web component.
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: Applies to web/**/*.mutation.ts : GraphQL mutations must be placed in .mutation.ts files under web/
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: All GraphQL under web/ must follow this naming convention (.query.ts for queries, .mutation.ts for mutations)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-graphql.mdc:0-0
Timestamp: 2025-06-30T14:51:12.348Z
Learning: Applies to web/**/*.{query.ts,mutation.ts} : All GraphQL under `web/` must follow this naming convention
Learnt from: pujitm
PR: unraid/api#978
File: web/helpers/apollo-cache/index.ts:133-157
Timestamp: 2024-12-11T17:20:09.604Z
Learning: In `web/helpers/apollo-cache/index.ts`, when updating the cache in the `cache.updateQuery` function, it's sufficient to check if `data` is present, as type checking inside `data` is handled at the GraphQL layer.
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: Applies to web/store/**/*.{ts,js} : Ensure Vue reactivity imports are added to store files (computed, ref, watchEffect)
Learnt from: pujitm
PR: unraid/api#982
File: web/helpers/apollo-cache/index.ts:142-142
Timestamp: 2024-12-13T17:28:15.384Z
Learning: In `web/helpers/apollo-cache/index.ts`, it's acceptable to use `structuredClone` since the project targets Node.js v20 and browsers where `structuredClone` is supported.
Learnt from: elibosley
PR: unraid/api#1068
File: api/src/unraid-api/auth/api-key.service.ts:122-137
Timestamp: 2025-01-22T18:34:06.925Z
Learning: The store in @app/store is implemented using Redux's configureStore, where dispatch operations for config updates are synchronous in-memory state updates that cannot fail, making transaction-like patterns unnecessary.
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes by updating the store in store tests
.claude/settings.local.json (8)
Learnt from: elibosley
PR: unraid/api#1120
File: api/scripts/build.mjs:81-83
Timestamp: 2025-02-05T17:48:23.465Z
Learning: In Node.js projects, executable permissions (755) must be set for:
1. All files in node_modules/.bin and their symlink targets
2. JavaScript files (*.js and *.mjs)
3. All directories (for traversal)
While other files should be read-only (644).
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: Always run pnpm codegen for GraphQL code generation in the web directory
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: Always run scripts from api/package.json unless requested
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/api-rules.mdc:0-0
Timestamp: 2025-06-30T14:50:52.281Z
Learning: Always run scripts from api/package.json unless requested otherwise
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/api-rules.mdc:0-0
Timestamp: 2025-06-30T14:50:52.281Z
Learning: Use pnpm ONLY for package management
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-graphql.mdc:0-0
Timestamp: 2025-06-30T14:51:12.348Z
Learning: Always run `pnpm codegen` for GraphQL code generation in the web directory
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: Use pnpm ONLY for package management in the API package
Learnt from: elibosley
PR: unraid/api#1120
File: plugin/package.json:0-0
Timestamp: 2025-02-05T14:43:48.568Z
Learning: In Node.js projects, npm scripts should be organized with clear namespacing (e.g., build:*, docker:*, env:*) and include proper environment validation and error handling. Each script should follow the single responsibility principle.
web/store/account.ts (14)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-graphql.mdc:0-0
Timestamp: 2025-06-30T14:51:12.348Z
Learning: Applies to web/**/*.mutation.ts : GraphQL mutations must be placed in `.mutation.ts` files
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: Applies to web/**/*.mutation.ts : GraphQL mutations must be placed in .mutation.ts files under web/
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes after actions in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes by updating the store in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects and state changes in store tests
Learnt from: mdatelle
PR: unraid/api#942
File: api/src/unraid-api/graph/resolvers/auth/auth.resolver.ts:111-113
Timestamp: 2024-11-06T20:59:25.809Z
Learning: In the Unraid API project, error handling for mutations is handled at the service level rather than in the GraphQL resolvers. Specifically, in `api/src/unraid-api/graph/resolvers/auth/auth.resolver.ts`, methods like `removeRoleFromApiKey` rely on service-level error handling.
Learnt from: elibosley
PR: unraid/api#1068
File: api/src/unraid-api/auth/api-key.service.ts:122-137
Timestamp: 2025-01-22T18:34:06.925Z
Learning: The store in @app/store is implemented using Redux's configureStore, where dispatch operations for config updates are synchronous in-memory state updates that cannot fail, making transaction-like patterns unnecessary.
Learnt from: mdatelle
PR: unraid/api#942
File: api/src/unraid-api/graph/resolvers/auth/auth.resolver.ts:87-89
Timestamp: 2024-11-06T20:59:06.096Z
Learning: Error handling in mutations like `addRoleForUser` in `auth.resolver.ts` is performed at the service level, so additional error handling in the resolver is unnecessary.
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: All GraphQL under web/ must follow this naming convention (.query.ts for queries, .mutation.ts for mutations)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-graphql.mdc:0-0
Timestamp: 2025-06-30T14:51:12.348Z
Learning: Applies to web/**/*.{query.ts,mutation.ts} : All GraphQL under `web/` must follow this naming convention
Learnt from: pujitm
PR: unraid/api#1211
File: api/src/graphql/schema/types/connect/connect.graphql:142-146
Timestamp: 2025-03-14T16:10:38.562Z
Learning: The updateApiSettings mutation in api/src/unraid-api/graph/connect/connect.resolver.ts is protected with the @UsePermissions decorator that requires UPDATE permission on the CONFIG resource.
Learnt from: zackspear
PR: unraid/api#0
File: :0-0
Timestamp: 2025-03-27T23:52:57.888Z
Learning: In the unraid/api project, Vue components are compiled into web components. Using `setActivePinia(createPinia())` in store files ensures that all web components share a single Pinia store instance, which is the desired behavior. Without this initialization, each web component would have its own isolated store, breaking the intended architecture.
Learnt from: zackspear
PR: unraid/api#0
File: :0-0
Timestamp: 2025-03-27T23:52:57.888Z
Learning: In the unraid/api project, Vue components are compiled into web components. The `setActivePinia(createPinia())` call at the module level in store files is intentional and ensures all web components share a single Pinia store instance, which is the desired behavior. This shared state approach is critical for the application's architecture to function correctly.
Learnt from: zackspear
PR: unraid/api#0
File: :0-0
Timestamp: 2025-03-27T23:33:13.215Z
Learning: In the unraid/api project, Vue components are compiled into web components. Using `setActivePinia(createPinia())` in store files would break the build by causing all web components to share a singular Pinia store instance. Each web component needs its own Pinia store instance to maintain proper isolation and encapsulation.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build Web App
  • GitHub Check: Build API
  • GitHub Check: Build Unraid UI Library (Webcomponent Version)
  • GitHub Check: Test API
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)
🔇 Additional comments (4)
.claude/settings.local.json (1)

6-8: LGTM! Development workflow enhancement.

The added pnpm command patterns support essential development tasks and align with the project's package management standards.

web/store/account.ts (3)

65-67: Good Apollo context management approach.

Initializing mutations during store setup maintains proper Apollo context and avoids re-creating mutation instances on each call.


69-86: Comprehensive sign out error handling.

The centralized error handling approach properly manages mutation results and provides detailed error reporting to the errors store.


88-115: Robust sign in mutation handling.

The logic correctly handles both successful and failed mutations, with proper payload validation and error reporting.

@elibosley elibosley merged commit f3671c3 into main Jul 8, 2025
9 checks passed
@elibosley elibosley deleted the fix/sign-out branch July 8, 2025 20:28
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2025

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR1486/dynamix.unraid.net.plg

mdatelle pushed a commit that referenced this pull request Jul 8, 2025
🤖 I have created a release *beep* *boop*
---


## [4.9.1](v4.9.0...v4.9.1)
(2025-07-08)


### Bug Fixes

* **HeaderOsVersion:** adjust top margin for header component
([#1485](#1485))
([862b54d](862b54d))
* sign out doesn't work
([#1486](#1486))
([f3671c3](f3671c3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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