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
3 changes: 2 additions & 1 deletion apps/web/src/git-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export async function fetchSourceFile(args: {
dir,
url: args.url,
ref: MAIN_REF,
// The hub's git server advertises no `shallow` capability, so a
// depth-limited fetch is rejected outright; fetch the full branch.
singleBranch: true,
depth: 1,
tags: false,
headers: { Authorization: `Bearer ${args.token}` },
});
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/pages/new-workbench-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,20 @@ export function NewWorkbenchPickerRoute() {
});
navigate(workbenchPath(tenantId));
},
onError: (cause: unknown) => {
onError: (cause: unknown, variables) => {
const refId = reportError(cause, {
operation: "workbench_create",
...(selectedTenantId !== null ? { tenantId: selectedTenantId } : {}),
});
toast(describeWorkbenchCreateFailure(cause, refId));
// The room exists once a later stage fails; the toast says to retry
// from the room, so go there.
if (cause instanceof WorkbenchCreateError && cause.tenantId !== undefined) {
void queryClient.invalidateQueries({
queryKey: chatKeys.childTenants(variables.benchTenantId),
});
navigate(workbenchPath(cause.tenantId));
}
},
});

Expand Down
19 changes: 15 additions & 4 deletions apps/web/src/workbench-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export class WorkbenchCreateError extends Error {
constructor(
message: string,
readonly stage: "create" | "deploy" | "opening-message",
/** Set once the room tenant exists, so a later-stage failure can
* still land the person in the room it created. */
readonly tenantId?: string,
) {
super(message);
this.name = "WorkbenchCreateError";
Expand All @@ -32,8 +35,16 @@ function workbenchSlug(name: string): string {
return `${base === "" ? "workbench" : base}-${Date.now().toString(36)}`;
}

function failure(cause: unknown, stage: WorkbenchCreateError["stage"]): WorkbenchCreateError {
return new WorkbenchCreateError(cause instanceof Error ? cause.message : String(cause), stage);
function failure(
cause: unknown,
stage: WorkbenchCreateError["stage"],
tenantId?: string,
): WorkbenchCreateError {
return new WorkbenchCreateError(
cause instanceof Error ? cause.message : String(cause),
stage,
tenantId,
);
}

export type CreateWorkbenchInput = {
Expand Down Expand Up @@ -92,7 +103,7 @@ export async function createWorkbench(input: CreateWorkbenchInput): Promise<stri
});
}
} catch (cause) {
throw failure(cause, "deploy");
throw failure(cause, "deploy", tenantId);
}

if (input.openingMessage !== undefined && input.openingMessage !== "") {
Expand All @@ -106,7 +117,7 @@ export async function createWorkbench(input: CreateWorkbenchInput): Promise<stri
await sendToRoom({ roomTenantId: tenantId, agents, content: input.openingMessage });
}
} catch (cause) {
throw failure(cause, "opening-message");
throw failure(cause, "opening-message", tenantId);
}
}

Expand Down
Loading