Skip to content

feat: cache hub assistants for offline fallback#12016

Open
yzlu0917 wants to merge 1 commit intocontinuedev:mainfrom
yzlu0917:codex/issue-6893-hub-offline-cache
Open

feat: cache hub assistants for offline fallback#12016
yzlu0917 wants to merge 1 commit intocontinuedev:mainfrom
yzlu0917:codex/issue-6893-hub-offline-cache

Conversation

@yzlu0917
Copy link
Copy Markdown

@yzlu0917 yzlu0917 commented Apr 3, 2026

Summary

  • cache successfully loaded Hub assistant metadata in global context so installed Hub profiles can be reconstructed without a live Hub response
  • fall back to cached Hub organizations and assistant definitions when listOrganizations or listAssistants fails
  • add a regression test that warms the cache, simulates a Hub outage, and verifies both personal and org-scoped Hub assistants remain available

Why

Right now, if Continue Hub goes down, profiles installed from the Hub can disappear entirely even when they only target local backends like llama.cpp or 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

  • ran npm run vitest -- config/ConfigHandler.hubCache.vitest.ts in core

Closes #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

    • Store loaded Hub data in global context as cachedHubOrganizations with CachedHubOrganization/CachedHubAssistant types.
    • Fallback to cached orgs and assistants when listOrganizations/listAssistants return null, and surface a non-fatal warning.
    • Regression test warms the cache, simulates a Hub outage, and verifies personal and org-scoped assistants remain available.
  • Refactors

    • ControlPlaneClient.listOrganizations and listAssistants now return null on failure (instead of empty arrays) to signal outages; ConfigHandler handles this and builds profiles via cached data.

Written for commit 03f8af3. Summary will update on new commits.

@yzlu0917 yzlu0917 requested a review from a team as a code owner April 3, 2026 06:23
@yzlu0917 yzlu0917 requested review from sestinj and removed request for a team April 3, 2026 06:23
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 3, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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

@cubic-dev-ai cubic-dev-ai bot Apr 3, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +189 to +193
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Local models from the Hub should still work when the continue web service is down

1 participant