Skip to content

Commit 1e95da7

Browse files
parmartejassTejas Parmarmaria-rcks
authored
fix(git): honor project provider settings (pingdotgg#23672)
Co-authored-by: Tejas Parmar <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent bae3c19 commit 1e95da7

3 files changed

Lines changed: 60 additions & 11 deletions

File tree

‎apps/mobile/src/features/threads/DraftThreadHeader.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ export function DraftThreadHeader(props: {
8787
},
8888
onRunAction: async (input) => {
8989
if (!canWriteGit || !props.cwd) return null;
90-
const result = await runAction({ ...input, actionId: uuidv4() });
90+
const result = await runAction({
91+
...input,
92+
projectId: props.project.id,
93+
actionId: uuidv4(),
94+
});
9195
if (AsyncResult.isFailure(result)) {
9296
Dialog.alert("Git action failed", String(Cause.squash(result.cause)));
9397
return null;

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2599,7 +2599,45 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
25992599
}),
26002600
);
26012601

2602-
it.effect("applies a V2-native thread's project settings to generated commit text", () =>
2602+
it.effect("uses an explicit project's provider settings for generated commit text", () =>
2603+
Effect.gen(function* () {
2604+
const repoDir = yield* makeTempDir("t3code-git-manager-");
2605+
yield* initRepo(repoDir);
2606+
NodeFS.writeFileSync(NodePath.join(repoDir, "README.md"), "hello\nproject\n");
2607+
const projectId = ProjectId.make("project:git-action-settings");
2608+
const disabledInstanceId = DEFAULT_SERVER_SETTINGS.textGenerationModelSelection.instanceId;
2609+
let generatedModelSelection:
2610+
| TextGeneration.CommitMessageGenerationInput["modelSelection"]
2611+
| undefined;
2612+
2613+
const { manager } = yield* makeManager({
2614+
serverSettings: {
2615+
projectSettingsOverrides: {
2616+
[projectId]: {
2617+
providerInstances: { [disabledInstanceId]: { enabled: false } },
2618+
},
2619+
},
2620+
},
2621+
textGeneration: {
2622+
generateCommitMessage: (input) => {
2623+
generatedModelSelection = input.modelSelection;
2624+
return Effect.succeed({ subject: "Use the project writer", body: "" });
2625+
},
2626+
},
2627+
});
2628+
2629+
yield* manager.runStackedAction({
2630+
actionId: "test-project-action-settings",
2631+
cwd: repoDir,
2632+
action: "commit",
2633+
projectId,
2634+
});
2635+
2636+
expect(generatedModelSelection?.instanceId).toBe(ProviderInstanceId.make("claudeAgent"));
2637+
}),
2638+
);
2639+
2640+
it.effect("prefers a V2-native thread's project settings over an explicit project", () =>
26032641
Effect.gen(function* () {
26042642
const repoDir = yield* makeTempDir("t3code-git-manager-");
26052643
yield* initRepo(repoDir);
@@ -2686,6 +2724,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
26862724
cwd: repoDir,
26872725
action: "commit",
26882726
threadId,
2727+
projectId: ProjectId.make("project:other"),
26892728
});
26902729

26912730
expect(generatedModelSelection).toEqual(projectModel);

‎apps/server/src/git/GitManager.ts‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -672,19 +672,25 @@ export const make = Effect.gen(function* () {
672672
const projectSettingsFor = Effect.fnUntraced(function* (input: {
673673
readonly cwd: string;
674674
readonly threadId?: ThreadId | undefined;
675+
readonly projectId?: ProjectId | undefined;
675676
}) {
676677
const settings = yield* serverSettingsService.getSettings;
677678
if (!hasProjectSettingsOverrides(settings))
678679
return { settings, projectId: null as ProjectId | null };
679-
const projectId: ProjectId | null = yield* input.threadId !== undefined
680-
? threads.getThreadShell(input.threadId).pipe(
681-
Effect.map((thread) => thread?.projectId ?? null),
682-
Effect.orElseSucceed(() => null),
683-
)
684-
: projects.findActiveByWorkspaceRoot(input.cwd).pipe(
685-
Effect.map((project) => Option.getOrNull(project)?.projectId ?? null),
686-
Effect.orElseSucceed(() => null),
687-
);
680+
const threadProjectId =
681+
input.threadId === undefined
682+
? null
683+
: yield* threads.getThreadShell(input.threadId).pipe(
684+
Effect.map((thread) => thread?.projectId ?? null),
685+
Effect.orElseSucceed(() => null),
686+
);
687+
const projectId =
688+
threadProjectId ??
689+
input.projectId ??
690+
(yield* projects.findActiveByWorkspaceRoot(input.cwd).pipe(
691+
Effect.map((project) => Option.getOrNull(project)?.projectId ?? null),
692+
Effect.orElseSucceed(() => null),
693+
));
688694
return { settings: resolveProjectSettings(settings, projectId).settings, projectId };
689695
});
690696
const readThreadContext = Effect.fnUntraced(

0 commit comments

Comments
 (0)