mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-23 09:42:53 +00:00
* feat(app): give compact Changes an overview and a straight rail Three fixes to the Explorer's Changes tab on phones, where there is no tree rail and the diff is the only view of what changed. No placeholder stat while the sidebar slides in. `useCheckoutDiffQuery` reported `isLoading` only when the query was enabled and connected, so an inactive retained panel settled on `files: []`. The comparison toolbar summed that into "+0 -0" and the body rendered "No changes" for a diff nobody had fetched yet, both replaced a moment later by real numbers. The result now derives from the payload alone: no payload means loading, whatever the query is doing. Callers already handle loading correctly, so nothing downstream needed a special case. Jump to file. A floating action button over the diff opens a sheet with the same changed-files tree the desktop rail renders; tapping a file closes the sheet and scrolls the diff there. `ChangedFilesTree` moved out of `diff-pane.tsx` into its own module so both surfaces own one tree, and its list is now the sheet-aware one so it scrolls with the sheet gesture on native. `DiffDocument` takes a `contentInsetBottom` so the button never traps the last line. Rails on the compact header. The tab labels sat at 20dp and the close X at 16dp while every toolbar row below them used 12dp leading and 8dp trailing. The close button was also a hand-rolled Pressable rather than a ToolbarButton. `paneContentToolbarTrailingPadding` now takes whether the row's last control is a bare glyph or a framed one: a glyph's hitbox overhangs its ink so the row pads by less than the rail, but the compact git-actions trigger paints its own frame and was landing flush against the screen edge. The commits header chevron moved to the depth-0 tree rail. Desktop geometry is unchanged. * fix(app): preserve Explorer touch targets and reset file overview * fix(app): preserve diff selections across repaints Header typography refreshes and height resizes changed the repaint callback and inadvertently cleared active source selections. Keep selection updates stable while retaining explicit source and selection-layout invalidation. * test(app): express diff copy regression as user actions * test(app): express file overview flows as user actions
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { ParsedDiffFile } from "@getpaseo/protocol/messages";
|
|
import { deriveCheckoutDiffResult } from "./use-diff-query";
|
|
|
|
function createParsedDiffFile(path: string): ParsedDiffFile {
|
|
return {
|
|
path,
|
|
isNew: false,
|
|
isDeleted: false,
|
|
additions: 3,
|
|
deletions: 1,
|
|
hunks: [
|
|
{
|
|
oldStart: 1,
|
|
oldCount: 1,
|
|
newStart: 1,
|
|
newCount: 1,
|
|
lines: [{ type: "add", content: "x", tokens: [] }],
|
|
},
|
|
],
|
|
} as ParsedDiffFile;
|
|
}
|
|
|
|
function createPayload(files: ParsedDiffFile[]) {
|
|
return { requestId: "req-1", cwd: "/repo", files, error: null };
|
|
}
|
|
|
|
describe("deriveCheckoutDiffResult", () => {
|
|
// No payload covers every not-yet-fetched case: the query is disabled because the
|
|
// retained panel is still inactive, the request is in flight, or the host is
|
|
// disconnected. None of them mean "the diff is empty".
|
|
it("reports loading while no payload has arrived, so an empty diff is never implied", () => {
|
|
const result = deriveCheckoutDiffResult(null);
|
|
|
|
expect(result.isLoading).toBe(true);
|
|
expect(result.files).toEqual([]);
|
|
});
|
|
|
|
it("reports a settled empty diff once a payload with zero files arrives", () => {
|
|
const result = deriveCheckoutDiffResult(createPayload([]));
|
|
|
|
expect(result.isLoading).toBe(false);
|
|
expect(result.files).toEqual([]);
|
|
});
|
|
|
|
it("passes the payload files through once the diff arrives", () => {
|
|
const files = [createParsedDiffFile("src/app.ts")];
|
|
|
|
const result = deriveCheckoutDiffResult(createPayload(files));
|
|
|
|
expect(result.isLoading).toBe(false);
|
|
expect(result.files).toEqual(files);
|
|
});
|
|
|
|
it("surfaces a payload error and the too-large flag", () => {
|
|
const error = { code: "NOT_GIT_REPO", message: "not a git repository" } as const;
|
|
|
|
const result = deriveCheckoutDiffResult({ ...createPayload([]), error, diffTooLarge: true });
|
|
|
|
expect(result).toEqual({
|
|
files: [],
|
|
payloadError: error,
|
|
diffTooLarge: true,
|
|
isLoading: false,
|
|
isFetching: false,
|
|
isError: true,
|
|
error: null,
|
|
});
|
|
});
|
|
});
|