From 45ab265df20de51edbe96d2d83e916f7b36551eb Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Tue, 24 Jun 2025 08:45:41 -0500 Subject: [PATCH 01/23] chore: add permissions to autobuilder & prebuilder to run wsbuild (#18527) Read organization member and read files is now required for dynamic param building. --- coderd/database/dbauthz/dbauthz.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/coderd/database/dbauthz/dbauthz.go b/coderd/database/dbauthz/dbauthz.go index 50f175a69499d..4ac2a14516b0b 100644 --- a/coderd/database/dbauthz/dbauthz.go +++ b/coderd/database/dbauthz/dbauthz.go @@ -228,6 +228,8 @@ var ( Identifier: rbac.RoleIdentifier{Name: "autostart"}, DisplayName: "Autostart Daemon", Site: rbac.Permissions(map[string][]policy.Action{ + rbac.ResourceOrganizationMember.Type: {policy.ActionRead}, + rbac.ResourceFile.Type: {policy.ActionRead}, // Required to read terraform files rbac.ResourceNotificationMessage.Type: {policy.ActionCreate, policy.ActionRead}, rbac.ResourceSystem.Type: {policy.WildcardSymbol}, rbac.ResourceTemplate.Type: {policy.ActionRead, policy.ActionUpdate}, @@ -443,6 +445,7 @@ var ( }, // Should be able to add the prebuilds system user as a member to any organization that needs prebuilds. rbac.ResourceOrganizationMember.Type: { + policy.ActionRead, policy.ActionCreate, }, // Needs to be able to assign roles to the system user in order to make it a member of an organization. @@ -456,6 +459,10 @@ var ( rbac.ResourceOrganization.Type: { policy.ActionRead, }, + // Required to read the terraform files of a template + rbac.ResourceFile.Type: { + policy.ActionRead, + }, }), }, }), From 4ff2254e5f1b1165814551799e66b6fe489df080 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Tue, 24 Jun 2025 16:24:01 +0200 Subject: [PATCH 02/23] chore: remove ai tasks from experiment (#18511) Closes https://github.com/coder/internal/issues/661 --- coderd/apidoc/docs.go | 7 ++----- coderd/apidoc/swagger.json | 7 ++----- coderd/coderd.go | 1 - coderd/httpmw/csp.go | 7 ++----- coderd/httpmw/csp_test.go | 5 +---- codersdk/deployment.go | 1 - docs/reference/api/schemas.md | 1 - site/src/api/typesGenerated.ts | 1 - site/src/modules/dashboard/Navbar/NavbarView.tsx | 5 +---- 9 files changed, 8 insertions(+), 27 deletions(-) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 9e20f3e268f90..647a49e646a88 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -12742,11 +12742,9 @@ const docTemplate = `{ "workspace-usage", "web-push", "workspace-prebuilds", - "agentic-chat", - "ai-tasks" + "agentic-chat" ], "x-enum-comments": { - "ExperimentAITasks": "Enables the new AI tasks feature.", "ExperimentAgenticChat": "Enables the new agentic AI chat feature.", "ExperimentAutoFillParameters": "This should not be taken out of experiments until we have redesigned the feature.", "ExperimentExample": "This isn't used for anything.", @@ -12762,8 +12760,7 @@ const docTemplate = `{ "ExperimentWorkspaceUsage", "ExperimentWebPush", "ExperimentWorkspacePrebuilds", - "ExperimentAgenticChat", - "ExperimentAITasks" + "ExperimentAgenticChat" ] }, "codersdk.ExternalAuth": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index ddf5fb0d40156..a80d07a165b01 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -11435,11 +11435,9 @@ "workspace-usage", "web-push", "workspace-prebuilds", - "agentic-chat", - "ai-tasks" + "agentic-chat" ], "x-enum-comments": { - "ExperimentAITasks": "Enables the new AI tasks feature.", "ExperimentAgenticChat": "Enables the new agentic AI chat feature.", "ExperimentAutoFillParameters": "This should not be taken out of experiments until we have redesigned the feature.", "ExperimentExample": "This isn't used for anything.", @@ -11455,8 +11453,7 @@ "ExperimentWorkspaceUsage", "ExperimentWebPush", "ExperimentWorkspacePrebuilds", - "ExperimentAgenticChat", - "ExperimentAITasks" + "ExperimentAgenticChat" ] }, "codersdk.ExternalAuth": { diff --git a/coderd/coderd.go b/coderd/coderd.go index bf10573b2888d..97e38047a3d50 100644 --- a/coderd/coderd.go +++ b/coderd/coderd.go @@ -1544,7 +1544,6 @@ func New(options *Options) *API { // Add CSP headers to all static assets and pages. CSP headers only affect // browsers, so these don't make sense on api routes. cspMW := httpmw.CSPHeaders( - api.Experiments, options.Telemetry.Enabled(), func() []*proxyhealth.ProxyHost { if api.DeploymentValues.Dangerous.AllowAllCors { // In this mode, allow all external requests. diff --git a/coderd/httpmw/csp.go b/coderd/httpmw/csp.go index 06897a45afd01..f39781ad51b03 100644 --- a/coderd/httpmw/csp.go +++ b/coderd/httpmw/csp.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/coder/coder/v2/coderd/proxyhealth" - "github.com/coder/coder/v2/codersdk" ) // cspDirectives is a map of all csp fetch directives to their values. @@ -59,7 +58,7 @@ const ( // Example: https://github.com/coder/coder/issues/15118 // //nolint:revive -func CSPHeaders(experiments codersdk.Experiments, telemetry bool, proxyHosts func() []*proxyhealth.ProxyHost, staticAdditions map[CSPFetchDirective][]string) func(next http.Handler) http.Handler { +func CSPHeaders(telemetry bool, proxyHosts func() []*proxyhealth.ProxyHost, staticAdditions map[CSPFetchDirective][]string) func(next http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Content-Security-Policy disables loading certain content types and can prevent XSS injections. @@ -124,9 +123,7 @@ func CSPHeaders(experiments codersdk.Experiments, telemetry bool, proxyHosts fun if len(extraConnect) > 0 { for _, extraHost := range extraConnect { // Allow embedding the app host. - if experiments.Enabled(codersdk.ExperimentAITasks) { - cspSrcs.Append(CSPDirectiveFrameSrc, extraHost.AppHost) - } + cspSrcs.Append(CSPDirectiveFrameSrc, extraHost.AppHost) if extraHost.Host == "*" { // '*' means all cspSrcs.Append(CSPDirectiveConnectSrc, "*") diff --git a/coderd/httpmw/csp_test.go b/coderd/httpmw/csp_test.go index 5fd4b5bbd38aa..7bf8b879ef26f 100644 --- a/coderd/httpmw/csp_test.go +++ b/coderd/httpmw/csp_test.go @@ -10,7 +10,6 @@ import ( "github.com/coder/coder/v2/coderd/httpmw" "github.com/coder/coder/v2/coderd/proxyhealth" - "github.com/coder/coder/v2/codersdk" ) func TestCSP(t *testing.T) { @@ -50,9 +49,7 @@ func TestCSP(t *testing.T) { r := httptest.NewRequest(http.MethodGet, "/", nil) rw := httptest.NewRecorder() - httpmw.CSPHeaders(codersdk.Experiments{ - codersdk.ExperimentAITasks, - }, false, func() []*proxyhealth.ProxyHost { + httpmw.CSPHeaders(false, func() []*proxyhealth.ProxyHost { return proxyHosts }, map[httpmw.CSPFetchDirective][]string{ httpmw.CSPDirectiveMediaSrc: expectedMedia, diff --git a/codersdk/deployment.go b/codersdk/deployment.go index ce15ee407a8f3..8cb5760749233 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -3369,7 +3369,6 @@ const ( ExperimentWebPush Experiment = "web-push" // Enables web push notifications through the browser. ExperimentWorkspacePrebuilds Experiment = "workspace-prebuilds" // Enables the new workspace prebuilds feature. ExperimentAgenticChat Experiment = "agentic-chat" // Enables the new agentic AI chat feature. - ExperimentAITasks Experiment = "ai-tasks" // Enables the new AI tasks feature. ) // ExperimentsKnown should include all experiments defined above. diff --git a/docs/reference/api/schemas.md b/docs/reference/api/schemas.md index c7ea766531e9e..04075bd574d1a 100644 --- a/docs/reference/api/schemas.md +++ b/docs/reference/api/schemas.md @@ -3513,7 +3513,6 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o | `web-push` | | `workspace-prebuilds` | | `agentic-chat` | -| `ai-tasks` | ## codersdk.ExternalAuth diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index b2c5c562a4dab..d88a229163936 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -834,7 +834,6 @@ export const EntitlementsWarningHeader = "X-Coder-Entitlements-Warning"; // From codersdk/deployment.go export type Experiment = - | "ai-tasks" | "agentic-chat" | "auto-fill-parameters" | "example" diff --git a/site/src/modules/dashboard/Navbar/NavbarView.tsx b/site/src/modules/dashboard/Navbar/NavbarView.tsx index 7e56c9643c066..3e70d56e4aabb 100644 --- a/site/src/modules/dashboard/Navbar/NavbarView.tsx +++ b/site/src/modules/dashboard/Navbar/NavbarView.tsx @@ -1,5 +1,4 @@ import { API } from "api/api"; -import { experiments } from "api/queries/experiments"; import type * as TypesGen from "api/typesGenerated"; import { Button } from "components/Button/Button"; import { ExternalImage } from "components/ExternalImage/ExternalImage"; @@ -10,7 +9,6 @@ import { useWebpushNotifications } from "contexts/useWebpushNotifications"; import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata"; import { NotificationsInbox } from "modules/notifications/NotificationsInbox/NotificationsInbox"; import type { FC } from "react"; -import { useQuery } from "react-query"; import { NavLink, useLocation } from "react-router-dom"; import { cn } from "utils/cn"; import { DeploymentDropdown } from "./DeploymentDropdown"; @@ -145,7 +143,6 @@ const NavItems: FC = ({ className }) => { const location = useLocation(); const agenticChat = useAgenticChat(); const { metadata } = useEmbeddedMetadata(); - const experimentsQuery = useQuery(experiments(metadata.experiments)); return (