Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions coderd/apidoc/docs.go

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

10 changes: 5 additions & 5 deletions coderd/apidoc/swagger.json

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

47 changes: 1 addition & 46 deletions coderd/chat_projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,25 +572,6 @@ WHERE datname = current_database()
}
})

t.Run("ExperimentDisabled", func(t *testing.T) {
t.Parallel()

ctx := testutil.Context(t, testutil.WaitLong)
client, api := newChatClientWithAPI(t, withChatWorkerDisabled)
firstUser := coderdtest.CreateFirstUser(t, client.Client)
_ = createChatModel(t, client)
project := dbgen.ChatProject(t, api.Database, database.ChatProject{
OrganizationID: firstUser.OrganizationID,
OwnerID: firstUser.UserID,
})
chat := createIdleChat(ctx, t, client, api, firstUser.OrganizationID)

err := client.UpdateChat(ctx, chat.ID, codersdk.UpdateChatRequest{ProjectID: &project.ID})
sdkErr := requireSDKError(t, err, http.StatusBadRequest)
require.Equal(t, "chat projects experiment is not enabled", sdkErr.Message)
requireChatProjectID(ctx, t, client, chat.ID, nil)
})

t.Run("PublishesProjectChange", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -711,32 +692,6 @@ func chatIDs(chats []codersdk.Chat) []uuid.UUID {
return ids
}

func TestChatProjectsExperimentDisabled(t *testing.T) {
t.Parallel()

ctx := testutil.Context(t, testutil.WaitLong)
client, db := newChatClientWithDatabase(t, withChatWorkerDisabled)
firstUser := coderdtest.CreateFirstUser(t, client.Client)
_ = createChatModel(t, client)
// The project routes bypass the experiment in development builds, so
// seed the row directly and exercise chat creation, which does not.
project := dbgen.ChatProject(t, db, database.ChatProject{
OrganizationID: firstUser.OrganizationID,
OwnerID: firstUser.UserID,
Name: "Off",
})

_, err := client.CreateChat(ctx, codersdk.CreateChatRequest{
OrganizationID: firstUser.OrganizationID,
ProjectID: &project.ID,
Content: []codersdk.ChatInputPart{{Type: codersdk.ChatInputPartTypeText, Text: "experiment off"}},
})
require.Equal(t, 400, coderdtest.SDKError(t, err).StatusCode())

_, err = client.ListChats(ctx, &codersdk.ListChatsOptions{ProjectID: &project.ID})
require.Equal(t, 400, coderdtest.SDKError(t, err).StatusCode())
}

func newChatProjectClient(t testing.TB, overrides ...func(*coderdtest.Options)) (*codersdk.ExperimentalClient, database.Store) {
t.Helper()
client, api := newChatProjectClientWithAPI(t, overrides...)
Expand All @@ -748,7 +703,7 @@ func newChatProjectClientWithAPI(t testing.TB, overrides ...func(*coderdtest.Opt
return newChatClientWithAPI(t, append([]func(*coderdtest.Options){
func(options *coderdtest.Options) {
options.DeploymentValues.Experiments = serpent.StringArray{
string(codersdk.ExperimentChatProjects),
string(codersdk.ExperimentChatProjectSharing),
}
},
withChatWorkerDisabled,
Expand Down
7 changes: 2 additions & 5 deletions coderd/chat_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ func (api *API) registerChatAPIRoutes(r chi.Router, apiKeyMiddleware func(http.H
func (api *API) registerExperimentalChatRoutes(r chi.Router, apiKeyMiddleware func(http.Handler) http.Handler) {
r.Route("/chats", func(r chi.Router) {
r.Use(apiKeyMiddleware)
r.Route("/projects", func(r chi.Router) {
r.Use(httpmw.RequireExperimentWithDevBypass(api.Experiments, codersdk.ExperimentChatProjects))
r.Get("/", api.listChatProjects)
})
r.Get("/projects", api.listChatProjects)
r.Route("/config", func(r chi.Router) {
r.Group(func(r chi.Router) {
r.Use(httpmw.RequireExperimentWithDevBypass(api.Experiments, codersdk.ExperimentChatVirtualDesktop))
Expand Down Expand Up @@ -144,14 +141,14 @@ func (api *API) registerExperimentalChatRoutes(r chi.Router, apiKeyMiddleware fu
// organization parameter.
func (api *API) registerExperimentalOrganizationChatRoutes(r chi.Router) {
r.Route("/chats/projects", func(r chi.Router) {
r.Use(httpmw.RequireExperimentWithDevBypass(api.Experiments, codersdk.ExperimentChatProjects))
r.Post("/", api.postChatProject)
r.Route("/{project}", func(r chi.Router) {
r.Use(httpmw.ExtractChatProjectParam(api.Database))
r.Get("/", api.getChatProject)
r.Patch("/", api.patchChatProject)
r.Delete("/", api.deleteChatProject)
r.Route("/acl", func(r chi.Router) {
r.Use(httpmw.RequireExperimentWithDevBypass(api.Experiments, codersdk.ExperimentChatProjectSharing))
r.Get("/", api.getChatProjectACL)
r.Patch("/", api.patchChatProjectACL)
})
Expand Down
13 changes: 1 addition & 12 deletions coderd/exp_chats.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func (api *API) chatsByWorkspace(rw http.ResponseWriter, r *http.Request) {
// @Param after_id query string false "After ID" format(uuid)
// @Param limit query int false "Page limit"
// @Param offset query int false "Page offset"
// @Param project_id query string false "Only chats in this project. Requires the chat-projects experiment." format(uuid)
// @Param project_id query string false "Only chats in this project." format(uuid)
// @Success 200 {array} codersdk.Chat
// @Router /api/v2/chats [get]
func (api *API) listChats(rw http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -528,12 +528,6 @@ func (api *API) listChats(rw http.ResponseWriter, r *http.Request) {

projectID := uuid.NullUUID{}
if rawProjectID := r.URL.Query().Get("project_id"); rawProjectID != "" {
// Ignoring the filter would return every chat as if it were the
// project's contents, so reject it like create and update do.
if !api.Experiments.Enabled(codersdk.ExperimentChatProjects) {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{Message: "chat projects experiment is not enabled"})
return
}
parsedProjectID, err := uuid.Parse(rawProjectID)
if err != nil || parsedProjectID == uuid.Nil {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{Message: "Invalid project_id query parameter."})
Expand Down Expand Up @@ -1410,9 +1404,6 @@ func (api *API) createChat(
}
}

if req.ProjectID != nil && !api.Experiments.Enabled(codersdk.ExperimentChatProjects) {
return database.Chat{}, codersdk.Chat{}, httperror.NewResponseError(http.StatusBadRequest, codersdk.Response{Message: "chat projects experiment is not enabled"})
}
projectID := uuid.NullUUID{}
if req.ProjectID != nil {
var status int
Expand Down Expand Up @@ -2855,8 +2846,6 @@ func (api *API) updateChat(
if req.ProjectID != nil {
var refusal string
switch {
case !api.Experiments.Enabled(codersdk.ExperimentChatProjects):
refusal = "chat projects experiment is not enabled"
case chat.ParentChatID.Valid:
refusal = "Cannot move a child chat."
case archived:
Expand Down
9 changes: 3 additions & 6 deletions coderd/x/chatd/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ import (

// resolveProjectMemory returns the durable-memory store and project name for
// a chat. Only root chats inside a project have memory; chats outside a
// project, subagents, chats whose owner cannot use the project, the disabled
// experiment, and transient lookup failures all report ok=false.
// project, subagents, chats whose owner cannot use the project, and transient
// lookup failures all report ok=false.
func (p *Server) resolveProjectMemory(ctx context.Context, chat database.Chat) (store chattool.MemoryStore, projectName string, ok bool) {
if !p.experiments.Enabled(codersdk.ExperimentChatProjects) {
return nil, "", false
}
if chat.ParentChatID.Valid || !chat.ProjectID.Valid {
return nil, "", false
}
Expand Down Expand Up @@ -88,7 +85,7 @@ func (p *Server) memoryAuditor(chat database.Chat) chattool.MemoryAuditFunc {
// so it reads the prompt only at a turn start, which history (the chat's
// user-visible messages) shows without a query.
func (p *Server) memoryIndexMessage(ctx context.Context, chat database.Chat, history []database.ChatMessage) (chatstate.Message, bool, error) {
if !p.experiments.Enabled(codersdk.ExperimentChatProjects) || chat.ParentChatID.Valid {
if chat.ParentChatID.Valid {
return chatstate.Message{}, false, nil
}
var store chattool.MemoryStore
Expand Down
8 changes: 0 additions & 8 deletions coderd/x/chatd/memory_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ func TestResolveProjectMemory(t *testing.T) {
require.False(t, ok)
})

t.Run("ExperimentDisabled", func(t *testing.T) {
t.Parallel()
db := dbmock.NewMockStore(gomock.NewController(t))
server := &Server{db: db, logger: slogtest.Make(t, nil)}
_, _, ok := server.resolveProjectMemory(t.Context(), database.Chat{ID: uuid.New(), ProjectID: uuid.NullUUID{UUID: uuid.New(), Valid: true}})
require.False(t, ok)
})

t.Run("ProjectLookupFailure", func(t *testing.T) {
t.Parallel()
db := dbmock.NewMockStore(gomock.NewController(t))
Expand Down
5 changes: 1 addition & 4 deletions coderd/x/chatd/project_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ import (
)

// resolveChatProjectID returns the project the chat belongs to, or an
// invalid ID when it has none or chat projects are disabled. Subagent chats
// invalid ID when it has none. Subagent chats
// do not carry a project, so they inherit the root chat's project at the cost
// of one extra lookup. A failed lookup is logged and treated as no project.
func (p *Server) resolveChatProjectID(ctx context.Context, logger slog.Logger, chat database.Chat) uuid.NullUUID {
if !p.experiments.Enabled(codersdk.ExperimentChatProjects) {
return uuid.NullUUID{}
}
if chat.ProjectID.Valid || !chat.RootChatID.Valid || chat.RootChatID.UUID == chat.ID {
return chat.ProjectID
}
Expand Down
10 changes: 0 additions & 10 deletions coderd/x/chatd/project_instructions_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,6 @@ func TestResolveUsableChatProjectID(t *testing.T) {
ProjectID: uuid.NullUUID{UUID: project.ID, Valid: true},
}).Valid)
})

t.Run("ExperimentDisabled", func(t *testing.T) {
t.Parallel()
server := newProjectTestServer(t, dbmock.NewMockStore(gomock.NewController(t)))
server.experiments = nil
require.False(t, server.resolveUsableChatProjectID(t.Context(), server.logger, database.Chat{
ID: uuid.New(),
ProjectID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
}).Valid)
})
}

func TestLoadProjectInstructions(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions coderd/x/chatd/skill_invocation_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ func TestResolveSkillInvocations(t *testing.T) {
db, _ := dbtestutil.NewDB(t)
authzDB := dbauthz.New(db, rbac.NewStrictCachingAuthorizer(prometheus.NewRegistry()), slogtest.Make(t, nil), nil)
server := &Server{
db: authzDB,
logger: slogtest.Make(t, nil),
experiments: codersdk.Experiments{codersdk.ExperimentChatProjects},
db: authzDB,
logger: slogtest.Make(t, nil),
modelConfigContext: func(ctx context.Context, ownerID uuid.UUID) (context.Context, error) {
return callerModelConfigContext(ctx, authzDB, ownerID)
},
Expand Down
23 changes: 9 additions & 14 deletions coderd/x/chatd/turn_environment_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,18 +483,16 @@ func TestBuildTurnEnvironmentMemory(t *testing.T) {
t.Parallel()

tests := []struct {
name string
project bool
subagent bool
experimentsEnabled bool
wantMemoryBlock bool
wantMemoryTools bool
intro string
name string
project bool
subagent bool
wantMemoryBlock bool
wantMemoryTools bool
intro string
}{
{name: "Project", project: true, experimentsEnabled: true, wantMemoryBlock: true, wantMemoryTools: true, intro: `project "platform"`},
{name: "NoProject", experimentsEnabled: true},
{name: "ExperimentDisabled"},
{name: "Subagent", experimentsEnabled: true, subagent: true},
{name: "Project", project: true, wantMemoryBlock: true, wantMemoryTools: true, intro: `project "platform"`},
{name: "NoProject"},
{name: "Subagent", subagent: true},
}

for _, tt := range tests {
Expand Down Expand Up @@ -532,9 +530,6 @@ func TestBuildTurnEnvironmentMemory(t *testing.T) {
require.NoError(t, err)

serverOpts := []internalTestServerOpt{withInternalTestServerTransportFactory(&aibridgeTestFactory{})}
if !tt.experimentsEnabled {
serverOpts = append(serverOpts, withInternalTestServerExperiments([]codersdk.Experiment{}))
}
server := newInternalTestServer(t, db, ps, chatprovider.ProviderAPIKeys{}, serverOpts...)
prepared, err := server.buildTurnEnvironment(ctx, generationPrepareInput{Chat: created.Chat, Messages: created.InitialMessages})
require.NoError(t, err)
Expand Down
10 changes: 5 additions & 5 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5508,7 +5508,7 @@ const (
ExperimentWorkspaceCapableLicensing Experiment = "workspace-capable-licensing" // Counts only users holding the workspace-create permission toward the license seat limit.
ExperimentAIGatewaySeatExclusion Experiment = "ai-gateway-seat-exclusion" // Excludes AI Gateway (AI Bridge) usage from AI Governance seat consumption.
ExperimentAIGatewayReverseProxy Experiment = "ai-gateway-reverse-proxy" // Uses stateless reverse proxy routing when MCP injection is not configured.
ExperimentChatProjects Experiment = "chat-projects" // Enables organization-scoped projects that group agent chats.
ExperimentChatProjectSharing Experiment = "chat-project-sharing" // Enables sharing agent chat projects with other users and groups.
ExperimentChatAdvisor Experiment = "chat-advisor" // Enables the advisor tool for root agent chats.
ExperimentChatVirtualDesktop Experiment = "chat-virtual-desktop" // Enables virtual desktop and computer use provider for agents.
ExperimentAgentLifecycleHooks Experiment = "agent-lifecycle-hooks" // Enables chat lifecycle hook webhooks for agent chats.
Expand Down Expand Up @@ -5540,8 +5540,8 @@ func (e Experiment) DisplayName() string {
return "AI Gateway Seat Exclusion"
case ExperimentAIGatewayReverseProxy:
return "AI Gateway Reverse Proxy"
case ExperimentChatProjects:
return "Chat Projects"
case ExperimentChatProjectSharing:
return "Chat Project Sharing"
case ExperimentChatAdvisor:
return "Chat Advisor"
case ExperimentChatVirtualDesktop:
Expand Down Expand Up @@ -5574,7 +5574,7 @@ var ExperimentsKnown = Experiments{
ExperimentWorkspaceCapableLicensing,
ExperimentAIGatewaySeatExclusion,
ExperimentAIGatewayReverseProxy,
ExperimentChatProjects,
ExperimentChatProjectSharing,
ExperimentChatAdvisor,
ExperimentChatVirtualDesktop,
ExperimentAgentLifecycleHooks,
Expand All @@ -5590,7 +5590,7 @@ var ExperimentsKnown = Experiments{
// not be included here and will be essentially hidden.
var ExperimentsSafe = Experiments{
ExperimentChatStageMetrics,
ExperimentChatProjects,
ExperimentChatProjectSharing,
}

// ExperimentsUserScoped lists the experiments that accept runtime rules
Expand Down
2 changes: 1 addition & 1 deletion codersdk/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestExperimentDisplayNames(t *testing.T) {
codersdk.ExperimentWorkspaceCapableLicensing: "Workspace-Capable Licensing",
codersdk.ExperimentAIGatewaySeatExclusion: "AI Gateway Seat Exclusion",
codersdk.ExperimentAIGatewayReverseProxy: "AI Gateway Reverse Proxy",
codersdk.ExperimentChatProjects: "Chat Projects",
codersdk.ExperimentChatProjectSharing: "Chat Project Sharing",
codersdk.ExperimentChatAdvisor: "Chat Advisor",
codersdk.ExperimentChatVirtualDesktop: "Chat Virtual Desktop",
codersdk.ExperimentAgentLifecycleHooks: "Agent Lifecycle Hooks",
Expand Down
Loading
Loading