DEV Community

Cover image for peektea narrows its gaze ๐Ÿ‘€ filter-as-you-type and hidden files
Athreya aka Maneshwar
Athreya aka Maneshwar

Posted on

peektea narrows its gaze ๐Ÿ‘€ filter-as-you-type and hidden files

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.


Last time I ended with two items left on the list.

Filter as you type โ€” Bubble Tea's textinput component from bubbles is sitting there waiting

Hidden file toggle โ€” show/hide dotfiles

Both ship today.

Press / and start typing, the list narrows instantly.

Press . and dotfiles appear.

Press it again and they vanish.

peektea filter and hidden files demo

Filter as you type

The / key enters filter mode.

A text input appears at the bottom of the panel right above the hint bar, like vim's command line.

Type anything and only matching entries stay visible.

Press esc to clear it.

The component doing the work is textinput from charmbracelet/bubbles, a library of ready-made Bubble Tea components.

Wiring it into the model is straightforward:

type model struct {
    // ...
    filterInput textinput.Model
    filtering   bool
}
Enter fullscreen mode Exit fullscreen mode

When / is pressed, focus the input and return textinput.Blink, that's the command that starts the cursor blinking animation:

case "/":
    m.filtering = true
    m.filterInput.Focus()
    return m, textinput.Blink
Enter fullscreen mode Exit fullscreen mode

While filtering, most keystrokes go straight to the textinput's own Update.

Navigation keys (โ†‘โ†“) are intercepted first so you can still move the cursor while typing:

if m.filtering {
    switch msg.String() {
    case "up", "k":
        if m.cursor > 0 { m.cursor-- }
    case "down", "j":
        if m.cursor < len(m.entries)-1 { m.cursor++ }
    case "esc":
        m.filtering = false
        m.filterInput.Blur()
        m.filterInput.SetValue("")
        m = m.withFilters()
    default:
        var tiCmd tea.Cmd
        m.filterInput, tiCmd = m.filterInput.Update(msg)
        m = m.withFilters()
        return m, tiCmd
    }
}
Enter fullscreen mode Exit fullscreen mode

The tiCmd returned by m.filterInput.Update carries the next blink tick.

You have to pass it back out of Update, drop it and the cursor freezes.

Composable filters with withFilters()

The model now stores two entry slices: allEntries (everything os.ReadDir returned) and entries (what's visible after filters).

Every filter change calls withFilters() to recompute:

func (m model) withFilters() model {
    q := strings.ToLower(m.filterInput.Value())
    var filtered []os.DirEntry
    for _, e := range m.allEntries {
        if !m.showHidden && strings.HasPrefix(e.Name(), ".") {
            continue
        }
        if q != "" && !strings.Contains(strings.ToLower(e.Name()), q) {
            continue
        }
        filtered = append(filtered, e)
    }
    m.entries = filtered
    if m.cursor >= len(m.entries) {
        m.cursor = max(0, len(m.entries)-1)
    }
    return m
}
Enter fullscreen mode Exit fullscreen mode

Hidden toggle and text filter compose naturally, you can filter by name with dotfiles visible or hidden simultaneously.

Adding a third filter later means touching one function.

withFilters returns a new model value rather than mutating in place, which fits cleanly with Bubble Tea's immutable-update pattern.

Hidden file toggle

The . key flips showHidden and calls withFilters():

case ".":
    m.showHidden = !m.showHidden
    m = m.withFilters()
    needPreview = true
Enter fullscreen mode Exit fullscreen mode

The hint bar reflects the current state so you always know where you are:

. show hidden   โ† dotfiles hidden
. hide hidden   โ† dotfiles visible
Enter fullscreen mode Exit fullscreen mode

Navigating into a directory clears the filter, the search you ran in one folder doesn't carry over to its children.

Makes the behaviour predictable without any extra state to manage.

The vim-style bottom bar

The filter input sits at the bottom of the panel, one line above the hint bar.

That's the slot vim uses for its command line, /pattern, :w, :q so it feels immediately familiar.

When filtering is active the text input renders there instead of the hint.

When you press enter to confirm and leave filter mode, the active filter stays visible:

/main  esc to clear
โ†‘/โ†“  โ†’/enter  o open  / filter  . hide hidden  p preview  โ†/h  q
Enter fullscreen mode Exit fullscreen mode

The hint never disappears, even in filter mode it's always one line below.

The layout calculates how many rows the file list consumed and pads blank lines to push both the filter bar and the hint bar to the very bottom of the terminal.


AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs โ€” without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.

Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.

โญ Star it on GitHub:

GitHub logo HexmosTech / git-lrc

Free, Micro AI Code Reviews That Run on Commit




AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.

See It In Action

See git-lrc catch serious security issues such as leaked credentials, expensive cloud operations, and sensitive material in log statements

git-lrc-intro-60s.mp4

Why

  • ๐Ÿค– AI agents silently break things. Code removed. Logic changed. Edge cases gone. You won't notice until production.
  • ๐Ÿ” Catch it before it ships. AI-powered inline comments show you exactly what changed and what looks wrong.
  • ๐Ÿ” Build aโ€ฆ

Top comments (0)