diff --git a/src/features/vcs/CommitView.tsx b/src/features/vcs/CommitView.tsx
index c7c0c335fe..0c3653d095 100644
--- a/src/features/vcs/CommitView.tsx
+++ b/src/features/vcs/CommitView.tsx
@@ -82,6 +82,7 @@ import {
} from "./changes";
import { amendPreviewNode } from "./amendPreview";
import { AmendTargetMenu } from "./AmendTargetMenu";
+import { useChangeModules } from "./changeModules";
import { commitChanges, deleteFiles } from "./changeOps";
import { CommitOptionsPopup } from "./CommitOptions";
import { CommitCheckSummary } from "./CommitCheckSummary";
@@ -113,6 +114,7 @@ import {
setCommitDiffPreview,
setDiffPreview,
setGroupByDir,
+ setGroupByModule,
setGroupByRepo,
setGroupByStaging,
setShowUnversionedSeparately,
@@ -806,6 +808,7 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
const ignored = useIgnoredFiles(root, staging && showIgnored);
const groupByStaging = useCommit((s) => s.groupByStaging) || staging;
const groupByRepo = useCommit((s) => s.groupByRepo);
+ const groupByModule = useCommit((s) => s.groupByModule);
const showUnversionedSeparately = useCommit((s) => s.showUnversionedSeparately);
const diffPreview = useCommit((s) => s.diffPreview);
const commitDiffPreview = useCommit((s) => s.commitDiffPreview);
@@ -825,6 +828,7 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
const heads = useVcs((s) => s.heads);
const projectRoot = useProject((s) => s.project?.root ?? null);
const projectRoots = useEffectiveRoots();
+ const changeModules = useChangeModules();
const detectedRoots = useDetectedRoots();
const attachedProjects = useProjectRoots((s) => (s.root === projectRoot ? s.attached : EMPTY_ATTACHED));
const buildPresentation = useProjectPresentation();
@@ -840,6 +844,8 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
groupByRepo,
showUnversionedSeparately,
ignored?.files,
+ changeModules,
+ groupByModule,
);
return amended ? [amended, ...changes] : changes;
}, [
@@ -853,6 +859,8 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
groupByRepo,
showUnversionedSeparately,
ignored,
+ changeModules,
+ groupByModule,
amended,
]);
const [byKey, parents] = useMemo(() => {
@@ -1007,6 +1015,9 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
...(repos.length > 1
? [{ label: "Repository", checked: groupByRepo, run: () => setGroupByRepo(!groupByRepo) }]
: []),
+ ...(changeModules.length > 0
+ ? [{ label: "Module", checked: groupByModule, run: () => setGroupByModule(!groupByModule) }]
+ : []),
...(staging
? []
: [
@@ -1274,6 +1285,8 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
className={clsx(styles.icon, n.warning && styles.committerWarning)}
/>
))
+ ) : n.module ? (
+
) : ignoredDirectory(n) || n.repository ? (
) : n.type === "dir" ? (
diff --git a/src/features/vcs/__tests__/changes.test.ts b/src/features/vcs/__tests__/changes.test.ts
index 6709605fce..b9bc9f847e 100644
--- a/src/features/vcs/__tests__/changes.test.ts
+++ b/src/features/vcs/__tests__/changes.test.ts
@@ -565,3 +565,88 @@ describe("changeFileNodes", () => {
expect(nodes.map((n) => n.group)).toEqual(["staged", "unstaged"]);
});
});
+
+describe("Group By › Module in buildChangeTree", () => {
+ const at = (path: string, unstaged: FileStatus["unstaged"] = "modified"): FileStatus => ({
+ path,
+ relPath: path.replace(/^\/w\//, ""),
+ staged: null,
+ unstaged,
+ renamedFrom: null,
+ });
+
+ const modules = [
+ { path: "/w/base", name: "base", tool: "maven" as const },
+ { path: "/w/basemdm", name: "BASEMDM", tool: "maven" as const },
+ { path: "/w/basemdm/sub", name: "sub-mod", tool: "maven" as const },
+ ];
+
+ it("groups files by module alone (flat and by directory)", () => {
+ const files = [
+ at("/w/base/src/Main.java"),
+ at("/w/basemdm/src/Mdm.java"),
+ at("/w/basemdm/sub/src/Sub.java"),
+ at("/w/README.md"),
+ ];
+ const flat = buildChangeTree(files, "/w", false, undefined, [], false, {}, false, true, [], modules, true);
+ expect(shape(flat)).toEqual([
+ "Changes",
+ " base",
+ " Main.java",
+ " BASEMDM",
+ " Mdm.java",
+ " sub-mod",
+ " Sub.java",
+ " README.md",
+ ]);
+ const dirs = buildChangeTree(files, "/w", true, undefined, [], false, {}, false, true, [], modules, true);
+ expect(shape(dirs)).toEqual([
+ "Changes",
+ " base",
+ " src",
+ " Main.java",
+ " BASEMDM",
+ " src",
+ " Mdm.java",
+ " sub-mod",
+ " src",
+ " Sub.java",
+ " README.md",
+ ]);
+ });
+
+ it("nests modules under repositories and computes relative path details", () => {
+ const repos = ["/w/base", "/w/basemdm"];
+ const heads = {
+ "/w/base": { head: "main", headCommit: "11111111" },
+ "/w/basemdm": { head: "master", headCommit: "22222222" },
+ };
+ const files = [at("/w/base/src/Main.java"), at("/w/basemdm/src/Mdm.java")];
+ const tree = buildChangeTree(files, "/w", true, undefined, repos, false, heads, true, true, [], modules, true);
+ expect(shape(tree)).toEqual([
+ "Changes",
+ " base",
+ " base",
+ " src",
+ " Main.java",
+ " basemdm",
+ " BASEMDM",
+ " src",
+ " Mdm.java",
+ ]);
+ const [baseRepo, mdmRepo] = tree[0]!.children!;
+ expect(baseRepo).toMatchObject({ repository: "/w/base", detail: "main", detailIcon: "branch" });
+ expect(mdmRepo).toMatchObject({ repository: "/w/basemdm", detail: "master", detailIcon: "branch" });
+ expect(baseRepo!.children![0]).toMatchObject({ module: "/w/base", label: "base" });
+ expect(baseRepo!.children![0]!.detail).toBeUndefined();
+ expect(mdmRepo!.children![0]).toMatchObject({ module: "/w/basemdm", label: "BASEMDM", detail: "basemdm" });
+ });
+
+ it("does not ignore the whole module directory from ignoreTargets", () => {
+ const files = [at("/w/basemdm/a.tmp", "untracked"), at("/w/basemdm/extra/b.tmp", "untracked")];
+ const tree = buildChangeTree(files, "/w", true, undefined, ["/w"], false, {}, true, true, [], modules, true);
+ const mdmMod = tree[0]!.children![0]!;
+ expect(mdmMod.module).toBe("/w/basemdm");
+ expect(ignoreTargets([mdmMod], ["/w"]).sort()).toEqual(["/w/basemdm/a.tmp", "/w/basemdm/extra"]);
+ });
+});
diff --git a/src/features/vcs/__tests__/changesGroupByModule.test.tsx b/src/features/vcs/__tests__/changesGroupByModule.test.tsx
new file mode 100644
index 0000000000..df3e20acda
--- /dev/null
+++ b/src/features/vcs/__tests__/changesGroupByModule.test.tsx
@@ -0,0 +1,228 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
+
+const mocks = vi.hoisted(() => ({
+ buildModel: vi.fn(),
+}));
+
+vi.mock("@/platform/ipc", async (importOriginal) => {
+ const real = await importOriginal();
+ return {
+ ...real,
+ isTauri: () => true,
+ commands: {
+ ...real.commands,
+ buildModel: mocks.buildModel,
+ },
+ };
+});
+
+vi.mock("@/ui", async (original) => ({
+ ...(await original()),
+ Icon: ({ name, className }: { name: string; className?: string }) => (
+
+ ),
+}));
+
+vi.mock("../DiffEditor", () => ({ DiffEditor: () => }));
+
+import { useProject } from "@/platform/project";
+import { useBuildPresentation } from "@/platform/projectPresentation";
+import { useProjectRoots } from "@/platform/projectRoots";
+import { useContextMenuStore, type MenuItem } from "@/ui/Menu";
+import { ChangesTree } from "../CommitView";
+import { resolveChangeModules } from "../changeModules";
+import { setGroupByModule, useCommit } from "../commitStore";
+import { useVcs } from "../store";
+
+const change = (path: string) => ({
+ path,
+ relPath: path.split("/").slice(3).join("/"),
+ staged: null,
+ unstaged: "modified" as const,
+ renamedFrom: null,
+});
+
+function groupByItems(): Record {
+ act(() => {
+ fireEvent.click(screen.getByRole("button", { name: "View Options" }));
+ });
+ const items = useContextMenuStore.getState().menu!.items as Array