Skip to content

Commit 05bb0c7

Browse files
refactor: remove SOURCEBOT_TENANCY_MODE and multi-tenancy code paths (#1075)
* refactor: remove SOURCEBOT_TENANCY_MODE and multi-tenancy code paths Single tenancy is now the only mode. Removes the tenancy mode env var, schema, multi-tenancy init logic, org selector UI, and tenancy docs page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * remove org selector --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 81419b2 commit 05bb0c7

File tree

11 files changed

+3
-267
lines changed

11 files changed

+3
-267
lines changed

.env.development

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,5 @@ SOURCEBOT_TELEMETRY_DISABLED=true # Disables telemetry collection
6969

7070
# CONFIG_MAX_REPOS_NO_TOKEN=
7171
NODE_ENV=development
72-
# SOURCEBOT_TENANCY_MODE=single
7372

7473
DEBUG_WRITE_CHAT_MESSAGES_TO_FILE=true

docs/docs/configuration/tenancy.mdx

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/shared/src/env.server.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { readFile } from 'fs/promises';
66
import stripJsonComments from "strip-json-comments";
77
import { z } from "zod";
88
import { getTokenFromConfig } from "./crypto.js";
9-
import { tenancyModeSchema } from "./types.js";
109

1110
// Booleans are specified as 'true' or 'false' strings.
1211
const booleanSchema = z.enum(["true", "false"]);
@@ -182,7 +181,6 @@ const options = {
182181
DATABASE_NAME: z.string().optional(),
183182
DATABASE_ARGS: z.string().optional(),
184183

185-
SOURCEBOT_TENANCY_MODE: tenancyModeSchema.default("single"),
186184
CONFIG_PATH: z.string(),
187185

188186
// Misc UI flags

packages/shared/src/index.server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export type {
1717
export {
1818
repoMetadataSchema,
1919
repoIndexingJobMetadataSchema,
20-
tenancyModeSchema,
2120
} from "./types.js";
2221
export {
2322
base64Decode,

packages/shared/src/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,4 @@ export const repoIndexingJobMetadataSchema = z.object({
6464

6565
export type RepoIndexingJobMetadata = z.infer<typeof repoIndexingJobMetadataSchema>;
6666

67-
export const tenancyModeSchema = z.enum(["multi", "single"]);
68-
6967
export type IdentityProviderType = IdentityProviderConfig['provider'];

packages/web/src/app/[domain]/components/navigationMenu/index.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import { auth } from "@/auth";
44
import { Button } from "@/components/ui/button";
55
import { NavigationMenu as NavigationMenuBase } from "@/components/ui/navigation-menu";
66
import { Separator } from "@/components/ui/separator";
7-
import { env } from "@sourcebot/shared";
87
import { ServiceErrorException } from "@/lib/serviceError";
98
import { isServiceError } from "@/lib/utils";
109
import { OrgRole, RepoIndexingJobStatus, RepoIndexingJobType } from "@sourcebot/db";
1110
import Link from "next/link";
12-
import { OrgSelector } from "../orgSelector";
1311
import { MeControlDropdownMenu } from "../meControlDropdownMenu";
1412
import WhatsNewIndicator from "../whatsNewIndicator";
1513
import { NavigationItems } from "./navigationItems";
@@ -100,15 +98,6 @@ export const NavigationMenu = async ({
10098
/>
10199
</Link>
102100

103-
{env.SOURCEBOT_TENANCY_MODE === 'multi' && (
104-
<>
105-
<OrgSelector
106-
domain={domain}
107-
/>
108-
<Separator orientation="vertical" className="h-6 mx-2" />
109-
</>
110-
)}
111-
112101
<NavigationMenuBase>
113102
<NavigationItems
114103
domain={domain}

packages/web/src/app/[domain]/components/orgSelector/index.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/web/src/app/[domain]/components/orgSelector/orgIcon.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/web/src/app/[domain]/components/orgSelector/orgSelectorDropdown.tsx

Lines changed: 0 additions & 129 deletions
This file was deleted.

packages/web/src/initialize.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createGuestUser } from '@/lib/authUtils';
2-
import { SOURCEBOT_SUPPORT_EMAIL } from "@/lib/constants";
32
import { prisma } from "@/prisma";
43
import { OrgRole } from '@sourcebot/db';
54
import { createLogger, env, hasEntitlement, loadConfig } from "@sourcebot/shared";
@@ -35,7 +34,7 @@ const pruneOldGuestUser = async () => {
3534
}
3635
}
3736

38-
const initSingleTenancy = async () => {
37+
const init = async () => {
3938
// This is needed because v4 introduces the GUEST org role as well as making authentication required.
4039
// To keep things simple, we'll just delete the old guest user if it exists in the DB
4140
await pruneOldGuestUser();
@@ -66,7 +65,7 @@ const initSingleTenancy = async () => {
6665
// search contexts that may be present in the DB. This could happen if a deployment had
6766
// the entitlement, synced search contexts, and then no longer had the entitlement
6867
const hasSearchContextEntitlement = hasEntitlement("search-contexts")
69-
if(!hasSearchContextEntitlement) {
68+
if (!hasSearchContextEntitlement) {
7069
await prisma.searchContext.deleteMany({
7170
where: {
7271
orgId: SINGLE_TENANT_ORG_ID,
@@ -115,20 +114,6 @@ const initSingleTenancy = async () => {
115114
}
116115
}
117116

118-
const initMultiTenancy = async () => {
119-
const hasMultiTenancyEntitlement = hasEntitlement("multi-tenancy");
120-
if (!hasMultiTenancyEntitlement) {
121-
logger.error(`SOURCEBOT_TENANCY_MODE is set to ${env.SOURCEBOT_TENANCY_MODE} but your license doesn't have multi-tenancy entitlement. Please contact ${SOURCEBOT_SUPPORT_EMAIL} to request a license upgrade.`);
122-
process.exit(1);
123-
}
124-
}
125-
126117
(async () => {
127-
if (env.SOURCEBOT_TENANCY_MODE === 'single') {
128-
await initSingleTenancy();
129-
} else if (env.SOURCEBOT_TENANCY_MODE === 'multi') {
130-
await initMultiTenancy();
131-
} else {
132-
throw new Error(`Invalid SOURCEBOT_TENANCY_MODE: ${env.SOURCEBOT_TENANCY_MODE}`);
133-
}
118+
await init();
134119
})();

0 commit comments

Comments
 (0)