Skip to content

[Enhancement] Make MENTION_MENU_LIMIT configurable via settings.toml #2360

@buko

Description

@buko

[Enhancement] Make MENTION_MENU_LIMIT configurable via settings.toml

Problem

The @ file-mention popup menu is hardcoded to show at most 6 entries (MENTION_MENU_LIMIT = 6 in crates/tui/src/tui/ui.rs). This limit is independent of terminal height, font size, or composer density setting. The menu always shows exactly 6 entries, even when the terminal has room for more.

This interacts badly with #2359 (COMPLETIONS_WALK_DEPTH = 6). Together they create a compounding failure:

  1. Walk depth caps discovery at 6 levels — files deeper than 6 directories from the workspace root are invisible to the walker. In workspaces with deep semantic directory trees (depth 8+), the walker never reaches the user's actual working files.

  2. Menu limit caps display at 6 entries — even when the walker does find matches, only 6 are returned to the renderer. The SLASH_MENU_LIMIT was bumped from 6 to 128 in the same file to fix TUI: slash-menu scrolling clipped at viewport — cannot reach lower entries #64 (selection couldn't reach commands beyond the visible window because the source list itself was capped). The @-mention menu has the identical pattern but was never updated.

The result: users with deeply-nested workspaces get zero relevant matches (walk depth too shallow) AND can only see 6 entries total (menu cap too low). The frecency store then promotes stale files from shallow depths, making the experience feel random and unresponsive.

Proposed Solution

Make the mention menu limit configurable through settings.toml with a default of 128 for backward compatibility (matching the slash-menu pattern).

Code Changes

1. Add a field to the Settings struct:

/// Maximum number of @-mention popup entries returned to the renderer.
/// Default: 128. The composer widget paginates by terminal height, so
/// this only needs to be high enough to encompass the full candidate list.
#[serde(default = "default_mention_menu_limit")]
pub mention_menu_limit: usize,

fn default_mention_menu_limit() -> usize {
    128
}

2. Replace the hardcoded constant in crates/tui/src/tui/ui.rs:

// Before (current):
const MENTION_MENU_LIMIT: usize = 6;

// After:
// Remove the constant. Pass the limit from Settings through the render path.

3. Thread the value through the render path. Two call sites in ui.rs:

// In the render function:
let mention_menu_entries =
    crate::tui::file_mention::visible_mention_menu_entries(app, MENTION_MENU_LIMIT);

// In the key-event handler:
let mention_menu_entries =
    crate::tui::file_mention::visible_mention_menu_entries(app, MENTION_MENU_LIMIT);

Replace MENTION_MENU_LIMIT with app.settings.mention_menu_limit (or however the settings struct is accessed from the App).

4. Document it in docs/CONFIGURATION.md:

## File Mentions

- `mention_menu_limit` (integer, default `128`): Maximum number of entries
  in the `@`-mention popup. The composer widget paginates by terminal height,
  so this only controls the data-side cap. Match with `SLASH_MENU_LIMIT`
  (128) for consistency.

Relationship to #2359

This issue and #2359 are complementary fixes to the same @-mention system:

Both should be addressed together. The walk depth fix is useless if the menu can only show 6 entries, and the menu limit fix is useless if the walker can't reach the files. They share the same Settings struct addition pattern and the same documentation section in CONFIGURATION.md.

Context

SLASH_MENU_LIMIT was bumped from 6 to 128 to fix #64. The comment reads:

/// Upper bound on slash-menu entries returned to the renderer. The composer's
/// render path already paginates with center-tracking (see
/// `widgets::ComposerWidget::render`), so this only needs to be high enough to
/// encompass the full filtered command list — never the visible-row budget.
/// Bumped from 6 to 128 to fix #64 (selection couldn't reach commands beyond
/// the visible window because the source list itself was capped).
const SLASH_MENU_LIMIT: usize = 128;

The same reasoning applies to MENTION_MENU_LIMIT. The composer widget already paginates by terminal height — the data-side cap only needs to be high enough to encompass the full candidate list.

This patch should fix the issue.

0002-make-MENTION_MENU_LIMIT-configurable.patch

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions