Files
kandev/apps/web/components/task/file-browser-path.ts
T
João Salavisa 5257dfbaab fix(web): close the i18n coverage gaps in the non-JSX scanner and locale catalogs (#2727)
Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 23:03:29 +00:00

44 lines
1.1 KiB
TypeScript

import type { TaskSession } from "@/lib/types/http";
import { getSessionWorkspacePath } from "@/lib/session-workspace-path";
import { t } from "@/lib/i18n";
const HOME_PATH_PATTERN = /^\/(?:Users|home)\/[^/]+\//;
export function getFileBrowserSessionWorkspacePath(
session: Pick<TaskSession, "workspace_path" | "worktree_path"> | null | undefined,
): string | undefined {
return getSessionWorkspacePath(session);
}
export type FileBrowserPathInput = {
sessionWorktreePath?: string | null;
repositoryLocalPath?: string | null;
treePath?: string | null;
treeLoaded: boolean;
};
export type FileBrowserPaths = {
fullPath: string;
displayPath: string;
};
export function resolveFileBrowserPaths({
sessionWorktreePath,
repositoryLocalPath,
treePath,
treeLoaded,
}: FileBrowserPathInput): FileBrowserPaths {
const fullPath = sessionWorktreePath || repositoryLocalPath || treePath || "";
if (fullPath) {
return {
fullPath,
displayPath: fullPath.replace(HOME_PATH_PATTERN, "~/"),
};
}
return {
fullPath,
displayPath: treeLoaded ? t("task:workspaceRoot") : "",
};
}