+
{activeThreadTitle}
{activeProjectName && (
-
+
{activeProjectName}
)}
@@ -89,7 +92,7 @@ export const ChatHeader = memo(function ChatHeader({
)}
-
+
{activeProjectScripts && (
=2.16.1", "react-native-reanimated": ">=3.16.0 || >=4.0.0-" }, "optionalPeers": ["@types/react", "@types/react-native"] }, "sha512-YwieCsEnTQnN2QW4VBKfCGszzxaw2ID7FydusEgqo7qB817fZ45N88kptcuNwZFnnauCjdyzKdrVBWmLmpl9oQ=="],
+
+ "@gorhom/portal": ["@gorhom/portal@1.0.14", "", { "dependencies": { "nanoid": "^3.3.1" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-MXyL4xvCjmgaORr/rtryDNFy3kU4qUbKlwtQqqsygd0xX3mhKjOLn6mQK8wfu0RkoE0pBE0nAasRoHua+/QZ7A=="],
+
"@hono/node-server": ["@hono/node-server@1.19.14", "", { "peerDependencies": { "hono": "^4" } }, "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw=="],
"@img/colour": ["@img/colour@1.1.0", "", {}, "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ=="],
@@ -907,6 +918,8 @@
"@react-native-masked-view/masked-view": ["@react-native-masked-view/masked-view@0.3.2", "", { "peerDependencies": { "react": ">=16", "react-native": ">=0.57" } }, "sha512-XwuQoW7/GEgWRMovOQtX3A4PrXhyaZm0lVUiY8qJDvdngjLms9Cpdck6SmGAUNqQwcj2EadHC1HwL0bEyoa/SQ=="],
+ "@react-native-menu/menu": ["@react-native-menu/menu@2.0.0", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-hb8Mirw6aKPGONhgo52IiNpwHtISVrgCT3rMdFX1qS7eOFNzOcQh8d2UDnaH5zVpxN+QuvWtaaiRMGFpIjzdtA=="],
+
"@react-native/assets-registry": ["@react-native/assets-registry@0.83.4", "", {}, "sha512-aqKtpbJDSQeSX/Dwv0yMe1/Rd2QfXi12lnyZDXNn/OEKz59u6+LuPBVgO/9CRyclHmdlvwg8c7PJ9eX2ZMnjWg=="],
"@react-native/babel-plugin-codegen": ["@react-native/babel-plugin-codegen@0.83.4", "", { "dependencies": { "@babel/traverse": "^7.25.3", "@react-native/codegen": "0.83.4" } }, "sha512-UFsK+c1rvT84XZfzpmwKePsc5nTr5LK7hh18TI0DooNlVcztDbMDsQZpDnhO/gmk7aTbWEqO5AB3HJ7tvGp+Jg=="],
@@ -1109,12 +1122,16 @@
"@types/deep-eql": ["@types/deep-eql@4.0.2", "", {}, "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw=="],
+ "@types/emscripten": ["@types/emscripten@1.41.5", "", {}, "sha512-cMQm7pxu6BxtHyqJ7mQZ2kXWV5SLmugybFdHCBbJ5eHzOo6VhBckEgAT3//rP5FwPHNPeEiq4SmQ5ucBwsOo4Q=="],
+
"@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
"@types/estree-jsx": ["@types/estree-jsx@1.0.5", "", { "dependencies": { "@types/estree": "*" } }, "sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg=="],
"@types/graceful-fs": ["@types/graceful-fs@4.1.9", "", { "dependencies": { "@types/node": "*" } }, "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ=="],
+ "@types/hammerjs": ["@types/hammerjs@2.0.46", "", {}, "sha512-ynRvcq6wvqexJ9brDMS4BnBLzmr0e14d6ZJTEShTBWKymQiHwlAyGu0ZPEFI2Fh1U53F7tN9ufClWM5KvqkKOw=="],
+
"@types/hast": ["@types/hast@3.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
"@types/http-cache-semantics": ["@types/http-cache-semantics@4.2.0", "", {}, "sha512-L3LgimLHXtGkWikKnsPg0/VFx9OGZaC+eN1u4r+OB1XRqH3meBIAVC2zr1WdMH+RHmnRkqliQAOHNJ/E0j/e0Q=="],
@@ -1141,6 +1158,8 @@
"@types/react-dom": ["@types/react-dom@19.2.3", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ=="],
+ "@types/react-test-renderer": ["@types/react-test-renderer@19.1.0", "", { "dependencies": { "@types/react": "*" } }, "sha512-XD0WZrHqjNrxA/MaR9O22w/RNidWR9YZmBdRGI7wcnWGrv/3dA8wKCJ8m63Sn+tLJhcjmuhOi629N66W6kgWzQ=="],
+
"@types/responselike": ["@types/responselike@1.0.3", "", { "dependencies": { "@types/node": "*" } }, "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw=="],
"@types/stack-utils": ["@types/stack-utils@2.0.3", "", {}, "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw=="],
@@ -1279,6 +1298,8 @@
"balanced-match": ["balanced-match@4.0.4", "", {}, "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA=="],
+ "barcode-detector": ["barcode-detector@3.1.2", "", { "dependencies": { "zxing-wasm": "3.0.2" } }, "sha512-Q5kjXpVH5I3ItykNzbWmfWnNryFN1ZTWp10k9/PKJuS0RnoKR7jTrHEJODR4fn04bRomq7TJwie/Dr9fj/GoGQ=="],
+
"base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="],
"baseline-browser-mapping": ["baseline-browser-mapping@2.10.18", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-VSnGQAOLtP5mib/DPyg2/t+Tlv65NTBz83BJBJvmLVHHuKJVaDOBvJJykiT5TR++em5nfAySPccDZDa4oSrn8A=="],
@@ -1567,6 +1588,8 @@
"expo-asset": ["expo-asset@55.0.15", "", { "dependencies": { "@expo/image-utils": "^0.8.13", "expo-constants": "~55.0.14" }, "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-d3FIpHJ6ZngYXxRItYWBGT5H8Wkk7/l4fMe8Mmd2xDyKrO0/CM7c8r/J5M71D+BJr5P3My8wertGYZXHSiZYxQ=="],
+ "expo-camera": ["expo-camera@55.0.15", "", { "dependencies": { "barcode-detector": "^3.0.0" }, "peerDependencies": { "expo": "*", "react": "*", "react-native": "*", "react-native-web": "*" }, "optionalPeers": ["react-native-web"] }, "sha512-WRVsZf+2p7EsxudwyiUMYijJS8M98t/BVP6yG7N+08JSUotkGjmZcemom1gM36uy27P8QsSVP0hD+FravmQiBA=="],
+
"expo-clipboard": ["expo-clipboard@55.0.13", "", { "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-PrOmmuVsGW4bAkNQmGKtxMXj3invsfN+jfIKmQxHwE/dn7ODqwFWviUTa+PMUjP3XZmYCDLyu/i0GLeu7HF9Ew=="],
"expo-constants": ["expo-constants@55.0.14", "", { "dependencies": { "@expo/config": "~55.0.15", "@expo/env": "~2.1.1" }, "peerDependencies": { "expo": "*", "react-native": "*" } }, "sha512-l23QVQCYBPKT5zbxxZdJeuhiunadvWdjcQ9+GC8h+02jCoLmWRk20064nCINnQTP3Hf+uLPteUiwYrJd0e446w=="],
@@ -1747,6 +1770,8 @@
"hermes-parser": ["hermes-parser@0.32.1", "", { "dependencies": { "hermes-estree": "0.32.1" } }, "sha512-175dz634X/W5AiwrpLdoMl/MOb17poLHyIqgyExlE8D9zQ1OPnoORnGMB5ltRKnpvQzBjMYvT2rN/sHeIfZW5Q=="],
+ "hoist-non-react-statics": ["hoist-non-react-statics@3.3.2", "", { "dependencies": { "react-is": "^16.7.0" } }, "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw=="],
+
"hono": ["hono@4.12.12", "", {}, "sha512-p1JfQMKaceuCbpJKAPKVqyqviZdS0eUxH9v82oWo1kb9xjQ5wA6iP3FNVAPDFlz5/p7d45lO+BpSk1tuSZMF4Q=="],
"hookable": ["hookable@6.1.0", "", {}, "sha512-ZoKZSJgu8voGK2geJS+6YtYjvIzu9AOM/KZXsBxr83uhLL++e9pEv/dlgwgy3dvHg06kTz6JOh1hk3C8Ceiymw=="],
@@ -2333,6 +2358,8 @@
"react-native-fit-image": ["react-native-fit-image@1.5.5", "", { "dependencies": { "prop-types": "^15.5.10" } }, "sha512-Wl3Vq2DQzxgsWKuW4USfck9zS7YzhvLNPpkwUUCF90bL32e1a0zOVQ3WsJILJOwzmPdHfzZmWasiiAUNBkhNkg=="],
+ "react-native-gesture-handler": ["react-native-gesture-handler@2.31.1", "", { "dependencies": { "@egjs/hammerjs": "^2.0.17", "@types/react-test-renderer": "^19.1.0", "hoist-non-react-statics": "^3.3.0", "invariant": "^2.2.4" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-wQDlECdEzHhYKTnQXFnSqWUtJ5TS3MGQi7EWvQczTnEVKfk6XVSBecnpWAoI/CqlYQ7IWMJEyutY6BxwEBoxeg=="],
+
"react-native-is-edge-to-edge": ["react-native-is-edge-to-edge@1.2.1", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-FLbPWl/MyYQWz+KwqOZsSyj2JmLKglHatd3xLZWskXOpRaio4LfEDEz8E/A6uD8QoTHW6Aobw1jbEwK7KMgR7Q=="],
"react-native-markdown-display": ["react-native-markdown-display@7.0.2", "", { "dependencies": { "css-to-react-native": "^3.0.0", "markdown-it": "^10.0.0", "prop-types": "^15.7.2", "react-native-fit-image": "^1.5.5" }, "peerDependencies": { "react": ">=16.2.0", "react-native": ">=0.50.4" } }, "sha512-Mn4wotMvMfLAwbX/huMLt202W5DsdpMO/kblk+6eUs55S57VVNni1gzZCh5qpznYLjIQELNh50VIozEfY6fvaQ=="],
@@ -2815,6 +2842,8 @@
"zwitch": ["zwitch@2.0.4", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
+ "zxing-wasm": ["zxing-wasm@3.0.2", "", { "dependencies": { "@types/emscripten": "^1.41.5", "type-fest": "^5.5.0" } }, "sha512-2YMAriaYHX9wrBY2k7H0epSo+dyCaCZg/vOtt+nEDXM9ul480gkXz/9SkwpOeHcD2H5qqDG8lWDSBwpTcZpa6w=="],
+
"@astrojs/language-server/@astrojs/compiler": ["@astrojs/compiler@2.13.1", "", {}, "sha512-f3FN83d2G/v32ipNClRKgYv30onQlMZX1vCeZMjPsMMPl1mDpmbl0+N5BYo4S/ofzqJyS5hvwacEo0CCVDn/Qg=="],
"@babel/code-frame/@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.28.5", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
@@ -2971,6 +3000,8 @@
"h3/cookie-es": ["cookie-es@1.2.3", "", {}, "sha512-lXVyvUvrNXblMqzIRrxHb57UUVmqsSWlxqt3XIjCkUP0wDAf6uicO6KMbEgYrMNtEvWgWHwe42CKxPu9MYAnWw=="],
+ "hoist-non-react-statics/react-is": ["react-is@16.13.1", "", {}, "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="],
+
"hosted-git-info/lru-cache": ["lru-cache@10.4.3", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],
"istanbul-lib-instrument/semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
diff --git a/packages/client-runtime/package.json b/packages/client-runtime/package.json
index bfe2d7828e..83afc7c770 100644
--- a/packages/client-runtime/package.json
+++ b/packages/client-runtime/package.json
@@ -3,10 +3,15 @@
"version": "0.0.0-alpha.1",
"private": true,
"type": "module",
+ "main": "./src/index.ts",
+ "types": "./src/index.ts",
"exports": {
".": {
"types": "./src/index.ts",
- "import": "./src/index.ts"
+ "react-native": "./src/index.ts",
+ "import": "./src/index.ts",
+ "require": "./src/index.ts",
+ "default": "./src/index.ts"
}
},
"scripts": {
diff --git a/packages/client-runtime/src/gitActions.ts b/packages/client-runtime/src/gitActions.ts
new file mode 100644
index 0000000000..97bd22557e
--- /dev/null
+++ b/packages/client-runtime/src/gitActions.ts
@@ -0,0 +1,430 @@
+import type {
+ GitRunStackedActionInput,
+ GitRunStackedActionResult,
+ GitStackedAction,
+ GitStatusResult,
+} from "@t3tools/contracts";
+
+export type GitActionIconName = "commit" | "push" | "pr";
+
+export type GitDialogAction = "commit" | "push" | "create_pr";
+
+export interface GitActionMenuItem {
+ id: "commit" | "push" | "pr";
+ label: string;
+ disabled: boolean;
+ icon: GitActionIconName;
+ kind: "open_dialog" | "open_pr";
+ dialogAction?: GitDialogAction;
+}
+
+export interface GitQuickAction {
+ label: string;
+ disabled: boolean;
+ kind: "run_action" | "run_pull" | "open_pr" | "show_hint";
+ action?: GitStackedAction;
+ hint?: string;
+}
+
+export interface DefaultBranchActionDialogCopy {
+ title: string;
+ description: string;
+ continueLabel: string;
+}
+
+export type DefaultBranchConfirmableAction =
+ | "push"
+ | "create_pr"
+ | "commit_push"
+ | "commit_push_pr";
+
+export type GitActionRequestInput = Pick<
+ GitRunStackedActionInput,
+ "action" | "commitMessage" | "featureBranch" | "filePaths"
+>;
+
+export function buildGitActionProgressStages(input: {
+ action: GitStackedAction;
+ hasCustomCommitMessage: boolean;
+ hasWorkingTreeChanges: boolean;
+ pushTarget?: string;
+ featureBranch?: boolean;
+ shouldPushBeforePr?: boolean;
+}): string[] {
+ const branchStages = input.featureBranch ? ["Preparing feature branch..."] : [];
+ const pushStage = input.pushTarget ? `Pushing to ${input.pushTarget}...` : "Pushing...";
+ const prStages = [
+ "Preparing PR...",
+ "Generating PR content...",
+ "Creating GitHub pull request...",
+ ];
+
+ if (input.action === "push") {
+ return [pushStage];
+ }
+ if (input.action === "create_pr") {
+ return input.shouldPushBeforePr ? [pushStage, ...prStages] : prStages;
+ }
+
+ const shouldIncludeCommitStages = input.action === "commit" || input.hasWorkingTreeChanges;
+ const commitStages = !shouldIncludeCommitStages
+ ? []
+ : input.hasCustomCommitMessage
+ ? ["Committing..."]
+ : ["Generating commit message...", "Committing..."];
+ if (input.action === "commit") {
+ return [...branchStages, ...commitStages];
+ }
+ if (input.action === "commit_push") {
+ return [...branchStages, ...commitStages, pushStage];
+ }
+ return [...branchStages, ...commitStages, pushStage, ...prStages];
+}
+
+export function buildMenuItems(
+ gitStatus: GitStatusResult | null,
+ isBusy: boolean,
+ hasOriginRemote = true,
+): GitActionMenuItem[] {
+ if (!gitStatus) return [];
+
+ const hasBranch = gitStatus.branch !== null;
+ const hasChanges = gitStatus.hasWorkingTreeChanges;
+ const hasOpenPr = gitStatus.pr?.state === "open";
+ const isBehind = gitStatus.behindCount > 0;
+ const canPushWithoutUpstream = hasOriginRemote && !gitStatus.hasUpstream;
+ const canCommit = !isBusy && hasChanges;
+ const canPush =
+ !isBusy &&
+ hasBranch &&
+ !hasChanges &&
+ !isBehind &&
+ gitStatus.aheadCount > 0 &&
+ (gitStatus.hasUpstream || canPushWithoutUpstream);
+ const canCreatePr =
+ !isBusy &&
+ hasBranch &&
+ !hasChanges &&
+ !hasOpenPr &&
+ gitStatus.aheadCount > 0 &&
+ !isBehind &&
+ (gitStatus.hasUpstream || canPushWithoutUpstream);
+ const canOpenPr = !isBusy && hasOpenPr;
+
+ return [
+ {
+ id: "commit",
+ label: "Commit",
+ disabled: !canCommit,
+ icon: "commit",
+ kind: "open_dialog",
+ dialogAction: "commit",
+ },
+ {
+ id: "push",
+ label: "Push",
+ disabled: !canPush,
+ icon: "push",
+ kind: "open_dialog",
+ dialogAction: "push",
+ },
+ hasOpenPr
+ ? {
+ id: "pr",
+ label: "View PR",
+ disabled: !canOpenPr,
+ icon: "pr",
+ kind: "open_pr",
+ }
+ : {
+ id: "pr",
+ label: "Create PR",
+ disabled: !canCreatePr,
+ icon: "pr",
+ kind: "open_dialog",
+ dialogAction: "create_pr",
+ },
+ ];
+}
+
+export function resolveQuickAction(
+ gitStatus: GitStatusResult | null,
+ isBusy: boolean,
+ isDefaultBranch = false,
+ hasOriginRemote = true,
+): GitQuickAction {
+ if (isBusy) {
+ return { label: "Commit", disabled: true, kind: "show_hint", hint: "Git action in progress." };
+ }
+
+ if (!gitStatus) {
+ return {
+ label: "Commit",
+ disabled: true,
+ kind: "show_hint",
+ hint: "Git status is unavailable.",
+ };
+ }
+
+ const hasBranch = gitStatus.branch !== null;
+ const hasChanges = gitStatus.hasWorkingTreeChanges;
+ const hasOpenPr = gitStatus.pr?.state === "open";
+ const isAhead = gitStatus.aheadCount > 0;
+ const isBehind = gitStatus.behindCount > 0;
+ const isDiverged = isAhead && isBehind;
+
+ if (!hasBranch) {
+ return {
+ label: "Commit",
+ disabled: true,
+ kind: "show_hint",
+ hint: "Create and checkout a branch before pushing or opening a PR.",
+ };
+ }
+
+ if (hasChanges) {
+ if (!gitStatus.hasUpstream && !hasOriginRemote) {
+ return { label: "Commit", disabled: false, kind: "run_action", action: "commit" };
+ }
+ if (hasOpenPr || isDefaultBranch) {
+ return { label: "Commit & push", disabled: false, kind: "run_action", action: "commit_push" };
+ }
+ return {
+ label: "Commit, push & PR",
+ disabled: false,
+ kind: "run_action",
+ action: "commit_push_pr",
+ };
+ }
+
+ if (!gitStatus.hasUpstream) {
+ if (!hasOriginRemote) {
+ if (hasOpenPr && !isAhead) {
+ return { label: "View PR", disabled: false, kind: "open_pr" };
+ }
+ return {
+ label: "Push",
+ disabled: true,
+ kind: "show_hint",
+ hint: 'Add an "origin" remote before pushing or creating a PR.',
+ };
+ }
+ if (!isAhead) {
+ if (hasOpenPr) {
+ return { label: "View PR", disabled: false, kind: "open_pr" };
+ }
+ return {
+ label: "Push",
+ disabled: true,
+ kind: "show_hint",
+ hint: "No local commits to push.",
+ };
+ }
+ if (hasOpenPr || isDefaultBranch) {
+ return {
+ label: "Push",
+ disabled: false,
+ kind: "run_action",
+ action: isDefaultBranch ? "commit_push" : "push",
+ };
+ }
+ return {
+ label: "Push & create PR",
+ disabled: false,
+ kind: "run_action",
+ action: "create_pr",
+ };
+ }
+
+ if (isDiverged) {
+ return {
+ label: "Sync branch",
+ disabled: true,
+ kind: "show_hint",
+ hint: "Branch has diverged from upstream. Rebase/merge first.",
+ };
+ }
+
+ if (isBehind) {
+ return {
+ label: "Pull",
+ disabled: false,
+ kind: "run_pull",
+ };
+ }
+
+ if (isAhead) {
+ if (hasOpenPr || isDefaultBranch) {
+ return {
+ label: "Push",
+ disabled: false,
+ kind: "run_action",
+ action: isDefaultBranch ? "commit_push" : "push",
+ };
+ }
+ return {
+ label: "Push & create PR",
+ disabled: false,
+ kind: "run_action",
+ action: "create_pr",
+ };
+ }
+
+ if (hasOpenPr && gitStatus.hasUpstream) {
+ return { label: "View PR", disabled: false, kind: "open_pr" };
+ }
+
+ return {
+ label: "Commit",
+ disabled: true,
+ kind: "show_hint",
+ hint: "Branch is up to date. No action needed.",
+ };
+}
+
+export function getGitActionDisabledReason(input: {
+ item: GitActionMenuItem;
+ gitStatus: GitStatusResult | null;
+ isBusy: boolean;
+ hasOriginRemote: boolean;
+}): string | null {
+ const { item, gitStatus, isBusy, hasOriginRemote } = input;
+ if (!item.disabled) return null;
+ if (isBusy) return "Git action in progress.";
+ if (!gitStatus) return "Git status is unavailable.";
+
+ const hasBranch = gitStatus.branch !== null;
+ const hasChanges = gitStatus.hasWorkingTreeChanges;
+ const hasOpenPr = gitStatus.pr?.state === "open";
+ const isAhead = gitStatus.aheadCount > 0;
+ const isBehind = gitStatus.behindCount > 0;
+
+ if (item.id === "commit") {
+ if (!hasChanges) {
+ return "Worktree is clean. Make changes before committing.";
+ }
+ return "Commit is currently unavailable.";
+ }
+
+ if (item.id === "push") {
+ if (!hasBranch) {
+ return "Detached HEAD: checkout a branch before pushing.";
+ }
+ if (hasChanges) {
+ return "Commit or stash local changes before pushing.";
+ }
+ if (isBehind) {
+ return "Branch is behind upstream. Pull/rebase before pushing.";
+ }
+ if (!gitStatus.hasUpstream && !hasOriginRemote) {
+ return 'Add an "origin" remote before pushing.';
+ }
+ if (!isAhead) {
+ return "No local commits to push.";
+ }
+ return "Push is currently unavailable.";
+ }
+
+ if (hasOpenPr) {
+ return "View PR is currently unavailable.";
+ }
+ if (!hasBranch) {
+ return "Detached HEAD: checkout a branch before creating a PR.";
+ }
+ if (hasChanges) {
+ return "Commit local changes before creating a PR.";
+ }
+ if (!gitStatus.hasUpstream && !hasOriginRemote) {
+ return 'Add an "origin" remote before creating a PR.';
+ }
+ if (!isAhead) {
+ return "No local commits to include in a PR.";
+ }
+ if (isBehind) {
+ return "Branch is behind upstream. Pull/rebase before creating a PR.";
+ }
+ return "Create PR is currently unavailable.";
+}
+
+export function requiresDefaultBranchConfirmation(
+ action: GitStackedAction,
+ isDefaultBranch: boolean,
+): boolean {
+ if (!isDefaultBranch) return false;
+ return (
+ action === "push" ||
+ action === "create_pr" ||
+ action === "commit_push" ||
+ action === "commit_push_pr"
+ );
+}
+
+export function resolveDefaultBranchActionDialogCopy(input: {
+ action: DefaultBranchConfirmableAction;
+ branchName: string;
+ includesCommit: boolean;
+}): DefaultBranchActionDialogCopy {
+ const branchLabel = input.branchName;
+ const suffix = ` on "${branchLabel}". You can continue on this branch or create a feature branch and run the same action there.`;
+
+ if (input.action === "push" || input.action === "commit_push") {
+ if (input.includesCommit) {
+ return {
+ title: "Commit & push to default branch?",
+ description: `This action will commit and push changes${suffix}`,
+ continueLabel: `Commit & push to ${branchLabel}`,
+ };
+ }
+ return {
+ title: "Push to default branch?",
+ description: `This action will push local commits${suffix}`,
+ continueLabel: `Push to ${branchLabel}`,
+ };
+ }
+
+ if (input.includesCommit) {
+ return {
+ title: "Commit, push & create PR from default branch?",
+ description: `This action will commit, push, and create a PR${suffix}`,
+ continueLabel: "Commit, push & create PR",
+ };
+ }
+ return {
+ title: "Push & create PR from default branch?",
+ description: `This action will push local commits and create a PR${suffix}`,
+ continueLabel: "Push & create PR",
+ };
+}
+
+export function resolveThreadBranchUpdate(
+ result: GitRunStackedActionResult,
+): { branch: string } | null {
+ if (result.branch.status !== "created" || !result.branch.name) {
+ return null;
+ }
+
+ return {
+ branch: result.branch.name,
+ };
+}
+
+export function resolveLiveThreadBranchUpdate(input: {
+ threadBranch: string | null;
+ gitStatus: GitStatusResult | null;
+}): { branch: string | null } | null {
+ if (!input.gitStatus) {
+ return null;
+ }
+
+ if (input.gitStatus.branch === null && input.threadBranch !== null) {
+ return null;
+ }
+
+ if (input.threadBranch === input.gitStatus.branch) {
+ return null;
+ }
+
+ return {
+ branch: input.gitStatus.branch,
+ };
+}
diff --git a/packages/client-runtime/src/index.ts b/packages/client-runtime/src/index.ts
index 5dd6b9afa5..8b32ce43f8 100644
--- a/packages/client-runtime/src/index.ts
+++ b/packages/client-runtime/src/index.ts
@@ -1,2 +1,3 @@
export * from "./knownEnvironment";
export * from "./scoped";
+export * from "./gitActions";