Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/drive-integration/src/hooks/useWorkflowAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ const getBackendWorkflowFailureReason = (runData: AgentRunData): WorkflowFailure
return WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND;
}

if (workflowFailure.code === WorkflowFailureReason.AI_SERVICE_UNAVAILABLE) {
return WorkflowFailureReason.AI_SERVICE_UNAVAILABLE;
}

if (workflowFailure.code === WorkflowFailureReason.APP_NOT_INSTALLED) {
return WorkflowFailureReason.APP_NOT_INSTALLED;
}

if (workflowFailure.code === WorkflowFailureReason.GENERIC) {
return WorkflowFailureReason.GENERIC;
}
Expand All @@ -146,6 +154,14 @@ const getWorkflowFailureMessage = (
return ERROR_MESSAGES.GOOGLE_DOCS_NOT_FOUND;
}

if (failureReason === WorkflowFailureReason.AI_SERVICE_UNAVAILABLE) {
return ERROR_MESSAGES.AI_SERVICE_UNAVAILABLE;
}

if (failureReason === WorkflowFailureReason.APP_NOT_INSTALLED) {
return ERROR_MESSAGES.APP_NOT_INSTALLED;
}

return getRunErrorMessage(runData);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,30 @@ export const ModalOrchestrator = forwardRef<ModalOrchestratorHandle, ModalOrches
return;
}

if (
error instanceof WorkflowRunError &&
error.reason === WorkflowFailureReason.AI_SERVICE_UNAVAILABLE
) {
setPreviewErrorState({
reason: WorkflowFailureReason.AI_SERVICE_UNAVAILABLE,
title: 'AI service temporarily unavailable',
message: ERROR_MESSAGES.AI_SERVICE_UNAVAILABLE,
});
return;
}

if (
error instanceof WorkflowRunError &&
error.reason === WorkflowFailureReason.APP_NOT_INSTALLED
) {
setPreviewErrorState({
reason: WorkflowFailureReason.APP_NOT_INSTALLED,
title: 'App not installed in this environment',
message: ERROR_MESSAGES.APP_NOT_INSTALLED,
});
return;
}

setPreviewErrorState({
reason: WorkflowFailureReason.GENERIC,
title: 'Unable to generate preview',
Expand Down
2 changes: 2 additions & 0 deletions apps/drive-integration/src/types/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export enum WorkflowFailureReason {
GENERIC = 'generic',
GOOGLE_DRIVE_AUTH_EXPIRED = 'google-drive-auth-expired',
GOOGLE_DOCS_NOT_FOUND = 'google-docs-not-found',
AI_SERVICE_UNAVAILABLE = 'ai-service-unavailable',
APP_NOT_INSTALLED = 'app-not-installed',
}

export interface WorkflowFailure {
Expand Down
4 changes: 4 additions & 0 deletions apps/drive-integration/src/utils/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const ERROR_MESSAGES = {
'Your Drive connection has expired or is no longer valid. Reconnect your account to continue generating a preview.',
GOOGLE_DOCS_NOT_FOUND:
'Google Doc not found. Make sure the document exists and your Google account has access to it.',
AI_SERVICE_UNAVAILABLE:
'The AI service is temporarily unavailable. Please try again in a few minutes.',
APP_NOT_INSTALLED:
'The Drive Integration app is not installed in this environment. Install it via Apps > Manage apps and try again.',
} as const;

export const SUCCESS_MESSAGES = {
Expand Down
Loading