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

feat(site): use new task data model and endpoints#20431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@mafredri
Copy link
Member

@mafredrimafredri commentedOct 23, 2025
edited by BrunoQuaresma
Loading

Updates the UI to use the new API endpoints for tasks and use its new data model.

Disclaimer: Since the base data model for tasks changed, we had to do a quite large refactor and I'm sorry for that 🙏, but you'll notice most of the changes are to adjust the types.

Closescoder/internal#976

@mafredriGraphite App
Copy link
MemberAuthor

mafredri commentedOct 23, 2025
edited
Loading

@mafredrimafredriforce-pushed therefactor-site-use-new-tasks-data-model-and-endpoints branch from5f883dd to1e0548cCompareOctober 23, 2025 08:32
@mafredrimafredri changed the base branch frommafredri/refactor-coderd-use-tasks-data-model-in-list tographite-base/20431October 23, 2025 08:37
@mafredrimafredriforce-pushed therefactor-site-use-new-tasks-data-model-and-endpoints branch fromeea8ed5 to6d13866CompareOctober 23, 2025 15:34
@mafredrimafredri changed the base branch fromgraphite-base/20431 tomafredri/chore-codersdk-document-taskstatus-and-taskstateOctober 23, 2025 15:35
@mafredrimafredri marked this pull request as ready for reviewOctober 23, 2025 15:51
@mafredrimafredriforce-pushed themafredri/chore-codersdk-document-taskstatus-and-taskstate branch 3 times, most recently frome1f7b87 to0554fd1CompareOctober 23, 2025 16:32
@mafredrimafredriforce-pushed therefactor-site-use-new-tasks-data-model-and-endpoints branch frombd91d75 tod530c4dCompareOctober 23, 2025 16:41
@mafredrimafredri changed the base branch frommafredri/chore-codersdk-document-taskstatus-and-taskstate tomafredri/refactor-coderd-use-tasks-data-model-in-listOctober 23, 2025 16:44
@mafredrimafredriforce-pushed therefactor-site-use-new-tasks-data-model-and-endpoints branch fromd530c4d toc9f1efdCompareOctober 23, 2025 16:46
@mafredrimafredriforce-pushed themafredri/refactor-coderd-use-tasks-data-model-in-list branch 3 times, most recently from9220413 toe605686CompareOctober 23, 2025 17:11
Base automatically changed frommafredri/refactor-coderd-use-tasks-data-model-in-list tomainOctober 23, 2025 17:22
@mafredrimafredriforce-pushed therefactor-site-use-new-tasks-data-model-and-endpoints branch fromc9f1efd toaecddafCompareOctober 23, 2025 17:23
@BrunoQuaresmaBrunoQuaresma requested a review froma teamOctober 23, 2025 18:48
Copy link
Contributor

@ParkreinerParkreiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nothing major stuck out to me for the frontend changes, but I did have a few questions.

The main thing that stuck out to me was whether we can stop polling every five seconds for some of the tasks, or if that's something we absolutely need for UX

