web: abbreviate the home directory in chat group labels

Use ~ for the server home prefix in directory bands and row meta, with the
full path still in the band's tooltip. Keeps long repository paths readable
inside the centred collapsible header.
This commit is contained in:
2026-10-20 14:39:15 +01:00
parent 3799d37d7c
commit f982c0b712
5 changed files with 65 additions and 10 deletions
+13
View File
@@ -110,6 +110,8 @@ import {
deltaPartId,
directoryChoices,
directoryLabel,
homeDirectoryFor,
abbreviateHome,
dismissChatNotice,
emptyChatOverrides,
emptyChatSeen,
@@ -569,6 +571,17 @@ test("groupSessionsByDirectory groups in first-occurrence order and labels a bla
assert.equal(directoryLabel("/a"), "/a");
});
test("directory labels abbreviate the user's home to ~", () => {
const home = homeDirectoryFor(["/Users/alan/repos/pipelines", "/Users/alan/notes"]);
assert.equal(home, "/Users/alan");
assert.equal(abbreviateHome("/Users/alan", "/Users/alan"), "~");
assert.equal(abbreviateHome("/Users/alan/repos/pipelines", home), "~/repos/pipelines");
assert.equal(abbreviateHome("/Users/alanother/x", home), "/Users/alanother/x");
assert.equal(abbreviateHome("/srv/work", home), "/srv/work");
assert.equal(homeDirectoryFor(["/srv/work"]), "");
assert.equal(abbreviateHome("/home/alan/x", homeDirectoryFor(["/home/alan/x"])), "~/x");
});
// --- History paging ---------------------------------------------------------
test("mergeHistoryPage prepends an older page and dedupes by id", () => {