Skip to content

refactor: Centralize cookie management with singleton pattern#10442

Merged
Cristhianzl merged 18 commits into
mainfrom
cz/fix-cookies-race-condition
Nov 5, 2025
Merged

refactor: Centralize cookie management with singleton pattern#10442
Cristhianzl merged 18 commits into
mainfrom
cz/fix-cookies-race-condition

Conversation

@Cristhianzl
Copy link
Copy Markdown
Member

@Cristhianzl Cristhianzl commented Oct 29, 2025

This pull request refactors cookie management throughout the frontend codebase by introducing a centralized singleton CookieManager utility. This change replaces all direct instantiations of the Cookies class with calls to the new manager, ensuring consistent and synchronized cookie handling across the application. Additionally, comprehensive unit tests are added for the new utility to verify its correctness and address previous race condition issues.

Cookie Management Refactor:

  • Added a new singleton CookieManager class in src/frontend/src/utils/cookie-manager.ts, providing unified get, set, and remove methods, and exported cookieManager and getCookiesInstance for use throughout the app.
  • Replaced all direct imports and instantiations of Cookies with usage of cookieManager or getCookiesInstance in files such as authContext.tsx, API controllers, and stores, ensuring all components use the same cookie instance. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Testing and Reliability:

  • Added a comprehensive test suite in src/frontend/src/utils/__tests__/cookie-manager.test.ts to verify the singleton pattern, correct cookie operations, integration scenarios, edge cases, and to ensure the fix for the previous race condition (issue fix: Add output item processing for tool results #10348).

These changes improve reliability and maintainability of authentication and session management by eliminating desynchronization issues and potential race conditions previously caused by multiple cookie instances.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed race condition in the login flow that could cause inconsistent authentication state initialization.
    • Improved asynchronous coordination during user and global data loading to prevent premature redirects.
    • Enhanced cookie synchronization and state management during the authentication process.
  • Tests

    • Added comprehensive test coverage for authentication scenarios including edge cases, rapid consecutive login attempts, and cookie state management.
    • Verified proper handling of failed authentication requests and recovery scenarios.

@Cristhianzl Cristhianzl self-assigned this Oct 29, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 29, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR introduces a centralized cookie management system and refactors the authentication context login flow to eliminate race conditions. A new CookieManager singleton replaces scattered new Cookies() instances across the codebase. The login flow shifts from synchronous immediate authentication to asynchronous coordination using mutation callbacks to ensure user data and global variables load in correct sequence before setting authenticated state.

Changes

Cohort / File(s) Summary
New Cookie Manager
src/frontend/src/utils/cookie-manager.ts, src/frontend/src/utils/__tests__/cookie-manager.test.ts
Adds singleton CookieManager wrapper around react-cookie's Cookies class with methods get, set, remove, and getCookies. Includes comprehensive test suite validating singleton behavior, cookie operations, token lifecycle, and race condition scenarios.
Auth Context Refactoring
src/frontend/src/contexts/authContext.tsx, src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
Replaces direct new Cookies() with getCookiesInstance(). Refactors login flow from synchronous setIsAuthenticated(true); getUser(); getGlobalVariables() to asynchronous coordination using userLoaded/variablesLoaded tracking and mutation callbacks (mutateLoggedUser, mutateGetGlobalVariables). Adds new comprehensive test suite covering sequencing, failures, and edge cases. Removes unused getGlobalVariables() function.
API and Query Layers
src/frontend/src/controllers/API/api.tsx, src/frontend/src/controllers/API/queries/auth/use-post-logout.ts, src/frontend/src/controllers/API/queries/auth/use-post-refresh-access.ts
Replace direct new Cookies() instantiation with getCookiesInstance() calls. Removes Cookies import from react-cookie and adds getCookiesInstance import.
Store Layer
src/frontend/src/stores/authStore.ts
Replaces new Cookies() with getCookiesInstance() for cookie initialization while maintaining existing state shape and public API.
Utility Layer
src/frontend/src/customization/utils/custom-get-access-token.ts
Replaces local Cookies instance with cookieManager singleton for centralized token retrieval.

Sequence Diagram

sequenceDiagram
    actor User
    participant AuthContext
    participant mutateLoggedUser
    participant mutateGetGlobalVariables
    participant CookieManager
    
    User->>AuthContext: login()
    AuthContext->>CookieManager: setIsAuthenticated(false)
    AuthContext->>mutateLoggedUser: trigger mutation
    AuthContext->>mutateGetGlobalVariables: trigger mutation
    
    par User Data Flow
        mutateLoggedUser->>mutateLoggedUser: fetch user data
        mutateLoggedUser->>AuthContext: onSuccess callback<br/>(set user, admin flag)
        AuthContext->>AuthContext: userLoaded = true<br/>checkAndSetAuthenticated()
    and Variables Flow
        mutateGetGlobalVariables->>mutateGetGlobalVariables: fetch global variables
        mutateGetGlobalVariables->>AuthContext: onSettled callback<br/>(set variablesLoaded)
        AuthContext->>AuthContext: variablesLoaded = true<br/>checkAndSetAuthenticated()
    end
    
    AuthContext->>AuthContext: Both loaded?<br/>setIsAuthenticated(true)
    AuthContext->>User: ✓ Authentication complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • authContext.tsx: Significant refactoring of login flow with new async coordination pattern using mutations and callbacks — requires careful verification of sequencing logic and race condition resolution
  • authContext-login-fix.test.tsx: Comprehensive test suite with multiple scenarios covering edge cases, sequencing variations, and race conditions — verify test coverage adequately captures the refactored flow
  • cookie-manager.ts / cookie-manager.test.ts: New singleton implementation with extensive test suite — standard pattern but verify singleton behavior and test coverage
  • Pattern replacements (api.tsx, queries, authStore.ts, custom-get-access-token.ts): Straightforward new Cookies()getCookiesInstance() changes with consistent application

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • lucaseduoli
  • deon-sanchez
  • ogabrielluiz

Pre-merge checks and finishing touches

❌ Failed checks (1 error, 2 warnings)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error The PR includes comprehensive new test files following project naming conventions with meaningful test coverage: cookie-manager.test.ts (398 lines, 25 test cases, 45 expect assertions) and authContext-login-fix.test.tsx (444 lines, 10 test cases, 31 expect assertions). However, the test coverage is critically incomplete. The existing test files for modified modules (use-post-logout.test.ts, use-post-refresh-access.test.ts, and authStore.test.ts) show zero references to the centralized cookie manager despite these files being modified to use getCookiesInstance(), meaning no regression tests verify these changes work correctly. Most critically, the remove() method still has signature remove(name: string, options?: { path?: string }) without domain support, yet review comments explicitly require domain parameter support for domain-scoped cookie removal in logout scenarios, and the test suite contains zero tests for domain-scoped removal (unlike the set method which is tested with domain parameters). This is a significant functional gap that could break logout flows. The PR requires three remedies to achieve adequate test coverage: First, update the existing test files (use-post-logout.test.ts, use-post-refresh-access.test.ts, authStore.test.ts) to include regression tests that verify these modules work correctly with the centralized cookie manager. Second, implement the domain parameter in the remove() method signature as requested in review comments (matching the set method's domain support). Third, add comprehensive tests to cookie-manager.test.ts verifying domain-scoped cookie removal works correctly, including scenarios like "should remove a cookie with custom path and domain" and "should remove auth tokens set with custom domain".
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Excessive Mock Usage Warning ⚠️ Warning The authContext test file exhibits excessive mocking with 10 jest.mock calls that include internal stores (authStore, storeStore, darkStore, alertStore) and utility functions, which are application core logic rather than external dependencies. While the cookie-manager test appropriately uses minimal mocking (1 mock of the external react-cookie library), the authContext test mocks nearly all of its dependencies, resulting in 444 lines of test code validating internal state transitions rather than real behavior. This pattern obscures whether the race condition fix actually works when integrated with real stores and utilities. A more appropriate approach would involve integration-style tests using real or partially real stores with mocking only for true external dependencies (API calls), or acceptance tests that verify the actual coordination works end-to-end. Refactor the authContext test to reduce excessive mocking by: (1) using real Zustand store instances or factory functions instead of mocking entire stores, (2) mocking only the actual API query hooks to control callback timing, and (3) removing mocks for utility functions like cookie-manager and local-storage-util to test real interactions. Alternatively, add a separate integration test that exercises the login flow with minimal mocking to verify the race condition fix works correctly in a realistic environment, while keeping a leaner unit test that focuses specifically on the coordination logic between userLoaded and variablesLoaded flags.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "refactor: Centralize cookie management with singleton pattern" directly and accurately describes the main change in the changeset. The PR introduces a new centralized CookieManager singleton utility and replaces direct Cookies instantiations across multiple files (authContext, API controllers, stores, and utilities) with this shared instance. The title is specific, concise, and clearly communicates both the intent (centralizing cookie management) and the implementation approach (singleton pattern), allowing teammates to immediately understand the primary objective when scanning PR history.
Test Quality And Coverage ✅ Passed The PR introduces comprehensive tests for two major changes: a new singleton CookieManager utility and an updated AuthContext login flow with async coordination. Jest requires async code to be properly awaited or returned from tests to ensure proper completion before the test finishes. The cookie-manager tests reportedly cover singleton behavior, get/set/remove methods, integration scenarios, and edge cases including the race condition fix from issue #10348. The authContext tests verify the asynchronous login flow using mocks for cookies, stores, and API hooks, with multiple sequencing variations where getUser or getGlobalVariables complete in different orders. Both test suites use appropriate patterns: the act function wraps code ensuring state changes and asynchronous actions are flushed before proceeding, which is crucial for testing components with asynchronous behavior. The waitFor function waits for asynchronous actions to complete before making assertions, being especially useful for delayed updates, API requests, and timers. Error scenarios are addressed through mocked failures in the authContext tests, and tests should verify both successful data fetches and error handling by using mockRejectedValue and wrapping assertions in waitFor. The tests appear to go beyond smoke tests by validating specific state transitions and callback invocations rather than just checking basic functionality.
Test File Naming And Structure ✅ Passed The PR introduces two new test files that correctly follow frontend test naming conventions: src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx and src/frontend/src/utils/__tests__/cookie-manager.test.ts with proper .test.ts(x) patterns. Both files use Jest with React Testing Library, which is appropriate for unit testing (distinct from Langflow's Playwright E2E tests). The cookie-manager test suite contains 25 test cases organized into 9 describe blocks with clear feature separation (Singleton Pattern, get/set/remove methods, Integration scenarios, Edge cases, and race condition fixes). The authContext test suite contains 10 test cases across 6 describe blocks covering race condition fixes, redirect prevention, cookie synchronization, and integration flows. Both files have proper setup with beforeEach(() => { jest.clearAllMocks(); }), descriptive test names explaining what each test validates, comprehensive edge case coverage (null/undefined handling, special characters, long values, rapid operations), and testing of both positive scenarios (successful operations) and negative scenarios (errors, missing data, sequencing variations). Test organization is logical with hierarchical describe blocks grouping related tests by functionality.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the refactor Maintenance tasks and housekeeping label Oct 29, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Oct 29, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 29, 2025

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 15%
14.67% (3955/26947) 7.45% (1533/20552) 9% (532/5906)

Unit Test Results

Tests Skipped Failures Errors Time
1588 0 💤 0 ❌ 0 🔥 18.8s ⏱️

@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Oct 29, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 75.78947% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.41%. Comparing base (0cfb4fd) to head (5ad03d1).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/frontend/src/contexts/authContext.tsx 77.08% 9 Missing and 2 partials ⚠️
src/frontend/src/pages/LoginPage/index.tsx 0.00% 3 Missing ⚠️
src/frontend/src/utils/cookie-manager.ts 88.88% 0 Missing and 3 partials ⚠️
...controllers/API/queries/folders/use-get-folders.ts 0.00% 2 Missing ⚠️
.../API/queries/variables/use-get-global-variables.ts 0.00% 2 Missing ⚠️
...src/customization/utils/custom-get-access-token.ts 50.00% 1 Missing ⚠️
src/frontend/src/utils/utils.ts 50.00% 0 Missing and 1 partial ⚠️

❌ Your project status has failed because the head coverage (39.37%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #10442      +/-   ##
==========================================
+ Coverage   31.32%   31.41%   +0.08%     
==========================================
  Files        1324     1325       +1     
  Lines       59920    59985      +65     
  Branches     8966     8979      +13     
==========================================
+ Hits        18769    18843      +74     
+ Misses      40254    40237      -17     
- Partials      897      905       +8     
Flag Coverage Δ
frontend 13.57% <75.78%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/frontend/src/controllers/API/api.tsx 8.55% <ø> (-0.97%) ⬇️
...rc/controllers/API/queries/auth/use-post-logout.ts 100.00% <100.00%> (ø)
...ollers/API/queries/auth/use-post-refresh-access.ts 93.75% <100.00%> (-0.70%) ⬇️
src/frontend/src/stores/authStore.ts 95.23% <100.00%> (+0.79%) ⬆️
...src/customization/utils/custom-get-access-token.ts 75.00% <50.00%> (+15.00%) ⬆️
src/frontend/src/utils/utils.ts 16.70% <50.00%> (+0.13%) ⬆️
...controllers/API/queries/folders/use-get-folders.ts 0.00% <0.00%> (ø)
.../API/queries/variables/use-get-global-variables.ts 30.76% <0.00%> (-1.24%) ⬇️
src/frontend/src/pages/LoginPage/index.tsx 0.00% <0.00%> (ø)
src/frontend/src/utils/cookie-manager.ts 88.88% <88.88%> (ø)
... and 1 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0f3f23 and c0dc841.

📒 Files selected for processing (9)
  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx (1 hunks)
  • src/frontend/src/contexts/authContext.tsx (3 hunks)
  • src/frontend/src/controllers/API/api.tsx (0 hunks)
  • src/frontend/src/controllers/API/queries/auth/use-post-logout.ts (2 hunks)
  • src/frontend/src/controllers/API/queries/auth/use-post-refresh-access.ts (2 hunks)
  • src/frontend/src/customization/utils/custom-get-access-token.ts (1 hunks)
  • src/frontend/src/stores/authStore.ts (1 hunks)
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts (1 hunks)
  • src/frontend/src/utils/cookie-manager.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/frontend/src/controllers/API/api.tsx
🧰 Additional context used
📓 Path-based instructions (7)
src/frontend/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)

src/frontend/src/**/*.{ts,tsx,js,jsx}: All frontend TypeScript and JavaScript code should be located under src/frontend/src/ and organized into components, pages, icons, stores, types, utils, hooks, services, and assets directories as per the specified directory layout.
Use React 18 with TypeScript for all UI components in the frontend.
Format all TypeScript and JavaScript code using the make format_frontend command.
Lint all TypeScript and JavaScript code using the make lint command.

Files:

  • src/frontend/src/utils/cookie-manager.ts
  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/customization/utils/custom-get-access-token.ts
  • src/frontend/src/stores/authStore.ts
  • src/frontend/src/contexts/authContext.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
  • src/frontend/src/controllers/API/queries/auth/use-post-refresh-access.ts
  • src/frontend/src/controllers/API/queries/auth/use-post-logout.ts
src/frontend/src/utils/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)

All utility functions should be placed in the utils directory.

Files:

  • src/frontend/src/utils/cookie-manager.ts
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
src/frontend/src/**/__tests__/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)

All frontend code should be tested using appropriate component and integration tests.

Files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx}: Frontend test files should be located in 'src/frontend/' and use '.test.{ts,tsx,js,jsx}' or '.spec.{ts,tsx,js,jsx}' extensions.
Test both sync and async code paths in frontend test files.
Mock external dependencies appropriately in frontend test files to isolate unit tests from external services.
Test error handling and edge cases in frontend test files.
Validate input/output behavior and test component initialization and configuration in frontend test files.
Each frontend test should have a clear description or comment explaining its purpose, especially for complex setups or mocks.

