Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/web/src/components/settings/trackedFolders.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ describe("trackedFolderDisplayPath", () => {
});

describe("resolveTrackedFolderInput", () => {
const overflowingPath = `/srv/${"a".repeat(127)}🚀`;
const paddedPath = `/srv/${" ".repeat(127)}🚀`;

it.each([
[
"an absolute path that is not listed",
Expand All @@ -35,6 +38,16 @@ describe("resolveTrackedFolderInput", () => {
},
{ path: "/home/me/code/tools", name: "tools" },
],
[
"an emoji crossing the name limit",
{ query: overflowingPath, listedDirectoryPath: null, exactEntryPath: null },
{ path: overflowingPath, name: "a".repeat(127) },
],
[
"an emoji after leading whitespace at the name limit",
{ query: paddedPath, listedDirectoryPath: null, exactEntryPath: null },
{ path: paddedPath, name: "🚀" },
],
[
"a directory name longer than a folder name may be",
{
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/components/settings/trackedFolders.logic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ProjectTrackedFolder } from "@t3tools/contracts";
import { hasTrailingPathSeparator } from "@t3tools/client-runtime/state/projects";
import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations";
import {
fileBasename,
isAbsolutePath,
Expand Down Expand Up @@ -34,7 +35,8 @@ export function resolveTrackedFolderInput(input: {
if (rawPath === null) return null;
const path = normalizeProjectPathForDispatch(rawPath);
// `ProjectTrackedFolder.name` takes at most 128 characters.
const name = fileBasename(path).slice(0, 128).trim();
const basename = fileBasename(path).trimStart();
const name = basename.slice(0, splitsSurrogatePair(basename, 128) ? 127 : 128).trimEnd();
if (path.length === 0 || name.length === 0) return null;
return { path, name };
}
Loading