Skip to content

Update Expert insights mode use app cache#7138

Open
Steve-Mcl wants to merge 3 commits into1178-app-cache-ttlfrom
7137-insights-cache
Open

Update Expert insights mode use app cache#7138
Steve-Mcl wants to merge 3 commits into1178-app-cache-ttlfrom
7137-insights-cache

Conversation

@Steve-Mcl
Copy link
Copy Markdown
Contributor

Description

This pull request refactors the Expert MCP access token caching system to use the application's centralized cache abstraction instead of the direct lru-cache dependency. It also updates affected API routes and tests to handle the now-async cache methods. These changes improve consistency, reliability, and testability of token caching and invalidation.

Caching system refactor:

  • Replaced direct usage of lru-cache with the application's cache abstraction (app.caches) in forge/expert/index.js, including new helper methods for cache access and token expiry handling. Now, token caching, retrieval, and clearing are all async and use the shared cache infrastructure. [1] [2] [3]

API updates:

  • Updated forge/routes/api/expert.js and forge/routes/api/project.js to await the now-async token cache methods, ensuring proper cache handling in API endpoints. [1] [2]

Test updates:

  • Updated all relevant tests in test/unit/forge/routes/api/expert_spec.js to await the async cache methods, ensuring tests correctly interact with the new caching logic. [1] [2] [3] [4] [5] [6] [7]

Related Issue(s)

closes #7137

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed.

Labels

  • Includes a DB migration? -> add the area:migration label

@Steve-Mcl Steve-Mcl requested a review from hardillb April 27, 2026 10:35
@Steve-Mcl Steve-Mcl linked an issue Apr 27, 2026 that may be closed by this pull request
@Steve-Mcl Steve-Mcl changed the title 7137 insights cache Update Expert insights mode use app cache Apr 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.57%. Comparing base (9dd545e) to head (7f83e85).
⚠️ Report is 2 commits behind head on 1178-app-cache-ttl.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           1178-app-cache-ttl    #7138   +/-   ##
===================================================
  Coverage               76.57%   76.57%           
===================================================
  Files                     405      405           
  Lines                   20382    20384    +2     
  Branches                 4905     4902    -3     
===================================================
+ Hits                    15607    15609    +2     
  Misses                   4775     4775           
Flag Coverage Δ
backend 76.57% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

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.

Change Expert insights local lru cache to use app cache

1 participant