Files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
**/{test_*.py,*.test.ts,*.test.tsx}

📄 CodeRabbit inference engine (coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt)

**/{test_*.py,*.test.ts,*.test.tsx}: Check if tests have too many mock objects that obscure what’s actually being tested
Warn when mocks are used instead of testing real behavior and interactions
Suggest using real objects or simpler test doubles when mocks become excessive
Ensure mocks are used only for external dependencies, not core business logic
Recommend integration tests when unit tests become overly mocked
Check that test files follow the project’s naming conventions (backend: test_*.py; frontend: *.test.ts/tsx)
Verify that tests actually exercise the new or changed functionality, not placeholder assertions
Test files should have descriptive test function names explaining what is being tested
Organize tests logically with proper setup and teardown
Include edge cases and error conditions for comprehensive coverage
Verify tests cover both positive (success) and negative (failure) scenarios
Ensure tests are not mere smoke tests; they should validate behavior thoroughly
Ensure tests follow the project’s testing frameworks (pytest for backend, Playwright for frontend)

Files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt)

Frontend tests should be named *.test.ts or *.test.tsx and use Playwright

Files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
src/frontend/src/stores/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)

Use Zustand for state management in frontend stores.

Files:

  • src/frontend/src/stores/authStore.ts
🧠 Learnings (15)
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx} : Mock external dependencies appropriately in frontend test files to isolate unit tests from external services.

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx} : Validate input/output behavior and test component initialization and configuration in frontend test files.

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx} : Test both sync and async code paths in frontend test files.

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx} : Each frontend test should have a clear description or comment explaining its purpose, especially for complex setups or mocks.

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx} : Test error handling and edge cases in frontend test files.

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-10-23T19:53:43.132Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-10-23T19:53:43.132Z
Learning: Applies to **/{test_*.py,*.test.ts,*.test.tsx} : Ensure mocks are used only for external dependencies, not core business logic

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
📚 Learning: 2025-07-18T18:27:12.609Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/**/__tests__/**/*.{ts,tsx,js,jsx} : All frontend code should be tested using appropriate component and integration tests.

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-06-23T12:46:42.048Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-23T12:46:42.048Z
Learning: Frontend tests should be written using testing-library/react, with both component and integration tests verifying rendering, user interaction, and data loading.

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
📚 Learning: 2025-10-23T19:53:43.132Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-10-23T19:53:43.132Z
Learning: Applies to **/{test_*.py,*.test.ts,*.test.tsx} : Recommend integration tests when unit tests become overly mocked

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
📚 Learning: 2025-10-23T19:53:43.132Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-10-23T19:53:43.132Z
Learning: Applies to **/{test_*.py,*.test.ts,*.test.tsx} : Verify that tests actually exercise the new or changed functionality, not placeholder assertions

