Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7607138c5 |
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
readdirSync,
|
||||
rmSync,
|
||||
statSync,
|
||||
writeFileSync,
|
||||
@@ -19,7 +20,7 @@ import { fileURLToPath } from "node:url";
|
||||
const isDevelopment = Boolean(process.env.VITE_DEV_SERVER_URL);
|
||||
const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
|
||||
const APP_BUNDLE_ID = isDevelopment ? "com.t3tools.t3code.dev" : "com.t3tools.t3code";
|
||||
const LAUNCHER_VERSION = 2;
|
||||
const LAUNCHER_VERSION = 3;
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
export const desktopDir = resolve(__dirname, "..");
|
||||
@@ -120,6 +121,41 @@ function patchMainBundleInfoPlist(appBundlePath, iconPath) {
|
||||
copyFileSync(iconPath, join(resourcesDir, "electron.icns"));
|
||||
}
|
||||
|
||||
function patchHelperBundleInfoPlists(appBundlePath) {
|
||||
const frameworksDir = join(appBundlePath, "Contents", "Frameworks");
|
||||
if (!existsSync(frameworksDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const entry of readdirSync(frameworksDir, { withFileTypes: true })) {
|
||||
if (
|
||||
!entry.isDirectory() ||
|
||||
!entry.name.startsWith("Electron Helper") ||
|
||||
!entry.name.endsWith(".app")
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const helperPlistPath = join(frameworksDir, entry.name, "Contents", "Info.plist");
|
||||
if (!existsSync(helperPlistPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const suffix = entry.name.replace("Electron Helper", "").replace(".app", "").trim();
|
||||
const helperName = suffix
|
||||
? `${APP_DISPLAY_NAME} Helper ${suffix}`
|
||||
: `${APP_DISPLAY_NAME} Helper`;
|
||||
const helperIdSuffix = suffix.replace(/[()]/g, "").trim().toLowerCase().replace(/\s+/g, "-");
|
||||
const helperBundleId = helperIdSuffix
|
||||
? `${APP_BUNDLE_ID}.helper.${helperIdSuffix}`
|
||||
: `${APP_BUNDLE_ID}.helper`;
|
||||
|
||||
setPlistString(helperPlistPath, "CFBundleDisplayName", helperName);
|
||||
setPlistString(helperPlistPath, "CFBundleName", helperName);
|
||||
setPlistString(helperPlistPath, "CFBundleIdentifier", helperBundleId);
|
||||
}
|
||||
}
|
||||
|
||||
function readJson(path) {
|
||||
try {
|
||||
return JSON.parse(readFileSync(path, "utf8"));
|
||||
@@ -157,6 +193,7 @@ function buildMacLauncher(electronBinaryPath) {
|
||||
rmSync(targetAppBundlePath, { recursive: true, force: true });
|
||||
cpSync(sourceAppBundlePath, targetAppBundlePath, { recursive: true });
|
||||
patchMainBundleInfoPlist(targetAppBundlePath, iconPath);
|
||||
patchHelperBundleInfoPlists(targetAppBundlePath);
|
||||
writeFileSync(metadataPath, `${JSON.stringify(expectedMetadata, null, 2)}\n`);
|
||||
|
||||
return targetBinaryPath;
|
||||
|
||||
@@ -117,11 +117,7 @@ import { getProviderModelCapabilities, resolveSelectableProvider } from "../prov
|
||||
import { useSettings } from "../hooks/useSettings";
|
||||
import { resolveAppModelSelection } from "../modelSelection";
|
||||
import { isTerminalFocused } from "../lib/terminalFocus";
|
||||
import {
|
||||
buildLogicalProjectKeyMap,
|
||||
deriveLogicalProjectKeyFromSettings,
|
||||
derivePhysicalProjectKey,
|
||||
} from "../logicalProject";
|
||||
import { deriveLogicalProjectKeyFromSettings } from "../logicalProject";
|
||||
import {
|
||||
useSavedEnvironmentRegistryStore,
|
||||
useSavedEnvironmentRuntimeStore,
|
||||
@@ -860,19 +856,11 @@ export default function ChatView(props: ChatViewProps) {
|
||||
sidebarProjectGroupingMode: settings.sidebarProjectGroupingMode,
|
||||
sidebarProjectGroupingOverrides: settings.sidebarProjectGroupingOverrides,
|
||||
}));
|
||||
const logicalProjectKeyByPhysicalKey = useMemo(
|
||||
() => buildLogicalProjectKeyMap(allProjects, projectGroupingSettings),
|
||||
[allProjects, projectGroupingSettings],
|
||||
);
|
||||
const logicalProjectEnvironments = useMemo(() => {
|
||||
if (!activeProject) return [];
|
||||
const logicalKey =
|
||||
logicalProjectKeyByPhysicalKey.get(derivePhysicalProjectKey(activeProject)) ??
|
||||
deriveLogicalProjectKeyFromSettings(activeProject, projectGroupingSettings);
|
||||
const logicalKey = deriveLogicalProjectKeyFromSettings(activeProject, projectGroupingSettings);
|
||||
const memberProjects = allProjects.filter(
|
||||
(p) =>
|
||||
(logicalProjectKeyByPhysicalKey.get(derivePhysicalProjectKey(p)) ??
|
||||
deriveLogicalProjectKeyFromSettings(p, projectGroupingSettings)) === logicalKey,
|
||||
(p) => deriveLogicalProjectKeyFromSettings(p, projectGroupingSettings) === logicalKey,
|
||||
);
|
||||
const seen = new Set<string>();
|
||||
const envs: Array<{
|
||||
@@ -909,7 +897,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
}, [
|
||||
activeProject,
|
||||
allProjects,
|
||||
logicalProjectKeyByPhysicalKey,
|
||||
projectGroupingSettings,
|
||||
primaryEnvironmentId,
|
||||
savedEnvironmentRegistry,
|
||||
@@ -940,9 +927,10 @@ export default function ChatView(props: ChatViewProps) {
|
||||
throw new Error("No active project is available for this pull request.");
|
||||
}
|
||||
const activeProjectRef = scopeProjectRef(activeProject.environmentId, activeProject.id);
|
||||
const logicalProjectKey =
|
||||
logicalProjectKeyByPhysicalKey.get(derivePhysicalProjectKey(activeProject)) ??
|
||||
deriveLogicalProjectKeyFromSettings(activeProject, projectGroupingSettings);
|
||||
const logicalProjectKey = deriveLogicalProjectKeyFromSettings(
|
||||
activeProject,
|
||||
projectGroupingSettings,
|
||||
);
|
||||
const storedDraftSession = getDraftSessionByLogicalProjectKey(logicalProjectKey);
|
||||
if (storedDraftSession) {
|
||||
setDraftThreadContext(storedDraftSession.draftId, input);
|
||||
@@ -1003,7 +991,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
getDraftSessionByLogicalProjectKey,
|
||||
isServerThread,
|
||||
navigate,
|
||||
logicalProjectKeyByPhysicalKey,
|
||||
projectGroupingSettings,
|
||||
routeKind,
|
||||
setDraftThreadContext,
|
||||
|
||||
@@ -216,17 +216,6 @@ function formatProjectMemberActionLabel(
|
||||
return member.environmentLabel ? `${member.environmentLabel} — ${member.cwd}` : member.cwd;
|
||||
}
|
||||
|
||||
function hasDuplicateMemberEnvironment(members: readonly SidebarProjectGroupMember[]): boolean {
|
||||
const seen = new Set<string>();
|
||||
for (const member of members) {
|
||||
if (seen.has(member.environmentId)) {
|
||||
return true;
|
||||
}
|
||||
seen.add(member.environmentId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function projectGroupingModeDescription(mode: SidebarProjectGroupingMode): string {
|
||||
switch (mode) {
|
||||
case "repository":
|
||||
@@ -1685,15 +1674,8 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (
|
||||
project.memberProjects.length === 1 ||
|
||||
!hasDuplicateMemberEnvironment(project.memberProjects)
|
||||
) {
|
||||
const representative =
|
||||
project.memberProjects.find(
|
||||
(member) => member.environmentId === project.environmentId && member.id === project.id,
|
||||
) ?? project.memberProjects[0]!;
|
||||
createThreadForProjectMember(representative);
|
||||
if (project.memberProjects.length === 1) {
|
||||
createThreadForProjectMember(project.memberProjects[0]!);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1724,13 +1706,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
createThreadForProjectMember(targetMember);
|
||||
})();
|
||||
},
|
||||
[
|
||||
createThreadForProjectMember,
|
||||
project.environmentId,
|
||||
project.groupedProjectCount,
|
||||
project.id,
|
||||
project.memberProjects,
|
||||
],
|
||||
[createThreadForProjectMember, project.groupedProjectCount, project.memberProjects],
|
||||
);
|
||||
|
||||
const attemptArchiveThread = useCallback(
|
||||
@@ -2759,9 +2735,9 @@ export default function Sidebar() {
|
||||
});
|
||||
}, [projectOrder, projects]);
|
||||
|
||||
// Build a mapping from physical project key -> logical project key. Matching
|
||||
// projects can group across environments, but each rendered group keeps at
|
||||
// most one member per environment so thread creation remains unambiguous.
|
||||
// Build a mapping from physical project key → logical project key for
|
||||
// cross-environment grouping. Projects that share a repositoryIdentity
|
||||
// canonicalKey are treated as one logical project in the sidebar.
|
||||
const physicalToLogicalKey = useMemo(() => {
|
||||
return buildPhysicalToLogicalProjectKeyMap({
|
||||
projects: orderedProjects,
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
type EnvironmentState,
|
||||
} from "./store";
|
||||
import {
|
||||
buildLogicalProjectKeyMap,
|
||||
deriveLogicalProjectKey,
|
||||
deriveLogicalProjectKeyFromSettings,
|
||||
derivePhysicalProjectKey,
|
||||
@@ -450,125 +449,6 @@ describe("environment grouping", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildLogicalProjectKeyMap", () => {
|
||||
it("groups matching projects across environments without merging distinct projects in one environment", () => {
|
||||
const localRoot = makeProject({
|
||||
id: sharedProjectPrimaryId,
|
||||
environmentId: primaryEnvId,
|
||||
name: "shared-repo",
|
||||
cwd: "/workspace/repo",
|
||||
repositoryIdentity: {
|
||||
canonicalKey: SHARED_REPO_CANONICAL_KEY,
|
||||
rootPath: "/workspace/repo",
|
||||
locator: {
|
||||
source: "git-remote",
|
||||
remoteName: "origin",
|
||||
remoteUrl: "https://github.com/example/shared-repo.git",
|
||||
},
|
||||
},
|
||||
});
|
||||
const localWeb = makeProject({
|
||||
id: localOnlyProjectId,
|
||||
environmentId: primaryEnvId,
|
||||
name: "web",
|
||||
cwd: "/workspace/repo/apps/web",
|
||||
repositoryIdentity: {
|
||||
canonicalKey: SHARED_REPO_CANONICAL_KEY,
|
||||
rootPath: "/workspace/repo",
|
||||
locator: {
|
||||
source: "git-remote",
|
||||
remoteName: "origin",
|
||||
remoteUrl: "https://github.com/example/shared-repo.git",
|
||||
},
|
||||
},
|
||||
});
|
||||
const remoteRoot = makeProject({
|
||||
id: sharedProjectRemoteId,
|
||||
environmentId: remoteEnvId,
|
||||
name: "shared-repo",
|
||||
cwd: "/srv/checkout",
|
||||
repositoryIdentity: {
|
||||
canonicalKey: SHARED_REPO_CANONICAL_KEY,
|
||||
rootPath: "/srv/checkout",
|
||||
locator: {
|
||||
source: "git-remote",
|
||||
remoteName: "origin",
|
||||
remoteUrl: "https://github.com/example/shared-repo.git",
|
||||
},
|
||||
},
|
||||
});
|
||||
const remoteWeb = makeProject({
|
||||
id: remoteOnlyProjectId,
|
||||
environmentId: remoteEnvId,
|
||||
name: "web",
|
||||
cwd: "/srv/checkout/apps/web",
|
||||
repositoryIdentity: {
|
||||
canonicalKey: SHARED_REPO_CANONICAL_KEY,
|
||||
rootPath: "/srv/checkout",
|
||||
locator: {
|
||||
source: "git-remote",
|
||||
remoteName: "origin",
|
||||
remoteUrl: "https://github.com/example/shared-repo.git",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const keys = buildLogicalProjectKeyMap(
|
||||
[localRoot, localWeb, remoteRoot, remoteWeb],
|
||||
DEFAULT_GROUPING_SETTINGS,
|
||||
);
|
||||
|
||||
expect(keys.get(derivePhysicalProjectKey(localRoot))).toBe(
|
||||
keys.get(derivePhysicalProjectKey(remoteRoot)),
|
||||
);
|
||||
expect(keys.get(derivePhysicalProjectKey(localWeb))).toBe(
|
||||
keys.get(derivePhysicalProjectKey(remoteWeb)),
|
||||
);
|
||||
expect(keys.get(derivePhysicalProjectKey(localRoot))).not.toBe(
|
||||
keys.get(derivePhysicalProjectKey(localWeb)),
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps duplicate clones in the same environment separate when repo-relative paths match", () => {
|
||||
const firstClone = makeProject({
|
||||
id: sharedProjectPrimaryId,
|
||||
environmentId: primaryEnvId,
|
||||
name: "first",
|
||||
cwd: "/workspace/first/repo",
|
||||
repositoryIdentity: {
|
||||
canonicalKey: SHARED_REPO_CANONICAL_KEY,
|
||||
rootPath: "/workspace/first/repo",
|
||||
locator: {
|
||||
source: "git-remote",
|
||||
remoteName: "origin",
|
||||
remoteUrl: "https://github.com/example/shared-repo.git",
|
||||
},
|
||||
},
|
||||
});
|
||||
const secondClone = makeProject({
|
||||
id: localOnlyProjectId,
|
||||
environmentId: primaryEnvId,
|
||||
name: "second",
|
||||
cwd: "/workspace/second/repo",
|
||||
repositoryIdentity: {
|
||||
canonicalKey: SHARED_REPO_CANONICAL_KEY,
|
||||
rootPath: "/workspace/second/repo",
|
||||
locator: {
|
||||
source: "git-remote",
|
||||
remoteName: "origin",
|
||||
remoteUrl: "https://github.com/example/shared-repo.git",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const keys = buildLogicalProjectKeyMap([firstClone, secondClone], DEFAULT_GROUPING_SETTINGS);
|
||||
|
||||
expect(keys.get(derivePhysicalProjectKey(firstClone))).not.toBe(
|
||||
keys.get(derivePhysicalProjectKey(secondClone)),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("selectProjectsAcrossEnvironments", () => {
|
||||
it("returns all projects from all environments", () => {
|
||||
const state = makeFixtureState();
|
||||
|
||||
@@ -62,7 +62,6 @@ import { useUiStateStore } from "~/uiStateStore";
|
||||
import { WsTransport } from "../../rpc/wsTransport";
|
||||
import { createWsRpcClient, type WsRpcClient } from "../../rpc/wsRpcClient";
|
||||
import {
|
||||
buildLogicalProjectKeyMap,
|
||||
deriveLogicalProjectKeyFromSettings,
|
||||
derivePhysicalProjectKey,
|
||||
} from "../../logicalProject";
|
||||
@@ -474,13 +473,10 @@ function coalesceOrchestrationUiEvents(
|
||||
function syncProjectUiFromStore() {
|
||||
const projects = selectProjectsAcrossEnvironments(useStore.getState());
|
||||
const clientSettings = getClientSettings();
|
||||
const logicalKeyByPhysicalKey = buildLogicalProjectKeyMap(projects, clientSettings);
|
||||
useUiStateStore.getState().syncProjects(
|
||||
projects.map((project) => ({
|
||||
key: derivePhysicalProjectKey(project),
|
||||
logicalKey:
|
||||
logicalKeyByPhysicalKey.get(derivePhysicalProjectKey(project)) ??
|
||||
deriveLogicalProjectKeyFromSettings(project, clientSettings),
|
||||
logicalKey: deriveLogicalProjectKeyFromSettings(project, clientSettings),
|
||||
cwd: project.cwd,
|
||||
})),
|
||||
);
|
||||
@@ -552,13 +548,10 @@ function applyRecoveredEventBatch(
|
||||
if (needsProjectUiSync) {
|
||||
const projects = selectProjectsAcrossEnvironments(useStore.getState());
|
||||
const clientSettings = getClientSettings();
|
||||
const logicalKeyByPhysicalKey = buildLogicalProjectKeyMap(projects, clientSettings);
|
||||
useUiStateStore.getState().syncProjects(
|
||||
projects.map((project) => ({
|
||||
key: derivePhysicalProjectKey(project),
|
||||
logicalKey:
|
||||
logicalKeyByPhysicalKey.get(derivePhysicalProjectKey(project)) ??
|
||||
deriveLogicalProjectKeyFromSettings(project, clientSettings),
|
||||
logicalKey: deriveLogicalProjectKeyFromSettings(project, clientSettings),
|
||||
cwd: project.cwd,
|
||||
})),
|
||||
);
|
||||
|
||||
@@ -10,12 +10,7 @@ import {
|
||||
} from "../composerDraftStore";
|
||||
import { newDraftId, newThreadId } from "../lib/utils";
|
||||
import { orderItemsByPreferredIds } from "../components/Sidebar.logic";
|
||||
import {
|
||||
buildLogicalProjectKeyMap,
|
||||
deriveLogicalProjectKeyFromSettings,
|
||||
derivePhysicalProjectKey,
|
||||
getProjectOrderKey,
|
||||
} from "../logicalProject";
|
||||
import { deriveLogicalProjectKeyFromSettings, getProjectOrderKey } from "../logicalProject";
|
||||
import { selectProjectsAcrossEnvironments, useStore } from "../store";
|
||||
import { createThreadSelectorByRef } from "../storeSelectors";
|
||||
import { resolveThreadRouteTarget } from "../threadRoutes";
|
||||
@@ -28,10 +23,6 @@ function useNewThreadState() {
|
||||
sidebarProjectGroupingMode: settings.sidebarProjectGroupingMode,
|
||||
sidebarProjectGroupingOverrides: settings.sidebarProjectGroupingOverrides,
|
||||
}));
|
||||
const logicalKeyByPhysicalKey = useMemo(
|
||||
() => buildLogicalProjectKeyMap(projects, projectGroupingSettings),
|
||||
[projectGroupingSettings, projects],
|
||||
);
|
||||
const router = useRouter();
|
||||
const getCurrentRouteTarget = useCallback(() => {
|
||||
const currentRouteParams = router.state.matches[router.state.matches.length - 1]?.params ?? {};
|
||||
@@ -62,8 +53,7 @@ function useNewThreadState() {
|
||||
candidate.environmentId === projectRef.environmentId,
|
||||
);
|
||||
const logicalProjectKey = project
|
||||
? (logicalKeyByPhysicalKey.get(derivePhysicalProjectKey(project)) ??
|
||||
deriveLogicalProjectKeyFromSettings(project, projectGroupingSettings))
|
||||
? deriveLogicalProjectKeyFromSettings(project, projectGroupingSettings)
|
||||
: scopedProjectKey(projectRef);
|
||||
const hasBranchOption = options?.branch !== undefined;
|
||||
const hasWorktreePathOption = options?.worktreePath !== undefined;
|
||||
@@ -144,7 +134,7 @@ function useNewThreadState() {
|
||||
});
|
||||
})();
|
||||
},
|
||||
[getCurrentRouteTarget, logicalKeyByPhysicalKey, projectGroupingSettings, router, projects],
|
||||
[getCurrentRouteTarget, projectGroupingSettings, router, projects],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,21 +51,6 @@ function deriveRepositoryRelativeProjectPath(
|
||||
return normalizedProjectPath.slice(rootPrefix.length).replaceAll("\\", "/");
|
||||
}
|
||||
|
||||
function formatProjectGroupDiscriminator(value: string): string {
|
||||
return value.length === 0 ? "." : value;
|
||||
}
|
||||
|
||||
function hasDuplicateEnvironment(projects: ReadonlyArray<Pick<Project, "environmentId">>): boolean {
|
||||
const seen = new Set<string>();
|
||||
for (const project of projects) {
|
||||
if (seen.has(project.environmentId)) {
|
||||
return true;
|
||||
}
|
||||
seen.add(project.environmentId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function derivePhysicalProjectKeyFromPath(environmentId: string, cwd: string): string {
|
||||
return `${environmentId}:${normalizeProjectPathForComparison(cwd)}`;
|
||||
}
|
||||
@@ -147,88 +132,6 @@ export function deriveLogicalProjectKeyFromSettings(
|
||||
});
|
||||
}
|
||||
|
||||
export function buildLogicalProjectKeyMap(
|
||||
projects: ReadonlyArray<Pick<Project, "environmentId" | "id" | "cwd" | "repositoryIdentity">>,
|
||||
settings: ProjectGroupingSettings,
|
||||
): Map<string, string> {
|
||||
const baseBuckets = new Map<
|
||||
string,
|
||||
Array<Pick<Project, "environmentId" | "id" | "cwd" | "repositoryIdentity">>
|
||||
>();
|
||||
const physicalKeyByProject = new Map<
|
||||
Pick<Project, "environmentId" | "id" | "cwd" | "repositoryIdentity">,
|
||||
string
|
||||
>();
|
||||
|
||||
for (const project of projects) {
|
||||
const physicalKey = derivePhysicalProjectKey(project);
|
||||
physicalKeyByProject.set(project, physicalKey);
|
||||
const baseKey = deriveLogicalProjectKeyFromSettings(project, settings);
|
||||
const bucket = baseBuckets.get(baseKey);
|
||||
if (bucket) {
|
||||
bucket.push(project);
|
||||
} else {
|
||||
baseBuckets.set(baseKey, [project]);
|
||||
}
|
||||
}
|
||||
|
||||
const result = new Map<string, string>();
|
||||
const assignBucket = (
|
||||
baseKey: string,
|
||||
bucket: ReadonlyArray<Pick<Project, "environmentId" | "id" | "cwd" | "repositoryIdentity">>,
|
||||
discriminatorIndex: number,
|
||||
) => {
|
||||
if (!hasDuplicateEnvironment(bucket)) {
|
||||
for (const project of bucket) {
|
||||
result.set(physicalKeyByProject.get(project)!, baseKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const discriminatorFns = [
|
||||
(project: Pick<Project, "cwd" | "repositoryIdentity">) => {
|
||||
const relativePath = deriveRepositoryRelativeProjectPath(project);
|
||||
return relativePath === null ? null : formatProjectGroupDiscriminator(relativePath);
|
||||
},
|
||||
(project: Pick<Project, "cwd">) => normalizeProjectPathForComparison(project.cwd),
|
||||
(project: Pick<Project, "environmentId" | "id" | "cwd" | "repositoryIdentity">) =>
|
||||
physicalKeyByProject.get(project) ?? derivePhysicalProjectKey(project),
|
||||
] as const;
|
||||
const discriminator = discriminatorFns[discriminatorIndex];
|
||||
if (!discriminator) {
|
||||
for (const project of bucket) {
|
||||
result.set(physicalKeyByProject.get(project)!, physicalKeyByProject.get(project)!);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const buckets = new Map<
|
||||
string,
|
||||
Array<Pick<Project, "environmentId" | "id" | "cwd" | "repositoryIdentity">>
|
||||
>();
|
||||
for (const project of bucket) {
|
||||
const value = discriminator(project) ?? normalizeProjectPathForComparison(project.cwd);
|
||||
const key = `${baseKey}::${value}`;
|
||||
const existing = buckets.get(key);
|
||||
if (existing) {
|
||||
existing.push(project);
|
||||
} else {
|
||||
buckets.set(key, [project]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [key, projectsForKey] of buckets) {
|
||||
assignBucket(key, projectsForKey, discriminatorIndex + 1);
|
||||
}
|
||||
};
|
||||
|
||||
for (const [baseKey, bucket] of baseBuckets) {
|
||||
assignBucket(baseKey, bucket, 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function deriveLogicalProjectKeyFromRef(
|
||||
projectRef: ScopedProjectRef,
|
||||
project: Pick<Project, "environmentId" | "id" | "cwd" | "repositoryIdentity"> | null | undefined,
|
||||
|
||||
@@ -29,9 +29,7 @@ import { resolveAndPersistPreferredEditor } from "../editorPreferences";
|
||||
import { readLocalApi } from "../localApi";
|
||||
import { useSettings } from "../hooks/useSettings";
|
||||
import {
|
||||
buildLogicalProjectKeyMap,
|
||||
deriveLogicalProjectKeyFromSettings,
|
||||
derivePhysicalProjectKey,
|
||||
derivePhysicalProjectKeyFromPath,
|
||||
} from "../logicalProject";
|
||||
import {
|
||||
@@ -42,7 +40,7 @@ import {
|
||||
useServerConfigUpdatedSubscription,
|
||||
useServerWelcomeSubscription,
|
||||
} from "../rpc/serverState";
|
||||
import { selectProjectsAcrossEnvironments, useStore } from "../store";
|
||||
import { useStore } from "../store";
|
||||
import { useUiStateStore } from "../uiStateStore";
|
||||
import { syncBrowserChromeTheme } from "../hooks/useTheme";
|
||||
import {
|
||||
@@ -244,12 +242,9 @@ function EventRouter() {
|
||||
useStore.getState().environmentStateById[payload.environment.environmentId];
|
||||
const bootstrapProject =
|
||||
bootstrapEnvironmentState?.projectById[payload.bootstrapProjectId] ?? null;
|
||||
const projects = selectProjectsAcrossEnvironments(useStore.getState());
|
||||
const logicalKeyByPhysicalKey = buildLogicalProjectKeyMap(projects, projectGroupingSettings);
|
||||
const bootstrapProjectKey =
|
||||
(bootstrapProject
|
||||
? (logicalKeyByPhysicalKey.get(derivePhysicalProjectKey(bootstrapProject)) ??
|
||||
deriveLogicalProjectKeyFromSettings(bootstrapProject, projectGroupingSettings))
|
||||
? deriveLogicalProjectKeyFromSettings(bootstrapProject, projectGroupingSettings)
|
||||
: null) ??
|
||||
(serverConfig?.cwd
|
||||
? derivePhysicalProjectKeyFromPath(payload.environment.environmentId, serverConfig.cwd)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { scopeProjectRef } from "@t3tools/client-runtime";
|
||||
import type { EnvironmentId, ScopedProjectRef } from "@t3tools/contracts";
|
||||
import {
|
||||
buildLogicalProjectKeyMap,
|
||||
deriveLogicalProjectKeyFromSettings,
|
||||
derivePhysicalProjectKey,
|
||||
deriveProjectGroupLabel,
|
||||
@@ -30,7 +29,14 @@ export function buildPhysicalToLogicalProjectKeyMap(input: {
|
||||
projects: ReadonlyArray<Project>;
|
||||
settings: ProjectGroupingSettings;
|
||||
}): Map<string, string> {
|
||||
return buildLogicalProjectKeyMap(input.projects, input.settings);
|
||||
const mapping = new Map<string, string>();
|
||||
for (const project of input.projects) {
|
||||
mapping.set(
|
||||
derivePhysicalProjectKey(project),
|
||||
deriveLogicalProjectKeyFromSettings(project, input.settings),
|
||||
);
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
export function buildSidebarProjectSnapshots(input: {
|
||||
@@ -39,12 +45,9 @@ export function buildSidebarProjectSnapshots(input: {
|
||||
primaryEnvironmentId: EnvironmentId | null;
|
||||
resolveEnvironmentLabel: (environmentId: EnvironmentId) => string | null;
|
||||
}): SidebarProjectSnapshot[] {
|
||||
const logicalKeyByPhysicalKey = buildLogicalProjectKeyMap(input.projects, input.settings);
|
||||
const groupedMembers = new Map<string, SidebarProjectGroupMember[]>();
|
||||
for (const project of input.projects) {
|
||||
const logicalKey =
|
||||
logicalKeyByPhysicalKey.get(derivePhysicalProjectKey(project)) ??
|
||||
deriveLogicalProjectKeyFromSettings(project, input.settings);
|
||||
const logicalKey = deriveLogicalProjectKeyFromSettings(project, input.settings);
|
||||
const member: SidebarProjectGroupMember = {
|
||||
...project,
|
||||
physicalProjectKey: derivePhysicalProjectKey(project),
|
||||
@@ -61,9 +64,7 @@ export function buildSidebarProjectSnapshots(input: {
|
||||
const result: SidebarProjectSnapshot[] = [];
|
||||
const seen = new Set<string>();
|
||||
for (const project of input.projects) {
|
||||
const logicalKey =
|
||||
logicalKeyByPhysicalKey.get(derivePhysicalProjectKey(project)) ??
|
||||
deriveLogicalProjectKeyFromSettings(project, input.settings);
|
||||
const logicalKey = deriveLogicalProjectKeyFromSettings(project, input.settings);
|
||||
if (seen.has(logicalKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { assert, it } from "@effect/vitest";
|
||||
import { ConfigProvider, Effect, Option } from "effect";
|
||||
|
||||
import {
|
||||
createBuildConfig,
|
||||
MAC_HELPER_BUNDLE_IDS,
|
||||
resolveBuildOptions,
|
||||
resolveDesktopBuildIconAssets,
|
||||
resolveDesktopProductName,
|
||||
@@ -37,6 +39,19 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("pins macOS Electron helper bundle IDs to the T3 Code app identity", () =>
|
||||
Effect.gen(function* () {
|
||||
const buildConfig = yield* createBuildConfig("mac", "dmg", "0.0.21", false, false, undefined);
|
||||
|
||||
assert.deepStrictEqual(buildConfig.mac, {
|
||||
target: ["dmg", "zip"],
|
||||
icon: "icon.icns",
|
||||
category: "public.app-category.developer-tools",
|
||||
...MAC_HELPER_BUNDLE_IDS,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
it("falls back to the default mock update port when the configured port is blank", () => {
|
||||
assert.equal(resolveMockUpdateServerUrl(undefined), "http://localhost:3000");
|
||||
assert.equal(resolveMockUpdateServerUrl(4123), "http://localhost:4123");
|
||||
|
||||
@@ -63,6 +63,17 @@ const PLATFORM_CONFIG: Record<typeof BuildPlatform.Type, PlatformConfig> = {
|
||||
},
|
||||
};
|
||||
|
||||
const MAC_APP_BUNDLE_ID = "com.t3tools.t3code";
|
||||
|
||||
export const MAC_HELPER_BUNDLE_IDS = {
|
||||
helperBundleId: `${MAC_APP_BUNDLE_ID}.helper`,
|
||||
helperEHBundleId: `${MAC_APP_BUNDLE_ID}.helper.eh`,
|
||||
helperGPUBundleId: `${MAC_APP_BUNDLE_ID}.helper.gpu`,
|
||||
helperNPBundleId: `${MAC_APP_BUNDLE_ID}.helper.np`,
|
||||
helperPluginBundleId: `${MAC_APP_BUNDLE_ID}.helper.plugin`,
|
||||
helperRendererBundleId: `${MAC_APP_BUNDLE_ID}.helper.renderer`,
|
||||
} as const;
|
||||
|
||||
interface BuildCliInput {
|
||||
readonly platform: Option.Option<typeof BuildPlatform.Type>;
|
||||
readonly target: Option.Option<string>;
|
||||
@@ -558,7 +569,7 @@ export function resolveDesktopProductName(version: string): string {
|
||||
: (desktopPackageJson.productName ?? "T3 Code");
|
||||
}
|
||||
|
||||
const createBuildConfig = Effect.fn("createBuildConfig")(function* (
|
||||
export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
|
||||
platform: typeof BuildPlatform.Type,
|
||||
target: string,
|
||||
version: string,
|
||||
@@ -567,7 +578,7 @@ const createBuildConfig = Effect.fn("createBuildConfig")(function* (
|
||||
mockUpdateServerPort: number | undefined,
|
||||
) {
|
||||
const buildConfig: Record<string, unknown> = {
|
||||
appId: "com.t3tools.t3code",
|
||||
appId: MAC_APP_BUNDLE_ID,
|
||||
productName: resolveDesktopProductName(version),
|
||||
artifactName: "T3-Code-${version}-${arch}.${ext}",
|
||||
directories: {
|
||||
@@ -592,6 +603,7 @@ const createBuildConfig = Effect.fn("createBuildConfig")(function* (
|
||||
target: target === "dmg" ? [target, "zip"] : [target],
|
||||
icon: "icon.icns",
|
||||
category: "public.app-category.developer-tools",
|
||||
...MAC_HELPER_BUNDLE_IDS,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user