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

Skip to content

feat: persist AI task state in template imports & workspace builds #18449

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 22 commits into from
Jun 24, 2025

Conversation

dannykopping
Copy link
Contributor

@dannykopping dannykopping commented Jun 19, 2025

Closes #18453

@dannykopping dannykopping force-pushed the dk/coder-ai-task-res branch from d240c0e to 0b2b732 Compare June 23, 2025 09:05
@@ -584,8 +584,6 @@ func (r *Runner) runTemplateImport(ctx context.Context) (*proto.CompletedJob, *p
externalAuthProviderNames = append(externalAuthProviderNames, it.Id)
}

// fmt.Println("completed job: template import: graph:", startProvision.Graph)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drive-by.

@dannykopping dannykopping marked this pull request as ready for review June 23, 2025 19:19
Signed-off-by: Danny Kopping <[email protected]>
Comment on lines 8 to 23
-- if has_ai_task is true, ai_task_sidebar_app_id MUST be set
-- ai_task_sidebar_app_id can ONLY be set if has_ai_task is true
--
-- has_ai_task | ai_task_sidebar_app_id | Result
-- ------------|------------------------|---------------
-- NULL | NULL | TRUE (passes)
-- NULL | NOT NULL | FALSE (fails)
-- FALSE | NULL | TRUE (passes)
-- FALSE | NOT NULL | FALSE (fails)
-- TRUE | NULL | FALSE (fails)
-- TRUE | NOT NULL | TRUE (passes)
ALTER TABLE workspace_builds
ADD CONSTRAINT workspace_builds_ai_task_sidebar_app_id_required CHECK (
((has_ai_task IS NULL OR has_ai_task = false) AND ai_task_sidebar_app_id IS NULL)
OR (has_ai_task = true AND ai_task_sidebar_app_id IS NOT NULL)
);
Copy link
Member

Choose a reason for hiding this comment

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

I originally wondered why has_ai_task was nullable by default, but the provisionerdserver changes below explain why:

  • New build: has_ai_task = null (unknown yet)
  • After build completes: provisionerdserver sets has_ai_task to (true|false).

My next question would be: in which case do we need to know the difference between has_ai_task = null and has_ai_task = false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My next question would be: in which case do we need to know the difference between has_ai_task = null and has_ai_task = false?

While has_ai_task is null (AND a build's provisioner job is in progress) we use other data (build params + template version has_ai_task) to determine if the build might be an AI task, but if it's false then we know for certain it is not. For builds at rest (i.e. no provisioner job in progress) they're functionally the same.

Signed-off-by: Danny Kopping <[email protected]>
@dannykopping dannykopping enabled auto-merge (squash) June 24, 2025 10:25
@dannykopping dannykopping merged commit 0238f29 into main Jun 24, 2025
38 of 39 checks passed
@dannykopping dannykopping deleted the dk/coder-ai-task-res branch June 24, 2025 10:36
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tasks: coder_ai_task resource support in coderd
2 participants