Applied to files:

  • src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx
  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-06-23T12:46:42.048Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-23T12:46:42.048Z
Learning: Use Zustand for state management in React components within the frontend; stores should expose both state and setter functions, and be imported via hooks (e.g., useMyStore).

Applied to files:

  • src/frontend/src/stores/authStore.ts
  • src/frontend/src/contexts/authContext.tsx
  • src/frontend/src/controllers/API/queries/auth/use-post-refresh-access.ts
📚 Learning: 2025-07-18T18:27:12.609Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/stores/**/*.{ts,tsx,js,jsx} : Use Zustand for state management in frontend stores.

Applied to files:

  • src/frontend/src/stores/authStore.ts
📚 Learning: 2025-10-23T19:53:43.132Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-10-23T19:53:43.132Z
Learning: Applies to **/{test_*.py,*.test.ts,*.test.tsx} : Include edge cases and error conditions for comprehensive coverage

Applied to files:

  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-10-23T19:53:43.132Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-10-23T19:53:43.132Z
Learning: Applies to **/{test_*.py,*.test.ts,*.test.tsx} : Ensure tests are not mere smoke tests; they should validate behavior thoroughly

Applied to files:

  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
📚 Learning: 2025-10-23T19:53:43.132Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-10-23T19:53:43.132Z
Learning: Applies to **/{test_*.py,*.test.ts,*.test.tsx} : Organize tests logically with proper setup and teardown

