{"slug": "peektea-past-the-roadmap-sorting-and-scrollable-previews", "title": "peektea past the roadmap 👀 sorting and scrollable previews", "summary": "Maneshwar added sorting and scrollable previews to peektea, the terminal-based file browser. The `s` key now cycles through sort modes by name, size, or modification time, while `[` and `]` keys enable scrolling through file previews. The update also integrates bat for syntax-highlighted previews and adds scrollbars to both panels.", "body_md": "*Hello, I'm Maneshwar. I'm building git-lrc, a Micro AI code reviewer that runs on every commit. It is free and source-available on Github. Star git-lrc to help devs discover the project. Do give it a try and share your feedback.*\n\nLast time I said the list was empty.\n\nThat was true.\n\nThen I kept going anyway.\n\nPress `s`\n\nand the list sorts by size. Press it again, newest-modified first.\n\nPreviwing something? Press `[`\n\nand `]`\n\nand scroll through the preview without leaving the peektea cli.\n\nThe `s`\n\nkey cycles through three modes: **name → size → modified → name**.\n\nThe current mode is always visible in the hint bar: `s:sorted by name`\n\n, `s:sorted by size`\n\n, `s:sorted by modified`\n\n.\n\nUnder the hood it's a single `sort.SliceStable`\n\ncall inside `withFilters()`\n\n.\n\nThe sort runs on the filtered slice, so it composes with the text filter and the hidden file toggle, same composable approach as before:\n\n```\nsort.SliceStable(filtered, func(i, j int) bool {\n    switch m.sortMode {\n    case sortSize:\n        ii, _ := filtered[i].Info()\n        jj, _ := filtered[j].Info()\n        return ii.Size() > jj.Size() // largest first\n    case sortMod:\n        ii, _ := filtered[i].Info()\n        jj, _ := filtered[j].Info()\n        return ii.ModTime().After(jj.ModTime()) // newest first\n    default:\n        return strings.ToLower(filtered[i].Name()) < strings.ToLower(filtered[j].Name())\n    }\n})\n```\n\n`SliceStable`\n\npreserves the relative order of entries that compare equal, which keeps directories grouped sensibly when names or sizes match.\n\nThe preview panel used to show the first N lines of a file and stop there.\n\nNow you can scroll through it with `[`\n\n(up) and `]`\n\n(down). Each press moves a quarter of the panel height.\n\nThe key insight: instead of limiting what gets loaded to the visible height, the preview now loads up to 500 lines and stores the whole thing.\n\nThe rendering step slices out the visible window:\n\n```\nlines := strings.Split(m.previewContent, \"\\n\")\nscroll := m.previewScroll\nmaxScroll := len(lines) - ph\nif maxScroll < 0 {\n    maxScroll = 0\n}\nif scroll > maxScroll {\n    scroll = maxScroll\n}\nvisible := lines[scroll:]\nif len(visible) > ph {\n    visible = visible[:ph]\n}\nbody = strings.Join(visible, \"\\n\")\n```\n\n`previewScroll`\n\nresets to zero whenever you move to a new file, so you always start at the top.\n\nWhile reworking the preview loading, I added a bat check.\n\n[bat](https://github.com/sharkdp/bat) is a `cat`\n\nclone with syntax highlighting. If it's installed, peektea uses it for text previews:\n\n```\nif _, err := exec.LookPath(\"bat\"); err == nil {\n    out, err := exec.Command(\"bat\",\n        \"--color=always\",\n        \"--style=plain\",\n        \"--line-range\", \":500\",\n        \"--terminal-width\", fmt.Sprintf(\"%d\", width),\n        path,\n    ).Output()\n    if err == nil {\n        return strings.TrimRight(string(out), \"\\n\")\n    }\n}\n// fallback to plain text reader\n```\n\nSame graceful-fallback pattern as chafa. Not installed? Plain text. Installed but fails on a particular file? Plain text. The preview never breaks.\n\nBoth panels now have scrollbars.\n\nWhen the preview has more content than fits on screen, a thin `│`\n\ntrack with a `┃`\n\nthumb appears on the right edge of the preview.\n\nSame thing in the file list when there are more entries than the terminal can show.\n\nA single function handles both:\n\n```\nfunc buildScrollbar(total, visible, scroll int) []string {\n    chars := make([]string, visible)\n    track := scrollTrackStyle.Render(\"│\")\n    thumb := scrollThumbStyle.Render(\"┃\")\n    if total <= visible {\n        for i := range chars {\n            chars[i] = track\n        }\n        return chars\n    }\n    thumbSize := visible * visible / total\n    if thumbSize < 1 {\n        thumbSize = 1\n    }\n    thumbPos := scroll * (visible - thumbSize) / (total - visible)\n    for i := range chars {\n        if i >= thumbPos && i < thumbPos+thumbSize {\n            chars[i] = thumb\n        } else {\n            chars[i] = track\n        }\n    }\n    return chars\n}\n```\n\nIt returns a slice of styled characters, one per visible row that get appended to each rendered line.\n\nThe thumb size scales proportionally: if half the content is visible, the thumb fills half the track.\n\nAI agents write code fast. They also silently remove logic, change behavior, and introduce bugs — without telling you. You often find out in production.\n\ngit-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.\n\nAny feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.\n\n⭐ Star it on GitHub:\n\n| [🇩🇰 Dansk](https://github.com/HexmosTech/git-lrc/readme/README.da.md) | [🇪🇸 Español](https://github.com/HexmosTech/git-lrc/readme/README.es.md) | [🇮🇷 Farsi](https://github.com/HexmosTech/git-lrc/readme/README.fa.md) | [🇫🇮 Suomi](https://github.com/HexmosTech/git-lrc/readme/README.fi.md) | [🇯🇵 日本語](https://github.com/HexmosTech/git-lrc/readme/README.ja.md) | [🇳🇴 Norsk](https://github.com/HexmosTech/git-lrc/readme/README.nn.md) | [🇵🇹 Português](https://github.com/HexmosTech/git-lrc/readme/README.pt.md) | [🇷🇺 Русский](https://github.com/HexmosTech/git-lrc/readme/README.ru.md) | [🇦🇱 Shqip](https://github.com/HexmosTech/git-lrc/readme/README.sq.md) | [🇨🇳 中文](https://github.com/HexmosTech/git-lrc/readme/README.zh.md) |\n\nAI agents write code fast. They also *silently remove logic*, change behavior, and introduce bugs -- without telling you. You often find out in production.\n\n** git-lrc fixes this.** It hooks into\n\n`git commit`\n\nand reviews every diff git-lrc-intro-60s.mp4See git-lrc catch serious security issues such as leaked credentials, expensive cloud operations, and sensitive material in log statements", "url": "https://wpnews.pro/news/peektea-past-the-roadmap-sorting-and-scrollable-previews", "canonical_source": "https://dev.to/lovestaco/peektea-past-the-roadmap-sorting-and-scrollable-previews-1f6g", "published_at": "2026-06-05 07:15:43+00:00", "updated_at": "2026-06-05 07:42:28.325911+00:00", "lang": "en", "topics": ["ai-tools", "ai-products"], "entities": ["Maneshwar", "git-lrc", "Github", "peektea"], "alternates": {"html": "https://wpnews.pro/news/peektea-past-the-roadmap-sorting-and-scrollable-previews", "markdown": "https://wpnews.pro/news/peektea-past-the-roadmap-sorting-and-scrollable-previews.md", "text": "https://wpnews.pro/news/peektea-past-the-roadmap-sorting-and-scrollable-previews.txt", "jsonld": "https://wpnews.pro/news/peektea-past-the-roadmap-sorting-and-scrollable-previews.jsonld"}}