The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 10:45 UTC
fix(clients): offer Commit when the branch is behind upstream (#24117)
Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Oct 30, 2026 at 16:03 UTC
e9dd8a68eeb89a5e7dea91b7c2a730db55591715
4 files changed
+78
-2
apps/web/src/components/GitActionsControl.logic.test.ts
+30
@@ -94,6 +94,36 @@ describe("when: on default ref without open PR", () => {
94
});
95
});
96
97
+describe("when: local changes are behind upstream", () => {
98
+ it("keeps the commit action available without pushing, with or without an open PR", () => {
99
+ const behind = status({ hasWorkingTreeChanges: true, behindCount: 2 });
100
+ const commit = {
101
+ label: "Commit",
102
+ disabled: false,
103
+ kind: "run_action",
104
+ action: "commit",
105
+ } as const;
106
+ assert.deepEqual(resolveQuickAction(behind, false), commit);
107
+ assert.deepEqual(
108
+ resolveQuickAction(
109
+ {
110
+ ...behind,
111
+ pr: {
112
+ number: 13,
113
+ title: "Open PR",
114
+ url: "https://example.com/pr/13",
115
+ baseRef: "main",
116
+ headRef: "feature/test",
117
+ state: "open",
118
+ },
119
+ },
120
+ false,
121
+ ),
122
+ commit,
123
+ );
124
+ });
125
+});
126
+
127
describe("when: ref has no upstream configured", () => {
128
it("resolveQuickAction runs push and create PR when no upstream and commits are ahead", () => {
129
const quick = resolveQuickAction(
apps/web/src/components/GitActionsControl.logic.ts
+1
-1
@@ -212,7 +212,7 @@ export function resolveQuickAction(
212
}
213
214
if (hasChanges) {
215
- if (!gitStatus.hasUpstream && !hasPrimaryRemote) {
215
+ if (isBehind || (!gitStatus.hasUpstream && !hasPrimaryRemote)) {
216
return { label: "Commit", disabled: false, kind: "run_action", action: "commit" };
217
}
218
if (hasOpenPr || isDefaultRef) {
packages/client-runtime/src/state/gitActions.ts
+1
-1
@@ -152,7 +152,7 @@ export function resolveQuickAction(
152
}
153
154
if (hasChanges) {
155
- if (!gitStatus.hasUpstream && !hasOriginRemote) {
155
+ if (isBehind || (!gitStatus.hasUpstream && !hasOriginRemote)) {
156
return { label: "Commit", disabled: false, kind: "run_action", action: "commit" };
157
}
158
if (hasOpenPr || isDefaultBranch) {
packages/client-runtime/src/state/vcs.test.ts
+46
@@ -5,6 +5,7 @@ import {
5
WS_METHODS,
6
VcsProcessExitError,
7
type VcsListRefsResult,
8
+ type VcsStatusResult,
9
} from "@t3tools/contracts";
10
import { describe, expect, it } from "@effect/vitest";
11
import * as Deferred from "effect/Deferred";
@@ -37,6 +38,7 @@ import {
38
commitVcsRefsRefresh,
39
createVcsEnvironmentAtoms,
40
makeCachedVcsRefsChanges,
41
+ resolveQuickAction,
42
} from "./vcs.ts";
43
import {
44
invalidateCachedVcsRefs,
@@ -618,3 +620,47 @@ const grantedSessions = Atom.family((_id: EnvironmentId) =>
620
}),
621
),
622
);
623
+
624
+function status(overrides: Partial<VcsStatusResult> = {}): VcsStatusResult {
625
+ return {
626
+ isRepo: true,
627
+ hasPrimaryRemote: true,
628
+ isDefaultRef: false,
629
+ refName: "feature/test",
630
+ hasWorkingTreeChanges: false,
631
+ workingTree: {
632
+ files: [],
633
+ insertions: 0,
634
+ deletions: 0,
635
+ },
636
+ hasUpstream: true,
637
+ aheadCount: 0,
638
+ behindCount: 0,
639
+ pr: null,
640
+ ...overrides,
641
+ };
642
+}
643
+
644
+describe("resolveQuickAction", () => {
645
+ it("commits local changes without pushing when the branch is behind upstream", () => {
646
+ const behind = status({ hasWorkingTreeChanges: true, behindCount: 2 });
647
+ const commit = { label: "Commit", disabled: false, kind: "run_action", action: "commit" };
648
+ expect(resolveQuickAction(behind, false)).toEqual(commit);
649
+ expect(
650
+ resolveQuickAction(
651
+ {
652
+ ...behind,
653
+ pr: {
654
+ number: 13,
655
+ title: "Open PR",
656
+ url: "https://example.com/pr/13",
657
+ baseRef: "main",
658
+ headRef: "feature/test",
659
+ state: "open",
660
+ },
661
+ },
662
+ false,
663
+ ),
664
+ ).toEqual(commit);
665
+ });
666
+});