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: add backend logic for determining tasks tab visibility#18401

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
hugodutka merged 5 commits intomainfromhugodutka/tasks-tab-visibility
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
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
3 changes: 3 additions & 0 deletionscli/testdata/coder_server_--help.golden
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ Clients include the Coder CLI, Coder Desktop, IDE extensions, and the web UI.
is detected. By default it instructs users to update using 'curl -L
https://coder.com/install.sh | sh'.

--hide-ai-tasks bool, $CODER_HIDE_AI_TASKS (default: false)
Hide AI tasks from the dashboard.

--ssh-config-options string-array, $CODER_SSH_CONFIG_OPTIONS
These SSH config options will override the default SSH config options.
Provide options in "key=value" or "key value" format separated by
Expand Down
3 changes: 3 additions & 0 deletionscli/testdata/server-config.yaml.golden
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -520,6 +520,9 @@ client:
# 'webgl', or 'dom'.
# (default: canvas, type: string)
webTerminalRenderer: canvas
# Hide AI tasks from the dashboard.
# (default: false, type: bool)
hideAITasks: false
# Support links to display in the top right drop down menu.
# (default: <unset>, type: struct[[]codersdk.LinkConfig])
supportLinks: []
Expand Down
3 changes: 3 additions & 0 deletionscoderd/apidoc/docs.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

3 changes: 3 additions & 0 deletionscoderd/apidoc/swagger.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

1 change: 1 addition & 0 deletionscoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -626,6 +626,7 @@ func New(options *Options) *API {
Entitlements: options.Entitlements,
Telemetry: options.Telemetry,
Logger: options.Logger.Named("site"),
HideAITasks: options.DeploymentValues.HideAITasks.Value(),
})
api.SiteHandler.Experiments.Store(&experiments)

Expand Down
5 changes: 5 additions & 0 deletionscoderd/database/dbauthz/dbauthz.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3451,6 +3451,11 @@ func (q *querier) GetWorkspacesEligibleForTransition(ctx context.Context, now ti
return q.db.GetWorkspacesEligibleForTransition(ctx, now)
}

func (q *querier) HasTemplateVersionsWithAITask(ctx context.Context) (bool, error) {
// Anyone can call HasTemplateVersionsWithAITask.
return q.db.HasTemplateVersionsWithAITask(ctx)
}

