Skip to content
Merged
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
12 changes: 10 additions & 2 deletions apps/drive-integration/src/hooks/useWorkflowAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ const getBackendWorkflowFailureReason = (runData: AgentRunData): WorkflowFailure
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 @@ -154,6 +158,10 @@ const getWorkflowFailureMessage = (
return ERROR_MESSAGES.AI_SERVICE_UNAVAILABLE;
}

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

return getRunErrorMessage(runData);
};

Expand Down Expand Up @@ -265,7 +273,7 @@ export const useWorkflowAgent = ({
setIsAnalyzing(true);

const spaceId = sdk.ids.space;
const environmentId = sdk.ids.environment;
const environmentId = sdk.ids.environmentAlias ?? sdk.ids.environment;
const threadId = [crypto.randomUUID(), WORKFLOW_AGENT_ID].join('-');

const payload: AgentGeneratePayload = {
Expand Down Expand Up @@ -308,7 +316,7 @@ export const useWorkflowAgent = ({
setIsAnalyzing(true);

const spaceId = sdk.ids.space;
const environmentId = sdk.ids.environment;
const environmentId = sdk.ids.environmentAlias ?? sdk.ids.environment;

try {
await resumeWorkflowRun(sdk, spaceId, environmentId, runId, resumePayload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ export const ModalOrchestrator = forwardRef<ModalOrchestratorHandle, ModalOrches
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;
}
Comment on lines +190 to +200

@FBanfi Franco Banfi (FBanfi) Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I find this a bit confusing, how would the user run the workflow if the app was not installed in that environment?
Or this error refers to cases where: in the middle of a workflow run, the app was uninstalled from a different browser tab?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The idea is to have better error handling. If by any chance the request fail in the BE, we want to be as clear as possible. Better a clear error message than a generic "Unable to generate preview" for the user. Also we want to know if the app is failing because of this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense! 💯


setPreviewErrorState({
reason: WorkflowFailureReason.GENERIC,
title: 'Unable to generate preview',
Expand Down
1 change: 1 addition & 0 deletions apps/drive-integration/src/types/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum WorkflowFailureReason {
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
2 changes: 2 additions & 0 deletions apps/drive-integration/src/utils/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const ERROR_MESSAGES = {
'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