Skip to content

Commit 3282af2

Browse files
nrjdalalclaude
andcommitted
feat: right-align file size in tree, dot separator in preview, symlink folder jump
- File size right-aligned at end of line in tree view - Preview header shows path • size format - Enter on symlink-to-folder jumps cursor to target folder and expands it Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1356893 commit 3282af2

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

bin/utils/interactive-picker.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,6 @@ export function interactivePicker(
336336
const idx = scrollOffset + i + 1 // +1 for the dot row
337337
const isCursor = idx === cursor
338338
const checkbox = item.node.selected ? green("●") : dim("○")
339-
const sizeStr =
340-
item.node.type === "blob" && item.node.size > 0
341-
? dim(` ${formatSize(item.node.size)}`)
342-
: ""
343339
const nameStr =
344340
item.node.type === "tree"
345341
? cyan(item.node.name + "/")
@@ -349,13 +345,18 @@ export function interactivePicker(
349345
(item.node.linkTarget.endsWith("/")
350346
? cyan(item.node.linkTarget)
351347
: item.node.linkTarget)
352-
: item.node.name + sizeStr
348+
: item.node.name
353349
const expandIcon =
354350
item.node.type === "tree" ? (item.node.expanded ? dim("▾ ") : dim("▸ ")) : " "
355351
const pointer = isCursor ? yellow(">") : " "
356-
let line = `${pointer} ${checkbox} ${dim(item.prefix)}${dim(item.connector)}${expandIcon}${nameStr}`
352+
const leftPart = `${pointer} ${checkbox} ${dim(item.prefix)}${dim(item.connector)}${expandIcon}${nameStr}`
353+
const sizeLabel =
354+
item.node.type === "blob" && item.node.size > 0 ? dim(formatSize(item.node.size)) : ""
355+
const leftLen = stripAnsi(leftPart).length
356+
const sizeLen = stripAnsi(sizeLabel).length
357+
const gap = Math.max(1, cols - leftLen - sizeLen - 1)
358+
let line = sizeLabel ? `${leftPart}${" ".repeat(gap)}${sizeLabel} ` : leftPart
357359
if (isCursor) {
358-
// Pad to full width, subtle dark gray background (ANSI 256 color 236)
359360
const pad = Math.max(0, cols - stripAnsi(line).length)
360361
line = `\x1B[48;5;236m${line}${" ".repeat(pad)}\x1B[49m`
361362
}
@@ -446,7 +447,7 @@ export function interactivePicker(
446447
let out = "\x1B[H\x1B[2J"
447448
const pathStr =
448449
node.type === "symlink" ? yellow(node.path) + dim(" -> ") + node.linkTarget : node.path
449-
out += `\n ${bold(pathStr)} ${dim(formatSize(node.size))}\n\n`
450+
out += `\n ${bold(pathStr)} ${dim("•")} ${dim(formatSize(node.size))}\n\n`
450451

451452
const visibleCount = Math.min(viewportHeight, lines.length - previewScrollOffset)
452453
for (let i = 0; i < visibleCount; i++) {
@@ -560,11 +561,21 @@ export function interactivePicker(
560561
}
561562
}
562563

563-
// Enter → expand/collapse directory, or preview file
564+
// Enter → expand/collapse directory, preview file, or jump to symlink target
564565
if (key === "\r" && cursor > 0) {
565566
const item = items[cursor - 1]
566567
if (item && item.node.type === "tree") {
567568
item.node.expanded = !item.node.expanded
569+
} else if (item && item.node.type === "symlink" && item.node.linkTarget.endsWith("/")) {
570+
// Symlink to folder - jump to target and expand it
571+
const targetPath = item.node.linkTarget.replace(/\/$/, "")
572+
const targetNode = findNodeByPath(tree, targetPath)
573+
if (targetNode) {
574+
targetNode.expanded = true
575+
const updatedItems = flatten(tree)
576+
const targetIdx = updatedItems.findIndex((fi) => fi.node === targetNode)
577+
if (targetIdx >= 0) cursor = targetIdx + 1 // +1 for dot row
578+
}
568579
} else if (
569580
item &&
570581
basePath &&

0 commit comments

Comments
 (0)