Skip to content

refactor: create tasks in coderd instead of frontend #19280

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: aiTasksCreate -> tasksCreate
  • Loading branch information
DanielleMaywood committed Aug 12, 2025
commit 27b58230e070d17de99855857514940d1671cc9d
22 changes: 5 additions & 17 deletions coderd/aitasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,19 @@ func (api *API) aiTasksPrompts(rw http.ResponseWriter, r *http.Request) {

// This endpoint is experimental and not guaranteed to be stable, so we're not
// generating public-facing documentation for it.
func (api *API) aiTasksCreate(rw http.ResponseWriter, r *http.Request) {
func (api *API) tasksCreate(rw http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
apiKey = httpmw.APIKey(r)
auditor = api.Auditor.Load()
member = httpmw.OrganizationMemberParam(r)
)

var req codersdk.CreateAITasksRequest
if !httpapi.Read(ctx, rw, r, &req) {
return
}

user, err := api.Database.GetUserByID(ctx, apiKey.UserID)
if httpapi.Is404Error(err) {
httpapi.ResourceNotFound(rw)
return
}
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error fetching user.",
Detail: err.Error(),
})
return
}

hasAITask, err := api.Database.GetTemplateVersionHasAITask(ctx, req.TemplateVersionID)
if err != nil {
if errors.Is(err, sql.ErrNoRows) || rbac.IsUnauthorizedError(err) {
Expand Down Expand Up @@ -125,9 +113,9 @@ func (api *API) aiTasksCreate(rw http.ResponseWriter, r *http.Request) {
}

owner := workspaceOwner{
ID: user.ID,
Username: user.Username,
AvatarURL: user.AvatarURL,
ID: member.UserID,
Username: member.Username,
AvatarURL: member.AvatarURL,
}

aReq, commitAudit := audit.InitRequest[database.WorkspaceTable](rw, &audit.RequestParams{
Expand Down
5 changes: 4 additions & 1 deletion coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,8 +994,11 @@ func New(options *Options) *API {
r.Use(apiKeyMiddleware)
r.Route("/aitasks", func(r chi.Router) {
r.Get("/prompts", api.aiTasksPrompts)
})
r.Route("/tasks", func(r chi.Router) {
r.Use(apiRateLimiter)

r.With(apiRateLimiter).Post("/", api.aiTasksCreate)
r.Post("/{user}", api.tasksCreate)
})
r.Route("/mcp", func(r chi.Router) {
r.Use(
Expand Down
Loading