Applied to files:

  • src/frontend/src/utils/__tests__/cookie-manager.test.ts
🧬 Code graph analysis (7)
src/frontend/src/contexts/__tests__/authContext-login-fix.test.tsx (1)
src/frontend/src/contexts/authContext.tsx (2)
  • AuthProvider (32-157)
  • AuthContext (30-30)
src/frontend/src/customization/utils/custom-get-access-token.ts (2)
src/frontend/src/utils/cookie-manager.ts (1)
  • cookieManager (50-50)
src/frontend/src/constants/constants.ts (1)
  • LANGFLOW_ACCESS_TOKEN (862-862)
src/frontend/src/stores/authStore.ts (1)
src/frontend/src/utils/cookie-manager.ts (1)
  • getCookiesInstance (51-51)
src/frontend/src/contexts/authContext.tsx (2)
src/frontend/src/utils/cookie-manager.ts (1)
  • getCookiesInstance (51-51)
src/frontend/src/controllers/API/index.ts (1)
  • checkHasStore (202-211)
src/frontend/src/utils/__tests__/cookie-manager.test.ts (1)
src/frontend/src/utils/cookie-manager.ts (2)
  • getCookiesInstance (51-51)
  • cookieManager (50-50)
src/frontend/src/controllers/API/queries/auth/use-post-refresh-access.ts (1)
src/frontend/src/utils/cookie-manager.ts (1)
  • getCookiesInstance (51-51)
