Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

perf(workbench): cache config reads longer (#472)

Call White4a4086bd1dcb
diff --git a/docs/plans/config-read-cache.md b/docs/plans/config-read-cache.md
new file mode 100644
index 000000000..20e5ed6e5
--- /dev/null
+++ b/docs/plans/config-read-cache.md
@@ -0,0 +1,20 @@
+# Config Read Cache Plan
+
+## Goal
+
+Reduce repeated Workbench UI round-trips to `GET /api/config` over remote links.
+The config payload is read by the app shell and several pages, but changes only
+through explicit mutations in the same API context.
+
+## Scope
+
+- Keep the existing shared read-cache mechanism.
+- Give `/api/config` a longer client-side TTL than generic read endpoints.
+- Keep successful mutating calls invalidating the read cache, so `saveConfig`
+ and related writes still make the next `getConfig()` fresh.
+- Do not change the `/api/config` response shape or add a new endpoint.
+
+## Validation
+
+- Frontend production build.
+- Diff review for cache invalidation paths.
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index dfe1e4b57..ab2e37523 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -1092,6 +1092,7 @@ export class ApiError extends Error {
}
const ApiContext = createContext<ApiContextType | undefined>(undefined);
+const CONFIG_CACHE_TTL_MS = 30_000;
export const useApi = () => {
const context = useContext(ApiContext);
@@ -1444,7 +1445,7 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
// is correct (cached error messages would otherwise stay in the
// old language).
const value: ApiContextType = useMemo(() => ({
- getConfig: () => getCachedJson('/api/config'),
+ getConfig: () => getCachedJson('/api/config', CONFIG_CACHE_TTL_MS),
getPlatformCatalog: () => getJson('/api/platforms'),
saveConfig: (payload) => postJson('/api/config', payload),
getSettings: (platform) => getJson(platform ? `/api/settings?platform=${encodeURIComponent(platform)}` : '/api/settings'),