feat: add frontend features store and FEATURE_NOT_INSTALLED error handling

Add Zustand features store for tracking AI feature bundle state with
fetch, refresh, isToolInstalled, and getBundleForTool methods. Extend
parseApiError to return structured FeatureNotInstalledError objects
when the backend returns FEATURE_NOT_INSTALLED, and handle them in
both tool and pipeline processor hooks with user-friendly messages.
This commit is contained in:
ashim-hq
2026-04-18 02:45:43 +08:00
parent 494bb3d78b
commit 0b9c760e5e
4 changed files with 96 additions and 5 deletions
+20 -1
View File
@@ -1,6 +1,25 @@
const API_BASE = "/api";
export function parseApiError(body: Record<string, unknown>, fallbackStatus: number): string {
export interface FeatureNotInstalledError {
type: "feature_not_installed";
feature: string;
featureName: string;
estimatedSize: string;
}
export function parseApiError(
body: Record<string, unknown>,
fallbackStatus: number,
): string | FeatureNotInstalledError {
if (body.code === "FEATURE_NOT_INSTALLED") {
return {
type: "feature_not_installed",
feature: body.feature as string,
featureName: body.featureName as string,
estimatedSize: body.estimatedSize as string,
};
}
const error = typeof body.error === "string" ? body.error : "";
const details = body.details;
if (!details) {