Surface workspace changes from agent panes (#3682)
* feat(app): refine workspace pane actions Prioritize Changes when available, keep Files useful before a selection, and reserve desktop diff clicks for selection so comments require the explicit affordance. Move the Changes shortcut to Shift+G to avoid consuming a likely copy variant. * feat(app): improve access to workspace changes
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { act, renderHook } from "@testing-library/react";
|
||||
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { useSessionStore, type WorkspaceDescriptor } from "@/stores/session-store";
|
||||
import { seedSessionWorkspaces } from "@/test/seed-session";
|
||||
import { useWorkspaceHasDiffStat } from "./workspace-diff-stat";
|
||||
|
||||
const SERVER_ID = "diff-stat-pill";
|
||||
const WORKSPACE_ID = "workspace";
|
||||
|
||||
const workspace: WorkspaceDescriptor = {
|
||||
id: WORKSPACE_ID,
|
||||
projectId: "project",
|
||||
projectDisplayName: "Project",
|
||||
projectRootPath: "/repo",
|
||||
workspaceDirectory: "/repo",
|
||||
projectKind: "git",
|
||||
workspaceKind: "local_checkout",
|
||||
name: "main",
|
||||
status: "done",
|
||||
statusEnteredAt: null,
|
||||
archivingAt: null,
|
||||
diffStat: null,
|
||||
scripts: [],
|
||||
};
|
||||
|
||||
function setDiffStat(diffStat: WorkspaceDescriptor["diffStat"]): void {
|
||||
useSessionStore.getState().setWorkspaces(SERVER_ID, (workspaces) => {
|
||||
const next = new Map(workspaces);
|
||||
next.set(WORKSPACE_ID, { ...workspace, diffStat });
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
describe("useWorkspaceHasDiffStat", () => {
|
||||
beforeEach(() => {
|
||||
useSessionStore.getState().initializeSession(SERVER_ID, null as unknown as DaemonClient);
|
||||
seedSessionWorkspaces(SERVER_ID, new Map([[WORKSPACE_ID, workspace]]));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
useSessionStore.getState().clearSession(SERVER_ID);
|
||||
});
|
||||
|
||||
it("does not re-render its owner when only the visible counts change", () => {
|
||||
let renderCount = 0;
|
||||
const { result } = renderHook(() => {
|
||||
renderCount += 1;
|
||||
return useWorkspaceHasDiffStat(SERVER_ID, WORKSPACE_ID);
|
||||
});
|
||||
|
||||
expect(result.current).toBe(false);
|
||||
expect(renderCount).toBe(1);
|
||||
|
||||
act(() => setDiffStat({ additions: 2, deletions: 0 }));
|
||||
expect(result.current).toBe(true);
|
||||
expect(renderCount).toBe(2);
|
||||
|
||||
act(() => setDiffStat({ additions: 5, deletions: 3 }));
|
||||
expect(result.current).toBe(true);
|
||||
expect(renderCount).toBe(2);
|
||||
|
||||
act(() => setDiffStat(null));
|
||||
expect(result.current).toBe(false);
|
||||
expect(renderCount).toBe(3);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user