Split stacked git actions into push and create_pr

- Replace push/PR flags with explicit actions
- Update server, web, and contract schemas for clearer progress handling
- Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marminge committed 2026-04-01 14:59:47 -07:00
1 parent 604bdb8367
commit 5dc3c21250
10 files changed
+211 -118

No files matched your search

+83 -10
View File
@@ -570,11 +570,10 @@ function runStackedAction(
manager: GitManagerShape,
input: {
cwd: string;
action: "commit" | "commit_push" | "commit_push_pr";
action: "commit" | "push" | "create_pr" | "commit_push" | "commit_push_pr";
actionId?: string;
commitMessage?: string;
featureBranch?: boolean;
prOnlyIfReady?: boolean;
filePaths?: readonly string[];
},
options?: Parameters<GitManagerShape["runStackedAction"]>[1],
@@ -1048,8 +1047,9 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
cta: {
kind: "run_action",
label: "Push",
action: "commit_push",
forcePushOnlyProgress: true,
action: {
kind: "push",
},
},
});
expect(result.toast.title).toMatch(/^Committed [0-9a-f]{7}$/);
@@ -1167,9 +1167,9 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
cta: {
kind: "run_action",
label: "Create PR",
action: "commit_push_pr",
prOnlyIfReady: true,
isDefaultBranch: false,
action: {
kind: "create_pr",
},
},
});
expect(result.toast.title).toMatch(
@@ -1371,6 +1371,80 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
}),
);
it.effect("pushes existing clean commits without rerunning commit logic", () =>
Effect.gen(function* () {
const repoDir = yield* makeTempDir("t3code-git-manager-");
yield* initRepo(repoDir);
yield* runGit(repoDir, ["checkout", "-b", "feature/push-only"]);
const remoteDir = yield* createBareRemote();
yield* runGit(repoDir, ["remote", "add", "origin", remoteDir]);
fs.writeFileSync(path.join(repoDir, "push-only.txt"), "push only\n");
yield* runGit(repoDir, ["add", "push-only.txt"]);
yield* runGit(repoDir, ["commit", "-m", "Push only branch"]);
const { manager } = yield* makeManager();
const result = yield* runStackedAction(manager, {
cwd: repoDir,
action: "push",
});
expect(result.commit.status).toBe("skipped_no_changes");
expect(result.push.status).toBe("pushed");
expect(result.pr.status).toBe("skipped_not_requested");
expect(
yield* runGit(repoDir, ["rev-parse", "--abbrev-ref", "@{upstream}"]).pipe(
Effect.map((output) => output.stdout.trim()),
),
).toBe("origin/feature/push-only");
}),
);
it.effect("create_pr pushes a clean branch before creating the PR when needed", () =>
Effect.gen(function* () {
const repoDir = yield* makeTempDir("t3code-git-manager-");
yield* initRepo(repoDir);
yield* runGit(repoDir, ["checkout", "-b", "feature/create-pr-only"]);
const remoteDir = yield* createBareRemote();
yield* runGit(repoDir, ["remote", "add", "origin", remoteDir]);
fs.writeFileSync(path.join(repoDir, "create-pr-only.txt"), "create pr\n");
yield* runGit(repoDir, ["add", "create-pr-only.txt"]);
yield* runGit(repoDir, ["commit", "-m", "Create PR only branch"]);
const { manager, ghCalls } = yield* makeManager({
ghScenario: {
prListSequence: [
"[]",
JSON.stringify([
{
number: 303,
title: "Create PR only branch",
url: "https://github.com/pingdotgg/codething-mvp/pull/303",
baseRefName: "main",
headRefName: "feature/create-pr-only",
},
]),
],
},
});
const result = yield* runStackedAction(manager, {
cwd: repoDir,
action: "create_pr",
});
expect(result.commit.status).toBe("skipped_no_changes");
expect(result.push.status).toBe("pushed");
expect(result.push.setUpstream).toBe(true);
expect(result.pr.status).toBe("created");
expect(result.pr.number).toBe(303);
expect(
ghCalls.some((call) =>
call.includes("pr create --base main --head feature/create-pr-only"),
),
).toBe(true);
}),
);
it.effect("returns existing PR metadata for commit/push/pr action", () =>
Effect.gen(function* () {
const repoDir = yield* makeTempDir("t3code-git-manager-");
@@ -2604,7 +2678,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
}),
);
it.effect("prOnlyIfReady emits only the PR phase when the branch is already pushed", () =>
it.effect("create_pr emits only the PR phase when the branch is already pushed", () =>
Effect.gen(function* () {
const repoDir = yield* makeTempDir("t3code-git-manager-");
yield* initRepo(repoDir);
@@ -2640,8 +2714,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
manager,
{
cwd: repoDir,
action: "commit_push_pr",
prOnlyIfReady: true,
action: "create_pr",
},
{
actionId: "action-pr-only",
+51 -25
View File
@@ -6,6 +6,7 @@ import {
GitActionProgressEvent,
GitActionProgressPhase,
GitRunStackedActionResult,
GitStackedAction,
ModelSelection,
} from "@t3tools/contracts";
import {
@@ -429,6 +430,12 @@ interface CommitAndBranchSuggestion {
commitMessage: string;
}
function isCommitAction(
action: GitStackedAction,
): action is "commit" | "commit_push" | "commit_push_pr" {
return action === "commit" || action === "commit_push" || action === "commit_push_pr";
}
function formatCommitMessage(subject: string, body: string): string {
const trimmedBody = body.trim();
if (trimmedBody.length === 0) {
@@ -542,7 +549,7 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
const serverSettingsService = yield* ServerSettingsService;
const createProgressEmitter = (
input: { cwd: string; action: "commit" | "commit_push" | "commit_push_pr" },
input: { cwd: string; action: GitStackedAction },
options?: GitRunStackedActionOptions,
) => {
const actionId = options?.actionId ?? randomUUID();
@@ -944,7 +951,7 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
}
: null;
const shouldLookupExistingOpenPr =
result.action === "commit_push" &&
(result.action === "commit_push" || result.action === "push") &&
result.push.status === "pushed" &&
result.branch.status !== "created" &&
!currentBranchIsDefault &&
@@ -968,10 +975,12 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
? {
kind: "run_action" as const,
label: "Push",
action: "commit_push" as const,
forcePushOnlyProgress: true,
action: { kind: "push" as const },
}
: (result.action === "commit_push" || result.action === "commit_push_pr") &&
: (result.action === "push" ||
result.action === "create_pr" ||
result.action === "commit_push" ||
result.action === "commit_push_pr") &&
openPr?.url &&
(!currentBranchIsDefault ||
result.pr.status === "created" ||
@@ -981,15 +990,13 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
label: "View PR",
url: openPr.url,
}
: result.action === "commit_push" &&
: (result.action === "push" || result.action === "commit_push") &&
result.push.status === "pushed" &&
!currentBranchIsDefault
? {
kind: "run_action" as const,
label: "Create PR",
action: "commit_push_pr" as const,
prOnlyIfReady: true,
isDefaultBranch: false,
action: { kind: "create_pr" as const },
}
: {
kind: "none" as const,
@@ -1484,19 +1491,37 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
GitManagerServiceError
> {
const initialStatus = yield* gitCore.statusDetails(input.cwd);
const prOnlyIfReady =
input.action === "commit_push_pr" &&
input.prOnlyIfReady === true &&
!input.featureBranch &&
initialStatus.branch !== null &&
!initialStatus.hasWorkingTreeChanges &&
initialStatus.hasUpstream &&
initialStatus.aheadCount === 0;
const wantsPush = input.action !== "commit" && !prOnlyIfReady;
const wantsPr = input.action === "commit_push_pr";
const wantsCommit = isCommitAction(input.action);
const wantsPush =
input.action === "push" ||
input.action === "commit_push" ||
input.action === "commit_push_pr" ||
(input.action === "create_pr" &&
(!initialStatus.hasUpstream || initialStatus.aheadCount > 0));
const wantsPr = input.action === "create_pr" || input.action === "commit_push_pr";
if (input.featureBranch && !wantsCommit) {
return yield* gitManagerError(
"runStackedAction",
"Feature-branch checkout is only supported for commit actions.",
);
}
if (input.action === "push" && initialStatus.hasWorkingTreeChanges) {
return yield* gitManagerError(
"runStackedAction",
"Commit or stash local changes before pushing.",
);
}
if (input.action === "create_pr" && initialStatus.hasWorkingTreeChanges) {
return yield* gitManagerError(
"runStackedAction",
"Commit local changes before creating a PR.",
);
}
const phases: GitActionProgressPhase[] = [
...(input.featureBranch ? (["branch"] as const) : []),
...(prOnlyIfReady ? [] : (["commit"] as const)),
...(wantsCommit ? (["commit"] as const) : []),
...(wantsPush ? (["push"] as const) : []),
...(wantsPr ? (["pr"] as const) : []),
];
@@ -1549,15 +1574,15 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
}
const currentBranch = branchStep.name ?? initialStatus.branch;
const commitAction = isCommitAction(input.action) ? input.action : null;
const commit = prOnlyIfReady
? { status: "skipped_no_changes" as const }
: yield* Ref.set(currentPhase, Option.some("commit")).pipe(
const commit = commitAction
? yield* Ref.set(currentPhase, Option.some("commit")).pipe(
Effect.flatMap(() =>
runCommitStep(
modelSelection,
input.cwd,
input.action,
commitAction,
currentBranch,
commitMessageForStep,
preResolvedCommitSuggestion,
@@ -1566,7 +1591,8 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
progress.actionId,
),
),
);
)
: { status: "skipped_no_changes" as const };
const push = wantsPush
? yield* progress
+1 -1
View File
@@ -56,7 +56,7 @@ export interface GitManagerShape {
) => Effect.Effect<GitPreparePullRequestThreadResult, GitManagerServiceError>;
/**
* Run a stacked Git action (`commit`, `commit_push`, `commit_push_pr`).
* Run a Git action (`commit`, `push`, `create_pr`, `commit_push`, `commit_push_pr`).
* When `featureBranch` is set, creates and checks out a feature branch first.
*/
readonly runStackedAction: (
+3 -2
View File
@@ -848,8 +848,9 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
cta: {
kind: "run_action" as const,
label: "Push",
action: "commit_push" as const,
forcePushOnlyProgress: true,
action: {
kind: "push" as const,
},
},
},
};
@@ -163,7 +163,7 @@ describe("when: branch is clean, ahead, and has an open PR", () => {
}),
false,
);
assert.deepInclude(quick, { kind: "run_action", action: "commit_push", label: "Push" });
assert.deepInclude(quick, { kind: "run_action", action: "push", label: "Push" });
});
it("buildMenuItems enables push and keeps open PR available", () => {
@@ -214,7 +214,7 @@ describe("when: branch is clean, ahead, and has no open PR", () => {
const quick = resolveQuickAction(status({ aheadCount: 2, pr: null }), false);
assert.deepInclude(quick, {
kind: "run_action",
action: "commit_push_pr",
action: "create_pr",
label: "Push & create PR",
});
});
@@ -586,7 +586,7 @@ describe("when: branch has no upstream configured", () => {
);
assert.deepInclude(quick, {
kind: "run_action",
action: "commit_push",
action: "push",
label: "Push",
disabled: false,
});
@@ -633,7 +633,7 @@ describe("when: branch has no upstream configured", () => {
);
assert.deepInclude(quick, {
kind: "run_action",
action: "commit_push_pr",
action: "create_pr",
label: "Push & create PR",
disabled: false,
});
@@ -856,34 +856,33 @@ describe("resolveDefaultBranchActionDialogCopy", () => {
});
describe("buildGitActionProgressStages", () => {
it("shows only push progress when push-only is forced", () => {
it("shows only push progress for explicit push actions", () => {
const stages = buildGitActionProgressStages({
action: "commit_push",
action: "push",
hasCustomCommitMessage: false,
hasWorkingTreeChanges: true,
forcePushOnly: true,
hasWorkingTreeChanges: false,
pushTarget: "origin/feature/test",
});
assert.deepEqual(stages, ["Pushing to origin/feature/test..."]);
});
it("skips commit stages for create-pr flow when push-only is forced", () => {
it("shows push and PR progress for create-pr actions that still need a push", () => {
const stages = buildGitActionProgressStages({
action: "commit_push_pr",
action: "create_pr",
hasCustomCommitMessage: false,
hasWorkingTreeChanges: true,
forcePushOnly: true,
hasWorkingTreeChanges: false,
pushTarget: "origin/feature/test",
shouldPushBeforePr: true,
});
assert.deepEqual(stages, ["Pushing to origin/feature/test...", "Creating PR..."]);
});
it("shows only PR progress when the follow-up action is already PR-ready", () => {
it("shows only PR progress when create-pr can skip the push", () => {
const stages = buildGitActionProgressStages({
action: "commit_push_pr",
action: "create_pr",
hasCustomCommitMessage: false,
hasWorkingTreeChanges: false,
prOnlyIfReady: true,
shouldPushBeforePr: false,
});
assert.deepEqual(stages, ["Creating PR..."]);
});
@@ -37,24 +37,26 @@ export function buildGitActionProgressStages(input: {
action: GitStackedAction;
hasCustomCommitMessage: boolean;
hasWorkingTreeChanges: boolean;
forcePushOnly?: boolean;
pushTarget?: string;
featureBranch?: boolean;
prOnlyIfReady?: boolean;
shouldPushBeforePr?: boolean;
}): string[] {
if (input.action === "commit_push_pr" && input.prOnlyIfReady) {
return ["Creating PR..."];
const branchStages = input.featureBranch ? ["Preparing feature branch..."] : [];
const pushStage = input.pushTarget ? `Pushing to ${input.pushTarget}...` : "Pushing...";
if (input.action === "push") {
return [pushStage];
}
if (input.action === "create_pr") {
return input.shouldPushBeforePr ? [pushStage, "Creating PR..."] : ["Creating PR..."];
}
const branchStages = input.featureBranch ? ["Preparing feature branch..."] : [];
const shouldIncludeCommitStages =
!input.forcePushOnly && (input.action === "commit" || input.hasWorkingTreeChanges);
const shouldIncludeCommitStages = input.action === "commit" || input.hasWorkingTreeChanges;
const commitStages = !shouldIncludeCommitStages
? []
: input.hasCustomCommitMessage
? ["Committing..."]
: ["Generating commit message...", "Committing..."];
const pushStage = input.pushTarget ? `Pushing to ${input.pushTarget}...` : "Pushing...";
if (input.action === "commit") {
return [...branchStages, ...commitStages];
}
@@ -204,13 +206,18 @@ export function resolveQuickAction(
};
}
if (hasOpenPr || isDefaultBranch) {
return { label: "Push", disabled: false, kind: "run_action", action: "commit_push" };
return {
label: "Push",
disabled: false,
kind: "run_action",
action: isDefaultBranch ? "commit_push" : "push",
};
}
return {
label: "Push & create PR",
disabled: false,
kind: "run_action",
action: "commit_push_pr",
action: "create_pr",
};
}
@@ -233,13 +240,18 @@ export function resolveQuickAction(
if (isAhead) {
if (hasOpenPr || isDefaultBranch) {
return { label: "Push", disabled: false, kind: "run_action", action: "commit_push" };
return {
label: "Push",
disabled: false,
kind: "run_action",
action: isDefaultBranch ? "commit_push" : "push",
};
}
return {
label: "Push & create PR",
disabled: false,
kind: "run_action",
action: "commit_push_pr",
action: "create_pr",
};
}
+16 -33
View File
@@ -64,7 +64,6 @@ interface PendingDefaultBranchAction {
branchName: string;
includesCommit: boolean;
commitMessage?: string;
forcePushOnlyProgress: boolean;
onConfirmed?: () => void;
filePaths?: string[];
}
@@ -85,13 +84,10 @@ interface ActiveGitActionProgress {
interface RunGitActionWithToastInput {
action: GitStackedAction;
commitMessage?: string;
forcePushOnlyProgress?: boolean;
onConfirmed?: () => void;
skipDefaultBranchPrompt?: boolean;
statusOverride?: GitStatusResult | null;
featureBranch?: boolean;
prOnlyIfReady?: boolean;
isDefaultBranchOverride?: boolean;
progressToastId?: GitActionToastId;
filePaths?: string[];
}
@@ -200,7 +196,9 @@ function GitQuickActionIcon({ quickAction }: { quickAction: GitQuickAction }) {
if (quickAction.kind === "run_pull") return <InfoIcon className={iconClassName} />;
if (quickAction.kind === "run_action") {
if (quickAction.action === "commit") return <GitCommitIcon className={iconClassName} />;
if (quickAction.action === "commit_push") return <CloudUploadIcon className={iconClassName} />;
if (quickAction.action === "push" || quickAction.action === "commit_push") {
return <CloudUploadIcon className={iconClassName} />;
}
return <GitHubIcon className={iconClassName} />;
}
if (quickAction.label === "Commit") return <GitCommitIcon className={iconClassName} />;
@@ -407,22 +405,21 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
async ({
action,
commitMessage,
forcePushOnlyProgress = false,
onConfirmed,
skipDefaultBranchPrompt = false,
statusOverride,
featureBranch = false,
prOnlyIfReady = false,
isDefaultBranchOverride,
progressToastId,
filePaths,
}: RunGitActionWithToastInput) => {
const actionStatus = statusOverride ?? gitStatusForActions;
const actionBranch = actionStatus?.branch ?? null;
const actionIsDefaultBranch =
isDefaultBranchOverride ?? (featureBranch ? false : isDefaultBranch);
const actionIsDefaultBranch = featureBranch ? false : isDefaultBranch;
const actionCanCommit =
action === "commit" || action === "commit_push" || action === "commit_push_pr";
const includesCommit =
!forcePushOnlyProgress && (action === "commit" || !!actionStatus?.hasWorkingTreeChanges);
actionCanCommit &&
(action === "commit" || !!actionStatus?.hasWorkingTreeChanges || featureBranch);
if (
!skipDefaultBranchPrompt &&
requiresDefaultBranchConfirmation(action, actionIsDefaultBranch) &&
@@ -436,7 +433,6 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
branchName: actionBranch,
includesCommit,
...(commitMessage ? { commitMessage } : {}),
forcePushOnlyProgress,
...(onConfirmed ? { onConfirmed } : {}),
...(filePaths ? { filePaths } : {}),
});
@@ -448,9 +444,10 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
action,
hasCustomCommitMessage: !!commitMessage?.trim(),
hasWorkingTreeChanges: !!actionStatus?.hasWorkingTreeChanges,
forcePushOnly: forcePushOnlyProgress,
featureBranch,
prOnlyIfReady,
shouldPushBeforePr:
action === "create_pr" &&
(!actionStatus?.hasUpstream || (actionStatus?.aheadCount ?? 0) > 0),
});
const actionId = randomUUID();
const resolvedProgressToastId =
@@ -545,7 +542,6 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
action,
...(commitMessage ? { commitMessage } : {}),
...(featureBranch ? { featureBranch } : {}),
...(prOnlyIfReady ? { prOnlyIfReady } : {}),
...(filePaths ? { filePaths } : {}),
onProgress: applyProgressEvent,
});
@@ -569,16 +565,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
onClick: () => {
closeResultToast();
void runGitActionWithToast({
action: toastCta.action,
...(toastCta.forcePushOnlyProgress !== undefined
? { forcePushOnlyProgress: toastCta.forcePushOnlyProgress }
: {}),
...(toastCta.prOnlyIfReady !== undefined
? { prOnlyIfReady: toastCta.prOnlyIfReady }
: {}),
...(toastCta.isDefaultBranch !== undefined
? { isDefaultBranchOverride: toastCta.isDefaultBranch }
: {}),
action: toastCta.action.kind,
});
},
};
@@ -619,13 +606,11 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
const continuePendingDefaultBranchAction = useCallback(() => {
if (!pendingDefaultBranchAction) return;
const { action, commitMessage, forcePushOnlyProgress, onConfirmed, filePaths } =
pendingDefaultBranchAction;
const { action, commitMessage, onConfirmed, filePaths } = pendingDefaultBranchAction;
setPendingDefaultBranchAction(null);
void runGitActionWithToast({
action,
...(commitMessage ? { commitMessage } : {}),
forcePushOnlyProgress,
...(onConfirmed ? { onConfirmed } : {}),
...(filePaths ? { filePaths } : {}),
skipDefaultBranchPrompt: true,
@@ -634,13 +619,11 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
const checkoutFeatureBranchAndContinuePendingAction = useCallback(() => {
if (!pendingDefaultBranchAction) return;
const { action, commitMessage, forcePushOnlyProgress, onConfirmed, filePaths } =
pendingDefaultBranchAction;
const { action, commitMessage, onConfirmed, filePaths } = pendingDefaultBranchAction;
setPendingDefaultBranchAction(null);
void runGitActionWithToast({
action,
...(commitMessage ? { commitMessage } : {}),
forcePushOnlyProgress,
...(onConfirmed ? { onConfirmed } : {}),
...(filePaths ? { filePaths } : {}),
featureBranch: true,
@@ -714,11 +697,11 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
return;
}
if (item.dialogAction === "push") {
void runGitActionWithToast({ action: "commit_push", forcePushOnlyProgress: true });
void runGitActionWithToast({ action: "push" });
return;
}
if (item.dialogAction === "create_pr") {
void runGitActionWithToast({ action: "commit_push_pr" });
void runGitActionWithToast({ action: "create_pr" });
return;
}
setExcludedFiles(new Set());
-3
View File
@@ -121,7 +121,6 @@ export function gitRunStackedActionMutationOptions(input: {
action,
commitMessage,
featureBranch,
prOnlyIfReady,
filePaths,
onProgress,
}: {
@@ -129,7 +128,6 @@ export function gitRunStackedActionMutationOptions(input: {
action: GitStackedAction;
commitMessage?: string;
featureBranch?: boolean;
prOnlyIfReady?: boolean;
filePaths?: string[];
onProgress?: (event: GitActionProgressEvent) => void;
}) => {
@@ -141,7 +139,6 @@ export function gitRunStackedActionMutationOptions(input: {
action,
...(commitMessage ? { commitMessage } : {}),
...(featureBranch ? { featureBranch } : {}),
...(prOnlyIfReady ? { prOnlyIfReady } : {}),
...(filePaths ? { filePaths } : {}),
},
...(onProgress ? [{ onProgress }] : []),
+7 -11
View File
@@ -62,17 +62,15 @@ describe("GitResolvePullRequestResult", () => {
});
describe("GitRunStackedActionInput", () => {
it("requires a client-provided actionId for progress correlation", () => {
it("accepts explicit stacked actions and requires a client-provided actionId", () => {
const parsed = decodeRunStackedActionInput({
actionId: "action-1",
cwd: "/repo",
action: "commit_push_pr",
prOnlyIfReady: true,
action: "create_pr",
});
expect(parsed.actionId).toBe("action-1");
expect(parsed.action).toBe("commit_push_pr");
expect(parsed.prOnlyIfReady).toBe(true);
expect(parsed.action).toBe("create_pr");
});
});
@@ -103,18 +101,16 @@ describe("GitRunStackedActionResult", () => {
cta: {
kind: "run_action",
label: "Create PR",
action: "commit_push_pr",
prOnlyIfReady: true,
isDefaultBranch: false,
action: {
kind: "create_pr",
},
},
},
});
expect(parsed.toast.cta.kind).toBe("run_action");
if (parsed.toast.cta.kind === "run_action") {
expect(parsed.toast.cta.action).toBe("commit_push_pr");
expect(parsed.toast.cta.prOnlyIfReady).toBe(true);
expect(parsed.toast.cta.isDefaultBranch).toBe(false);
expect(parsed.toast.cta.action.kind).toBe("create_pr");
}
});
});
+12 -6
View File
@@ -5,7 +5,13 @@ const TrimmedNonEmptyStringSchema = TrimmedNonEmptyString;
// Domain Types
export const GitStackedAction = Schema.Literals(["commit", "commit_push", "commit_push_pr"]);
export const GitStackedAction = Schema.Literals([
"commit",
"push",
"create_pr",
"commit_push",
"commit_push_pr",
]);
export type GitStackedAction = typeof GitStackedAction.Type;
export const GitActionProgressPhase = Schema.Literals(["branch", "commit", "push", "pr"]);
export type GitActionProgressPhase = typeof GitActionProgressPhase.Type;
@@ -33,6 +39,10 @@ const GitStatusPrState = Schema.Literals(["open", "closed", "merged"]);
const GitPullRequestReference = TrimmedNonEmptyStringSchema;
const GitPullRequestState = Schema.Literals(["open", "closed", "merged"]);
const GitPreparePullRequestThreadMode = Schema.Literals(["local", "worktree"]);
export const GitRunStackedActionToastRunAction = Schema.Struct({
kind: GitStackedAction,
});
export type GitRunStackedActionToastRunAction = typeof GitRunStackedActionToastRunAction.Type;
const GitRunStackedActionToastCta = Schema.Union([
Schema.Struct({
kind: Schema.Literal("none"),
@@ -45,10 +55,7 @@ const GitRunStackedActionToastCta = Schema.Union([
Schema.Struct({
kind: Schema.Literal("run_action"),
label: TrimmedNonEmptyStringSchema,
action: GitStackedAction,
forcePushOnlyProgress: Schema.optional(Schema.Boolean),
isDefaultBranch: Schema.optional(Schema.Boolean),
prOnlyIfReady: Schema.optional(Schema.Boolean),
action: GitRunStackedActionToastRunAction,
}),
]);
export type GitRunStackedActionToastCta = typeof GitRunStackedActionToastCta.Type;
@@ -101,7 +108,6 @@ export const GitRunStackedActionInput = Schema.Struct({
action: GitStackedAction,
commitMessage: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(10_000))),
featureBranch: Schema.optional(Schema.Boolean),
prOnlyIfReady: Schema.optional(Schema.Boolean),
filePaths: Schema.optional(
Schema.Array(TrimmedNonEmptyStringSchema).check(Schema.isMinLength(1)),
),