Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite335ced

Browse files
committed
Fix connecting to off workspaces
We made a change to always include the agent in the host name so thesession is stable, however for workspaces that are off there is no agentincluded in the response, and we were silently returning in these cases.So for these cases, fetch the first agent through a different API thatstill returns agents when the workspace is off.Workspace picker is broken out into a separate function, logic isunchanged.Instead of a possibly-undefined agent on a tree item, I switch on thetree item type. I feel the intent this way is easier to follow.To extract agents from both APIs, make extractAgents accept an array ofresources instead of a workspace.
1 parentcb2a4ec commite335ced

File tree

4 files changed

+195
-176
lines changed

4 files changed

+195
-176
lines changed

‎src/api-helper.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import{isApiError,isApiErrorResponse}from"coder/site/src/api/errors";
2-
import{Workspace,WorkspaceAgent}from"coder/site/src/api/typesGenerated";
2+
import{
3+
Workspace,
4+
WorkspaceAgent,
5+
WorkspaceResource,
6+
}from"coder/site/src/api/typesGenerated";
37
import{ErrorEvent}from"eventsource";
48
import{z}from"zod";
59

@@ -24,12 +28,14 @@ export function extractAllAgents(
2428
workspaces:readonlyWorkspace[],
2529
):WorkspaceAgent[]{
2630
returnworkspaces.reduce((acc,workspace)=>{
27-
returnacc.concat(extractAgents(workspace));
31+
returnacc.concat(extractAgents(workspace.latest_build.resources));
2832
},[]asWorkspaceAgent[]);
2933
}
3034

31-
exportfunctionextractAgents(workspace:Workspace):WorkspaceAgent[]{
32-
returnworkspace.latest_build.resources.reduce((acc,resource)=>{
35+
exportfunctionextractAgents(
36+
resources:readonlyWorkspaceResource[],
37+
):WorkspaceAgent[]{
38+
returnresources.reduce((acc,resource)=>{
3339
returnacc.concat(resource.agents||[]);
3440
},[]asWorkspaceAgent[]);
3541
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp