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

Commit322a95c

Browse files
committed
Update recents to support workspaces from other users
1 parent30839c8 commit322a95c

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

‎CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
include agents in the initial workspaces query) and add them individually to
1616
the SSH config. In the future, we would like to use a wildcard host name to
1717
work around this issue.
18+
19+
Additionally, be aware that the recents view is using the same query filter.
20+
This means if you connect to a workspace, then change the filter such that the
21+
workspace is excluded, you could cause the workspace to be deleted from the
22+
recent connections even if the workspace still exists in actuality, as it
23+
would no longer show up in the query which the plugin takes as its cue to
24+
delete the connection.
1825
- Add owner column to connections view table.
1926
- Add agent name to the recent connections view.
2027

‎src/main/kotlin/com/coder/gateway/models/WorkspaceProjectIDE.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import kotlin.io.path.name
1616
* workspace.
1717
*/
1818
classWorkspaceProjectIDE(
19+
// Either `workspace.agent` for old connections or `user/workspace.agent`
20+
// for new connections.
1921
valname:String,
2022
valhostname:String,
2123
valprojectPath:String,

‎src/main/kotlin/com/coder/gateway/util/LinkHandler.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ open class LinkHandler(
108108
indicator?.invoke("Configuring Coder CLI...")
109109
cli.configSsh(workspacesAndAgents= client.withAgents(workspaces), currentUser= client.me)
110110

111-
val name="${workspace.name}.${agent.name}"
112111
val openDialog=
113112
parameters.ideProductCode().isNullOrBlank()||
114113
parameters.ideBuildNumber().isNullOrBlank()||
@@ -122,7 +121,7 @@ open class LinkHandler(
122121
// allowlisted. If not, check with the user whether to proceed.
123122
verifyDownloadLink(parameters)
124123
WorkspaceProjectIDE.fromInputs(
125-
name=name,
124+
name=CoderCLIManager.getWorkspaceParts(workspace, agent),
126125
hostname=CoderCLIManager.getHostName(deploymentURL.toURL(), workspace, client.me, agent),
127126
projectPath= parameters.folder(),
128127
ideProductCode= parameters.ideProductCode(),

‎src/main/kotlin/com/coder/gateway/views/CoderGatewayRecentWorkspaceConnectionsView.kt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,16 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
171171
}else {
172172
false
173173
}
174-
val workspaceWithAgent= deployment?.items?.firstOrNull { it.workspace.name== workspaceName }
174+
val me= deployment?.client?.me?.username
175+
val workspaceWithAgent= deployment?.items?.firstOrNull {
176+
it.workspace.ownerName+"/"+ it.workspace.name== workspaceName||
177+
(it.workspace.ownerName== me&& it.workspace.name== workspaceName)
178+
}
175179
val status=
176180
if (deploymentError!=null) {
177181
Triple(UIUtil.getErrorForeground(), deploymentError,UIUtil.getBalloonErrorIcon())
178182
}elseif (workspaceWithAgent!=null) {
179-
val inLoadingState=listOf(WorkspaceStatus.STARTING,WorkspaceStatus.CANCELING,WorkspaceStatus.DELETING,WorkspaceStatus.STOPPING).contains(workspaceWithAgent?.workspace?.latestBuild?.status)
183+
val inLoadingState=listOf(WorkspaceStatus.STARTING,WorkspaceStatus.CANCELING,WorkspaceStatus.DELETING,WorkspaceStatus.STOPPING).contains(workspaceWithAgent.workspace.latestBuild.status)
180184

181185
Triple(
182186
workspaceWithAgent.status.statusColor(),
@@ -244,7 +248,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
244248
foreground=Color.GRAY
245249
}
246250
}
247-
label(workspaceProjectIDE.name.replace(workspaceName+".","")).resizableColumn()
251+
label(workspaceProjectIDE.name.replace("$workspaceName.","")).resizableColumn()
248252
label(workspaceProjectIDE.ideName).applyToComponent {
249253
foreground=JBUI.CurrentTheme.ContextHelp.FOREGROUND
250254
font=ComponentPanelBuilder.getCommentFont(font)
@@ -276,7 +280,10 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
276280
}
277281

278282
/**
279-
* Get valid connections grouped by deployment and workspace.
283+
* Get valid connections grouped by deployment and workspace name. The
284+
* workspace name will be in the form `owner/workspace.agent`, without the agent
285+
* name, or just `workspace`, if the connection predates when we added owner
286+
* information, in which case it belongs to the current user.
280287
*/
281288
privatefungetConnectionsByDeployment(filter:Boolean):Map<String,Map<String,List<WorkspaceProjectIDE>>>= recentConnectionsService.getAllRecentConnections()
282289
// Validate and parse connections.
@@ -351,10 +358,20 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
351358
throwException("Unable to make request; token was not found in CLI config.")
352359
}
353360

361+
// This is purely to populate the current user, which is
362+
// used to match workspaces that were not recorded with owner
363+
// information.
364+
val me= client.authenticate().username
365+
354366
// Delete connections that have no workspace.
367+
// TODO: Deletion without confirmation seems sketchy.
355368
val items= client.workspaces().flatMap { it.toAgentList() }
356369
connectionsByWorkspace.forEach { (name, connections)->
357-
if (items.firstOrNull { it.workspace.name== name }==null) {
370+
if (items.firstOrNull {
371+
it.workspace.ownerName+"/"+ it.workspace.name== name||
372+
(it.workspace.ownerName== me&& it.workspace.name== name)
373+
}==null
374+
) {
358375
logger.info("Removing recent connections for deleted workspace$name (found${connections.size})")
359376
connections.forEach { recentConnectionsService.removeConnection(it.toRecentWorkspaceConnection()) }
360377
}

‎src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspaceProjectIDEStepView.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,8 @@ class CoderWorkspaceProjectIDEStepView(
402402
* Return the selected parameters. Throw if not configured.
403403
*/
404404
overridefundata():WorkspaceProjectIDE= withoutNull(cbIDE.selectedItem, state) { selectedIDE, state->
405-
val name="${state.workspace.name}.${state.agent.name}"
406405
selectedIDE.withWorkspaceProject(
407-
name=name,
406+
name=CoderCLIManager.getWorkspaceParts(state.workspace, state.agent),
408407
hostname=CoderCLIManager.getHostName(state.client.url, state.workspace, state.client.me, state.agent),
409408
projectPath= tfProject.text,
410409
deploymentURL= state.client.url,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp