GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(git): the commit button shows the right action and waits for the … · pingdotgg/t3code@82580b5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps
    • mobile/src
      • features/threads
        • ThreadGitControls.tsx
        • git
          • GitCommitSheet.tsx
          • GitConfirmSheet.tsx
          • GitOverviewSheet.tsx
          • confirmCommitDuringRun.ts
      • state
        • use-selected-thread-git-actions.ts
        • vcs.ts
    • server/src
      • git
        • GitManager.test.ts
        • GitManager.ts
      • orchestration-v2
        • RunFinalizationService.test.ts
        • RunFinalizationService.ts
        • VcsStatusTurnReactor.test.ts
        • VcsStatusTurnReactor.ts
      • server.ts
      • vcs
        • VcsStatusBroadcaster.test.ts
        • VcsStatusBroadcaster.ts
      • ws.ts
    • web/src
      • components
        • GitActionsControl.logic.test.ts
        • GitActionsControl.logic.ts
        • GitActionsControl.tsx
      • state
        • vcs.ts
  • docs/user
    • source-control.md
  • packages
    • client-runtime/src/state
      • gitActionQueue.test.ts
      • gitActionQueue.ts
      • gitActions.test.ts
      • gitActions.ts
      • vcs.ts
      • vcsAction.ts
    • contracts/src
      • git.ts
    • shared/src
      • git.test.ts
      • git.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/ThreadGitControls.tsx
