Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import type { JSX } from "react";
|
|
|
|
interface AgentPathTailLabelProps {
|
|
path?: string | null;
|
|
fallback: string;
|
|
className?: string;
|
|
}
|
|
|
|
export function AgentPathTailLabel({
|
|
path,
|
|
fallback,
|
|
className
|
|
}: AgentPathTailLabelProps): JSX.Element {
|
|
"use memo";
|
|
const label = path?.trim() || fallback;
|
|
const parts = splitPathTail(label);
|
|
|
|
if (!parts) {
|
|
return (
|
|
<span
|
|
className={`agent-path-tail-label ${className ?? ""}`}
|
|
title={path ?? undefined}
|
|
>
|
|
<span className="agent-path-tail-label__file">{label}</span>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<span
|
|
className={`agent-path-tail-label ${className ?? ""}`}
|
|
title={path ?? undefined}
|
|
>
|
|
<span className="agent-path-tail-label__directory">
|
|
{parts.directory}
|
|
</span>
|
|
<span className="agent-path-tail-label__file">{parts.fileName}</span>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
function splitPathTail(
|
|
value: string
|
|
): { directory: string; fileName: string } | null {
|
|
const lastForwardSlash = value.lastIndexOf("/");
|
|
const lastBackwardSlash = value.lastIndexOf("\\");
|
|
const lastSeparator = Math.max(lastForwardSlash, lastBackwardSlash);
|
|
if (lastSeparator <= 0 || lastSeparator === value.length - 1) {
|
|
return null;
|
|
}
|
|
return {
|
|
directory: value.slice(0, lastSeparator + 1),
|
|
fileName: value.slice(lastSeparator + 1)
|
|
};
|
|
}
|