src/frontend/src/controllers/API/queries/auth/use-post-logout.ts (1)
src/frontend/src/utils/cookie-manager.ts (1)
  • getCookiesInstance (51-51)
🪛 Gitleaks (8.28.0)
src/frontend/src/utils/__tests__/cookie-manager.test.ts

[high] 90-90: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 163-163: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ 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). (41)
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 40/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 39/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 24/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 30/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 38/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 33/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 25/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 27/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 31/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 37/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 36/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 35/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 34/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 29/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 20/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 18/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 32/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 28/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 21/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 22/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 26/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 19/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 23/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 14/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 17/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 15/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 16/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 13/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 10/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 12/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 11/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 1/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/40
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/40
  • GitHub Check: Test Starter Templates

Comment thread src/frontend/src/utils/cookie-manager.ts Outdated
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 3, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 3, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 3, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 3, 2025
Copy link
Copy Markdown
Collaborator

@lucaseduoli lucaseduoli left a comment

Choose a reason for hiding this comment

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

lgtm!

@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Nov 4, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 4, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 4, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 4, 2025
@Cristhianzl Cristhianzl enabled auto-merge November 4, 2025 20:43
@Cristhianzl Cristhianzl added this pull request to the merge queue Nov 4, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 4, 2025
@Cristhianzl Cristhianzl added this pull request to the merge queue Nov 4, 2025
@Cristhianzl Cristhianzl removed this pull request from the merge queue due to a manual request Nov 5, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 5, 2025
@Cristhianzl Cristhianzl enabled auto-merge November 5, 2025 00:07
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Nov 5, 2025
@Cristhianzl Cristhianzl added this pull request to the merge queue Nov 5, 2025
Merged via the queue into main with commit 115c5b6 Nov 5, 2025
66 of 67 checks passed
@Cristhianzl Cristhianzl deleted the cz/fix-cookies-race-condition branch November 5, 2025 01:45
korenLazar pushed a commit to kiran-kate/langflow that referenced this pull request Nov 13, 2025
…ow-ai#10442)

* add cookies factory to prevent race condition

* add tests

* [autofix.ci] apply automated fixes

* add retry timeout on auth

* add login page control to remove old sessions

* fix auth context tests

* add max retries to auth cookies settings

* add folder auth option

* fix nth children progress track test

* fix user progress test

* fix user progress track test validation screen

* fix login redirect on switch between users

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor Maintenance tasks and housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants