feat: v2.7.8 — Artifacts hub, clone related repos as extra folders, quieter resume prompt
- Artifacts (/artifacts): claude.ai pages sessions publish (captured from the Artifact tool's hook), pinned workspace files, skills and plugins, each kept as a snapshot; shared ones appear in a Hub and a skill or plugin installs into the viewer's own account (server/lib/artifacts.js, /api/artifacts, docs/plans/artifacts/). - Workspace extra folders: clone one or more related repos beside the workspace and add them in one step (POST /api/lanes/:id/sources/clone). - A pane that ended by itself while tmux kept running is no longer offered for resume (tmux.serverStartedAt in reconcileOrphans). - Changes panel: a folder that is not a git repo opens on Files, and its files open from there. - Plus the parallel sessions' work in this tree: File Explorer button in the panel header, user delete, RSA SSH keys, chat/terminal and pet fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @file Tests for the `/files` page's starting place: the workspace last
|
||||
* shown wins (from PhuNT → AC_SHOP, Files opens AC_SHOP — not the viewer's
|
||||
* own home, empty but for hidden files), the home is the fallback, and an
|
||||
* explicit `?home=` / `?lane=` is obeyed — also when it changes after the
|
||||
* page opened (an admin opening another user's home, then a folder in it).
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { act, render, waitFor } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import { FilesPage } from "../FilesPage";
|
||||
import { api } from "../../lib/api";
|
||||
|
||||
type Props = {
|
||||
laneId?: number | null;
|
||||
initialHome?: string | null;
|
||||
onNavigate?: (place: unknown, path: string) => void;
|
||||
};
|
||||
const seen: Array<{ laneId?: number | null; initialHome?: string | null }> = [];
|
||||
let nav: Props["onNavigate"];
|
||||
vi.mock("../../components/lanes/FileExplorer", () => ({
|
||||
FileBrowser: (p: Props) => {
|
||||
seen.push({ laneId: p.laneId, initialHome: p.initialHome });
|
||||
nav = p.onNavigate;
|
||||
return null;
|
||||
},
|
||||
}));
|
||||
vi.mock("../../lib/api", () => ({
|
||||
isHomePlace: (p: unknown) => typeof p === "object" && p !== null && "home" in p,
|
||||
api: {
|
||||
lanes: { list: vi.fn() },
|
||||
files: { homes: vi.fn() },
|
||||
},
|
||||
}));
|
||||
|
||||
const open = (url = "/files") =>
|
||||
render(
|
||||
<MemoryRouter initialEntries={[url]}>
|
||||
<FilesPage />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
seen.length = 0;
|
||||
localStorage.clear();
|
||||
vi.mocked(api.lanes.list).mockResolvedValue({
|
||||
lanes: [
|
||||
{ id: 1, title: "AgentHub", cwd: "/a" },
|
||||
{ id: 2, title: "AC_SHOP", cwd: "/srv/agenthub/users/phunt/AC_SHOP" },
|
||||
],
|
||||
counts: {},
|
||||
} as never);
|
||||
vi.mocked(api.files.homes).mockResolvedValue({
|
||||
homes: [{ id: "me", label: "Vi", readOnly: false }],
|
||||
});
|
||||
});
|
||||
|
||||
describe("FilesPage", () => {
|
||||
it("opens the workspace last shown, not the viewer's own home", async () => {
|
||||
localStorage.setItem("agenthub.workspace.selected", "2");
|
||||
open();
|
||||
await waitFor(() => expect(seen[seen.length - 1]).toEqual({ laneId: 2, initialHome: null }));
|
||||
});
|
||||
|
||||
it("falls back to the home when no workspace was shown", async () => {
|
||||
open();
|
||||
await waitFor(() => expect(seen[seen.length - 1]).toEqual({ laneId: null, initialHome: "me" }));
|
||||
});
|
||||
|
||||
it("obeys an explicit ?home= or ?lane=", async () => {
|
||||
localStorage.setItem("agenthub.workspace.selected", "2");
|
||||
open("/files?home=me");
|
||||
await waitFor(() => expect(seen[seen.length - 1]).toEqual({ laneId: null, initialHome: "me" }));
|
||||
seen.length = 0;
|
||||
open("/files?lane=1");
|
||||
await waitFor(() => expect(seen[seen.length - 1]).toEqual({ laneId: 1, initialHome: null }));
|
||||
});
|
||||
|
||||
it("follows a place picked in the browser, so a folder opened there stays there", async () => {
|
||||
open("/files?home=me");
|
||||
await waitFor(() => expect(nav).toBeTruthy());
|
||||
act(() => nav!({ home: "phunt" }, ""));
|
||||
act(() => nav!({ home: "phunt" }, "AC_SHOP"));
|
||||
await waitFor(() =>
|
||||
expect(seen[seen.length - 1]).toEqual({ laneId: null, initialHome: "phunt" })
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user