Skip to content

Commit 8f6a5af

Browse files
authored
feat: add backend logic for determining tasks tab visibility (#18401)
This PR implements the backend logic for determining if the Tasks tab should be visible in the web UI as described in [the RFC](https://www.notion.so/coderhq/Coder-Tasks-207d579be5928053ab68c8d9a4b59eaa?source=copy_link#210d579be5928013ab5acbe69a2f548b). The frontend component will be added in a follow-up PR once the entire Tasks backend is implemented so as not to break the dogfood environment until then.
1 parent 591f5db commit 8f6a5af

File tree

24 files changed

+145
-0
lines changed

24 files changed

+145
-0
lines changed

cli/testdata/coder_server_--help.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ Clients include the Coder CLI, Coder Desktop, IDE extensions, and the web UI.
8585
is detected. By default it instructs users to update using 'curl -L
8686
https://coder.com/install.sh | sh'.
8787

88+
--hide-ai-tasks bool, $CODER_HIDE_AI_TASKS (default: false)
89+
Hide AI tasks from the dashboard.
90+
8891
--ssh-config-options string-array, $CODER_SSH_CONFIG_OPTIONS
8992
These SSH config options will override the default SSH config options.
9093
Provide options in "key=value" or "key value" format separated by

cli/testdata/server-config.yaml.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ client:
520520
# 'webgl', or 'dom'.
521521
# (default: canvas, type: string)
522522
webTerminalRenderer: canvas
523+
# Hide AI tasks from the dashboard.
524+
# (default: false, type: bool)
525+
hideAITasks: false
523526
# Support links to display in the top right drop down menu.
524527
# (default: <unset>, type: struct[[]codersdk.LinkConfig])
525528
supportLinks: []

coderd/apidoc/docs.go

Lines changed: 3 additions & 0 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: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ func New(options *Options) *API {
628628
Entitlements: options.Entitlements,
629629
Telemetry: options.Telemetry,
630630
Logger: options.Logger.Named("site"),
631+
HideAITasks: options.DeploymentValues.HideAITasks.Value(),
631632
})
632633
api.SiteHandler.Experiments.Store(&experiments)
633634

coderd/database/dbauthz/dbauthz.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3451,6 +3451,11 @@ func (q *querier) GetWorkspacesEligibleForTransition(ctx context.Context, now ti
34513451
return q.db.GetWorkspacesEligibleForTransition(ctx, now)
34523452
}
34533453

3454+
func (q *querier) HasTemplateVersionsWithAITask(ctx context.Context) (bool, error) {
3455+
// Anyone can call HasTemplateVersionsWithAITask.
3456+
return q.db.HasTemplateVersionsWithAITask(ctx)
3457+
}
3458+
34543459
func (q *querier) InsertAPIKey(ctx context.Context, arg database.InsertAPIKeyParams) (database.APIKey, error) {
34553460
return insert(q.log, q.auth,
34563461
rbac.ResourceApiKey.WithOwner(arg.UserID.String()),

coderd/database/dbauthz/dbauthz_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4566,6 +4566,9 @@ func (s *MethodTestSuite) TestSystemFunctions() {
45664566
s.Run("GetProvisionerJobByIDForUpdate", s.Subtest(func(db database.Store, check *expects) {
45674567
check.Args(uuid.New()).Asserts(rbac.ResourceProvisionerJobs, policy.ActionRead).Errors(sql.ErrNoRows)
45684568
}))
4569+
s.Run("HasTemplateVersionsWithAITask", s.Subtest(func(db database.Store, check *expects) {
4570+
check.Args().Asserts()
4571+
}))
45694572
}
45704573

45714574
func (s *MethodTestSuite) TestNotifications() {

coderd/database/dbmem/dbmem.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8495,6 +8495,19 @@ func (q *FakeQuerier) GetWorkspacesEligibleForTransition(ctx context.Context, no
84958495
return workspaces, nil
84968496
}
84978497

8498+
func (q *FakeQuerier) HasTemplateVersionsWithAITask(_ context.Context) (bool, error) {
8499+
q.mutex.RLock()
8500+
defer q.mutex.RUnlock()
8501+
8502+
for _, templateVersion := range q.templateVersions {
8503+
if templateVersion.HasAITask {
8504+
return true, nil
8505+
}
8506+
}
8507+
8508+
return false, nil
8509+
}
8510+
84988511
func (q *FakeQuerier) InsertAPIKey(_ context.Context, arg database.InsertAPIKeyParams) (database.APIKey, error) {
84998512
if err := validateDatabaseType(arg); err != nil {
85008513
return database.APIKey{}, err

coderd/database/dbmetrics/querymetrics.go

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

coderd/database/dbmock/dbmock.go

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy