Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0306938

Browse files
committed
display apps
1 parent 8879191 commit 0306938

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

App/ViewModels/AgentAppViewModel.cs

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ private void OpenApp(object parameter)
142142
var cred = _credentialManager.GetCachedCredentials();
143143
if (cred.State is CredentialState.Valid && cred.ApiToken is not null)
144144
uriString = uriString.Replace(SessionTokenUriVar, cred.ApiToken);
145-
uriString += SessionTokenUriVar;
146145
if (uriString.Contains(SessionTokenUriVar))
147146
throw new Exception($"URI contains {SessionTokenUriVar} variable but could not be replaced");
148147

App/ViewModels/AgentViewModel.cs

+31
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public partial class AgentViewModel : ObservableObject, IModelUpdateable<AgentVi
6060
private const string DefaultDashboardUrl = "https://coder.com";
6161
private const int MaxAppsPerRow = 6;
6262

63+
// These are fake UUIDs, for UI purposes only. Display apps don't exist on
64+
// the backend as real app resources and therefore don't have an ID.
65+
private static readonly Uuid VscodeAppUuid = new("819828b1-5213-4c3d-855e-1b74db6ddd19");
66+
private static readonly Uuid VscodeInsidersAppUuid = new("becf1e10-5101-4940-a853-59af86468069");
67+
6368
private readonly ILogger<AgentViewModel> _logger;
6469
private readonly ICoderApiClientFactory _coderApiClientFactory;
6570
private readonly ICredentialManager _credentialManager;
@@ -274,6 +279,32 @@ private void ContinueFetchApps(Task<WorkspaceAgent> task)
274279
apps.Add(_agentAppViewModelFactory.Create(uuid, app.DisplayName, app.Url, iconUrl));
275280
}
276281

282+
foreach (var displayApp in workspaceAgent.DisplayApps)
283+
{
284+
if (displayApp is not WorkspaceAgent.DisplayAppVscode and not WorkspaceAgent.DisplayAppVscodeInsiders)
285+
continue;
286+
287+
var id = VscodeAppUuid;
288+
var displayName = "VS Code";
289+
var icon = "/icon/code.svg";
290+
var scheme = "vscode";
291+
if (displayApp is WorkspaceAgent.DisplayAppVscodeInsiders)
292+
{
293+
id = VscodeInsidersAppUuid;
294+
displayName = "VS Code Insiders";
295+
icon = "/icon/code-insiders.svg";
296+
scheme = "vscode-insiders";
297+
}
298+
299+
var appUri = $"{scheme}://vscode-remote/ssh-remote+{FullHostname}/{workspaceAgent.ExpandedDirectory}";
300+
301+
// Icon parse failures are not fatal, we will just use the fallback
302+
// icon.
303+
_ = Uri.TryCreate(DashboardBaseUrl, icon, out var iconUrl);
304+
305+
apps.Add(_agentAppViewModelFactory.Create(id, displayName, appUri, iconUrl));
306+
}
307+
277308
// Sort by name.
278309
ModelUpdate.ApplyLists(Apps, apps, (a, b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal));
279310
}

CoderSdk/Coder/WorkspaceAgents.cs

+9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ public partial interface ICoderApiClient
77

88
public class WorkspaceAgent
99
{
10+
public const string DisplayAppVscode = "vscode";
11+
public const string DisplayAppVscodeInsiders = "vscode_insiders";
12+
13+
public string ExpandedDirectory { get; set; } = "";
14+
1015
public WorkspaceApp[] Apps { get; set; } = [];
16+
17+
// This isn't an enum to avoid future display apps breaking the desktop
18+
// app.
19+
public string[] DisplayApps { get; set; } = [];
1120
}
1221

1322
public class WorkspaceApp

0 commit comments

Comments
 (0)