feat: cache hub assistants for offline fallback#12016
feat: cache hub assistants for offline fallback#12016yzlu0917 wants to merge 1 commit intocontinuedev:mainfrom
Conversation
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="core/config/ConfigHandler.ts">
<violation number="1" location="core/config/ConfigHandler.ts:192">
P1: Hub fallback cache is not scoped or cleared per account, so unavailable Hub responses can expose stale orgs/assistants after account switch.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| ...d, | ||
| policy: policyResponse?.policy, | ||
| })); | ||
| const orgsWithPolicy = (orgDescriptions ?? cachedHubOrganizations) |
There was a problem hiding this comment.
P1: Hub fallback cache is not scoped or cleared per account, so unavailable Hub responses can expose stale orgs/assistants after account switch.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At core/config/ConfigHandler.ts, line 192:
<comment>Hub fallback cache is not scoped or cleared per account, so unavailable Hub responses can expose stale orgs/assistants after account switch.</comment>
<file context>
@@ -176,30 +180,71 @@ export class ConfigHandler {
- ...d,
- policy: policyResponse?.policy,
- }));
+ const orgsWithPolicy = (orgDescriptions ?? cachedHubOrganizations)
+ .filter((org) => org.id !== this.PERSONAL_ORG_DESC.id)
+ .map((d) => ({
</file context>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03f8af385b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const cachedHubOrganizations = this.getCachedHubOrganizations(); | ||
| const orgDescriptions = | ||
| await this.controlPlaneClient.listOrganizations(); | ||
| const orgsWithPolicy = orgDescriptions.map((d) => ({ | ||
| ...d, | ||
| policy: policyResponse?.policy, | ||
| })); | ||
| const orgsWithPolicy = (orgDescriptions ?? cachedHubOrganizations) | ||
| .filter((org) => org.id !== this.PERSONAL_ORG_DESC.id) |
There was a problem hiding this comment.
Scope hub-assistant fallback cache to active account
When listOrganizations() fails, this path falls back to cachedHubOrganizations from global context, but the cached records are not keyed to the signed-in account and this change does not invalidate them on auth/org changes. In practice, if a user switches accounts (or loses org membership) and the Hub is unavailable, the app can resurrect assistants/orgs from the previous account, exposing stale/private profile metadata and selecting profiles the current user should not see. Please scope the cache by account identity (or clear it on session changes) before using it for offline fallback.
Useful? React with 👍 / 👎.
Summary
listOrganizationsorlistAssistantsfailsWhy
Right now, if Continue Hub goes down, profiles installed from the Hub can disappear entirely even when they only target local backends like
llama.cppor LM Studio. That makes previously working local models fail with missing-profile and config-loading errors even though the model runtime itself is still healthy.This change makes Hub-backed local profiles resilient to temporary Hub outages by reusing the last successfully loaded assistant definitions.
Validation
npm run vitest -- config/ConfigHandler.hubCache.vitest.tsincoreCloses #6893
Summary by cubic
Cache Hub organizations and assistant definitions and use them when the Hub is down, so installed Hub-backed profiles stay available and local models keep working during outages.
New Features
cachedHubOrganizationswithCachedHubOrganization/CachedHubAssistanttypes.listOrganizations/listAssistantsreturnnull, and surface a non-fatal warning.Refactors
ControlPlaneClient.listOrganizationsandlistAssistantsnow returnnullon failure (instead of empty arrays) to signal outages;ConfigHandlerhandles this and builds profiles via cached data.Written for commit 03f8af3. Summary will update on new commits.