1jehuang / 1jehuang/jcode

feat(tui): file selection mentions with frecency ranking

Open
#570 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

autonomous: no enhancement from-pr priority: medium triage: needs-decision
Dominant language
Rust
Stars
19.9k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
30

Description

Feature: File Selection Mentions in TUI Composer

Reason

When composing prompts in the jcode TUI, there is no way to quickly reference files by name. Users have to manually type full file paths, which is error-prone and slow, especially in large codebases. This feature adds an autocomplete-style file mention system (similar to @file mentions in editors and chat apps) so users can quickly insert file references into their prompts.

What was done

Implemented file selection mentions in the TUI composer with the following commits:

  1. feat(tui): add file selection mentions — Core feature: typing @ in the composer triggers a file mention popup. Files are indexed from the working directory (respecting .gitignore and common ignore patterns). New modules:

    • file_mention.rs (~1900 lines) — file index, fuzzy matching, and mention popup logic
    • char_bag.rs — compact character-bag fuzzy matching helper
    • state_ui_input_helpers.rs — input state helpers for mention navigation
  2. fix(tui): preserve chat selection across composer drags — Ensures the chat view selection is not lost when dragging/resizing the composer, which previously caused mention state corruption.

  3. fix(tui): harden file mention index and path matching — Hardened the file index against race conditions (files changing during indexing) and improved path matching accuracy (case-insensitive, partial path segments).

  4. feat(tui): rank file mentions by frecency — Added frecency (frequency + recency) ranking so recently and frequently opened files appear first in the mention popup. Introduced a FrecencyEntry struct to track access patterns.

Files changed (15 files, +3808 / -986 lines)

Key new files:

  • crates/jcode-tui/src/tui/app/file_mention.rs — main mention logic
  • crates/jcode-tui/src/tui/app/char_bag.rs — fuzzy matching
  • crates/jcode-tui/src/tui/app/state_ui_input_helpers.rs — UI helpers

Modified files:

  • crates/jcode-tui/src/tui/app/input.rs@ trigger handling
  • crates/jcode-tui/src/tui/ui_input.rs — popup rendering and key handling
  • crates/jcode-tui/src/tui/app/tui_lifecycle.rs, tui_state.rs, mod.rs — wiring
Branch

The full implementation is available on my fork:

🔗 https://github.com/alecuba16/jcode/tree/select_files

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the implementation on the select_files branch and the listed files under crates/jcode-tui/src/tui/app/, starting with file_mention.rs and input.rs. Check how the popup, fuzzy matching, indexing, path handling, and frecency ranking are wired through ui_input.rs and the lifecycle files; done means the complete feature is integrated and behaves as described in the TUI.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.