getTasks=async(
filter:TypesGen.TasksFilter,
):Promise<readonlyTypesGen.Task[]>=>{
constquery=[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nit: can we type this asstring[]?

BrunoQuaresma reacted with thumbs up emoji
Comment on lines 28 to 30
exporttypeWorkspaceAppWithAgent=WorkspaceApp&{
agent:WorkspaceAgent;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nit: I know this is used in a few other files, but just because this is only used in one spot for this file, I'd move the type definition to be closer to where it's used, especially since it's more of a "kludge" type

BrunoQuaresma reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Moved tomodules/tasks/apps.ts

Comment on lines 155 to 162
returnworkspace.latest_build.resources
.flatMap((r)=>r.agents??[])
.flatMap((agent)=>
agent.apps.map((app)=>({
...app,
agent,
})),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I wish I knew a little bit more of Coder's backend implementations so I didn't have to ask this: are the same apps able to be shared across multiple agents? I'm wondering if we need any de-duplication

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No, a workspace_app is linked to a single workspace_agent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes. We can change this function to accept an agent ID, but the agent ID can be null depending on the state. Unfortunately, sice Go does not support uninon types, we need to update the code in a few places to handle that. Since we are quite out of time for this, I'm going to skip it for now.

Comment on lines +203 to 205
constfilter:TypesGen.TasksFilter={
owner:user.username,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We should be able to extract it outside of the component so it doesn't get recreated each render

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not sure if I go it... the filter needs to be mounted inside of the component, so we can access theuser.username 🤔

Comment on lines 22 to 25
path:`/tasks/${MockTasks[0].owner_name}/${MockTasks[0].id}`,
pathParams:{
workspace:MockTasks[0].workspace.name,
owner_name:MockTasks[0].owner_name,
task:MockTasks[0].id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not a huge deal, but I'm wondering if we can:

  1. Split off the first mock task into a separate variable
  2. Put the variable in the array at the first position still
  3. Export the variable along with the array

It's not a big deal for a story, but in production, I would want to make sure that when we're dealing with empty arrays properly (and ourtsconfig file isn't tuned tightly enough to catch potential mismatches at the type level)

Comment on lines +65 to +67
refetchInterval:({ state})=>{
returnstate.error ?false :5_000;
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we want this to be constantly refetching? Because even if all tasks are settled, we'll still refetch every five seconds, as long as there is no error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, because task has statuses and states that are updated during its lifecycle.

Comment on lines +72 to +74
refetchInterval:({ state})=>{
returnstate.error ?false :5_000;
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Same question here

Comment on lines +202 to +203
queryKey:["workspace",workspace.id,"parameters"],
queryFn:()=>API.getWorkspaceParameters(workspace),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I feel like the API setup is a little bit off here. The API function only needs the workspace's latest build, but we're not putting it in the query key, and we're also putting in the workspace's ID, which isn't used by the function at all

Wondering if it might be worth changing what the API function accepts at input to minimize its dependencies

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I do agree with you, but we are doing this in three other places in the codebase, so I'm not going to touch this right now, since it would be outside of the scope.

Comment on lines -394 to -399
if(
workspace.latest_build.job.completed_at&&
!workspace.latest_build.has_ai_task
){
thrownewWorkspaceDoesNotHaveAITaskError(workspace);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we need equivalent functionality still, or do we have guarantees that we'll never trigger it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We've inverted the relationship, there is now a tasks table with a workspace_id column.

Comment on lines 116 to 118
current_state:{
...(firstTask.current_stateasTaskStateEntry),
state:"idle",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Instead of doing the type assertion, could we pass a function tomockResolvedValue, and have it throw an error iffirstTask.current_state is null?

BrunoQuaresma reacted with thumbs up emoji
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Backend changes LGTM

TemplateDisplayNamestring`json:"template_display_name" table:"template display name"`
TemplateIconstring`json:"template_icon" table:"template icon"`
WorkspaceID uuid.NullUUID`json:"workspace_id" format:"uuid" table:"workspace id"`
WorkspaceNamestring`json:"workspace_name" table:"workspace name"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Might be good to add some asserts for this incoderd/aitasks_test.go e.g. inTestTasks/{Get,List}.

BrunoQuaresma reacted with thumbs up emoji
Copy link
MemberAuthor

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

BE changes look good 👍🏻

BrunoQuaresma reacted with thumbs up emoji
FilterQuerystring`json:"filter_query,omitempty"`
}

// Experimental response shape for tasks list (server returns []Task).
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
//Experimentalresponse shape for tasks list (server returns []Task).
//TaskListResponse is theresponse shape for tasks list.
//
// Experimental: This type is experimental and may change in the future.

@BrunoQuaresmaBrunoQuaresma merged commit51d3abb intomainOct 24, 2025
36 checks passed
@BrunoQuaresmaBrunoQuaresma deleted the refactor-site-use-new-tasks-data-model-and-endpoints branchOctober 24, 2025 13:45
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 24, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@aslilacaslilacAwaiting requested review from aslilac

+2 more reviewers

@BrunoQuaresmaBrunoQuaresmaBrunoQuaresma left review comments

@ParkreinerParkreinerParkreiner left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

@BrunoQuaresmaBrunoQuaresma

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

chore: tasks: refactor existing API endpoints to use new data model

5 participants

@mafredri@BrunoQuaresma@johnstcn@Parkreiner

[8]ページ先頭

©2009-2025 Movatter.jp