Skip to content

Commit a24308e

Browse files
msukkariclaude
andcommitted
refactor(web): Rename sourceOverride param to source
The "override" suffix is redundant — callers are simply providing the source value. Renamed across all 9 files (function signatures, types, and call sites). No behavioral changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 32601a5 commit a24308e

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

packages/web/src/app/[domain]/browse/[...path]/components/codePreviewPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
1818
path,
1919
repo: repoName,
2020
ref: revisionName,
21-
}, { sourceOverride: 'sourcebot-web-client' }),
21+
}, { source: 'sourcebot-web-client' }),
2222
getRepoInfoByName(repoName),
2323
]);
2424

packages/web/src/app/api/(server)/repos/listReposApi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import { getBrowsePath } from "@/app/[domain]/browse/hooks/utils";
66
import { env } from "@sourcebot/shared";
77
import { headers } from "next/headers";
88

9-
export const listRepos = async ({ query, page, perPage, sort, direction, sourceOverride }: ListReposQueryParams & { sourceOverride?: string }) => sew(() =>
9+
export const listRepos = async ({ query, page, perPage, sort, direction, source }: ListReposQueryParams & { source?: string }) => sew(() =>
1010
withOptionalAuthV2(async ({ org, prisma, user }) => {
1111
if (user) {
12-
const source = sourceOverride ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
12+
const resolvedSource = source ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
1313
getAuditService().createAudit({
1414
action: 'user.listed_repos',
1515
actor: { id: user.id, type: 'user' },
1616
target: { id: org.id.toString(), type: 'org' },
1717
orgId: org.id,
18-
metadata: { source },
18+
metadata: { source: resolvedSource },
1919
});
2020
}
2121

packages/web/src/features/chat/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const createAgentStream = async ({
171171
path: source.path,
172172
repo: source.repo,
173173
ref: source.revision,
174-
}, { sourceOverride: 'sourcebot-ask-agent' });
174+
}, { source: 'sourcebot-ask-agent' });
175175

176176
if (isServiceError(fileSource)) {
177177
logger.error("Error fetching file source:", fileSource);

packages/web/src/features/chat/tools.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const readFilesTool = tool({
115115
path,
116116
repo: repository,
117117
ref: revision,
118-
}, { sourceOverride: 'sourcebot-ask-agent' });
118+
}, { source: 'sourcebot-ask-agent' });
119119
}));
120120

121121
if (responses.some(isServiceError)) {
@@ -222,7 +222,7 @@ export const createCodeSearchTool = (selectedRepos: string[]) => tool({
222222
isCaseSensitivityEnabled: caseSensitive,
223223
isRegexEnabled: useRegex,
224224
},
225-
sourceOverride: 'sourcebot-ask-agent',
225+
source: 'sourcebot-ask-agent',
226226
});
227227

