Skip to content

Commit d8335f8

Browse files
Merge branch 'main' into brendan/fix-bitbucket-repo-name-project-key-SOU-513
2 parents f747495 + 1d57be3 commit d8335f8

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111
- Fixed Bitbucket Server and Cloud repo identifiers to include the project key, preventing collisions across projects. [#904](https://github.com/sourcebot-dev/sourcebot/pull/904)
1212

13+
### Added
14+
- Added optional `visibility` parameter to `/api/chat/blocking` endpoint and MCP `ask_codebase` tool to allow controlling chat session visibility in shared environments. [#903](https://github.com/sourcebot-dev/sourcebot/pull/903)
15+
1316
## [4.11.1] - 2026-02-18
1417

1518
### Changed

packages/mcp/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- Added optional `visibility` parameter to `ask_codebase` tool to allow controlling chat session visibility in shared environments. [#903](https://github.com/sourcebot-dev/sourcebot/pull/903)
12+
1013
## [1.0.16] - 2026-02-10
1114

1215
### Added

packages/mcp/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ server.tool(
416416
417417
Returns a detailed answer in markdown format with code references, plus a link to view the full research session (including all tool calls and reasoning) in the Sourcebot web UI.
418418
419+
When using this in shared environments (e.g., Slack), you can set the visibility parameter to 'PUBLIC' to ensure everyone can access the chat link.
420+
419421
This is a blocking operation that may take 30-60+ seconds for complex questions as the agent researches the codebase.
420422
`,
421423
askCodebaseRequestSchema.shape,

packages/mcp/src/schemas.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ export const askCodebaseRequestSchema = z.object({
381381
.omit({ displayName: true })
382382
.optional()
383383
.describe("The language model to use for answering the question. If not provided, defaults to the first model in the config. Use list_language_models to see available options."),
384+
visibility: z
385+
.enum(['PRIVATE', 'PUBLIC'])
386+
.optional()
387+
.describe("The visibility of the chat session. If not provided, defaults to PRIVATE for authenticated users and PUBLIC for anonymous users. Set to PUBLIC to make the chat viewable by anyone with the link."),
384388
});
385389

386390
export const sourceSchema = z.object({

packages/web/src/app/api/(server)/chat/blocking/route.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const blockingChatRequestSchema = z.object({
3333
languageModel: languageModelInfoSchema
3434
.optional()
3535
.describe("The language model to use for the chat. If not provided, the first configured model is used."),
36+
visibility: z
37+
.nativeEnum(ChatVisibility)
38+
.optional()
39+
.describe("The visibility of the chat session. If not provided, defaults to PRIVATE for authenticated users and PUBLIC for anonymous users. Set to PUBLIC to make the chat viewable by anyone with the link. Note: Anonymous users cannot create PRIVATE chats; any PRIVATE request from an unauthenticated user will be ignored and set to PUBLIC."),
3640
});
3741

3842
/**
@@ -62,7 +66,7 @@ export const POST = apiHandler(async (request: NextRequest) => {
6266
return serviceErrorResponse(requestBodySchemaValidationError(parsed.error));
6367
}
6468

65-
const { query, repos = [], languageModel: requestedLanguageModel } = parsed.data;
69+
const { query, repos = [], languageModel: requestedLanguageModel, visibility: requestedVisibility } = parsed.data;
6670

6771
const response: BlockingChatResponse | ServiceError = await sew(() =>
6872
withOptionalAuthV2(async ({ org, user, prisma }) => {
@@ -95,12 +99,18 @@ export const POST = apiHandler(async (request: NextRequest) => {
9599
const { model, providerOptions } = await _getAISDKLanguageModelAndOptions(languageModelConfig);
96100
const modelName = languageModelConfig.displayName ?? languageModelConfig.model;
97101

102+
// Determine visibility: anonymous users cannot create private chats (they would be inaccessible)
103+
// Only use requested visibility if user is authenticated, otherwise always use PUBLIC
104+
const chatVisibility = (requestedVisibility && user)
105+
? requestedVisibility
106+
: (user ? ChatVisibility.PRIVATE : ChatVisibility.PUBLIC);
107+
98108
// Create a new chat session
99109
const chat = await prisma.chat.create({
100110
data: {
101111
orgId: org.id,
102112
createdById: user?.id,
103-
visibility: user ? ChatVisibility.PRIVATE : ChatVisibility.PUBLIC,
113+
visibility: chatVisibility,
104114
messages: [] as unknown as Prisma.InputJsonValue,
105115
},
106116
});

0 commit comments

Comments
 (0)