Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(git): branch off instead of committing on the default branch, and never hide the local state (#632)

Ruben Lütkea7e20faa6d97
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitHubRepoPicker.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitHubRepoPicker.tsx
index f68edc6652..89811180e3 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitHubRepoPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitHubRepoPicker.tsx
@@ -25,6 +25,53 @@ export function ConnectGitHubCard() {
);
}
+/**
+ * GitHub is connected but this folder has no repository picked yet. The local
+ * state stays on screen; this card offers the one click that adds pull
+ * requests and CI — the repository the folder's remote points at, or the list.
+ */
+export function ConnectRepositoryCard({
+ suggested,
+ busy,
+ onUse,
+ onChoose,
+}: {
+ suggested: string;
+ busy: boolean;
+ onUse: (repo: string) => void;
+ onChoose: () => void;
+}) {
+ const t = useT();
+ return (
+ <div data-testid="git-connect-repo" className="mx-3 my-2.5 space-y-2 rounded-lg border border-border/60 bg-muted/30 p-2.5">
+ <p className="text-[11.5px] leading-snug text-muted-foreground">{t("ide_side_panel.git.connect_repo_body")}</p>
+ <div className="flex flex-wrap items-center gap-1.5">
+ {suggested && (
+ <button
+ type="button"
+ data-testid="git-connect-suggested"
+ disabled={busy}
+ onClick={() => onUse(suggested)}
+ className="inline-flex h-7 max-w-full items-center gap-1.5 rounded-md bg-primary px-2.5 text-[11.5px] font-medium text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60"
+ >
+ {busy ? <Loader2 className="h-3 w-3 shrink-0 animate-spin" aria-hidden /> : <Github className="h-3 w-3 shrink-0" aria-hidden />}
+ <span className="truncate font-mono">{suggested}</span>
+ </button>
+ )}
+ <button
+ type="button"
+ data-testid="git-connect-choose"
+ disabled={busy}
+ onClick={onChoose}
+ className="inline-flex h-7 items-center rounded-md border border-border-strong px-2.5 text-[11.5px] font-medium text-foreground hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60"
+ >
+ {t(suggested ? "ide_side_panel.git.connect_repo_other" : "ide_side_panel.git.connect_repo_choose")}
+ </button>
+ </div>
+ </div>
+ );
+}
+
/**
* "Which of your GitHub repositories is this folder?" — asked once per
* folder. The repository the folder's git remote points at comes first,
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
index 51e08ad9f5..4a9db425f1 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
@@ -165,7 +165,7 @@ const REPOS = {
{ name: "o/r", description: "", private: false, fork: false, url: "", pushed_at: "" },
],
};
-const ACTION = /\/api\/agentic-ide\/git\/(fetch|pull|commit|switch|branch\/push|branch\/pull-request|branch\/update|branch\/delete)$/;
+const ACTION = /\/api\/agentic-ide\/git\/(fetch|pull|commit|switch|prepare|branch\/push|branch\/pull-request|branch\/update|branch\/delete)$/;
beforeEach(() => {
answer = OVERVIEW;
@@ -190,7 +190,16 @@ beforeEach(() => {
posts.push({ path: action[1], body: JSON.parse(String(init.body)) });
const refusal = refusals[action[1]]?.shift();
if (refusal) return json({ detail: refusal[1] }, refusal[0]);
- return json({ ok: true, message: "Done.", upstream: "origin/feature/wip", commit: "abc1234", url: "https://github.com/o/r/pull/11" });
+ return json({
+ ok: true,
+ message: "Done.",
+ upstream: "origin/feature/wip",
+ commit: "abc1234",
+ url: "https://github.com/o/r/pull/11",
+ folder: "/code/app",
+ branch: String(posts.at(-1)?.body.branch ?? ""),
+ created: true,
+ });
}
if (url.includes("/github/repos")) return json(REPOS);
if (url.includes("/branch/contents")) return json(CONTENTS);
@@ -259,6 +268,30 @@ describe("GitOverviewTab — the checkout at a glance", () => {
await vi.waitFor(() => expect(screen.queryByTestId("git-commit-form")).toBeNull());
});
+ it("moves edits made on the default branch to a new branch instead of committing them there", async () => {
+ answer = {
+ ...withCheckout({ branch: "main", upstream: "origin/main", ahead: 0, files: 62, unstaged: 60, untracked: 2 }),
+ branch: "main",
+ branches: [branch("main", { current: true }), ...OVERVIEW.branches.slice(2)],
+ pull_requests: [pr(7, "open")],
+ };
+ render(<GitOverviewTab />);
+ const next = await screen.findByTestId("git-next");
+ expect(next.dataset.step).toBe("branch_off");
+ expect(next.textContent).toContain("Move 60 changed files to a branch");
+ expect(next.textContent).toContain("main is the default branch");
+ fireEvent.click(screen.getByTestId("git-next-action"));
+ expect((screen.getByTestId("git-branch-submit") as HTMLButtonElement).disabled).toBe(true);
+ fireEvent.change(screen.getByTestId("git-branch-name"), { target: { value: "feature/tidy-up" } });
+ fireEvent.click(screen.getByTestId("git-branch-submit"));
+ await vi.waitFor(() =>
+ expect(posted("prepare")).toEqual([{ folder: "/code/app", mode: "new_branch", branch: "feature/tidy-up", base: "" }]),
+ );
+ await vi.waitFor(() => expect(screen.queryByTestId("git-branch-form")).toBeNull());
+ // Committing on the default branch stays possible for whoever wants it, as the second choice.
+ expect(posted("commit")).toEqual([]);
+ });
+
it("opens the Changes tab to review what is uncommitted", async () => {
answer = withCheckout({ files: 1, unstaged: 1 });
render(<GitOverviewTab />);
@@ -755,9 +788,42 @@ describe("GitOverviewTab — connecting", () => {
expect((await screen.findByTestId("git-unavailable")).textContent).toContain("not a git repository");
});
- it("asks once which GitHub repository the folder is, recommending its remote", async () => {
+ it("shows the local state before a GitHub repository is picked, and connects the recommended one in a click", async () => {
+ answer = { ...OVERVIEW, github: { ...OVERVIEW.github, available: false, code: "needs_repo", repo: "", repo_url: "" } };
+ render(<GitOverviewTab />);
+ // Nothing is hidden behind the question: branch, sync and branches are all there.
+ expect((await screen.findByTestId("git-current-branch")).textContent).toBe("feature/wip");
+ expect(screen.getByTestId("git-sync-push").dataset.count).toBe("2");
+ expect(screen.getAllByTestId("git-branch-row")).toHaveLength(6);
+ expect(screen.queryByTestId("git-repo-picker")).toBeNull();
+ const card = screen.getByTestId("git-connect-repo");
+ expect(within(card).getByTestId("git-connect-suggested").textContent).toBe("o/r");
+ fireEvent.click(within(card).getByTestId("git-connect-suggested"));
+ await vi.waitFor(() => expect(puts).toEqual([JSON.stringify({ workspace_id: "w1", repo: "o/r" })]));
+ await vi.waitFor(() => expect(screen.queryByTestId("git-connect-repo")).toBeNull());
+ expect(await screen.findByTestId("git-section-prs")).toBeTruthy();
+ });
+
+ it("offers the list of repositories for a folder whose remote is not on GitHub", async () => {
+ answer = {
+ ...OVERVIEW,
+ github: { ...OVERVIEW.github, available: false, code: "needs_repo", repo: "", repo_url: "", suggested_repo: "" },
+ };
+ render(<GitOverviewTab />);
+ const card = await screen.findByTestId("git-connect-repo");
+ expect(within(card).queryByTestId("git-connect-suggested")).toBeNull();
+ expect(screen.getAllByTestId("git-branch-row")).toHaveLength(6);
+ fireEvent.click(within(card).getByTestId("git-connect-choose"));
+ await vi.waitFor(() => expect(screen.getAllByTestId("git-repo-choice")).toHaveLength(2));
+ // The list can be left again without picking; the local state comes back.
+ fireEvent.click(screen.getByLabelText("Keep the current repository"));
+ expect(await screen.findAllByTestId("git-branch-row")).toHaveLength(6);
+ });
+
+ it("asks which GitHub repository the folder is, recommending its remote", async () => {
answer = { ...OVERVIEW, github: { ...OVERVIEW.github, available: false, code: "needs_repo", repo: "", repo_url: "" } };
render(<GitOverviewTab />);
+ fireEvent.click(within(await screen.findByTestId("git-connect-repo")).getByTestId("git-connect-choose"));
// The recommendation is clickable at once; the rest of the list follows.
await vi.waitFor(() => expect(screen.getAllByTestId("git-repo-choice")).toHaveLength(2));
const choices = screen.getAllByTestId("git-repo-choice");
@@ -773,6 +839,7 @@ describe("GitOverviewTab — connecting", () => {
it("leaves the picker at once after a pick, while GitHub is still being read", async () => {
answer = { ...OVERVIEW, github: { ...OVERVIEW.github, available: false, code: "needs_repo", repo: "", repo_url: "" } };
render(<GitOverviewTab />);
+ fireEvent.click(within(await screen.findByTestId("git-connect-repo")).getByTestId("git-connect-choose"));
await vi.waitFor(() => expect(screen.getAllByTestId("git-repo-choice")).toHaveLength(2));
let release: () => void = () => {};
gate = new Promise<void>((resolve) => {
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
index 5b7a77109d..430a8c8748 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
@@ -14,9 +14,17 @@ import { BranchMenu } from "./BranchMenu";
import { CleanupDialog } from "./CleanupDialog";
import { ConfirmDialog } from "./ConfirmDialog";
import { agoLabel, LinkIcon } from "./gitBadges";
-import { ConnectGitHubCard, GitHubRepoPicker } from "./GitHubRepoPicker";
+import { ConnectGitHubCard, ConnectRepositoryCard, GitHubRepoPicker } from "./GitHubRepoPicker";
import { attention, canCleanUp, checkoutOf, openPullRequests, type AttentionItem, type BranchFilter } from "./gitInsights";
-import { fetchBranchEditors, fetchGitOverview, GitOverviewError, type BranchEditors, type BranchRow, type RepoOverview } from "./gitOverviewApi";
+import {
+ bindGitHubRepo,
+ fetchBranchEditors,
+ fetchGitOverview,
+ GitOverviewError,
+ type BranchEditors,
+ type BranchRow,
+ type RepoOverview,
+} from "./gitOverviewApi";
import { PullRequestList } from "./PullRequestList";
import { Section } from "./Section";
import { StatusPanel } from "./StatusPanel";
@@ -237,6 +245,8 @@ export function GitOverviewTab() {
// answer lands the tab shows the choice and the local branches, never the
// picker again — a picker that stays put reads as "the click did nothing".
const [pickedRepo, setPickedRepo] = useState("");
+ const [binding, setBinding] = useState(false);
+ const pushToast = useEventStore((state) => state.pushToast);
useEffect(() => setChanging(false), [workspaceId]);
useEffect(() => setPickedRepo(""), [data, workspaceId]);
useEffect(() => {
@@ -253,9 +263,20 @@ export function GitOverviewTab() {
return <p className="px-4 py-6 text-center text-xs text-muted-foreground">{t("ide_side_panel.git.no_workspace")}</p>;
}
const github = data?.github;
- const picking = Boolean(
- data && workspaceId && !pickedRepo && (github?.code === "needs_repo" || (changing && github?.code !== "not_connected")),
- );
+ // The list of repositories only opens when asked for: a folder without a
+ // repository picked still shows its local state, with a card that offers the pick.
+ const picking = Boolean(data && workspaceId && !pickedRepo && changing && github?.code !== "not_connected");
+ const connectRepository = (repo: string) => {
+ if (!workspaceId || binding) return;
+ setBinding(true);
+ bindGitHubRepo(workspaceId, repo)
+ .then(() => {
+ setPickedRepo(repo);
+ refresh();
+ })
+ .catch((err: Error) => pushToast("error", err.message))
+ .finally(() => setBinding(false));
+ };
const boundRepo = pickedRepo || github?.repo || "";
const repoName = (data?.root || workspace.path).replace(/\\/g, "/").split("/").filter(Boolean).pop() ?? workspace.name;
const checkout = data?.available ? checkoutOf(data) : null;
@@ -359,7 +380,7 @@ export function GitOverviewTab() {
setChanging(false);
refresh();
}}
- onCancel={github?.repo ? () => setChanging(false) : undefined}
+ onCancel={() => setChanging(false)}
/>
) : (
<div className="min-h-0 flex-1 overflow-y-auto">
@@ -384,6 +405,14 @@ export function GitOverviewTab() {
{!data.checkout && <OlderBackendNote />}
<StatusPanel key={workspace.id} overview={data} actions={actions} onOpenChanges={() => useIdeSidePanelStore.getState().openTab("changes")} />
{github?.code === "not_connected" && <ConnectGitHubCard />}
+ {github?.code === "needs_repo" && !pickedRepo && (
+ <ConnectRepositoryCard
+ suggested={github.suggested_repo}
+ busy={binding}
+ onUse={connectRepository}
+ onChoose={() => setChanging(true)}
+ />
+ )}
<AttentionList items={items} onAct={onAttention} />
{github?.available && (
<div ref={prsRef}>
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/StatusPanel.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/StatusPanel.tsx
index dba25a7410..a85cfdad3f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/StatusPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/StatusPanel.tsx
@@ -85,6 +85,13 @@ function describe(t: Translate, step: NextStep, overview: RepoOverview): StepVie
};
case "commit":
return { title: plural(t, "ide_side_panel.git.next.commit", step.count), reason: key("commit_reason"), action: key("commit_action"), tone: "action" };
+ case "branch_off":
+ return {
+ title: plural(t, "ide_side_panel.git.next.branch_off", step.count),
+ reason: fill(key("branch_off_reason"), { branch: overview.default_branch }),
+ action: key("branch_off_action"),
+ tone: "action",
+ };
case "rebase":
return {
title: fill(key("rebase"), { upstream }),
@@ -154,6 +161,8 @@ export function StatusPanel({
const tree = workingTree(t, overview);
const [composing, setComposing] = useState(false);
const [message, setMessage] = useState("");
+ const [naming, setNaming] = useState(false);
+ const [branchName, setBranchName] = useState("");
const tracking = Boolean(checkout.upstream) && !row?.upstream_gone && !checkout.detached;
const working = actions.busy !== "" && actions.busy === busyKey(step);
@@ -169,6 +178,8 @@ export function StatusPanel({
return actions.rebase();
case "commit":
return setComposing(true);
+ case "branch_off":
+ return setNaming(true);
case "publish":
case "push":
return actions.push();
@@ -197,6 +208,14 @@ export function StatusPanel({
if (tracking && checkout.ahead > 0 && checkout.behind === 0 && step.kind !== "push" && step.kind !== "resolve") {
extras.push({ id: "push", label: t("ide_side_panel.git.next.push_action"), run: () => actions.push() });
}
+ const startBranch = async () => {
+ const name = branchName.trim();
+ if (!name) return;
+ if (await actions.createBranch(name)) {
+ setBranchName("");
+ setNaming(false);
+ }
+ };
const commit = async () => {
if (!message.trim()) return;
if (await actions.commit(message.trim())) {
@@ -257,7 +276,46 @@ export function StatusPanel({
</p>
)}
- {composing ? (
+ {naming ? (
+ <div data-testid="git-branch-form" className="mt-2.5 space-y-1.5 rounded-lg border border-border/70 bg-secondary/40 p-2">
+ <input
+ data-testid="git-branch-name"
+ autoFocus
+ value={branchName}
+ onChange={(event) => setBranchName(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") void startBranch();
+ if (event.key === "Escape") {
+ event.stopPropagation();
+ setNaming(false);
+ }
+ }}
+ placeholder={t("ide_side_panel.git.branch.placeholder")}
+ aria-label={t("ide_side_panel.git.branch.placeholder")}
+ className="h-7 w-full rounded-md border border-border/70 bg-background px-2 font-mono text-[12px] text-foreground outline-none placeholder:font-sans placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring"
+ />
+ <p className="text-[10.5px] leading-snug text-muted-foreground">{t("ide_side_panel.git.branch.scope")}</p>
+ <div className="flex justify-end gap-1.5">
+ <button
+ type="button"
+ onClick={() => setNaming(false)}
+ className="h-7 rounded-md px-2.5 text-[11.5px] text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ {t("ide_side_panel.git.confirm.cancel")}
+ </button>
+ <button
+ type="button"
+ data-testid="git-branch-submit"
+ disabled={!branchName.trim() || actions.busy !== ""}
+ onClick={() => void startBranch()}
+ className="inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2.5 text-[11.5px] font-medium text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50"
+ >
+ {actions.busy.startsWith("branch:") && <Loader2 className="h-3 w-3 animate-spin motion-reduce:animate-none" aria-hidden />}
+ {t("ide_side_panel.git.branch.create")}
+ </button>
+ </div>
+ </div>
+ ) : composing ? (
<div data-testid="git-commit-form" className="mt-2.5 space-y-1.5 rounded-lg border border-border/70 bg-secondary/40 p-2">
<textarea
data-testid="git-commit-message"
@@ -337,7 +395,7 @@ export function StatusPanel({
)}
</div>
)}
- {!composing && extras.length > 0 && (
+ {!composing && !naming && extras.length > 0 && (
<div data-testid="git-quick-actions" className="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 px-0.5 text-[11px]">
<span className="text-muted-foreground">{t("ide_side_panel.git.next.also")}</span>
{extras.map((extra) => (
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitInsights.test.ts b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitInsights.test.ts
index 69b5741bc8..f763d3ebbe 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitInsights.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitInsights.test.ts
@@ -128,6 +128,20 @@ describe("nextStep", () => {
expect(step({ upstream: "" }, { on_github: false }).kind).toBe("publish");
});
+ it("sends edits on the default branch to a branch of their own where work lands through pull requests", () => {
+ const onMain = { branch: "main", upstream: "origin/main", files: 5, unstaged: 3, untracked: 2 };
+ const withPrs = overview(onMain);
+ withPrs.pull_requests = [pr(4)];
+ // Only what git tracks is counted: new files nobody added are not the reason to branch.
+ expect(nextStep(withPrs)).toEqual({ kind: "branch_off", count: 3 });
+ // No pull requests anywhere: committing on the default branch is how this repository works.
+ expect(nextStep(overview(onMain))).toEqual({ kind: "commit", count: 5 });
+ // A feature branch commits as before, pull requests or not.
+ const feature = overview({ files: 2, unstaged: 2 });
+ feature.pull_requests = [pr(4)];
+ expect(nextStep(feature)).toEqual({ kind: "commit", count: 2 });
+ });
+
it("does not suggest committing files git does not track yet", () => {
expect(step({ files: 5, untracked: 5 }).kind).not.toBe("commit");
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitInsights.ts b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitInsights.ts
index 6c28237c80..ba79c0f7ff 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitInsights.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitInsights.ts
@@ -119,6 +119,13 @@ export function openPullRequests(overview: RepoOverview): PullRequest[] {
return found;
}
+/** The repository lands its work through pull requests (GitHub knows at least one). */
+export function usesPullRequests(overview: RepoOverview): boolean {
+ if (!overview.github.available) return false;
+ if ((overview.pull_requests ?? []).length > 0) return true;
+ return [...overview.branches, ...overview.remote_branches].some((row) => row.pull_requests.length > 0);
+}
+
// ------------------------------------------------------------------ next step
export type NextStep =
@@ -127,6 +134,7 @@ export type NextStep =
| { kind: "fetch" }
| { kind: "pull"; count: number }
| { kind: "commit"; count: number }
+ | { kind: "branch_off"; count: number }
| { kind: "rebase"; ahead: number; behind: number }
| { kind: "publish" }
| { kind: "push"; count: number }
@@ -155,11 +163,16 @@ export function nextStep(overview: RepoOverview): NextStep {
// A fast-forward never touches local commits, so it comes before anything else.
if (checkout.behind > 0 && checkout.ahead === 0) return { kind: "pull", count: checkout.behind };
const tracked = checkout.staged + checkout.unstaged;
- if (tracked > 0) return { kind: "commit", count: checkout.files };
+ const isDefault = checkout.branch === overview.default_branch;
+ if (tracked > 0) {
+ // Where work lands through pull requests, edits on the default branch
+ // belong on a branch of their own first — committing here is the wrong turn.
+ if (isDefault && usesPullRequests(overview)) return { kind: "branch_off", count: tracked };
+ return { kind: "commit", count: checkout.files };
+ }
if (checkout.behind > 0 && checkout.ahead > 0) {
return { kind: "rebase", ahead: checkout.ahead, behind: checkout.behind };
}
- const isDefault = checkout.branch === overview.default_branch;
const hasWork = (row?.base_ahead ?? 1) > 0;
if (!checkout.upstream && checkout.has_remote && (!isDefault || !row?.on_github) && hasWork) {
return { kind: "publish" };
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/useGitActions.ts b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/useGitActions.ts
index 6a666d2874..291fee4465 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/useGitActions.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/useGitActions.ts
@@ -6,6 +6,7 @@ import {
fetchRemotes,
GitApiError,
openBranchPullRequest,
+ prepareGit,
pullBranch,
pushWorkspaceBranch,
switchBranch,
@@ -37,6 +38,8 @@ export interface GitActions {
push: (branch?: string) => void;
/** Stage everything and commit; resolves true when the commit was made. */
commit: (message: string) => Promise<boolean>;
+ /** Start a new branch here, taking the uncommitted changes along; true when it exists. */
+ createBranch: (name: string) => Promise<boolean>;
switchTo: (branch: string) => void;
update: (branch: string) => void;
remove: (row: BranchRow) => void;
@@ -146,6 +149,13 @@ export function useGitActions(workspaceId: string, folder: string, branch: strin
const failure = await run("commit", async () => fill(t("ide_side_panel.git.done.committed"), { commit: (await commitAll(folder, message)).commit }));
return failure === null;
},
+ createBranch: async (name) => {
+ const failure = await run(`branch:${name}`, async () => {
+ const made = await prepareGit(folder, { mode: "new_branch", branch: name, base: "" });
+ return fill(t("ide_side_panel.git.done.branch_created"), { branch: made.branch || name });
+ });
+ return failure === null;
+ },
switchTo: (target) => {
void run(`switch:${target}`, async () => {
await switchBranch(workspaceId, target);
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index bc574737d7..b7c43a3ce2 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -7852,7 +7852,11 @@
"ready": "#{number} hat alle Prüfungen bestanden",
"ready_reason": "Er kann geprüft und gemergt werden.",
"done": "Alles ist auf dem aktuellen Stand",
- "done_reason": "Nichts zu committen, zu pushen oder zu holen."
+ "done_reason": "Nichts zu committen, zu pushen oder zu holen.",
+ "branch_off_one": "{n} geänderte Datei auf einen Branch legen",
+ "branch_off_other": "{n} geänderte Dateien auf einen Branch legen",
+ "branch_off_reason": "{branch} ist der Standard-Branch. Arbeit kommt hier über Pull Requests an, also beginnt sie auf einem eigenen Branch.",
+ "branch_off_action": "Neuer Branch …"
},
"commit": {
"placeholder": "Commit-Nachricht",
@@ -7882,7 +7886,8 @@
"rebased": "{branch} auf sein Remote rebased.",
"switched": "Zu {branch} gewechselt.",
"updated": "{branch} ist auf dem Stand seines Remotes.",
- "deleted": "{branch} gelöscht."
+ "deleted": "{branch} gelöscht.",
+ "branch_created": "Jetzt auf {branch}."
},
"attention": {
"title": "Braucht Aufmerksamkeit",
@@ -7955,7 +7960,15 @@
"unfetched_tip": "GitHub hat neuere Commits, die noch nicht geholt sind.",
"gone": "Remote gelöscht",
"gone_tip": "Sein Branch auf dem Remote wurde gelöscht."
- }
+ },
+ "branch": {
+ "placeholder": "Name des neuen Branches",
+ "scope": "Deine nicht committeten Änderungen kommen mit; es wird nichts committet.",
+ "create": "Branch anlegen"
+ },
+ "connect_repo_body": "Wähle das GitHub-Repository dieses Ordners, um hier Pull Requests und CI zu sehen.",
+ "connect_repo_other": "Anderes …",
+ "connect_repo_choose": "Repository wählen …"
},
"skills": {
"subtitle": "Auf ein Terminal ziehen, um ihn einzufügen",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 0fdcd6f26b..1ba5c64b22 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -7852,7 +7852,11 @@
"ready": "#{number} passed every check",
"ready_reason": "It is ready to be reviewed and merged.",
"done": "Everything is up to date",
- "done_reason": "Nothing to commit, push or pull."
+ "done_reason": "Nothing to commit, push or pull.",
+ "branch_off_one": "Move {n} changed file to a branch",
+ "branch_off_other": "Move {n} changed files to a branch",
+ "branch_off_reason": "{branch} is the default branch. Work lands here through pull requests, so it starts on a branch of its own.",
+ "branch_off_action": "New branch…"
},
"commit": {
"placeholder": "Commit message",
@@ -7882,7 +7886,8 @@
"rebased": "Rebased {branch} onto its remote.",
"switched": "Switched to {branch}.",
"updated": "{branch} is up to date with its remote.",
- "deleted": "Deleted {branch}."
+ "deleted": "Deleted {branch}.",
+ "branch_created": "Now on {branch}."
},
"attention": {
"title": "Needs attention",
@@ -7955,7 +7960,15 @@
"unfetched_tip": "GitHub has newer commits that are not fetched yet.",
"gone": "remote deleted",
"gone_tip": "Its branch on the remote was deleted."
- }
+ },
+ "branch": {
+ "placeholder": "Name of the new branch",
+ "scope": "Your uncommitted changes come along; nothing is committed.",
+ "create": "Create branch"
+ },
+ "connect_repo_body": "Pick this folder's GitHub repository to see pull requests and CI here.",
+ "connect_repo_other": "Another…",
+ "connect_repo_choose": "Choose a repository…"
},
"skills": {
"subtitle": "Drag one onto a terminal to paste it",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 731eec37c5..03cc1adbf8 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -7852,7 +7852,11 @@
"ready": "#{number} pasó todas las comprobaciones",
"ready_reason": "Está lista para revisarse y fusionarse.",
"done": "Todo está al día",
- "done_reason": "Nada que confirmar, subir o traer."
+ "done_reason": "Nada que confirmar, subir o traer.",
+ "branch_off_one": "Mover {n} archivo modificado a una rama",
+ "branch_off_other": "Mover {n} archivos modificados a una rama",
+ "branch_off_reason": "{branch} es la rama por defecto. El trabajo llega aquí mediante pull requests, así que empieza en su propia rama.",
+ "branch_off_action": "Nueva rama…"
},
"commit": {
"placeholder": "Mensaje del commit",
@@ -7882,7 +7886,8 @@
"rebased": "Rebase de {branch} sobre su remoto hecho.",
"switched": "Cambiado a {branch}.",
"updated": "{branch} está al día con su remoto.",
- "deleted": "{branch} eliminada."
+ "deleted": "{branch} eliminada.",
+ "branch_created": "Ahora en {branch}."
},
"attention": {
"title": "Requiere atención",
@@ -7955,7 +7960,15 @@
"unfetched_tip": "GitHub tiene commits más nuevos que aún no se han traído.",
"gone": "remoto eliminado",
"gone_tip": "Su rama en el remoto fue eliminada."
- }
+ },
+ "branch": {
+ "placeholder": "Nombre de la nueva rama",
+ "scope": "Tus cambios sin confirmar van contigo; no se confirma nada.",
+ "create": "Crear rama"
+ },
+ "connect_repo_body": "Elige el repositorio de GitHub de esta carpeta para ver aquí las pull requests y la CI.",
+ "connect_repo_other": "Otro…",
+ "connect_repo_choose": "Elegir un repositorio…"
},
"skills": {
"subtitle": "Arrástralo a un terminal para pegarlo",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/pt.json b/jarvis/ui/web/frontend/src/i18n/locales/pt.json
index 7646671ead..9ab6258390 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/pt.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/pt.json
@@ -7852,7 +7852,11 @@
"ready": "#{number} passou em todas as verificações",
"ready_reason": "Está pronto para ser revisto e integrado.",
"done": "Está tudo atualizado",
- "done_reason": "Nada para fazer commit, enviar ou receber."
+ "done_reason": "Nada para fazer commit, enviar ou receber.",
+ "branch_off_one": "Mover {n} ficheiro alterado para um branch",
+ "branch_off_other": "Mover {n} ficheiros alterados para um branch",
+ "branch_off_reason": "{branch} é o branch predefinido. O trabalho chega aqui através de pull requests, por isso começa num branch próprio.",
+ "branch_off_action": "Novo branch…"
},
"commit": {
"placeholder": "Mensagem do commit",
@@ -7882,7 +7886,8 @@
"rebased": "Rebase de {branch} sobre o remoto concluído.",
"switched": "Mudou para {branch}.",
"updated": "{branch} está atualizado com o remoto.",
- "deleted": "{branch} eliminado."
+ "deleted": "{branch} eliminado.",
+ "branch_created": "Agora em {branch}."
},
"attention": {
"title": "Precisa de atenção",
@@ -7955,7 +7960,15 @@
"unfetched_tip": "O GitHub tem commits mais recentes que ainda não foram buscados.",
"gone": "remoto eliminado",
"gone_tip": "O branch dele no remoto foi eliminado."
- }
+ },
+ "branch": {
+ "placeholder": "Nome do novo branch",
+ "scope": "As suas alterações sem commit vão consigo; nada é registado.",
+ "create": "Criar branch"
+ },
+ "connect_repo_body": "Escolha o repositório GitHub desta pasta para ver aqui os pull requests e a CI.",
+ "connect_repo_other": "Outro…",
+ "connect_repo_choose": "Escolher um repositório…"
},
"skills": {
"subtitle": "Arrasta uma para um terminal para a colar",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/zh.json b/jarvis/ui/web/frontend/src/i18n/locales/zh.json
index 7d6409c045..1c59274f95 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/zh.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/zh.json
@@ -7852,7 +7852,11 @@
"ready": "#{number} 已通过全部检查",
"ready_reason": "可以审阅并合并了。",
"done": "一切都是最新的",
- "done_reason": "没有需要提交、推送或拉取的内容。"
+ "done_reason": "没有需要提交、推送或拉取的内容。",
+ "branch_off_one": "把 {n} 个有改动的文件移到新分支",
+ "branch_off_other": "把 {n} 个有改动的文件移到新分支",
+ "branch_off_reason": "{branch} 是默认分支。这里的改动通过拉取请求合入,所以应先在独立分支上进行。",
+ "branch_off_action": "新建分支…"
},
"commit": {
"placeholder": "提交说明",
@@ -7882,7 +7886,8 @@
"rebased": "已将 {branch} 变基到远程。",
"switched": "已切换到 {branch}。",
"updated": "{branch} 已与远程同步。",
- "deleted": "已删除 {branch}。"
+ "deleted": "已删除 {branch}。",
+ "branch_created": "现在位于 {branch}。"
},
"attention": {
"title": "需要关注",
@@ -7955,7 +7960,15 @@
"unfetched_tip": "GitHub 上有尚未获取的新提交。",
"gone": "远程已删除",
"gone_tip": "它在远程的分支已被删除。"
- }
+ },
+ "branch": {
+ "placeholder": "新分支的名称",
+ "scope": "未提交的更改会一并带过去,不会提交任何内容。",
+ "create": "创建分支"
+ },
+ "connect_repo_body": "为此文件夹选择 GitHub 仓库,即可在这里查看拉取请求和 CI。",
+ "connect_repo_other": "其他…",
+ "connect_repo_choose": "选择仓库…"
},
"skills": {
"subtitle": "拖到终端上即可粘贴",