Skip to content

Commit 48f0148

Browse files
refactor!: remove TaskAppID from codersdk.WorkspaceBuild
We can instead use the new data model for this, there is no reason to have it stored inside the workspace build. `TaskAppID` has not _yet_ been shipped into a release. This would need cherry-picking if we wanted to go ahead with it.
1 parent 197b422 commit 48f0148

File tree

12 files changed

+115
-144
lines changed

12 files changed

+115
-144
lines changed

coderd/apidoc/docs.go

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspacebuilds.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,6 @@ func (api *API) convertWorkspaceBuild(
12281228
TemplateVersionPresetID: presetID,
12291229
HasAITask: hasAITask,
12301230
AITaskSidebarAppID: taskAppID,
1231-
TaskAppID: taskAppID,
12321231
HasExternalAgent: hasExternalAgent,
12331232
}, nil
12341233
}

codersdk/workspacebuilds.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ type WorkspaceBuild struct {
8989
MatchedProvisioners *MatchedProvisioners `json:"matched_provisioners,omitempty"`
9090
TemplateVersionPresetID *uuid.UUID `json:"template_version_preset_id" format:"uuid"`
9191
HasAITask *bool `json:"has_ai_task,omitempty"`
92-
// Deprecated: This field has been replaced with `TaskAppID`
92+
// Deprecated: This field has been replaced with `Task.WorkspaceAppID`
9393
AITaskSidebarAppID *uuid.UUID `json:"ai_task_sidebar_app_id,omitempty" format:"uuid"`
94-
TaskAppID *uuid.UUID `json:"task_app_id,omitempty" format:"uuid"`
9594
HasExternalAgent *bool `json:"has_external_agent,omitempty"`
9695
}
9796

docs/reference/api/builds.md

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/schemas.md

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/workspaces.md

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/pages/TaskPage/TaskApps.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
MockPrimaryWorkspaceProxy,
3+
MockTask,
34
MockUserOwner,
45
MockWorkspace,
56
MockWorkspaceAgent,
@@ -33,24 +34,28 @@ type Story = StoryObj<typeof TaskApps>;
3334

3435
export const NoEmbeddedApps: Story = {
3536
args: {
37+
task: MockTask,
3638
workspace: mockWorkspaceWithApps([]),
3739
},
3840
};
3941

4042
export const WithExternalAppsOnly: Story = {
4143
args: {
44+
task: MockTask,
4245
workspace: mockWorkspaceWithApps([mockExternalApp]),
4346
},
4447
};
4548

4649
export const WithEmbeddedApps: Story = {
4750
args: {
51+
task: MockTask,
4852
workspace: mockWorkspaceWithApps([mockEmbeddedApp()]),
4953
},
5054
};
5155

5256
export const WithMixedApps: Story = {
5357
args: {
58+
task: MockTask,
5459
workspace: mockWorkspaceWithApps([mockEmbeddedApp(), mockExternalApp]),
5560
},
5661
};
@@ -69,6 +74,7 @@ export const WithWildcardWarning: Story = {
6974
user: MockUserOwner,
7075
},
7176
args: {
77+
task: MockTask,
7278
workspace: mockWorkspaceWithApps([
7379
{
7480
...mockEmbeddedApp(),
@@ -80,6 +86,7 @@ export const WithWildcardWarning: Story = {
8086

8187
export const WithManyEmbeddedApps: Story = {
8288
args: {
89+
task: MockTask,
8390
workspace: mockWorkspaceWithApps([
8491
mockEmbeddedApp("Code Server"),
8592
mockEmbeddedApp("Jupyter Notebook"),

site/src/pages/TaskPage/TaskApps.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Workspace } from "api/typesGenerated";
1+
import type { Task, Workspace } from "api/typesGenerated";
22
import { Button } from "components/Button/Button";
33
import {
44
DropdownMenu,
@@ -24,27 +24,26 @@ import { docs } from "utils/docs";
2424
import { TaskAppIFrame, TaskIframe } from "./TaskAppIframe";
2525

2626
type TaskAppsProps = {
27+
task: Task;
2728
workspace: Workspace;
2829
};
2930

3031
const TERMINAL_TAB_ID = "terminal";
3132

32-
export const TaskApps: FC<TaskAppsProps> = ({ workspace }) => {
33+
export const TaskApps: FC<TaskAppsProps> = ({ task, workspace }) => {
3334
const apps = getAllAppsWithAgent(workspace).filter(
3435
// The Chat UI app will be displayed in the sidebar, so we don't want to
3536
// show it as a web app.
36-
(app) =>
37-
app.id !== workspace.latest_build.task_app_id &&
38-
app.health !== "disabled",
37+
(app) => app.id !== task.workspace_app_id && app.health !== "disabled",
3938
);
4039
const [embeddedApps, externalApps] = splitEmbeddedAndExternalApps(apps);
4140
const [activeAppId, setActiveAppId] = useState(embeddedApps.at(0)?.id);
4241
const hasAvailableAppsToDisplay =
4342
embeddedApps.length > 0 || externalApps.length > 0;
4443
const taskAgent = apps.at(0)?.agent;
4544
const terminalHref = getTerminalHref({
46-
username: workspace.owner_name,
47-
workspace: workspace.name,
45+
username: task.owner_name,
46+
workspace: task.workspace_name,
4847
agent: taskAgent?.name,
4948
});
5049
const isTerminalActive = activeAppId === TERMINAL_TAB_ID;

0 commit comments

Comments
 (0)