* feat(server): derive owner/repo display name for any remote host Generalize deriveProjectGroupingName so any remote:<host>/<segments...> project key returns the last two path segments (owner/repo) instead of just the trailing segment. Path-fallback for non-remote keys is unchanged. Brings GitLab, Gitea, Bitbucket, and self-hosted remotes to parity with the prior github.com-only behavior — no separate special-case needed. * feat(app): show projects from any git remote in Projects settings Remove the isSupportedProjectKey filter so workspaces with non-GitHub remotes (GitLab, Gitea, Bitbucket, self-hosted, ssh-style) appear in the Projects list and route to the project settings screen. The daemon RPCs, config schema, and registry were already host-agnostic; this lifts a client-side filter that hid them. Also remove the now-vestigial hiddenUnsupportedRemoteCount field from ProjectSummary, BuildProjectsResult, and UseProjectsResult — once the filter is gone, the count is always zero and the field is dead state. This is an internal app-package type, not a wire schema, so deletion is safe. * chore(app): simplify Projects empty state to "No projects yet" Drop the "Non-GitHub remote projects aren't supported yet" empty-state branch — it can no longer fire now that any git remote is shown. The empty state is unconditional now. * test(app): cover non-GitHub remote in projects-settings e2e Add a fixture that creates a temp git repo with origin pointing at a gitlab.com URL and exercises the same paseo.json read/edit/save flow already covered for local repos. Verifies the project surfaces with the "acme/app" display name and that the round-trip persists correctly. Extracted the remote-setup branch in createTempGitRepo into a small configureRemote helper to keep the main function under the cyclomatic complexity limit. --------- Co-authored-by: Mathias Kurz <mkurz@stamus-networks.com>
200 lines
6.3 KiB
TypeScript
200 lines
6.3 KiB
TypeScript
import { describe, expect, test, vi } from "vitest";
|
|
|
|
import {
|
|
classifyDirectoryForProjectMembership,
|
|
deriveProjectGroupingName,
|
|
deriveProjectRootPath,
|
|
deriveWorkspaceKind,
|
|
deriveWorkspaceId,
|
|
detectStaleWorkspaces,
|
|
normalizeWorkspaceId,
|
|
} from "./workspace-registry-model.js";
|
|
import { createPersistedWorkspaceRecord } from "./workspace-registry.js";
|
|
|
|
function createWorkspaceRecord(workspaceId: string) {
|
|
return createPersistedWorkspaceRecord({
|
|
workspaceId,
|
|
projectId: workspaceId,
|
|
cwd: workspaceId,
|
|
kind: "directory",
|
|
displayName: workspaceId.split("/").at(-1) ?? workspaceId,
|
|
createdAt: "2026-03-01T00:00:00.000Z",
|
|
updatedAt: "2026-03-01T00:00:00.000Z",
|
|
});
|
|
}
|
|
|
|
describe("deriveProjectGroupingName", () => {
|
|
test("returns owner/repo for a github remote project key", () => {
|
|
expect(deriveProjectGroupingName("remote:github.com/acme/app")).toBe("acme/app");
|
|
});
|
|
|
|
test("returns owner/repo for a gitlab remote project key", () => {
|
|
expect(deriveProjectGroupingName("remote:gitlab.com/acme/app")).toBe("acme/app");
|
|
});
|
|
|
|
test("returns last two segments for a self-hosted remote project key", () => {
|
|
expect(deriveProjectGroupingName("remote:git.acme.internal/platform/api")).toBe("platform/api");
|
|
});
|
|
|
|
test("returns last two segments for a deeply-nested remote project key", () => {
|
|
expect(deriveProjectGroupingName("remote:gitlab.com/group/sub/app")).toBe("sub/app");
|
|
});
|
|
|
|
test("returns the lone path segment when only one segment follows the host", () => {
|
|
expect(deriveProjectGroupingName("remote:github.com/solo")).toBe("solo");
|
|
});
|
|
|
|
test("returns the trailing path segment for a non-remote project key", () => {
|
|
expect(deriveProjectGroupingName("/repo/local")).toBe("local");
|
|
});
|
|
|
|
test("returns the project key itself when no segments are present", () => {
|
|
expect(deriveProjectGroupingName("")).toBe("");
|
|
});
|
|
});
|
|
|
|
describe("detectStaleWorkspaces", () => {
|
|
test("returns workspace ids whose directories no longer exist", async () => {
|
|
const checkDirectoryExists = vi.fn(async (cwd: string) => cwd !== "/tmp/missing");
|
|
|
|
const staleWorkspaceIds = await detectStaleWorkspaces({
|
|
activeWorkspaces: [
|
|
createWorkspaceRecord("/tmp/existing"),
|
|
createWorkspaceRecord("/tmp/missing"),
|
|
],
|
|
checkDirectoryExists,
|
|
});
|
|
|
|
expect(Array.from(staleWorkspaceIds)).toEqual(["/tmp/missing"]);
|
|
expect(checkDirectoryExists.mock.calls).toEqual([["/tmp/existing"], ["/tmp/missing"]]);
|
|
});
|
|
|
|
test("keeps workspaces whose directories exist even when all agents are archived", async () => {
|
|
const staleWorkspaceIds = await detectStaleWorkspaces({
|
|
activeWorkspaces: [createWorkspaceRecord("/tmp/repo"), createWorkspaceRecord("/tmp/other")],
|
|
checkDirectoryExists: async () => true,
|
|
});
|
|
|
|
expect(Array.from(staleWorkspaceIds)).toEqual([]);
|
|
});
|
|
|
|
test("keeps workspaces with no agents when directory exists", async () => {
|
|
const staleWorkspaceIds = await detectStaleWorkspaces({
|
|
activeWorkspaces: [
|
|
createWorkspaceRecord("/tmp/active"),
|
|
createWorkspaceRecord("/tmp/no-agents"),
|
|
],
|
|
checkDirectoryExists: async () => true,
|
|
});
|
|
|
|
expect(Array.from(staleWorkspaceIds)).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe("deriveWorkspaceId", () => {
|
|
test("uses git worktree root when available", () => {
|
|
expect(
|
|
deriveWorkspaceId("/tmp/repo/packages/app", {
|
|
cwd: "/tmp/repo/packages/app",
|
|
isGit: true,
|
|
currentBranch: "main",
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
worktreeRoot: "/tmp/repo",
|
|
isPaseoOwnedWorktree: false,
|
|
mainRepoRoot: null,
|
|
}),
|
|
).toBe("/tmp/repo");
|
|
});
|
|
|
|
test("falls back to normalized cwd when git worktree root contains multiple lines", () => {
|
|
const cwd = String.raw`E:\project\node-ai`;
|
|
|
|
expect(
|
|
deriveWorkspaceId(cwd, {
|
|
cwd,
|
|
isGit: true,
|
|
currentBranch: "main",
|
|
remoteUrl: null,
|
|
worktreeRoot: `--path-format=absolute\n${cwd}`,
|
|
isPaseoOwnedWorktree: false,
|
|
mainRepoRoot: null,
|
|
}),
|
|
).toBe(normalizeWorkspaceId(cwd));
|
|
});
|
|
|
|
test("falls back to normalized cwd for non-git directories", () => {
|
|
const cwd = "/tmp/repo/../repo/scratch";
|
|
|
|
expect(
|
|
deriveWorkspaceId(cwd, {
|
|
cwd,
|
|
isGit: false,
|
|
currentBranch: null,
|
|
remoteUrl: null,
|
|
worktreeRoot: null,
|
|
isPaseoOwnedWorktree: false,
|
|
mainRepoRoot: null,
|
|
}),
|
|
).toBe(normalizeWorkspaceId("/tmp/repo/scratch"));
|
|
});
|
|
});
|
|
|
|
describe("git worktree grouping", () => {
|
|
test("classifies plain git worktrees for project membership from git facts", () => {
|
|
const membership = classifyDirectoryForProjectMembership({
|
|
cwd: "/tmp/repo-feature",
|
|
checkout: {
|
|
cwd: "/tmp/repo-feature",
|
|
isGit: true,
|
|
currentBranch: "feature/plain",
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
worktreeRoot: "/tmp/repo-feature",
|
|
isPaseoOwnedWorktree: false,
|
|
mainRepoRoot: "/tmp/repo",
|
|
},
|
|
});
|
|
|
|
expect(membership).toMatchObject({
|
|
cwd: normalizeWorkspaceId("/tmp/repo-feature"),
|
|
workspaceId: "/tmp/repo-feature",
|
|
workspaceKind: "worktree",
|
|
workspaceDisplayName: "feature/plain",
|
|
projectKey: "remote:github.com/acme/repo",
|
|
projectName: "acme/repo",
|
|
projectRootPath: "/tmp/repo",
|
|
projectKind: "git",
|
|
});
|
|
});
|
|
|
|
test("uses mainRepoRoot as the project root for plain git worktrees", () => {
|
|
expect(
|
|
deriveProjectRootPath({
|
|
cwd: "/tmp/repo-feature",
|
|
checkout: {
|
|
cwd: "/tmp/repo-feature",
|
|
isGit: true,
|
|
currentBranch: "feature/plain",
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
worktreeRoot: "/tmp/repo-feature",
|
|
isPaseoOwnedWorktree: false,
|
|
mainRepoRoot: "/tmp/repo",
|
|
},
|
|
}),
|
|
).toBe("/tmp/repo");
|
|
});
|
|
|
|
test("classifies plain git worktrees as workspaces of kind worktree", () => {
|
|
expect(
|
|
deriveWorkspaceKind({
|
|
cwd: "/tmp/repo-feature",
|
|
isGit: true,
|
|
currentBranch: "feature/plain",
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
worktreeRoot: "/tmp/repo-feature",
|
|
isPaseoOwnedWorktree: false,
|
|
mainRepoRoot: "/tmp/repo",
|
|
}),
|
|
).toBe("worktree");
|
|
});
|
|
});
|