feat(cli): prioritize system/ directory in /memory viewer (#771)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -55,7 +55,7 @@ function scanMemoryFilesystem(memoryRoot: string): TreeNode[] {
|
||||
(name) => !name.startsWith(".") && name !== MEMORY_FS_STATE_FILE,
|
||||
);
|
||||
|
||||
// Sort: directories first, then alphabetically
|
||||
// Sort: directories first, "system" always first among dirs, then alphabetically
|
||||
const sorted = filtered.sort((a, b) => {
|
||||
const aPath = join(dir, a);
|
||||
const bPath = join(dir, b);
|
||||
@@ -68,6 +68,11 @@ function scanMemoryFilesystem(memoryRoot: string): TreeNode[] {
|
||||
bIsDir = statSync(bPath).isDirectory();
|
||||
} catch {}
|
||||
if (aIsDir !== bIsDir) return aIsDir ? -1 : 1;
|
||||
// "system" directory comes first (only at root level, depth 0)
|
||||
if (aIsDir && bIsDir && depth === 0) {
|
||||
if (a === "system") return -1;
|
||||
if (b === "system") return 1;
|
||||
}
|
||||
return a.localeCompare(b);
|
||||
});
|
||||
|
||||
@@ -397,6 +402,8 @@ export function MemfsTreeViewer({
|
||||
!node.isDirectory &&
|
||||
node.relativePath === selectedFile?.relativePath;
|
||||
const prefix = renderTreePrefix(node);
|
||||
// "system/" directory gets special green color
|
||||
const isSystemDir = node.isDirectory && node.name === "system/";
|
||||
|
||||
return (
|
||||
<Box key={node.relativePath} flexDirection="row">
|
||||
@@ -412,8 +419,14 @@ export function MemfsTreeViewer({
|
||||
backgroundColor={
|
||||
isSelected ? colors.selector.itemHighlighted : undefined
|
||||
}
|
||||
color={isSelected ? "black" : undefined}
|
||||
dimColor={node.isDirectory}
|
||||
color={
|
||||
isSelected
|
||||
? "black"
|
||||
: isSystemDir
|
||||
? colors.status.success
|
||||
: undefined
|
||||
}
|
||||
dimColor={node.isDirectory && !isSystemDir}
|
||||
>
|
||||
{node.name}
|
||||
</Text>
|
||||
|
||||
Reference in New Issue
Block a user