228228
if (isServiceError(response)) {
@@ -254,7 +254,7 @@ export const listReposTool = tool({
254254
description: 'Lists repositories in the organization with optional filtering and pagination.',
255255
inputSchema: listReposQueryParamsSchema,
256256
execute: async (request: ListReposQueryParams) => {
257-
const reposResponse = await listRepos({ ...request, sourceOverride: 'sourcebot-ask-agent' });
257+
const reposResponse = await listRepos({ ...request, source: 'sourcebot-ask-agent' });
258258

259259
if (isServiceError(reposResponse)) {
260260
return reposResponse;

packages/web/src/features/codeNav/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const findSearchBasedSymbolReferences = async (props: FindRelatedSymbolsR
5858
matches: MAX_REFERENCE_COUNT,
5959
contextLines: 0,
6060
},
61-
sourceOverride: 'sourcebot-ui-codenav',
61+
source: 'sourcebot-ui-codenav',
6262
});
6363

6464
if (isServiceError(searchResult)) {
@@ -118,7 +118,7 @@ export const findSearchBasedSymbolDefinitions = async (props: FindRelatedSymbols
118118
matches: MAX_REFERENCE_COUNT,
119119
contextLines: 0,
120120
},
121-
sourceOverride: 'sourcebot-ui-codenav',
121+
source: 'sourcebot-ui-codenav',
122122
});
123123

124124
if (isServiceError(searchResult)) {

packages/web/src/features/git/getFileSourceApi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ export const fileSourceResponseSchema = z.object({
3333
});
3434
export type FileSourceResponse = z.infer<typeof fileSourceResponseSchema>;
3535

36-
export const getFileSource = async ({ path: filePath, repo: repoName, ref }: FileSourceRequest, { sourceOverride }: { sourceOverride?: string } = {}): Promise<FileSourceResponse | ServiceError> => sew(() => withOptionalAuthV2(async ({ org, prisma, user }) => {
36+
export const getFileSource = async ({ path: filePath, repo: repoName, ref }: FileSourceRequest, { source }: { source?: string } = {}): Promise<FileSourceResponse | ServiceError> => sew(() => withOptionalAuthV2(async ({ org, prisma, user }) => {
3737
if (user) {
38-
const source = sourceOverride ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
38+
const resolvedSource = source ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
3939
getAuditService().createAudit({
4040
action: 'user.fetched_file_source',
4141
actor: { id: user.id, type: 'user' },
4242
target: { id: org.id.toString(), type: 'org' },
4343
orgId: org.id,
44-
metadata: { source },
44+
metadata: { source: resolvedSource },
4545
});
4646
}
4747

packages/web/src/features/git/getTreeApi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ export type GetTreeResponse = z.infer<typeof getTreeResponseSchema>;
2626
* repo/revision, including intermediate directories needed to connect them
2727
* into a single tree.
2828
*/
29-
export const getTree = async ({ repoName, revisionName, paths }: GetTreeRequest, { sourceOverride }: { sourceOverride?: string } = {}): Promise<GetTreeResponse | ServiceError> => sew(() =>
29+
export const getTree = async ({ repoName, revisionName, paths }: GetTreeRequest, { source }: { source?: string } = {}): Promise<GetTreeResponse | ServiceError> => sew(() =>
3030
withOptionalAuthV2(async ({ org, prisma, user }) => {
3131
if (user) {
32-
const source = sourceOverride ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
32+
const resolvedSource = source ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
3333
getAuditService().createAudit({
3434
action: 'user.fetched_file_tree',
3535
actor: { id: user.id, type: 'user' },
3636
target: { id: org.id.toString(), type: 'org' },
3737
orgId: org.id,
38-
metadata: { source },
38+
metadata: { source: resolvedSource },
3939
});
4040
}
4141

packages/web/src/features/mcp/server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function createMcpServer(): McpServer {
127127
isRegexEnabled: useRegex,
128128
isCaseSensitivityEnabled: caseSensitive,
129129
},
130-
sourceOverride: 'mcp',
130+
source: 'mcp',
131131
});
132132

133133
if (isServiceError(response)) {
@@ -242,7 +242,7 @@ export function createMcpServer(): McpServer {
242242
})
243243
},
244244
async ({ query, page, perPage, sort, direction }) => {
245-
const result = await listRepos({ query, page, perPage, sort, direction, sourceOverride: 'mcp' });
245+
const result = await listRepos({ query, page, perPage, sort, direction, source: 'mcp' });
246246

247247
if (isServiceError(result)) {
248248
return {
@@ -280,7 +280,7 @@ export function createMcpServer(): McpServer {
280280
},
281281
},
282282
async ({ repo, path, ref }) => {
283-
const response = await getFileSource({ repo, path, ref }, { sourceOverride: 'mcp' });
283+
const response = await getFileSource({ repo, path, ref }, { source: 'mcp' });
284284

285285
if (isServiceError(response)) {
286286
return {
@@ -373,7 +373,7 @@ export function createMcpServer(): McpServer {
373373
repoName: repo,
374374
revisionName: ref,
375375
paths: currentLevelPaths.filter(Boolean),
376-
}, { sourceOverride: 'mcp' });
376+
}, { source: 'mcp' });
377377

378378
if (isServiceError(treeResult)) {
379379
treeError = treeResult.message;

packages/web/src/features/search/searchApi.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ type QueryStringSearchRequest = {
1515
queryType: 'string';
1616
query: string;
1717
options: SearchOptions;
18-
sourceOverride?: string;
18+
source?: string;
1919
}
2020

2121
type QueryIRSearchRequest = {
2222
queryType: 'ir';
2323
query: QueryIR;
2424
// Omit options that are specific to query syntax parsing.
2525
options: Omit<SearchOptions, 'isRegexEnabled' | 'isCaseSensitivityEnabled'>;
26-
sourceOverride?: string;
26+
source?: string;
2727
}
2828

2929
type SearchRequest = QueryStringSearchRequest | QueryIRSearchRequest;
3030

3131
export const search = (request: SearchRequest) => sew(() =>
3232
withOptionalAuthV2(async ({ prisma, user, org }) => {
3333
if (user) {
34-
const source = request.sourceOverride ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
34+
const source = request.source ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
3535
getAuditService().createAudit({
3636
action: 'user.performed_code_search',
3737
actor: { id: user.id, type: 'user' },
@@ -62,7 +62,7 @@ export const search = (request: SearchRequest) => sew(() =>
6262
export const streamSearch = (request: SearchRequest) => sew(() =>
6363
withOptionalAuthV2(async ({ prisma, user, org }) => {
6464
if (user) {
65-
const source = request.sourceOverride ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
65+
const source = request.source ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
6666
getAuditService().createAudit({
6767
action: 'user.performed_code_search',
6868
actor: { id: user.id, type: 'user' },

0 commit comments

Comments
 (0)