mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
+20
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user