647 lines
22 KiB
TypeScript
647 lines
22 KiB
TypeScript
import {
|
|
DEFAULT_SERVER_SETTINGS,
|
|
EnvironmentAuthorizationError,
|
|
EnvironmentId,
|
|
ProjectId,
|
|
type ServerSettings,
|
|
} from "@t3tools/contracts";
|
|
import { describe, expect, it, vi } from "vite-plus/test";
|
|
import { applyServerSettingsPatch } from "@t3tools/shared/serverSettings";
|
|
import * as Cause from "effect/Cause";
|
|
import { resolveWorktreeCleanup } from "@t3tools/shared/projectSettings";
|
|
|
|
import type { SidebarProjectSnapshot } from "../../sidebarProjectGrouping";
|
|
import {
|
|
listProjectOverrides,
|
|
persistScopedSettingsPatch,
|
|
planProjectOverridesClear,
|
|
planScopedSettingsClear,
|
|
planScopedSettingsPatch,
|
|
resolveScopedSettingsTargets,
|
|
scopedSettingsAreMixed,
|
|
scopedSettingsSource,
|
|
selectScopedSettingsEnvironments,
|
|
} from "./scopedSettings";
|
|
import { resolveSettingsScope } from "./settingsScope";
|
|
|
|
function environment(
|
|
id: string,
|
|
options: {
|
|
connected?: boolean;
|
|
loaded?: boolean;
|
|
settings?: Partial<ServerSettings>;
|
|
projectOverrides?: boolean;
|
|
} = {},
|
|
) {
|
|
return {
|
|
environmentId: EnvironmentId.make(id),
|
|
label: id,
|
|
connection: {
|
|
phase: options.connected === false ? ("offline" as const) : ("connected" as const),
|
|
},
|
|
serverConfig:
|
|
options.loaded === false
|
|
? null
|
|
: {
|
|
settings: { ...DEFAULT_SERVER_SETTINGS, ...options.settings },
|
|
environment: {
|
|
capabilities: { projectSettingsOverrides: options.projectOverrides !== false },
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
const laptop = environment("Laptop");
|
|
const server = environment("Server");
|
|
const offline = environment("Offline", { connected: false });
|
|
const loading = environment("Loading", { loaded: false });
|
|
const environments = [laptop, server, offline, loading];
|
|
const all = resolveSettingsScope({}, [], environments);
|
|
const named = resolveSettingsScope({ machine: server.environmentId }, [], environments);
|
|
|
|
const projectId = ProjectId.make("project");
|
|
const laptopProjectId = ProjectId.make("laptop-project");
|
|
const member = {
|
|
id: projectId,
|
|
environmentId: server.environmentId,
|
|
title: "Project",
|
|
workspaceRoot: "/repo",
|
|
physicalProjectKey: `${server.environmentId}:/repo`,
|
|
environmentLabel: server.label,
|
|
defaultModelSelection: null,
|
|
scripts: [],
|
|
createdAt: "2026-09-07T00:00:00.000Z",
|
|
updatedAt: "2026-09-07T00:00:00.000Z",
|
|
};
|
|
const laptopMember = {
|
|
...member,
|
|
id: laptopProjectId,
|
|
environmentId: laptop.environmentId,
|
|
physicalProjectKey: `${laptop.environmentId}:/repo`,
|
|
environmentLabel: laptop.label,
|
|
};
|
|
const group: SidebarProjectSnapshot = {
|
|
...member,
|
|
projectKey: "project-group",
|
|
displayName: "Project",
|
|
memberProjects: [member, laptopMember],
|
|
memberProjectRefs: [
|
|
{ environmentId: server.environmentId, projectId },
|
|
{ environmentId: laptop.environmentId, projectId: laptopProjectId },
|
|
],
|
|
groupedProjectCount: 2,
|
|
environmentPresence: "remote-only",
|
|
allRemoteMembersAreDesktopLocal: false,
|
|
allRemoteMembersAreWsl: false,
|
|
remoteEnvironmentLabels: [server.label, laptop.label],
|
|
};
|
|
const project = resolveSettingsScope({ project: group.projectKey }, [group], environments);
|
|
const checkout = resolveSettingsScope(
|
|
{ project: group.projectKey, machine: server.environmentId, checkout: member.physicalProjectKey },
|
|
[group],
|
|
environments,
|
|
);
|
|
|
|
describe("scoped settings targets", () => {
|
|
it("uses the named environment even when a different primary is available", () => {
|
|
const selected = selectScopedSettingsEnvironments(named, environments, laptop.environmentId);
|
|
expect(selected.environments).toEqual([server]);
|
|
expect(selected.environment).toBe(server);
|
|
});
|
|
|
|
it("keeps an offline named environment selected without falling back to primary", () => {
|
|
const scope = resolveSettingsScope({ machine: offline.environmentId }, [], environments);
|
|
const selected = selectScopedSettingsEnvironments(scope, environments, laptop.environmentId);
|
|
expect(selected.environments).toEqual([offline]);
|
|
expect(selected.connectedEnvironments).toEqual([]);
|
|
expect(selected.environment).toBeNull();
|
|
expect(
|
|
planScopedSettingsPatch(scope, environments, { enableProviderUpdateChecks: false }),
|
|
).toMatchObject({
|
|
serverWrites: [],
|
|
unavailableReason: "Connect Offline to save this setting.",
|
|
});
|
|
});
|
|
|
|
it("prefers the selected primary as the aggregate representative without including disconnected targets", () => {
|
|
const selected = selectScopedSettingsEnvironments(all, environments, server.environmentId);
|
|
expect(selected.environment).toBe(server);
|
|
expect(selected.environments).toEqual(environments);
|
|
expect(selected.connectedEnvironments).toEqual([laptop, server]);
|
|
});
|
|
|
|
it("resolves each member's effective settings and source at project scope", () => {
|
|
const overridden = environment("Server", {
|
|
settings: {
|
|
defaultAutoPull: false,
|
|
projectSettingsOverrides: { [projectId]: { defaultAutoPull: true } },
|
|
},
|
|
});
|
|
const targets = resolveScopedSettingsTargets(project, [laptop, overridden]);
|
|
expect(targets.map((target) => [target.projectId, target.settings.defaultAutoPull])).toEqual([
|
|
[projectId, true],
|
|
[laptopProjectId, false],
|
|
]);
|
|
expect(scopedSettingsSource(targets, ["defaultAutoPull"])).toBe("mixed");
|
|
expect(scopedSettingsSource([targets[0]!], ["defaultAutoPull"])).toBe("project");
|
|
expect(scopedSettingsSource(targets, ["enableProviderUpdateChecks"])).toBe("environment");
|
|
expect(scopedSettingsAreMixed(targets, ["defaultAutoPull"])).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("scoped settings writes", () => {
|
|
it("edits the effective machine policy without changing other machines' rules", () => {
|
|
const custom = environment("Laptop", {
|
|
settings: {
|
|
worktreeCleanup: {
|
|
mode: "custom",
|
|
rules: {
|
|
worktreeAfterDays: 12,
|
|
worktreeOnDelete: true,
|
|
worktreeOnMerge: true,
|
|
worktreeUnchanged: false,
|
|
worktreeKeepWhen: "uncommitted-changes",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
const disabled = environment("Server", {
|
|
settings: { worktreeCleanup: { mode: "off" } },
|
|
});
|
|
const targets = [custom, disabled];
|
|
const plan = planScopedSettingsPatch(all, targets, {
|
|
storageCleanup: { worktreeOnDelete: false },
|
|
});
|
|
const policies = plan.serverWrites.map((write, index) =>
|
|
resolveWorktreeCleanup(
|
|
applyServerSettingsPatch(targets[index]!.serverConfig!.settings, write.patch),
|
|
null,
|
|
),
|
|
);
|
|
expect(policies).toEqual([
|
|
{
|
|
worktreeAfterDays: 12,
|
|
worktreeOnDelete: false,
|
|
worktreeOnMerge: true,
|
|
worktreeUnchanged: false,
|
|
worktreeKeepWhen: "uncommitted-changes",
|
|
},
|
|
{
|
|
worktreeAfterDays: null,
|
|
worktreeOnDelete: false,
|
|
worktreeOnMerge: false,
|
|
worktreeUnchanged: false,
|
|
worktreeKeepWhen: "uncommitted-changes",
|
|
},
|
|
]);
|
|
});
|
|
it("isolates a formerly shared server preference to the named environment", async () => {
|
|
const persistServer = vi.fn().mockResolvedValue({ _tag: "Success" });
|
|
const persistClient = vi.fn();
|
|
await persistScopedSettingsPatch(
|
|
planScopedSettingsPatch(named, environments, { sidebarAutoSettleOnMerge: false }),
|
|
persistServer,
|
|
persistClient,
|
|
);
|
|
expect(persistServer.mock.calls).toEqual([
|
|
[
|
|
{
|
|
environmentId: server.environmentId,
|
|
input: { patch: { sidebarAutoSettleOnMerge: false } },
|
|
},
|
|
],
|
|
]);
|
|
expect(persistClient).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("writes an aggregate preference only to connected environments with loaded configuration", async () => {
|
|
const persistServer = vi.fn().mockResolvedValue({ _tag: "Success" });
|
|
const persistClient = vi.fn();
|
|
await persistScopedSettingsPatch(
|
|
planScopedSettingsPatch(all, environments, { enableProviderUpdateChecks: false }),
|
|
persistServer,
|
|
persistClient,
|
|
);
|
|
expect(persistServer.mock.calls.map(([input]) => input.environmentId)).toEqual([
|
|
laptop.environmentId,
|
|
server.environmentId,
|
|
]);
|
|
expect(persistClient).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("persists client keys locally at any scope alongside server keys", async () => {
|
|
const persistServer = vi.fn().mockResolvedValue({ _tag: "Success" });
|
|
const persistClient = vi.fn();
|
|
await persistScopedSettingsPatch(
|
|
planScopedSettingsPatch(named, environments, {
|
|
diffIgnoreWhitespace: false,
|
|
enableProviderUpdateChecks: false,
|
|
}),
|
|
persistServer,
|
|
persistClient,
|
|
);
|
|
expect(persistClient).toHaveBeenCalledExactlyOnceWith({ diffIgnoreWhitespace: false });
|
|
expect(persistServer).toHaveBeenCalledExactlyOnceWith({
|
|
environmentId: server.environmentId,
|
|
input: { patch: { enableProviderUpdateChecks: false } },
|
|
});
|
|
});
|
|
|
|
it("writes project overrides into each member's entry on its environment", () => {
|
|
const withExisting = environment("Server", {
|
|
settings: {
|
|
projectSettingsOverrides: { [projectId]: { enableAgentBrowserAccess: false } },
|
|
},
|
|
});
|
|
const plan = planScopedSettingsPatch(project, [laptop, withExisting], {
|
|
defaultAutoPull: true,
|
|
});
|
|
expect(plan.unavailableReason).toBeNull();
|
|
expect(plan.serverWrites).toEqual([
|
|
{
|
|
environmentId: server.environmentId,
|
|
label: server.label,
|
|
patch: {
|
|
projectSettingsOverrides: {
|
|
[projectId]: { enableAgentBrowserAccess: false, defaultAutoPull: true },
|
|
},
|
|
},
|
|
},
|
|
{
|
|
environmentId: laptop.environmentId,
|
|
label: laptop.label,
|
|
patch: { projectSettingsOverrides: { [laptopProjectId]: { defaultAutoPull: true } } },
|
|
},
|
|
]);
|
|
expect(
|
|
planScopedSettingsPatch(checkout, [laptop, server], { defaultAutoPull: true }),
|
|
).toMatchObject({
|
|
serverWrites: [{ environmentId: server.environmentId }],
|
|
});
|
|
});
|
|
|
|
it("keeps each project's other cleanup rules when changing one rule across machines", () => {
|
|
const machine = environment("Laptop", {
|
|
settings: {
|
|
storageCleanup: { ...DEFAULT_SERVER_SETTINGS.storageCleanup, worktreeAfterDays: 30 },
|
|
},
|
|
});
|
|
const customized = environment("Server", {
|
|
settings: {
|
|
projectSettingsOverrides: {
|
|
[projectId]: {
|
|
defaultAutoPull: true,
|
|
worktreeCleanup: {
|
|
mode: "custom",
|
|
rules: {
|
|
worktreeAfterDays: 8,
|
|
worktreeOnDelete: false,
|
|
worktreeOnMerge: true,
|
|
worktreeUnchanged: false,
|
|
worktreeKeepWhen: "uncommitted-changes",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
const plan = planScopedSettingsPatch(project, [machine, customized], {
|
|
worktreeCleanup: { mode: "custom", rules: { worktreeOnDelete: true } },
|
|
});
|
|
expect(plan.serverWrites.map((write) => write.patch.projectSettingsOverrides)).toEqual([
|
|
{
|
|
[projectId]: {
|
|
defaultAutoPull: true,
|
|
worktreeCleanup: {
|
|
mode: "custom",
|
|
rules: {
|
|
worktreeAfterDays: 8,
|
|
worktreeOnDelete: true,
|
|
worktreeOnMerge: true,
|
|
worktreeUnchanged: false,
|
|
worktreeKeepWhen: "uncommitted-changes",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
[laptopProjectId]: {
|
|
worktreeCleanup: {
|
|
mode: "custom",
|
|
rules: {
|
|
worktreeAfterDays: 30,
|
|
worktreeOnDelete: true,
|
|
worktreeOnMerge: false,
|
|
worktreeUnchanged: false,
|
|
worktreeKeepWhen: "uncommitted-changes",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
]);
|
|
expect(
|
|
planScopedSettingsClear(checkout, [customized], ["worktreeCleanup"]).serverWrites[0]?.patch,
|
|
).toEqual({
|
|
projectSettingsOverrides: { [projectId]: { defaultAutoPull: true } },
|
|
});
|
|
expect(
|
|
planScopedSettingsPatch(project, [machine, customized], {
|
|
storageCleanup: { browserArtifactsAfterDays: 8 },
|
|
}).serverWrites,
|
|
).toEqual([]);
|
|
});
|
|
|
|
it("scopes agent device access to projects while keeping hub and hosts environment-wide", () => {
|
|
const plan = planScopedSettingsPatch(project, [laptop, server], {
|
|
enableAgentDeviceAccess: true,
|
|
});
|
|
expect(plan.serverWrites.map((write) => write.patch)).toEqual([
|
|
{ projectSettingsOverrides: { [projectId]: { enableAgentDeviceAccess: true } } },
|
|
{ projectSettingsOverrides: { [laptopProjectId]: { enableAgentDeviceAccess: true } } },
|
|
]);
|
|
for (const patch of [{ enableDeviceSupport: true }, { deviceHosts: [] }]) {
|
|
expect(planScopedSettingsPatch(project, environments, patch).serverWrites).toEqual([]);
|
|
}
|
|
});
|
|
|
|
it("refuses environment-wide keys and older servers at project scope", () => {
|
|
expect(
|
|
planScopedSettingsPatch(project, environments, { enableProviderUpdateChecks: false }),
|
|
).toMatchObject({
|
|
serverWrites: [],
|
|
unavailableReason: "This setting is environment-wide and cannot be overridden by a project.",
|
|
});
|
|
const legacy = environment("Server", { projectOverrides: false });
|
|
expect(
|
|
planScopedSettingsPatch(checkout, [laptop, legacy], { defaultAutoPull: true }),
|
|
).toMatchObject({ serverWrites: [], unavailableReason: expect.stringContaining("update") });
|
|
});
|
|
|
|
it("clears overrides per member and removes an emptied entry", () => {
|
|
const withOverrides = environment("Server", {
|
|
settings: {
|
|
projectSettingsOverrides: {
|
|
[projectId]: { defaultAutoPull: true, enableAgentBrowserAccess: false },
|
|
},
|
|
},
|
|
});
|
|
const plan = planScopedSettingsClear(checkout, [laptop, withOverrides], ["defaultAutoPull"]);
|
|
expect(plan.serverWrites).toEqual([
|
|
{
|
|
environmentId: server.environmentId,
|
|
label: server.label,
|
|
patch: { projectSettingsOverrides: { [projectId]: { enableAgentBrowserAccess: false } } },
|
|
},
|
|
]);
|
|
expect(
|
|
planScopedSettingsClear(
|
|
checkout,
|
|
[laptop, withOverrides],
|
|
["defaultAutoPull", "enableAgentBrowserAccess"],
|
|
).serverWrites[0]?.patch,
|
|
).toEqual({ projectSettingsOverrides: { [projectId]: null } });
|
|
});
|
|
|
|
it("never substitutes an environment-default write for an invalid scope", () => {
|
|
const scope = resolveSettingsScope({ machine: "removed" }, [group], environments);
|
|
const plan = planScopedSettingsPatch(scope, environments, { enableAgentBrowserAccess: false });
|
|
expect(plan.serverWrites).toEqual([]);
|
|
expect(plan.hasClientWrite).toBe(false);
|
|
expect(plan.unavailableReason).not.toBeNull();
|
|
});
|
|
|
|
it("waits for every target and identifies both RPC failures and rejected writes", async () => {
|
|
const third = environment("Third");
|
|
const fourth = environment("Fourth");
|
|
const selected = [...environments, third, fourth];
|
|
const scope = resolveSettingsScope({}, [], selected);
|
|
const persistServer = vi
|
|
.fn()
|
|
.mockResolvedValueOnce({ _tag: "Success" })
|
|
.mockResolvedValueOnce({
|
|
_tag: "Failure",
|
|
cause: Cause.fail(
|
|
new EnvironmentAuthorizationError({
|
|
requiredScope: "settings:write",
|
|
message: "This connection lacks permission to change settings.",
|
|
}),
|
|
),
|
|
})
|
|
.mockRejectedValueOnce(new Error("Disconnected during save"))
|
|
.mockResolvedValueOnce({ _tag: "Success" });
|
|
const result = await persistScopedSettingsPatch(
|
|
planScopedSettingsPatch(scope, selected, { enableAgentBrowserAccess: false }),
|
|
persistServer,
|
|
vi.fn(),
|
|
);
|
|
expect(result.savedEnvironmentCount).toBe(2);
|
|
expect(result.savedEnvironments.map(({ label }) => label)).toEqual([
|
|
laptop.label,
|
|
fourth.label,
|
|
]);
|
|
expect(result.failedEnvironments.map(({ message }) => message)).toEqual([
|
|
"This connection lacks permission to change settings.",
|
|
"Disconnected during save",
|
|
]);
|
|
expect(result.failedEnvironments.map(({ label }) => label)).toEqual([
|
|
server.label,
|
|
third.label,
|
|
]);
|
|
expect(persistServer).toHaveBeenCalledTimes(4);
|
|
});
|
|
});
|
|
|
|
describe("scoped settings mixed values", () => {
|
|
it("compares only requested settings across connected targets", () => {
|
|
const changed = environment("Changed", { settings: { enableAgentBrowserAccess: false } });
|
|
const targets = resolveScopedSettingsTargets(all, [laptop, changed]);
|
|
expect(scopedSettingsAreMixed(targets, ["enableAgentBrowserAccess"])).toBe(true);
|
|
expect(scopedSettingsAreMixed(targets, ["enableProviderUpdateChecks"])).toBe(false);
|
|
expect(scopedSettingsAreMixed([], ["enableAgentBrowserAccess"])).toBe(false);
|
|
});
|
|
|
|
it("treats independently decoded equal nested settings as the same value", () => {
|
|
const style = {
|
|
...DEFAULT_SERVER_SETTINGS.sourceControlWritingStyle,
|
|
mode: "custom" as const,
|
|
customInstructions: "Use plain language",
|
|
};
|
|
const first = environment("First", { settings: { sourceControlWritingStyle: { ...style } } });
|
|
const second = environment("Second", { settings: { sourceControlWritingStyle: { ...style } } });
|
|
const targets = resolveScopedSettingsTargets(all, [first, second]);
|
|
expect(scopedSettingsAreMixed(targets, ["sourceControlWritingStyle"])).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("project overrides at environment scope", () => {
|
|
const laptop = EnvironmentId.make("laptop");
|
|
const desk = EnvironmentId.make("desk");
|
|
const fleet = ProjectId.make("fleet");
|
|
const t3 = ProjectId.make("t3");
|
|
const environment = (
|
|
environmentId: EnvironmentId,
|
|
overrides: ServerSettings["projectSettingsOverrides"],
|
|
) => ({
|
|
environmentId,
|
|
label: environmentId,
|
|
connection: { phase: "connected" as const },
|
|
serverConfig: {
|
|
settings: { ...DEFAULT_SERVER_SETTINGS, projectSettingsOverrides: overrides },
|
|
environment: { capabilities: { projectSettingsOverrides: true } },
|
|
},
|
|
});
|
|
|
|
it("lists only the projects that override the keys", () => {
|
|
const entries = listProjectOverrides(
|
|
[
|
|
environment(laptop, {
|
|
[fleet]: { defaultAutoPull: true, defaultThreadEnvMode: "local" },
|
|
[t3]: { defaultThreadEnvMode: "local" },
|
|
}),
|
|
environment(desk, { [fleet]: { defaultAutoPull: false } }),
|
|
],
|
|
["defaultAutoPull"],
|
|
);
|
|
expect(entries).toEqual([
|
|
{ environmentId: laptop, projectId: fleet },
|
|
{ environmentId: desk, projectId: fleet },
|
|
]);
|
|
});
|
|
|
|
it("clears only those keys and drops entries that become empty", () => {
|
|
const plan = planProjectOverridesClear(
|
|
[
|
|
environment(laptop, {
|
|
[fleet]: { defaultAutoPull: true, defaultThreadEnvMode: "local" },
|
|
[t3]: { defaultAutoPull: true },
|
|
}),
|
|
],
|
|
[
|
|
{ environmentId: laptop, projectId: fleet },
|
|
{ environmentId: laptop, projectId: t3 },
|
|
],
|
|
["defaultAutoPull"],
|
|
);
|
|
expect(plan.serverWrites).toEqual([
|
|
{
|
|
environmentId: laptop,
|
|
label: laptop,
|
|
patch: {
|
|
projectSettingsOverrides: { [fleet]: { defaultThreadEnvMode: "local" }, [t3]: null },
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe("null patches at project scope", () => {
|
|
it("removes the override for keys that cannot store null and keeps it for keys that can", () => {
|
|
const environmentId = EnvironmentId.make("laptop");
|
|
const projectId = ProjectId.make("fleet");
|
|
const scope = {
|
|
kind: "project" as const,
|
|
group: {} as never,
|
|
environmentId: null,
|
|
label: "fleet",
|
|
members: [{ id: projectId, environmentId } as never],
|
|
environmentIds: [environmentId],
|
|
};
|
|
const environments = [
|
|
{
|
|
environmentId,
|
|
label: "Laptop",
|
|
connection: { phase: "connected" as const },
|
|
serverConfig: {
|
|
settings: {
|
|
...DEFAULT_SERVER_SETTINGS,
|
|
projectSettingsOverrides: {
|
|
[projectId]: { defaultThreadEnvMode: "worktree" as const, defaultAutoPull: true },
|
|
},
|
|
},
|
|
environment: { capabilities: { projectSettingsOverrides: true } },
|
|
},
|
|
},
|
|
];
|
|
expect(
|
|
planScopedSettingsPatch(scope, environments, { defaultThreadEnvMode: null }).serverWrites[0]
|
|
?.patch,
|
|
).toEqual({ projectSettingsOverrides: { [projectId]: { defaultAutoPull: true } } });
|
|
expect(
|
|
planScopedSettingsPatch(scope, environments, { defaultModelSelection: null }).serverWrites[0]
|
|
?.patch,
|
|
).toEqual({
|
|
projectSettingsOverrides: {
|
|
[projectId]: {
|
|
defaultThreadEnvMode: "worktree",
|
|
defaultAutoPull: true,
|
|
defaultModelSelection: null,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("partial object patches at project scope", () => {
|
|
it("completes a writing style field patch from the target's effective value", () => {
|
|
const environmentId = EnvironmentId.make("laptop");
|
|
const projectId = ProjectId.make("fleet");
|
|
const member = {
|
|
id: projectId,
|
|
environmentId,
|
|
physicalProjectKey: "laptop:/repo",
|
|
environmentLabel: "Laptop",
|
|
title: "fleet",
|
|
workspaceRoot: "/repo",
|
|
defaultModelSelection: null,
|
|
scripts: [],
|
|
createdAt: "2026-01-01T00:00:00.000Z",
|
|
updatedAt: "2026-01-01T00:00:00.000Z",
|
|
};
|
|
const settings = {
|
|
...DEFAULT_SERVER_SETTINGS,
|
|
projectSettingsOverrides: {
|
|
[projectId]: {
|
|
sourceControlWritingStyle: {
|
|
mode: "custom" as const,
|
|
customInstructions: "Keep it short.",
|
|
followChangeRequestTemplates: false,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
const plan = planScopedSettingsPatch(
|
|
{
|
|
kind: "project",
|
|
group: {} as never,
|
|
environmentId: null,
|
|
label: "fleet",
|
|
members: [member as never],
|
|
environmentIds: [environmentId],
|
|
},
|
|
[
|
|
{
|
|
environmentId,
|
|
label: "Laptop",
|
|
connection: { phase: "connected" },
|
|
serverConfig: {
|
|
settings,
|
|
environment: { capabilities: { projectSettingsOverrides: true } },
|
|
},
|
|
},
|
|
],
|
|
{ sourceControlWritingStyle: { customInstructions: "Be terse." } },
|
|
);
|
|
expect(plan.serverWrites[0]?.patch).toEqual({
|
|
projectSettingsOverrides: {
|
|
[projectId]: {
|
|
sourceControlWritingStyle: {
|
|
mode: "custom",
|
|
customInstructions: "Be terse.",
|
|
followChangeRequestTemplates: false,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
});
|