Marketplace: pin the commit the user reviewed (final review I2)
Install and update pinned whatever the marketplace head was when the click landed, so a background refresh between review and click could pin content nobody saw (including a hook's shell commands). install_marketplace_item and update_marketplace_item now take expected_commit and refuse with "changed since you reviewed this item — review it again" unless it is still the head. The UI passes the head the selected item was read at (Browse), the head frozen with a pending hook confirm (whose commands are frozen too), and the head of the accepted diff (Installed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,9 @@ import { useAppState } from "../../store/appState";
|
||||
import type { AppSettings, CatalogItem, MarketplaceSnapshot } from "../../lib/types";
|
||||
import type { MarketplaceApi } from "../../hooks/useMarketplace";
|
||||
|
||||
vi.mock("./InstallControls", () => ({ default: () => <div>install controls</div> }));
|
||||
vi.mock("./InstallControls", () => ({
|
||||
default: ({ headCommit }: { headCommit: string | null }) => <div>install controls at {headCommit}</div>,
|
||||
}));
|
||||
vi.mock("./AddMarketplaceModal", () => ({ default: () => <div>add modal</div> }));
|
||||
|
||||
import BrowsePane from "./BrowsePane";
|
||||
@@ -76,7 +78,15 @@ describe("BrowsePane", () => {
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: /code-reviewer/ }));
|
||||
expect(screen.getByText("code-reviewer preview body")).toBeInTheDocument();
|
||||
expect(screen.getByText("install controls")).toBeInTheDocument();
|
||||
expect(screen.getByText(`install controls at ${"a".repeat(40)}`)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("I2: installs pin the head the shown item was read at, not a later one", () => {
|
||||
const mp = api();
|
||||
const { rerender } = render(<BrowsePane mp={mp} />);
|
||||
fireEvent.click(screen.getByRole("button", { name: /code-reviewer/ }));
|
||||
rerender(<BrowsePane mp={{ ...mp, snapshots: [{ ...snapshot, head_commit: "b".repeat(40) }] }} />);
|
||||
expect(screen.getByText(`install controls at ${"a".repeat(40)}`)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows why an item is invalid", () => {
|
||||
|
||||
Reference in New Issue
Block a user