+27-2Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useAtomValue } from "@effect/atom-react";
12
import * as Dialog from "../../components/ui/Dialog";
23
import { useOpenPullRequest } from "../../native/useOpenPullRequest";
34
import type { AppBarMenu } from "../../components/ui/AppBar.types";
@@ -10,6 +11,7 @@ import {
1011
type VcsStatusResult,
1112
} from "@t3tools/contracts";
1213
import {
14+
CANCEL_QUEUED_QUICK_ACTION,
1315
type GitActionRequestInput,
1416
requiresDefaultBranchConfirmation,
1517
resolveQuickAction,
@@ -18,6 +20,8 @@ import { useNavigation } from "@react-navigation/native";
1820
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
1921

2022
import { useEnvironmentScope } from "../../state/session";
23+
import { gitActionQueue } from "../../state/vcs";
24+
import { confirmCommitDuringRun } from "./git/confirmCommitDuringRun";
2125
import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
2226
import {
2327
basename,
@@ -119,7 +123,14 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
119123
const hasPrimaryRemote = gitStatus?.hasPrimaryRemote ?? false;
120124
const isDefaultRef = gitStatus?.isDefaultRef ?? false;
121125

126+
const threadRef = {
127+
environmentId: EnvironmentId.make(String(environmentId)),
128+
threadId: ThreadId.make(String(threadId)),
129+
};
130+
const queuedGitAction = useAtomValue(gitActionQueue.queuedActionAtom(threadRef));
131+
122132
const quickAction = (() => {
133+
if (queuedGitAction !== null) return CANCEL_QUEUED_QUICK_ACTION;
123134
if (!isRepo) {
124135
return {
125136
label: "Git unavailable",
@@ -169,14 +180,24 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
169180

170181
const runActionWithPrompt = async (input: GitActionRequestInput) => {
171182
if (!canWriteSourceControl) return;
183+
const branchName = gitStatus?.refName;
184+
const request = { ...input, ...(branchName ? { expectedRefName: branchName } : {}) };
185+
const decision = await confirmCommitDuringRun({
186+
thread: threadRef,
187+
action: input.action,
188+
hasChanges: gitStatus?.hasWorkingTreeChanges === true,
189+
queuedRun: requiresDefaultBranchConfirmation(input.action, isDefaultRef)
190+
? null
191+
: () => void onRunAction(request),
192+
});
193+
if (decision !== "proceed") return;
172194
const confirmableAction =
173195
input.action === "push" ||
174196
input.action === "create_pr" ||
175197
input.action === "commit_push" ||
176198
input.action === "commit_push_pr"
177199
? input.action
178200
: null;
179-
const branchName = gitStatus?.refName;
180201
if (
181202
branchName &&
182203
confirmableAction &&
@@ -200,11 +221,15 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
200221
return;
201222
}
202223

203-
await onRunAction(input);
224+
await onRunAction(request);
204225
};
205226

206227
const runQuickAction = async () => {
207228
if (quickAction.disabled) return;
229+
if (quickAction.kind === "cancel_queued") {
230+
gitActionQueue.cancel(threadRef);
231+
return;
232+
}
208233
if (quickAction.kind === "open_pr") {
209234
await openExistingPr();
210235
return;
Collapse file

‎apps/mobile/src/features/threads/git/GitCommitSheet.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/git/GitCommitSheet.tsx
+18-3Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { AppText as Text, AppTextInput as TextInput } from "../../../components/
1212
import { cn } from "../../../lib/cn";
1313
import { useEnvironmentQuery } from "../../../state/query";
1414
import { useThreadSelection } from "../../../state/use-thread-selection";
15+
import { confirmCommitDuringRun } from "./confirmCommitDuringRun";
1516
import { useSelectedThreadGitActions } from "../../../state/use-selected-thread-git-actions";
1617
import { useSelectedThreadGitState } from "../../../state/use-selected-thread-git-state";
1718
import { useSelectedThreadWorktree } from "../../../state/use-selected-thread-worktree";
@@ -57,13 +58,27 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
5758
const runCommitAction = async (featureBranch: boolean) => {
5859
if (!canWriteSourceControl || (featureBranch && !canChangeThreadBranch)) return;
5960
const commitMessage = dialogCommitMessage.trim();
60-
navigation.goBack();
61-
await gitActions.onRunSelectedThreadGitAction({
62-
action: "commit",
61+
const refName = gitStatus.data?.refName;
62+
const request = {
63+
action: "commit" as const,
6364
featureBranch,
65+
...(refName ? { expectedRefName: refName } : {}),
6466
...(commitMessage ? { commitMessage } : {}),
6567
...(!allSelected ? { filePaths: selectedFiles.map((file) => file.path) } : {}),
68+
};
69+
const decision = await confirmCommitDuringRun({
70+
thread:
71+
selectedThread === null
72+
? null
73+
: { environmentId: selectedThread.environmentId, threadId: selectedThread.id },
74+
action: "commit",
75+
hasChanges: true,
76+
queuedRun: () => void gitActions.onRunSelectedThreadGitAction(request),
6677
});
78+
if (decision === "cancelled") return;
79+
navigation.goBack();
80+
if (decision === "queued") return;
81+
await gitActions.onRunSelectedThreadGitAction(request);
6782
};
6883

6984
const android = Platform.OS === "android";
Collapse file

‎apps/mobile/src/features/threads/git/GitConfirmSheet.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
7070
navigation.dispatch(StackActions.replace("Thread", { environmentId, threadId }));
7171
await gitActions.onRunSelectedThreadGitAction({
7272
action: confirmAction,
73+
...(branchName ? { expectedRefName: branchName } : {}),
7374
...(params.commitMessage ? { commitMessage: params.commitMessage } : {}),
7475
...(params.filePaths ? { filePaths: params.filePaths.split(",") } : {}),
7576
});
@@ -83,6 +84,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
8384
await gitActions.onRunSelectedThreadGitAction({
8485
action: confirmAction,
8586
featureBranch: true,
87+
...(branchName ? { expectedRefName: branchName } : {}),
8688
...(params.commitMessage ? { commitMessage: params.commitMessage } : {}),
8789
...(params.filePaths ? { filePaths: params.filePaths.split(",") } : {}),
8890
});
@@ -101,8 +103,12 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
101103
);
102104
const created = await gitActions.onCreateSelectedThreadBranch(newBranchName);
103105
if (created === null) return;
104-
await gitActions.onRunSelectedThreadGitAction({ action: confirmAction });
106+
await gitActions.onRunSelectedThreadGitAction({
107+
action: confirmAction,
108+
expectedRefName: newBranchName,
109+
});
105110
}, [
111+
branchName,
106112
canChangeThreadBranch,
107113
confirmAction,
108114
gitActions,
Collapse file

‎apps/mobile/src/features/threads/git/GitOverviewSheet.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
+23-4Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { useSelectedThreadGitActions } from "../../../state/use-selected-thread-
3232
import { useSelectedThreadGitState } from "../../../state/use-selected-thread-git-state";
3333
import { useSelectedThreadWorktree } from "../../../state/use-selected-thread-worktree";
3434
import { vcsEnvironment } from "../../../state/vcs";
35+
import { confirmCommitDuringRun } from "./confirmCommitDuringRun";
3536
import { menuItemIconName, statusSummary } from "./gitSheetComponents";
3637
import {
3738
LinkedPullRequestRow,
@@ -137,16 +138,35 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
137138
}
138139
};
139140

141+
const closeSheet = () => {
142+
if (!isInspector) navigation.goBack();
143+
else closeInspectorSheet?.();
144+
};
145+
140146
const runActionWithPrompt = async (input: GitActionRequestInput) => {
141147
if (!canWriteSourceControl) return;
148+
const branchName = gitStatus.data?.refName;
149+
const request = { ...input, ...(branchName ? { expectedRefName: branchName } : {}) };
150+
const decision = await confirmCommitDuringRun({
151+
thread: { environmentId, threadId },
152+
action: input.action,
153+
hasChanges: gitStatus.data?.hasWorkingTreeChanges === true,
154+
queuedRun: requiresDefaultBranchConfirmation(input.action, isDefaultRef)
155+
? null
156+
: () => void gitActions.onRunSelectedThreadGitAction(request),
157+
});
158+
if (decision === "cancelled") return;
159+
if (decision === "queued") {
160+
closeSheet();
161+
return;
162+
}
142163
const confirmableAction =
143164
input.action === "push" ||
144165
input.action === "create_pr" ||
145166
input.action === "commit_push" ||
146167
input.action === "commit_push_pr"
147168
? input.action
148169
: null;
149-
const branchName = gitStatus.data?.refName;
150170
if (
151171
branchName &&
152172
confirmableAction &&
@@ -168,9 +188,8 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
168188
}
169189

170190
// Close a sheet so the thread shows the action's progress.
171-
if (!isInspector) navigation.goBack();
172-
else closeInspectorSheet?.();
173-
await gitActions.onRunSelectedThreadGitAction(input);
191+
closeSheet();
192+
await gitActions.onRunSelectedThreadGitAction(request);
174193
};
175194

176195
const onPressMenuItem = async (item: (typeof menuItems)[number]) => {
Collapse file

‎apps/mobile/src/features/threads/git/confirmCommitDuringRun.ts‎

Copy file name to clipboard
+53Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { threadRuntimeIsActive } from "@t3tools/client-runtime/state/shell";
2+
import {
3+
ACTIVE_RUN_COMMIT_COPY,
4+
QUEUED_COMMIT_DROPPED_COPY,
5+
requiresActiveRunConfirmation,
6+
} from "@t3tools/client-runtime/state/vcs";
7+
import type { GitStackedAction, ScopedThreadRef } from "@t3tools/contracts";
8+
9+
import * as Dialog from "../../../components/ui/Dialog";
10+
import { appAtomRegistry } from "../../../state/atom-registry";
11+
import { environmentThreadShells } from "../../../state/threads";
12+
import { gitActionQueue } from "../../../state/vcs";
13+
14+
export function confirmCommitDuringRun(input: {
15+
readonly thread: ScopedThreadRef | null;
16+
readonly action: GitStackedAction;
17+
readonly hasChanges: boolean;
18+
readonly queuedRun: (() => void) | null;
19+
}): Promise<"proceed" | "queued" | "cancelled"> {
20+
const { thread, queuedRun } = input;
21+
// A native menu keeps the closure from when it opened, and a run can start while it is open.
22+
const shell =
23+
thread === null ? null : appAtomRegistry.get(environmentThreadShells.threadShellAtom(thread));
24+
const isThreadRunning = threadRuntimeIsActive(shell?.runtime);
25+
if (!requiresActiveRunConfirmation(input.action, isThreadRunning, input.hasChanges)) {
26+
return Promise.resolve("proceed");
27+
}
28+
return new Promise((resolve) => {
29+
Dialog.alert(ACTIVE_RUN_COMMIT_COPY.title, ACTIVE_RUN_COMMIT_COPY.description, [
30+
...(thread !== null && queuedRun !== null
31+
? [
32+
{
33+
text: ACTIVE_RUN_COMMIT_COPY.queueLabel,
34+
onPress: () => {
35+
gitActionQueue.enqueue(thread, {
36+
action: input.action,
37+
run: queuedRun,
38+
onDropped: () =>
39+
Dialog.alert(
40+
QUEUED_COMMIT_DROPPED_COPY.title,
41+
QUEUED_COMMIT_DROPPED_COPY.description,
42+
),
43+
});
44+
resolve("queued");
45+
},
46+
},
47+
]
48+
: []),
49+
{ text: ACTIVE_RUN_COMMIT_COPY.continueLabel, onPress: () => resolve("proceed") },
50+
{ text: "Cancel", style: "cancel", onPress: () => resolve("cancelled") },
51+
]);
52+
});
53+
}
Collapse file

‎apps/mobile/src/state/use-selected-thread-git-actions.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/state/use-selected-thread-git-actions.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ export function useSelectedThreadGitActions() {
368368
actionId,
369369
action: input.action,
370370
...(input.commitMessage ? { commitMessage: input.commitMessage } : {}),
371+
...(input.expectedRefName ? { expectedRefName: input.expectedRefName } : {}),
371372
...(input.featureBranch ? { featureBranch: input.featureBranch } : {}),
372373
...(input.filePaths?.length ? { filePaths: [...input.filePaths] } : {}),
373374
threadId: thread.id,
Collapse file

‎apps/mobile/src/state/vcs.ts‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import {
2+
createGitActionQueue,
23
createVcsActionManager,
34
createVcsEnvironmentAtoms,
45
} from "@t3tools/client-runtime/state/vcs";
56

67
import { connectionAtomRuntime } from "../connection/runtime";
8+
import { appAtomRegistry } from "./atom-registry";
9+
import { environmentThreadShells } from "./threads";
710

811
export const vcsEnvironment = createVcsEnvironmentAtoms(connectionAtomRuntime);
912
export const vcsActionManager = createVcsActionManager(connectionAtomRuntime);
13+
export const gitActionQueue = createGitActionQueue({
14+
registry: appAtomRegistry,
15+
threadShellAtom: environmentThreadShells.threadShellAtom,
16+
});

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.