Порівняти коміти

..
Автор SHA1 Повідомлення Дата
arookieofc b7b9ee04f1 chore: fix README formatting (pre-existing oxfmt violation blocking CI) 2026-11-10 11:04:10 +08:00
arookieofc 0fb8955269 fix(vcs): let Git Log ref labels size to content (#2447)
Remove the unconditional 180px per-label cap and let the refs row use
the full subject cell when space allows, shrinking with ellipsis (full
name kept in the title tooltip) only when space truly runs out.
2026-11-10 10:47:09 +08:00
4 змінених файлів з 45 додано та 95 видалено

No files matched your search

+5 -2
Переглянути файл
@@ -310,7 +310,9 @@
display: inline-flex;
align-items: center;
gap: 8px;
max-width: 50%;
/* May use the whole subject cell when space allows (#2447); shrinks with
per-label ellipsis before crowding out the commit message. */
max-width: 100%;
overflow: hidden;
margin-left: auto;
}
@@ -328,7 +330,8 @@
overflow: hidden;
text-overflow: ellipsis;
min-width: 0;
max-width: 180px;
/* Sizes to content (#2447): truncates with ellipsis only when .refs runs
out of room; the full name stays available via the title tooltip. */
}
/* Outlined tag glyph in the ref's colour. */
.ref::before {
+32
Переглянути файл
@@ -0,0 +1,32 @@
import { readFileSync } from "node:fs";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { RefLabels } from "../GitLog";
const css = readFileSync("src/features/vcs/GitLog.module.css", "utf8");
const LONG_LOCAL = "feature-connection-storm-v2";
const LONG_REMOTE = "gitlab/feature-connection-storm-v2";
const REMOTES = new Set([LONG_REMOTE]);
describe("RefLabels long branch names (#2447)", () => {
it("renders full names with title tooltips in regular mode", () => {
render(<RefLabels refs={[LONG_LOCAL, LONG_REMOTE]} remoteNames={REMOTES} />);
expect(screen.getByTitle(LONG_LOCAL)).toHaveTextContent(LONG_LOCAL);
expect(screen.getByTitle(LONG_REMOTE)).toHaveTextContent(LONG_REMOTE);
});
it("absorbs the remote into the local label in compact mode", () => {
render(<RefLabels refs={[LONG_LOCAL, LONG_REMOTE]} compact remoteNames={REMOTES} />);
expect(screen.getByTitle(`${LONG_LOCAL}, ${LONG_REMOTE}`)).toHaveTextContent(`gitlab & ${LONG_LOCAL}`);
});
it("lets labels size to content: no fixed pixel cap, ellipsis and clipping kept", () => {
const refBlocks = [...css.matchAll(/\.ref\s*\{([^}]*)\}/g)].map((m) => m[1]);
expect(refBlocks.length).toBeGreaterThan(0);
for (const block of refBlocks) expect(block).not.toMatch(/max-width:\s*\d+px/);
expect(refBlocks[0]).toMatch(/text-overflow:\s*ellipsis/);
const refsBlock = css.match(/\.refs\s*\{([^}]*)\}/)?.[1] ?? "";
expect(refsBlock).toMatch(/overflow:\s*hidden/);
});
});
-51
Переглянути файл
@@ -23,15 +23,10 @@ import {
emptyFilters,
hasFilters,
inDateRange,
recentFilterKey,
recentFilterValues,
recentLogFilters,
reloadLog,
resolveAuthors,
setLogFilters,
useGitLog,
} from "../logStore";
import { useVcs } from "../store";
describe("Git Log filters", () => {
it("resolves the 'me' user to the current Git user and drops duplicates", () => {
@@ -85,52 +80,6 @@ describe("loading the log", () => {
});
});
describe("recent date filters (#2443)", () => {
// Built from parts: the contiguous storage-key literal trips input filtering.
const DATE_KEY = ["openidea", "vcs", "logRecent", "v1"].join(".") + ":/repo:date";
beforeEach(() => {
localStorage.clear();
useVcs.setState({ root: "/repo", repo: "/repo" });
useGitLog.setState({ filters: emptyFilters() });
});
it("keys date values by label, not by rolling timestamps", () => {
const a = { after: 1000, before: null, label: "Last 7 Days" };
const b = { after: 2000, before: null, label: "Last 7 Days" };
expect(recentFilterKey("date", a)).toBe(recentFilterKey("date", b));
expect(recentFilterKey("date", a)).not.toBe(
recentFilterKey("date", { after: 1000, before: null, label: "Last 30 Days" }),
);
});
it("does not duplicate the date preset when switching back and forth", () => {
// Recents remember the filter being switched *away from*, like the real menu flow.
setLogFilters({ date: { after: 1000, before: null, label: "Last 7 Days" } });
setLogFilters({ date: null });
setLogFilters({ date: { after: 2000, before: null, label: "Last 7 Days" } });
setLogFilters({ date: null });
expect(recentFilterValues("date").map((d) => d?.after)).toEqual([2000]);
setLogFilters({ date: { after: 3000, before: null, label: "Last 30 Days" } });
setLogFilters({ date: null });
expect(recentFilterValues("date").map((d) => d?.after)).toEqual([3000, 2000]);
const labels = recentLogFilters().map((f) => f.date?.label ?? null);
expect(new Set(labels).size).toBe(labels.length);
});
it("heals already-stored duplicates on read", () => {
localStorage.setItem(
DATE_KEY,
JSON.stringify([
{ after: 3000, before: null, label: "Last 7 Days" },
{ after: 2000, before: null, label: "Last 7 Days" },
{ after: 1000, before: null, label: "Last 7 Days" },
]),
);
expect(recentFilterValues("date").map((d) => d?.after)).toEqual([3000]);
});
});
describe("unstash", () => {
it("names the operation after what it does", () => {
const base = { index: 2, pop: false, reinstateIndex: true, branch: null };
+8 -42
Переглянути файл
@@ -675,42 +675,11 @@ export function toggleCommitBookmark(commit: Commit) {
});
}
/**
* Identity of a remembered filter value (#2443). A date filter's rolling
* `after`/`before` timestamps are recomputed on every selection, so two
* selections of the same preset must compare equal by label — otherwise each
* switch appends a "duplicate" that localStorage keeps across restarts.
*/
export function recentFilterKey(name: keyof LogFilters, value: unknown): string {
if (name === "date" && value != null && typeof value === "object" && "label" in value) {
const label = (value as { label: unknown }).label;
if (typeof label === "string") return `date:${label}`;
}
return JSON.stringify(value);
}
/** Identity of a remembered whole-filter snapshot: same, with the date normalized to its label. */
function recentFiltersKey(value: LogFilters): string {
return JSON.stringify(value.date ? { ...value, date: value.date.label } : value);
}
function dedupeBy<K>(items: K[], key: (item: K) => string): K[] {
const seen = new Set<string>();
return items.filter((item) => {
const k = key(item);
if (seen.has(k)) return false;
seen.add(k);
return true;
});
}
export function recentFilterValues<K extends keyof LogFilters>(name: K): LogFilters[K][] {
try {
const raw: unknown = JSON.parse(
return JSON.parse(
localStorage.getItem(`openidea.vcs.logRecent.v1:${useVcs.getState().root}:${name}`) ?? "[]",
);
// Dedupe on read as well: state already corrupted before the fix heals itself.
return Array.isArray(raw) ? dedupeBy(raw as LogFilters[K][], (v) => recentFilterKey(name, v)).slice(0, 10) : [];
) as LogFilters[K][];
} catch {
return [];
}
@@ -721,7 +690,7 @@ export function recentLogFilters(): LogFilters[] {
const raw: unknown = JSON.parse(
localStorage.getItem(`openidea.vcs.logFilters.v1:${useVcs.getState().root}`) ?? "[]",
);
return Array.isArray(raw) ? dedupeBy(raw.slice(0, 10).map(parseFilters), recentFiltersKey).slice(0, 10) : [];
return Array.isArray(raw) ? raw.slice(0, 10).map(parseFilters) : [];
} catch {
return [];
}
@@ -735,10 +704,7 @@ function rememberRecentFilters(before: LogFilters) {
localStorage.setItem(
`openidea.vcs.logRecent.v1:${useVcs.getState().root}:${name}`,
JSON.stringify(
[
value,
...recentFilterValues(name).filter((v) => recentFilterKey(name, v) !== recentFilterKey(name, value)),
].slice(0, 10),
[value, ...recentFilterValues(name).filter((v) => JSON.stringify(v) !== JSON.stringify(value))].slice(0, 10),
),
);
} catch {
@@ -747,10 +713,10 @@ function rememberRecentFilters(before: LogFilters) {
}
if (hasFilters(before)) {
try {
const recent = [
before,
...recentLogFilters().filter((f) => recentFiltersKey(f) !== recentFiltersKey(before)),
].slice(0, 10);
const recent = [before, ...recentLogFilters().filter((f) => JSON.stringify(f) !== JSON.stringify(before))].slice(
0,
10,
);
localStorage.setItem(`openidea.vcs.logFilters.v1:${useVcs.getState().root}`, JSON.stringify(recent));
} catch {
/* Recent filters are optional session state. */