@devries-cameron20 / t3code-1 / commits / b2be7f4e4f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Address PR feedback on git workflows

Co-authored-by: codex <codex@users.noreply.github.com>

Julius Marminge committed Mar 2, 2026 at 19:40 UTC b2be7f4e4f0aed3c4b03e3986dd3507c501a4abb
6 files changed +56 -32
apps/server/src/git/Layers/GitManager.test.ts
+17 -1
@@ -546,8 +546,23 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
546 yield* runGit(repoDir, ["remote", "add", "origin", remoteDir]);
547 yield* runGit(repoDir, ["push", "-u", "origin", "main"]);
548 fs.writeFileSync(path.join(repoDir, "README.md"), "hello\nfeature-branch\n");
549 + let generatedCount = 0;
550
550 - const { manager } = yield* makeManager();
551 + const { manager } = yield* makeManager({
552 + textGeneration: {
553 + generateCommitMessage: (input) =>
554 + Effect.sync(() => {
555 + generatedCount += 1;
556 + return {
557 + subject: "Implement stacked git actions",
558 + body: "",
559 + ...(input.includeBranch
560 + ? { branch: "feature/implement-stacked-git-actions" }
561 + : {}),
562 + };
563 + }),
564 + },
565 + });
566 const result = yield* runStackedAction(manager, {
567 cwd: repoDir,
568 action: "commit_push",
@@ -571,6 +586,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
586 Effect.map((r) => r.stdout.trim()),
587 );
588 expect(mergeBase).toBe(mainSha);
589 + expect(generatedCount).toBe(1);
590 }),
591 );
592
apps/server/src/git/Layers/GitManager.ts
+29 -7
@@ -105,6 +105,13 @@ function sanitizeCommitMessage(generated: {
105 };
106 }
107
108 +interface CommitAndBranchSuggestion {
109 + subject: string;
110 + body: string;
111 + branch?: string | undefined;
112 + commitMessage: string;
113 +}
114 +
115 function formatCommitMessage(subject: string, body: string): string {
116 const trimmedBody = body.trim();
117 if (trimmedBody.length === 0) {
@@ -311,13 +318,20 @@ export const makeGitManager = Effect.gen(function* () {
318 };
319 });
320
314 - const runCommitStep = (cwd: string, branch: string | null, commitMessage?: string) =>
321 + const runCommitStep = (
322 + cwd: string,
323 + branch: string | null,
324 + commitMessage?: string,
325 + preResolvedSuggestion?: CommitAndBranchSuggestion,
326 + ) =>
327 Effect.gen(function* () {
316 - const suggestion = yield* resolveCommitAndBranchSuggestion({
317 - cwd,
318 - branch,
319 - ...(commitMessage ? { commitMessage } : {}),
320 - });
328 + const suggestion =
329 + preResolvedSuggestion ??
330 + (yield* resolveCommitAndBranchSuggestion({
331 + cwd,
332 + branch,
333 + ...(commitMessage ? { commitMessage } : {}),
334 + }));
335 if (!suggestion) {
336 return { status: "skipped_no_changes" as const };
337 }
@@ -456,6 +470,7 @@ export const makeGitManager = Effect.gen(function* () {
470 return {
471 branchStep: { status: "created" as const, name: resolvedBranch },
472 resolvedCommitMessage: suggestion.commitMessage,
473 + resolvedCommitSuggestion: suggestion,
474 };
475 });
476
@@ -477,6 +492,7 @@ export const makeGitManager = Effect.gen(function* () {
492
493 let branchStep: { status: "created" | "skipped_not_requested"; name?: string };
494 let commitMessageForStep = input.commitMessage;
495 + let preResolvedCommitSuggestion: CommitAndBranchSuggestion | undefined = undefined;
496
497 if (input.featureBranch) {
498 const result = yield* runFeatureBranchStep(
@@ -486,13 +502,19 @@ export const makeGitManager = Effect.gen(function* () {
502 );
503 branchStep = result.branchStep;
504 commitMessageForStep = result.resolvedCommitMessage;
505 + preResolvedCommitSuggestion = result.resolvedCommitSuggestion;
506 } else {
507 branchStep = { status: "skipped_not_requested" as const };
508 }
509
510 const currentBranch = branchStep.name ?? initialStatus.branch;
511
495 - const commit = yield* runCommitStep(input.cwd, currentBranch, commitMessageForStep);
512 + const commit = yield* runCommitStep(
513 + input.cwd,
514 + currentBranch,
515 + commitMessageForStep,
516 + preResolvedCommitSuggestion,
517 + );
518
519 const push = wantsPush
520 ? yield* gitCore.pushCurrentBranch(input.cwd, currentBranch)
apps/web/src/components/GitActionsControl.logic.test.ts
+5
@@ -943,6 +943,11 @@ describe("resolveAutoFeatureBranchName", () => {
943 assert.equal(branch, "feature/fix-toast-copy-3");
944 });
945
946 + it("treats existing branch names as case-insensitive for collision checks", () => {
947 + const branch = resolveAutoFeatureBranchName(["Feature/Ticket-1"], "feature/ticket-1");
948 + assert.equal(branch, "feature/ticket-1-2");
949 + });
950 +
951 it("falls back to feature/update when no preferred name is provided", () => {
952 const branch = resolveAutoFeatureBranchName(["main"]);
953 assert.equal(branch, "feature/update");
apps/web/src/components/GitActionsControl.tsx
+4 -3
@@ -254,8 +254,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
254 !skipDefaultBranchPrompt &&
255 !featureBranch &&
256 requiresDefaultBranchConfirmation(action, actionIsDefaultBranch) &&
257 - actionBranch &&
258 - !!actionStatus?.hasWorkingTreeChanges
257 + actionBranch
258 ) {
259 if (action !== "commit_push" && action !== "commit_push_pr") {
260 return;
@@ -416,6 +415,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
415 (actionParams: {
416 action: GitStackedAction;
417 commitMessage?: string;
418 + forcePushOnlyProgress?: boolean;
419 onConfirmed?: () => void;
420 }) => {
421 void runGitActionWithToast({
@@ -429,11 +429,12 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
429
430 const checkoutFeatureBranchAndContinuePendingAction = useCallback(() => {
431 if (!pendingDefaultBranchAction) return;
432 - const { action, commitMessage, onConfirmed } = pendingDefaultBranchAction;
432 + const { action, commitMessage, forcePushOnlyProgress, onConfirmed } = pendingDefaultBranchAction;
433 setPendingDefaultBranchAction(null);
434 checkoutNewBranchAndRunAction({
435 action,
436 ...(commitMessage ? { commitMessage } : {}),
437 + forcePushOnlyProgress,
438 ...(onConfirmed ? { onConfirmed } : {}),
439 });
440 }, [pendingDefaultBranchAction, checkoutNewBranchAndRunAction]);
apps/web/src/lib/gitReactQuery.ts
-20
@@ -16,8 +16,6 @@ export const gitQueryKeys = {
16 export const gitMutationKeys = {
17 init: (cwd: string | null) => ["git", "mutation", "init", cwd] as const,
18 checkout: (cwd: string | null) => ["git", "mutation", "checkout", cwd] as const,
19 - createBranchAndCheckout: (cwd: string | null) =>
20 - ["git", "mutation", "create-branch-and-checkout", cwd] as const,
19 runStackedAction: (cwd: string | null) => ["git", "mutation", "run-stacked-action", cwd] as const,
20 pull: (cwd: string | null) => ["git", "mutation", "pull", cwd] as const,
21 };
@@ -89,24 +87,6 @@ export function gitCheckoutMutationOptions(input: {
87 });
88 }
89
92 -export function gitCreateBranchAndCheckoutMutationOptions(input: {
93 - cwd: string | null;
94 - queryClient: QueryClient;
95 -}) {
96 - return mutationOptions({
97 - mutationKey: gitMutationKeys.createBranchAndCheckout(input.cwd),
98 - mutationFn: async (branch: string) => {
99 - const api = ensureNativeApi();
100 - if (!input.cwd) throw new Error("Git branch creation is unavailable.");
101 - await api.git.createBranch({ cwd: input.cwd, branch });
102 - return api.git.checkout({ cwd: input.cwd, branch });
103 - },
104 - onSuccess: async () => {
105 - await invalidateGitQueries(input.queryClient);
106 - },
107 - });
108 -}
109 -
90 export function gitRunStackedActionMutationOptions(input: {
91 cwd: string | null;
92 queryClient: QueryClient;
packages/shared/src/git.ts
+1 -1
@@ -46,7 +46,7 @@ export function resolveAutoFeatureBranchName(
46 const resolvedBase = sanitizeFeatureBranchName(
47 preferred && preferred.length > 0 ? preferred : AUTO_FEATURE_BRANCH_FALLBACK,
48 );
49 - const existingNames = new Set(existingBranchNames);
49 + const existingNames = new Set(existingBranchNames.map((branch) => branch.toLowerCase()));
50
51 if (!existingNames.has(resolvedBase)) {
52 return resolvedBase;