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.

feat(agentic-ide): open branches on GitHub and add a branch menu to the Git tab

rubenluetke10-beep7f3d68c1145e
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/BranchMenu.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/BranchMenu.tsx
new file mode 100644
index 0000000000..1c68efff87
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/BranchMenu.tsx
@@ -0,0 +1,273 @@
+import { useEffect, useLayoutEffect, useRef, type KeyboardEvent as ReactKeyboardEvent } from "react";
+import { createPortal } from "react-dom";
+import {
+ Copy,
+ ExternalLink,
+ FolderOpen,
+ GitBranch,
+ GitCommitHorizontal,
+ GitCompareArrows,
+ GitPullRequest,
+ GitPullRequestCreate,
+ Hash,
+ History,
+ Link2,
+ CirclePlay,
+ SquareTerminal,
+ type LucideIcon,
+} from "lucide-react";
+import { fill, useT } from "@/i18n";
+import { robustCopy } from "@/lib/clipboard";
+import { openExternalUrl } from "@/lib/openExternal";
+import { useEventStore } from "@/store/events";
+import type { BranchRow } from "./gitOverviewApi";
+
+const MENU_WIDTH = 264;
+const MENU_MARGIN = 8;
+
+/** A branch name as a GitHub URL path: every segment encoded, the slashes kept. */
+export function branchPath(name: string): string {
+ return name.split("/").map(encodeURIComponent).join("/");
+}
+
+/** The branch's page on GitHub, or "" when it is not there to open. */
+export function branchUrl(repoUrl: string, row: BranchRow): string {
+ if (!repoUrl || !(row.on_github || row.remote_only)) return "";
+ return `${repoUrl}/tree/${branchPath(row.name)}`;
+}
+
+interface MenuItem {
+ id: string;
+ label: string;
+ hint?: string;
+ icon: LucideIcon;
+ disabled?: boolean;
+ onSelect: () => void;
+}
+
+/**
+ * Everything one branch row offers: its GitHub pages (branch, commits,
+ * comparison with the default branch, the pull request or a new one, the CI
+ * run) and the strings people paste elsewhere. Opened by right-click or by
+ * the row's ⋯ button; portalled so the scrolling list never clips it.
+ */
+export function BranchMenu({
+ row,
+ repoUrl,
+ defaultBranch,
+ x,
+ y,
+ onDismiss,
+}: {
+ row: BranchRow;
+ repoUrl: string;
+ defaultBranch: string;
+ x: number;
+ y: number;
+ onDismiss: () => void;
+}) {
+ const t = useT();
+ const pushToast = useEventStore((state) => state.pushToast);
+ const menuRef = useRef<HTMLDivElement | null>(null);
+
+ useEffect(() => {
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (event.key === "Escape") {
+ event.stopPropagation();
+ onDismiss();
+ }
+ };
+ const onPointerDown = (event: PointerEvent) => {
+ const target = event.target as Node;
+ if (menuRef.current?.contains(target)) return;
+ // The ⋯ button toggles the menu itself; closing here first would reopen it.
+ if (target instanceof Element && target.closest("[data-branch-menu-anchor]")) return;
+ onDismiss();
+ };
+ window.addEventListener("keydown", onKeyDown, true);
+ window.addEventListener("pointerdown", onPointerDown, true);
+ window.addEventListener("resize", onDismiss);
+ window.addEventListener("blur", onDismiss);
+ document.addEventListener("scroll", onDismiss, true);
+ return () => {
+ window.removeEventListener("keydown", onKeyDown, true);
+ window.removeEventListener("pointerdown", onPointerDown, true);
+ window.removeEventListener("resize", onDismiss);
+ window.removeEventListener("blur", onDismiss);
+ document.removeEventListener("scroll", onDismiss, true);
+ };
+ }, [onDismiss]);
+
+ useLayoutEffect(() => {
+ const node = menuRef.current;
+ if (!node) return;
+ const { width, height } = node.getBoundingClientRect();
+ node.style.left = `${Math.max(MENU_MARGIN, Math.min(x, window.innerWidth - width - MENU_MARGIN))}px`;
+ node.style.top = `${Math.max(MENU_MARGIN, Math.min(y, window.innerHeight - height - MENU_MARGIN))}px`;
+ node.style.visibility = "visible";
+ node.querySelector<HTMLButtonElement>("button:not([disabled])")?.focus();
+ }, [x, y]);
+
+ const onMenuKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
+ event.preventDefault();
+ const items = Array.from(menuRef.current?.querySelectorAll<HTMLButtonElement>("button:not([disabled])") ?? []);
+ if (!items.length) return;
+ const current = items.indexOf(document.activeElement as HTMLButtonElement);
+ const step = event.key === "ArrowDown" ? 1 : -1;
+ items[(current + step + items.length) % items.length]?.focus();
+ };
+
+ const open = (url: string) => () => {
+ onDismiss();
+ void openExternalUrl(url);
+ };
+ const copy = (text: string) => () => {
+ onDismiss();
+ void robustCopy(text).then((ok) =>
+ pushToast(ok ? "success" : "error", ok ? fill(t("ide_side_panel.git.menu.copied"), { text }) : t("ide_side_panel.git.menu.copy_failed")),
+ );
+ };
+
+ const onGitHub = Boolean(branchUrl(repoUrl, row));
+ const offHint = !repoUrl ? t("ide_side_panel.git.menu.no_repo") : onGitHub ? undefined : t("ide_side_panel.git.not_pushed");
+ const path = branchPath(row.name);
+ const isDefault = row.name === defaultBranch;
+ const pr = row.pull_requests[0];
+ const livePr = pr && pr.state !== "merged" && pr.state !== "closed" ? pr : undefined;
+
+ const github: MenuItem[] = [
+ {
+ id: "branch",
+ label: t("ide_side_panel.git.menu.open_branch"),
+ hint: offHint,
+ icon: GitBranch,
+ disabled: !onGitHub,
+ onSelect: open(`${repoUrl}/tree/${path}`),
+ },
+ {
+ id: "commits",
+ label: t("ide_side_panel.git.menu.commits"),
+ hint: offHint,
+ icon: History,
+ disabled: !onGitHub,
+ onSelect: open(`${repoUrl}/commits/${path}`),
+ },
+ ];
+ if (!isDefault && defaultBranch) {
+ github.push({
+ id: "compare",
+ label: fill(t("ide_side_panel.git.menu.compare"), { target: defaultBranch }),
+ hint: offHint,
+ icon: GitCompareArrows,
+ disabled: !onGitHub,
+ onSelect: open(`${repoUrl}/compare/${branchPath(defaultBranch)}...${path}`),
+ });
+ }
+ if (pr) {
+ github.push({
+ id: "pr",
+ label: fill(t("ide_side_panel.git.menu.open_pr"), { number: pr.number }),
+ hint: pr.title,
+ icon: GitPullRequest,
+ onSelect: open(pr.url),
+ });
+ }
+ if (!livePr && !isDefault && defaultBranch) {
+ github.push({
+ id: "create-pr",
+ label: t("ide_side_panel.git.menu.create_pr"),
+ hint: offHint ?? fill(t("ide_side_panel.git.menu.create_pr_hint"), { target: defaultBranch }),
+ icon: GitPullRequestCreate,
+ disabled: !onGitHub,
+ onSelect: open(`${repoUrl}/compare/${branchPath(defaultBranch)}...${path}?expand=1`),
+ });
+ }
+ if (row.ci.url) {
+ github.push({
+ id: "ci",
+ label: t("ide_side_panel.git.menu.open_ci"),
+ hint: t(`ide_side_panel.git.ci.${row.ci.state}`),
+ icon: CirclePlay,
+ onSelect: open(row.ci.url),
+ });
+ }
+ if (row.head && onGitHub) {
+ github.push({
+ id: "commit",
+ label: t("ide_side_panel.git.menu.open_commit"),
+ hint: row.head.slice(0, 7),
+ icon: GitCommitHorizontal,
+ onSelect: open(`${repoUrl}/commit/${encodeURIComponent(row.head)}`),
+ });
+ }
+
+ const copies: MenuItem[] = [
+ { id: "copy-name", label: t("ide_side_panel.git.menu.copy_name"), icon: Copy, onSelect: copy(row.name) },
+ {
+ id: "copy-switch",
+ label: t("ide_side_panel.git.menu.copy_switch"),
+ hint: `git switch ${row.name}`,
+ icon: SquareTerminal,
+ onSelect: copy(`git switch ${row.name}`),
+ },
+ ];
+ if (row.head) {
+ copies.push({ id: "copy-sha", label: t("ide_side_panel.git.menu.copy_sha"), hint: row.head.slice(0, 7), icon: Hash, onSelect: copy(row.head) });
+ }
+ if (onGitHub) {
+ copies.push({ id: "copy-link", label: t("ide_side_panel.git.menu.copy_link"), icon: Link2, onSelect: copy(`${repoUrl}/tree/${path}`) });
+ }
+ if (row.worktree) {
+ copies.push({
+ id: "copy-worktree",
+ label: t("ide_side_panel.git.menu.copy_worktree"),
+ hint: row.worktree,
+ icon: FolderOpen,
+ onSelect: copy(row.worktree),
+ });
+ }
+
+ return createPortal(
+ <div
+ ref={menuRef}
+ role="menu"
+ aria-label={fill(t("ide_side_panel.git.menu.aria"), { branch: row.name })}
+ data-testid="git-branch-menu"
+ onKeyDown={onMenuKeyDown}
+ style={{ width: MENU_WIDTH, visibility: "hidden" }}
+ className="fixed z-[100] overflow-hidden rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-float"
+ >
+ <div className="flex items-center gap-2 px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-muted-foreground">
+ <GitBranch aria-hidden className="h-3 w-3 shrink-0" />
+ <span className="min-w-0 truncate font-mono">{row.name}</span>
+ </div>
+ {[github, copies].map((section, index) => (
+ <div key={section[0]?.id ?? index} role="group" className={index > 0 ? "mt-1 border-t border-border/70 pt-1" : ""}>
+ {section.map((item) => {
+ const Icon = item.icon;
+ return (
+ <button
+ key={item.id}
+ type="button"
+ role="menuitem"
+ data-testid={`git-menu-${item.id}`}
+ disabled={item.disabled}
+ onClick={item.onSelect}
+ className="flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-left text-[13px] text-foreground transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45"
+ >
+ <Icon aria-hidden className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <span className="flex min-w-0 flex-1 flex-col">
+ <span className="truncate">{item.label}</span>
+ {item.hint && <span className="truncate text-[11px] text-muted-foreground">{item.hint}</span>}
+ </span>
+ {section === github && !item.disabled && <ExternalLink aria-hidden className="h-3 w-3 shrink-0 text-muted-foreground/70" />}
+ </button>
+ );
+ })}
+ </div>
+ ))}
+ </div>,
+ document.body,
+ );
+}
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 736068ba2c..fb6c7bc1c6 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
@@ -266,6 +266,45 @@ describe("GitOverviewTab", () => {
expect(useEventStore.getState().activeSection).toBe("plugins");
});
+ it("opens a branch on GitHub from its icon, and leaves unpushed branches inert", async () => {
+ answer = { ...OVERVIEW, branches: [...OVERVIEW.branches, branch("wip/local", { upstream: "", on_github: false })] };
+ render(<GitOverviewTab />);
+ await screen.findAllByTestId("git-branch-row");
+ fireEvent.click(within(row("feature/done")).getByTestId("git-branch-link"));
+ expect(openExternalUrl).toHaveBeenCalledWith("https://github.com/o/r/tree/feature/done");
+ expect(within(row("wip/local")).getByTestId("git-branch-link").tagName).toBe("SPAN");
+ });
+
+ it("offers GitHub pages and copies from a branch's menu", async () => {
+ render(<GitOverviewTab />);
+ await screen.findAllByTestId("git-branch-row");
+ fireEvent.click(within(row("feature/queued")).getByTestId("git-branch-more"));
+ const menu = await screen.findByTestId("git-branch-menu");
+ expect(within(menu).getByTestId("git-menu-pr").textContent).toContain("#8");
+ // A live pull request exists, so there is nothing new to create.
+ expect(within(menu).queryByTestId("git-menu-create-pr")).toBeNull();
+ fireEvent.click(within(menu).getByTestId("git-menu-compare"));
+ expect(openExternalUrl).toHaveBeenCalledWith("https://github.com/o/r/compare/main...feature/queued");
+ expect(screen.queryByTestId("git-branch-menu")).toBeNull();
+
+ fireEvent.contextMenu(row("feature/done"));
+ const second = await screen.findByTestId("git-branch-menu");
+ fireEvent.click(within(second).getByTestId("git-menu-create-pr"));
+ expect(openExternalUrl).toHaveBeenCalledWith("https://github.com/o/r/compare/main...feature/done?expand=1");
+ });
+
+ it("narrows the list by search and by filter", async () => {
+ render(<GitOverviewTab />);
+ await screen.findAllByTestId("git-branch-row");
+ fireEvent.click(screen.getByTestId("git-filter-failing"));
+ expect(screen.getAllByTestId("git-branch-row").map((el) => el.dataset.branch)).toEqual(["feature/dropped"]);
+ fireEvent.click(screen.getByTestId("git-filter-all"));
+ fireEvent.change(screen.getByTestId("git-search"), { target: { value: "#9" } });
+ expect(screen.getAllByTestId("git-branch-row").map((el) => el.dataset.branch)).toEqual(["feature/draft"]);
+ fireEvent.change(screen.getByTestId("git-search"), { target: { value: "nothing-like-this" } });
+ expect(screen.getByTestId("git-filter-empty")).toBeTruthy();
+ });
+
it("asks for one restart when the running backend does not know the route yet", async () => {
answer = { detail: "Not Found" };
status = 404;
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 83cd864d01..f22550963f 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
@@ -1,4 +1,4 @@
-import { useEffect, useState, type ReactNode, type SVGProps } from "react";
+import { useCallback, useEffect, useMemo, useState, type ReactNode, type SVGProps } from "react";
import {
ChevronRight,
CircleCheck,
@@ -6,6 +6,7 @@ import {
CircleDot,
CircleHelp,
CircleX,
+ Ellipsis,
ExternalLink,
FolderGit2,
GitBranch,
@@ -15,6 +16,8 @@ import {
GitPullRequestDraft,
Loader2,
RefreshCw,
+ Search,
+ X,
} from "lucide-react";
import { fill, useT } from "@/i18n";
import { openExternalUrl } from "@/lib/openExternal";
@@ -22,6 +25,7 @@ import { cn } from "@/lib/utils";
import { QuickTooltip } from "@/components/ui/tooltip";
import { useEventStore } from "@/store/events";
import { useIdeChatStore } from "@/store/ideChat";
+import { BranchMenu, branchUrl } from "./BranchMenu";
import { ConnectGitHubCard, GitHubRepoPicker } from "./GitHubRepoPicker";
import {
fetchGitOverview,
@@ -264,7 +268,19 @@ function MergedChips({ row }: { row: BranchRow }) {
);
}
-function BranchLine({ row, isDefault }: { row: BranchRow; isDefault: boolean }) {
+function BranchLine({
+ row,
+ isDefault,
+ repoUrl,
+ menuOpen,
+ onMenu,
+}: {
+ row: BranchRow;
+ isDefault: boolean;
+ repoUrl: string;
+ menuOpen: boolean;
+ onMenu: (row: BranchRow, x: number, y: number) => void;
+}) {
const t = useT();
const meta: string[] = [];
if (row.upstream && (row.ahead || row.behind)) {
@@ -282,14 +298,22 @@ function BranchLine({ row, isDefault }: { row: BranchRow; isDefault: boolean })
.filter(Boolean)
.join("\n");
const BranchIcon = row.current ? CircleDot : GitBranch;
+ const url = branchUrl(repoUrl, row);
+ const openTip = fill(t("ide_side_panel.git.open_branch"), { branch: row.name });
return (
<li
data-testid="git-branch-row"
data-branch={row.name}
data-current={row.current || undefined}
- className={cn("flex min-h-9 items-center gap-2 px-3 py-1", row.current && "bg-accent/10")}
+ onContextMenu={(event) => {
+ event.preventDefault();
+ onMenu(row, event.clientX, event.clientY);
+ }}
+ className={cn("group/row flex min-h-9 items-center gap-1 py-1 pl-2 pr-1", row.current && "bg-accent/10", menuOpen && "bg-secondary/60")}
>
- <BranchIcon className={cn("h-4 w-4 shrink-0", row.current ? "text-accent" : "text-muted-foreground")} aria-hidden />
+ <LinkIcon url={url} tip={url ? openTip : nameTip} label={url ? openTip : row.name} testId="git-branch-link">
+ <BranchIcon className={cn("h-4 w-4 shrink-0", row.current ? "text-accent" : "text-muted-foreground")} aria-hidden />
+ </LinkIcon>
<span className="flex min-w-0 flex-1 flex-col leading-tight">
<QuickTooltip content={nameTip} side="bottom" className="flex min-w-0 items-center gap-1.5">
<span className={cn("truncate font-mono text-[12.5px]", row.current ? "font-semibold text-foreground" : "text-foreground")}>
@@ -312,10 +336,118 @@ function BranchLine({ row, isDefault }: { row: BranchRow; isDefault: boolean })
</span>
<PullRequestBadge prs={row.pull_requests} />
<CiBadge ci={row.ci} stale={row.ci_stale} />
+ <QuickTooltip content={t("ide_side_panel.git.more")} side="bottom" className="inline-flex shrink-0">
+ <button
+ type="button"
+ data-testid="git-branch-more"
+ data-branch-menu-anchor
+ aria-label={fill(t("ide_side_panel.git.menu.aria"), { branch: row.name })}
+ aria-haspopup="menu"
+ aria-expanded={menuOpen}
+ onClick={(event) => {
+ const rect = event.currentTarget.getBoundingClientRect();
+ onMenu(row, rect.right - 264, rect.bottom + 4);
+ }}
+ className={cn(
+ "inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground opacity-0 hover:bg-secondary hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/row:opacity-100",
+ menuOpen && "bg-secondary text-foreground opacity-100",
+ )}
+ >
+ <Ellipsis className="h-4 w-4" aria-hidden />
+ </button>
+ </QuickTooltip>
</li>
);
}
+type BranchFilter = "all" | "pr" | "failing" | "unmerged" | "local";
+const BRANCH_FILTERS: BranchFilter[] = ["all", "pr", "failing", "unmerged", "local"];
+
+function matchesFilter(row: BranchRow, filter: BranchFilter): boolean {
+ if (filter === "pr") return row.pull_requests.some((pr) => pr.state !== "merged" && pr.state !== "closed");
+ if (filter === "failing") return row.ci.state === "failure";
+ if (filter === "unmerged") return row.merged_into.length === 0;
+ if (filter === "local") return !row.remote_only && !row.upstream && !row.on_github;
+ return true;
+}
+
+function matchesQuery(row: BranchRow, query: string): boolean {
+ if (!query) return true;
+ const needle = query.toLowerCase().replace(/^#/, "");
+ return (
+ row.name.toLowerCase().includes(needle) ||
+ row.pull_requests.some((pr) => String(pr.number) === needle || pr.title.toLowerCase().includes(needle))
+ );
+}
+
+/** Search by name or pull request, and narrow the list to what needs a look. */
+function BranchFilterBar({
+ query,
+ onQuery,
+ filter,
+ onFilter,
+ counts,
+}: {
+ query: string;
+ onQuery: (value: string) => void;
+ filter: BranchFilter;
+ onFilter: (value: BranchFilter) => void;
+ counts: Record<BranchFilter, number>;
+}) {
+ const t = useT();
+ return (
+ <div data-testid="git-filter-bar" className="shrink-0 space-y-1.5 border-b border-border/60 px-3 py-2">
+ <label className="flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 focus-within:ring-2 focus-within:ring-ring">
+ <Search className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden />
+ <input
+ data-testid="git-search"
+ value={query}
+ onChange={(event) => onQuery(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Escape" && query) {
+ event.stopPropagation();
+ onQuery("");
+ }
+ }}
+ placeholder={t("ide_side_panel.git.search")}
+ aria-label={t("ide_side_panel.git.search")}
+ className="min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground"
+ />
+ {query && (
+ <button
+ type="button"
+ aria-label={t("ide_side_panel.git.search_clear")}
+ onClick={() => onQuery("")}
+ className="inline-flex h-4 w-4 items-center justify-center rounded text-muted-foreground hover:text-foreground"
+ >
+ <X className="h-3 w-3" aria-hidden />
+ </button>
+ )}
+ </label>
+ <div role="group" aria-label={t("ide_side_panel.git.filter_aria")} className="flex flex-wrap gap-1">
+ {BRANCH_FILTERS.map((value) => (
+ <button
+ key={value}
+ type="button"
+ data-testid={`git-filter-${value}`}
+ aria-pressed={filter === value}
+ onClick={() => onFilter(value)}
+ className={cn(
+ "inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ filter === value
+ ? "border-primary/40 bg-primary/10 text-foreground"
+ : "border-border/70 text-muted-foreground hover:bg-secondary hover:text-foreground",
+ )}
+ >
+ {t(`ide_side_panel.git.filter.${value}`)}
+ <span className="tabular-nums text-muted-foreground">{counts[value]}</span>
+ </button>
+ ))}
+ </div>
+ </div>
+ );
+}
+
function Legend() {
const t = useT();
const pr = (["draft", "open", "queued", "merged", "closed"] as const).map((state) => {
@@ -409,6 +541,13 @@ export function GitOverviewTab() {
const { data, error, routeMissing, loading, refresh } = useGitOverview(workspaceId);
const [showRemote, setShowRemote] = useState(false);
const [showLegend, setShowLegend] = useState(false);
+ const [query, setQuery] = useState("");
+ const [filter, setFilter] = useState<BranchFilter>("all");
+ const [menu, setMenu] = useState<{ row: BranchRow; x: number; y: number } | null>(null);
+ const openMenu = useCallback((row: BranchRow, x: number, y: number) => {
+ setMenu((current) => (current?.row.name === row.name ? null : { row, x, y }));
+ }, []);
+ const closeMenu = useCallback(() => setMenu(null), []);
// Reopened from the repository chip to change an earlier choice.
const [changing, setChanging] = useState(false);
// The repository just picked. The pick is saved at once, but the GitHub
@@ -418,6 +557,22 @@ export function GitOverviewTab() {
const [pickedRepo, setPickedRepo] = useState("");
useEffect(() => setChanging(false), [workspaceId]);
useEffect(() => setPickedRepo(""), [data, workspaceId]);
+ useEffect(() => {
+ setQuery("");
+ setFilter("all");
+ setMenu(null);
+ }, [workspaceId]);
+ const allRows = useMemo(() => [...(data?.branches ?? []), ...(data?.remote_branches ?? [])], [data]);
+ const trimmed = query.trim();
+ const counts = useMemo(() => {
+ const result = {} as Record<BranchFilter, number>;
+ for (const value of BRANCH_FILTERS) {
+ result[value] = allRows.filter((row) => matchesFilter(row, value) && matchesQuery(row, trimmed)).length;
+ }
+ return result;
+ }, [allRows, trimmed]);
+ const narrowed = filter !== "all" || trimmed !== "";
+ const visible = (rows: BranchRow[]) => rows.filter((row) => matchesFilter(row, filter) && matchesQuery(row, trimmed));
if (!workspace) {
return <p className="px-4 py-6 text-center text-xs text-muted-foreground">{t("ide_side_panel.git.no_workspace")}</p>;
@@ -505,6 +660,9 @@ export function GitOverviewTab() {
<Legend />
</div>
)}
+ {!picking && data?.available && allRows.length > 0 && (
+ <BranchFilterBar query={query} onQuery={setQuery} filter={filter} onFilter={setFilter} counts={counts} />
+ )}
{picking && data && workspaceId ? (
<GitHubRepoPicker
key={workspaceId}
@@ -543,31 +701,50 @@ export function GitOverviewTab() {
) : (
<>
<ul aria-label={t("ide_side_panel.git.branches")}>
- {data.branches.map((row) => (
- <BranchLine key={row.name} row={row} isDefault={row.name === data.default_branch} />
+ {visible(data.branches).map((row) => (
+ <BranchLine
+ key={row.name}
+ row={row}
+ isDefault={row.name === data.default_branch}
+ repoUrl={github?.repo_url ?? ""}
+ menuOpen={menu?.row.name === row.name}
+ onMenu={openMenu}
+ />
))}
</ul>
+ {narrowed && counts[filter] === 0 && (
+ <p data-testid="git-filter-empty" className="px-4 py-6 text-center text-xs text-muted-foreground">
+ {t("ide_side_panel.git.filter_empty")}
+ </p>
+ )}
{data.truncated && (
<p className="px-3 py-2 text-[11px] text-muted-foreground">
{fill(t("ide_side_panel.git.truncated"), { n: data.branches.length })}
</p>
)}
- {data.remote_branches.length > 0 && (
+ {visible(data.remote_branches).length > 0 && (
<div className="mt-1 border-t border-border/60">
<button
type="button"
data-testid="git-remote-toggle"
- aria-expanded={showRemote}
+ aria-expanded={showRemote || narrowed}
onClick={() => setShowRemote((value) => !value)}
className="flex w-full items-center gap-1.5 px-3 py-2 text-left text-[11px] font-medium text-muted-foreground hover:text-foreground"
>
- <ChevronRight className={cn("h-3.5 w-3.5 transition-transform", showRemote && "rotate-90")} aria-hidden />
- {fill(t("ide_side_panel.git.remote_only"), { n: data.remote_branches.length })}
+ <ChevronRight className={cn("h-3.5 w-3.5 transition-transform", (showRemote || narrowed) && "rotate-90")} aria-hidden />
+ {fill(t("ide_side_panel.git.remote_only"), { n: visible(data.remote_branches).length })}
</button>
- {showRemote && (
- <ul aria-label={fill(t("ide_side_panel.git.remote_only"), { n: data.remote_branches.length })}>
- {data.remote_branches.map((row) => (
- <BranchLine key={row.name} row={row} isDefault={false} />
+ {(showRemote || narrowed) && (
+ <ul aria-label={fill(t("ide_side_panel.git.remote_only"), { n: visible(data.remote_branches).length })}>
+ {visible(data.remote_branches).map((row) => (
+ <BranchLine
+ key={row.name}
+ row={row}
+ isDefault={false}
+ repoUrl={github?.repo_url ?? ""}
+ menuOpen={menu?.row.name === row.name}
+ onMenu={openMenu}
+ />
))}
</ul>
)}
@@ -578,6 +755,16 @@ export function GitOverviewTab() {
)}
</div>
)}
+ {menu && data && (
+ <BranchMenu
+ row={menu.row}
+ repoUrl={github?.repo_url ?? ""}
+ defaultBranch={data.default_branch}
+ x={menu.x}
+ y={menu.y}
+ onDismiss={closeMenu}
+ />
+ )}
</section>
);
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 5dabbef2ca..746c28e8b8 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -6255,7 +6255,39 @@
"github_reading": "Pull Requests und CI werden von GitHub gelesen…",
"github_off": "Kein GitHub-Status: {reason}",
"seconds_ago": "vor {n} s",
- "minutes_ago": "vor {n} min"
+ "minutes_ago": "vor {n} min",
+ "open_branch": "{branch} auf GitHub öffnen",
+ "more": "Weitere Optionen",
+ "search": "Branches oder #PR suchen…",
+ "search_clear": "Suche leeren",
+ "filter_aria": "Branches anzeigen",
+ "filter": {
+ "all": "Alle",
+ "pr": "Offener PR",
+ "failing": "CI rot",
+ "unmerged": "Nicht gemergt",
+ "local": "Nur lokal"
+ },
+ "filter_empty": "Kein Branch passt.",
+ "menu": {
+ "aria": "Optionen für {branch}",
+ "open_branch": "Branch auf GitHub öffnen",
+ "commits": "Commit-Verlauf auf GitHub",
+ "compare": "Mit {target} vergleichen",
+ "open_pr": "Pull Request #{number} öffnen",
+ "create_pr": "Pull Request erstellen",
+ "create_pr_hint": "Nach {target}",
+ "open_ci": "CI-Lauf öffnen",
+ "open_commit": "Letzten Commit öffnen",
+ "copy_name": "Branch-Namen kopieren",
+ "copy_switch": "Wechsel-Befehl kopieren",
+ "copy_sha": "Commit-SHA kopieren",
+ "copy_link": "GitHub-Link kopieren",
+ "copy_worktree": "Worktree-Pfad kopieren",
+ "copied": "Kopiert: {text}",
+ "copy_failed": "Kopieren in die Zwischenablage hat nicht geklappt.",
+ "no_repo": "Noch kein GitHub-Repository gewählt"
+ }
},
"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 6278dd0ea5..72ca6d634d 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -6288,7 +6288,39 @@
"github_reading": "Reading pull requests and CI from GitHub…",
"github_off": "No GitHub status: {reason}",
"seconds_ago": "{n} s ago",
- "minutes_ago": "{n} min ago"
+ "minutes_ago": "{n} min ago",
+ "open_branch": "Open {branch} on GitHub",
+ "more": "More options",
+ "search": "Search branches or #PR…",
+ "search_clear": "Clear search",
+ "filter_aria": "Show branches",
+ "filter": {
+ "all": "All",
+ "pr": "Open PR",
+ "failing": "CI failed",
+ "unmerged": "Not merged",
+ "local": "Local only"
+ },
+ "filter_empty": "No branch matches.",
+ "menu": {
+ "aria": "Options for {branch}",
+ "open_branch": "Open branch on GitHub",
+ "commits": "Commit history on GitHub",
+ "compare": "Compare with {target}",
+ "open_pr": "Open pull request #{number}",
+ "create_pr": "Create pull request",
+ "create_pr_hint": "Into {target}",
+ "open_ci": "Open CI run",
+ "open_commit": "Open latest commit",
+ "copy_name": "Copy branch name",
+ "copy_switch": "Copy switch command",
+ "copy_sha": "Copy commit SHA",
+ "copy_link": "Copy GitHub link",
+ "copy_worktree": "Copy worktree path",
+ "copied": "Copied: {text}",
+ "copy_failed": "Could not copy to the clipboard.",
+ "no_repo": "No GitHub repository picked yet"
+ }
},
"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 c90933e327..ec59837c93 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -6255,7 +6255,39 @@
"github_reading": "Leyendo pull requests y CI de GitHub…",
"github_off": "Sin estado de GitHub: {reason}",
"seconds_ago": "hace {n} s",
- "minutes_ago": "hace {n} min"
+ "minutes_ago": "hace {n} min",
+ "open_branch": "Abrir {branch} en GitHub",
+ "more": "Más opciones",
+ "search": "Buscar ramas o #PR…",
+ "search_clear": "Borrar búsqueda",
+ "filter_aria": "Mostrar ramas",
+ "filter": {
+ "all": "Todas",
+ "pr": "PR abierto",
+ "failing": "CI fallido",
+ "unmerged": "Sin fusionar",
+ "local": "Solo local"
+ },
+ "filter_empty": "Ninguna rama coincide.",
+ "menu": {
+ "aria": "Opciones de {branch}",
+ "open_branch": "Abrir rama en GitHub",
+ "commits": "Historial de commits en GitHub",
+ "compare": "Comparar con {target}",
+ "open_pr": "Abrir pull request #{number}",
+ "create_pr": "Crear pull request",
+ "create_pr_hint": "Hacia {target}",
+ "open_ci": "Abrir ejecución de CI",
+ "open_commit": "Abrir último commit",
+ "copy_name": "Copiar nombre de la rama",
+ "copy_switch": "Copiar comando para cambiar",
+ "copy_sha": "Copiar SHA del commit",
+ "copy_link": "Copiar enlace de GitHub",
+ "copy_worktree": "Copiar ruta del worktree",
+ "copied": "Copiado: {text}",
+ "copy_failed": "No se pudo copiar al portapapeles.",
+ "no_repo": "Aún no hay repositorio de GitHub elegido"
+ }
},
"skills": {
"subtitle": "Arrástralo a un terminal para pegarlo",