func (q *querier) InsertAPIKey(ctx context.Context, arg database.InsertAPIKeyParams) (database.APIKey, error) {
return insert(q.log, q.auth,
rbac.ResourceApiKey.WithOwner(arg.UserID.String()),
Expand Down
3 changes: 3 additions & 0 deletionscoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4566,6 +4566,9 @@ func (s *MethodTestSuite) TestSystemFunctions() {
s.Run("GetProvisionerJobByIDForUpdate", s.Subtest(func(db database.Store, check *expects) {
check.Args(uuid.New()).Asserts(rbac.ResourceProvisionerJobs, policy.ActionRead).Errors(sql.ErrNoRows)
}))
s.Run("HasTemplateVersionsWithAITask", s.Subtest(func(db database.Store, check *expects) {
check.Args().Asserts()
}))
}

func (s *MethodTestSuite) TestNotifications() {
Expand Down
13 changes: 13 additions & 0 deletionscoderd/database/dbmem/dbmem.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8491,6 +8491,19 @@ func (q *FakeQuerier) GetWorkspacesEligibleForTransition(ctx context.Context, no
return workspaces, nil
}

func (q *FakeQuerier) HasTemplateVersionsWithAITask(_ context.Context) (bool, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()

for _, templateVersion := range q.templateVersions {
if templateVersion.HasAITask {
return true, nil
}
}

return false, nil
}

func (q *FakeQuerier) InsertAPIKey(_ context.Context, arg database.InsertAPIKeyParams) (database.APIKey, error) {
if err := validateDatabaseType(arg); err != nil {
return database.APIKey{}, err
Expand Down
7 changes: 7 additions & 0 deletionscoderd/database/dbmetrics/querymetrics.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

15 changes: 15 additions & 0 deletionscoderd/database/dbmock/dbmock.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 2 additions & 0 deletionscoderd/database/querier.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

12 changes: 12 additions & 0 deletionscoderd/database/queries.sql.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

4 changes: 4 additions & 0 deletionscoderd/database/queries/templateversions.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,3 +225,7 @@ FROM
WHERE
template_versions.id IN (archived_versions.id)
RETURNING template_versions.id;

-- name: HasTemplateVersionsWithAITask :one
-- Determines if the template versions table has any rows with has_ai_task = TRUE.
SELECT EXISTS (SELECT 1 FROM template_versions WHERE has_ai_task = TRUE);
11 changes: 11 additions & 0 deletionscodersdk/deployment.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -399,6 +399,7 @@ type DeploymentValues struct {
AdditionalCSPPolicy serpent.StringArray `json:"additional_csp_policy,omitempty" typescript:",notnull"`
WorkspaceHostnameSuffix serpent.String `json:"workspace_hostname_suffix,omitempty" typescript:",notnull"`
Prebuilds PrebuildsConfig `json:"workspace_prebuilds,omitempty" typescript:",notnull"`
HideAITasks serpent.Bool `json:"hide_ai_tasks,omitempty" typescript:",notnull"`

Config serpent.YAMLConfigPath `json:"config,omitempty" typescript:",notnull"`
WriteConfig serpent.Bool `json:"write_config,omitempty" typescript:",notnull"`
Expand DownExpand Up@@ -3116,6 +3117,16 @@ Write out the current server config as YAML to stdout.`,
YAML: "failure_hard_limit",
Hidden: true,
},
{
Name: "Hide AI Tasks",
Description: "Hide AI tasks from the dashboard.",
Flag: "hide-ai-tasks",
Env: "CODER_HIDE_AI_TASKS",
Default: "false",
Value: &c.HideAITasks,
Group: &deploymentGroupClient,
YAML: "hideAITasks",
},
}

return opts
Expand Down
1 change: 1 addition & 0 deletionsdocs/reference/api/general.md
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

3 changes: 3 additions & 0 deletionsdocs/reference/api/schemas.md
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

11 changes: 11 additions & 0 deletionsdocs/reference/cli/server.md
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

3 changes: 3 additions & 0 deletionsenterprise/cli/testdata/coder_server_--help.golden
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,9 @@ Clients include the Coder CLI, Coder Desktop, IDE extensions, and the web UI.
is detected. By default it instructs users to update using 'curl -L
https://coder.com/install.sh | sh'.

--hide-ai-tasks bool, $CODER_HIDE_AI_TASKS (default: false)
Hide AI tasks from the dashboard.

--ssh-config-options string-array, $CODER_SSH_CONFIG_OPTIONS
These SSH config options will override the default SSH config options.
Provide options in "key=value" or "key value" format separated by
Expand Down
1 change: 1 addition & 0 deletionssite/index.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@
<metaproperty="regions"content="{{ .Regions }}"/>
<metaproperty="docs-url"content="{{ .DocsURL }}"/>
<metaproperty="logo-url"content="{{ .LogoURL }}"/>
<metaproperty="tasks-tab-visible"content="{{ .TasksTabVisible }}"/>
<!-- We need to set data-react-helmet to be able to override it in the workspace page -->
<link
rel="alternate icon"
Expand Down
26 changes: 26 additions & 0 deletionssite/site.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ type Options struct {
Entitlements *entitlements.Set
Telemetry telemetry.Reporter
Logger slog.Logger
HideAITasks bool
}

func New(opts *Options) *Handler {
Expand DownExpand Up@@ -316,6 +317,8 @@ type htmlState struct {
Experiments string
Regions string
DocsURL string

TasksTabVisible string
}

type csrfState struct {
Expand DownExpand Up@@ -445,6 +448,7 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht
var user database.User
var themePreference string
var terminalFont string
var tasksTabVisible bool
orgIDs := []uuid.UUID{}
eg.Go(func() error {
var err error
Expand DownExpand Up@@ -480,6 +484,20 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht
orgIDs = memberIDs[0].OrganizationIDs
return err
})
eg.Go(func() error {
// If HideAITasks is true, force hide the tasks tab
if h.opts.HideAITasks {
tasksTabVisible = false
return nil
}

hasAITask, err := h.opts.Database.HasTemplateVersionsWithAITask(ctx)
if err != nil {
return err
}
tasksTabVisible = hasAITask
return nil
})
err := eg.Wait()
if err == nil {
var wg sync.WaitGroup
Expand DownExpand Up@@ -550,6 +568,14 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht
}
}()
}
wg.Add(1)
go func() {
defer wg.Done()
tasksTabVisible, err := json.Marshal(tasksTabVisible)
if err == nil {
state.TasksTabVisible = html.EscapeString(string(tasksTabVisible))
}
}()
wg.Wait()
}

Expand Down
1 change: 1 addition & 0 deletionssite/src/api/typesGenerated.ts
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

10 changes: 10 additions & 0 deletionssite/src/hooks/useEmbeddedMetadata.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import {
MockBuildInfo,
MockEntitlements,
MockExperiments,
MockTasksTabVisible,
MockUserAppearanceSettings,
MockUserOwner,
} from "testHelpers/entities";
Expand DownExpand Up@@ -41,6 +42,7 @@ const mockDataForTags = {
user: MockUserOwner,
userAppearance: MockUserAppearanceSettings,
regions: MockRegions,
tasksTabVisible: MockTasksTabVisible,
} as const satisfies Record<MetadataKey, MetadataValue>;

const emptyMetadata: RuntimeHtmlMetadata = {
Expand DownExpand Up@@ -72,6 +74,10 @@ const emptyMetadata: RuntimeHtmlMetadata = {
available: false,
value: undefined,
},
tasksTabVisible: {
available: false,
value: undefined,
},
};

const populatedMetadata: RuntimeHtmlMetadata = {
Expand DownExpand Up@@ -103,6 +109,10 @@ const populatedMetadata: RuntimeHtmlMetadata = {
available: true,
value: MockUserAppearanceSettings,
},
tasksTabVisible: {
available: true,
value: MockTasksTabVisible,
},
};

function seedInitialMetadata(metadataKey: string): () => void {
Expand Down
2 changes: 2 additions & 0 deletionssite/src/hooks/useEmbeddedMetadata.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@ type AvailableMetadata = Readonly<{
entitlements: Entitlements;
regions: readonly Region[];
"build-info": BuildInfoResponse;
tasksTabVisible: boolean;
}>;

export type MetadataKey = keyof AvailableMetadata;
Expand DownExpand Up@@ -91,6 +92,7 @@ export class MetadataManager implements MetadataManagerApi {
experiments: this.registerValue<Experiments>("experiments"),
"build-info": this.registerValue<BuildInfoResponse>("build-info"),
regions: this.registerRegionValue(),
tasksTabVisible: this.registerValue<boolean>("tasksTabVisible"),
};
}

Expand Down
2 changes: 2 additions & 0 deletionssite/src/testHelpers/entities.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -534,6 +534,8 @@ export const MockUserAppearanceSettings: TypesGen.UserAppearanceSettings = {
terminal_font: "",
};

export const MockTasksTabVisible: boolean = false;

export const MockOrganizationMember: TypesGen.OrganizationMemberWithUserData = {
organization_id: MockOrganization.id,
user_id: MockUserOwner.id,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp