Skip to content

Commit 6d69c0f

Browse files
fix(web): fetch agent source without a shallow depth the hub git server rejects (CL-8512) (#904)
* fix(web): fetch agent source without a shallow depth the hub git server rejects (CL-8512) * fix(web): land in the new room when a later create stage fails (CL-8512)
1 parent ecf224d commit 6d69c0f

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎apps/web/src/git-fetch.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ export async function fetchSourceFile(args: {
3030
dir,
3131
url: args.url,
3232
ref: MAIN_REF,
33+
// The hub's git server advertises no `shallow` capability, so a
34+
// depth-limited fetch is rejected outright; fetch the full branch.
3335
singleBranch: true,
34-
depth: 1,
3536
tags: false,
3637
headers: { Authorization: `Bearer ${args.token}` },
3738
});

‎apps/web/src/pages/new-workbench-picker.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,20 @@ export function NewWorkbenchPickerRoute() {
123123
});
124124
navigate(workbenchPath(tenantId));
125125
},
126-
onError: (cause: unknown) => {
126+
onError: (cause: unknown, variables) => {
127127
const refId = reportError(cause, {
128128
operation: "workbench_create",
129129
...(selectedTenantId !== null ? { tenantId: selectedTenantId } : {}),
130130
});
131131
toast(describeWorkbenchCreateFailure(cause, refId));
132+
// The room exists once a later stage fails; the toast says to retry
133+
// from the room, so go there.
134+
if (cause instanceof WorkbenchCreateError && cause.tenantId !== undefined) {
135+
void queryClient.invalidateQueries({
136+
queryKey: chatKeys.childTenants(variables.benchTenantId),
137+
});
138+
navigate(workbenchPath(cause.tenantId));
139+
}
132140
},
133141
});
134142

‎apps/web/src/workbench-create.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export class WorkbenchCreateError extends Error {
1515
constructor(
1616
message: string,
1717
readonly stage: "create" | "deploy" | "opening-message",
18+
/** Set once the room tenant exists, so a later-stage failure can
19+
* still land the person in the room it created. */
20+
readonly tenantId?: string,
1821
) {
1922
super(message);
2023
this.name = "WorkbenchCreateError";
@@ -32,8 +35,16 @@ function workbenchSlug(name: string): string {
3235
return `${base === "" ? "workbench" : base}-${Date.now().toString(36)}`;
3336
}
3437

35-
function failure(cause: unknown, stage: WorkbenchCreateError["stage"]): WorkbenchCreateError {
36-
return new WorkbenchCreateError(cause instanceof Error ? cause.message : String(cause), stage);
38+
function failure(
39+
cause: unknown,
40+
stage: WorkbenchCreateError["stage"],
41+
tenantId?: string,
42+
): WorkbenchCreateError {
43+
return new WorkbenchCreateError(
44+
cause instanceof Error ? cause.message : String(cause),
45+
stage,
46+
tenantId,
47+
);
3748
}
3849

3950
export type CreateWorkbenchInput = {
@@ -92,7 +103,7 @@ export async function createWorkbench(input: CreateWorkbenchInput): Promise<stri
92103
});
93104
}
94105
} catch (cause) {
95-
throw failure(cause, "deploy");
106+
throw failure(cause, "deploy", tenantId);
96107
}
97108

98109
if (input.openingMessage !== undefined && input.openingMessage !== "") {
@@ -106,7 +117,7 @@ export async function createWorkbench(input: CreateWorkbenchInput): Promise<stri
106117
await sendToRoom({ roomTenantId: tenantId, agents, content: input.openingMessage });
107118
}
108119
} catch (cause) {
109-
throw failure(cause, "opening-message");
120+
throw failure(cause, "opening-message", tenantId);
110121
}
111122
}
112123

0 commit comments

Comments
 (0)