UAT: Reference picker in app.py strips ALL @ signs from full prompt text instead of extracting the current @ token being typed #5958

Open
opened 2026-04-09 12:19:06 +00:00 by HAL9000 · 0 comments
Owner

Bug Report

Feature Area: TUI Reference and Command Input System — @ Reference Picker
Component: src/cleveragents/tui/app.py
ADR Reference: ADR-046 §Reference Picker Overlay — Activation and Lifecycle


What Was Tested

Code-level analysis of the reference picker activation logic in src/cleveragents/tui/app.py (lines 203–208) against ADR-046's reference picker specification.


Expected Behavior (from ADR-046 §Reference Picker Overlay)

User types @ anywhere in the prompt → overlay appears with all items (most recent first)
User continues typing after @ → overlay filters results in real-time

The reference picker should filter based on the text typed after the current @ token — i.e., the partial reference text being entered at the cursor position.

For a prompt like "review @handler.py and @auth", if the cursor is after @auth, the picker should filter on "auth", not on the full prompt text.


Actual Behavior (from code)

In src/cleveragents/tui/app.py, lines 203–208:

preview = result.expanded_text
if "@" in text:
    ref_picker = self.query_one("#reference-picker", ReferencePickerOverlay)
    ref_picker.set_suggestions(
        text, suggestions(text.replace("@", "").strip())
    )

The implementation calls text.replace("@", "").strip() — this:

  1. Removes ALL @ signs from the entire prompt text
  2. Passes the entire prompt text (minus @ signs) as the search query

For a prompt like "review @handler.py and @auth", this would call suggestions("review handler.py and auth") — searching for the entire sentence, not just the current @ token.

This means:

  • Multi-reference prompts produce incorrect search results
  • The query passed to suggestions() includes unrelated words from the prompt
  • The set_suggestions() call passes text (the full prompt) as the first argument, but ReferencePickerOverlay.set_suggestions() expects the query string (the text after @) as the first argument

Code Location

  • src/cleveragents/tui/app.py, lines 203–208 (reference picker activation in on_input_submitted)

Expected Fix

The reference picker should extract the last @token being typed (the text between the last @ and the cursor position):

if "@" in text:
    # Extract the partial query after the last @ sign
    at_idx = text.rfind("@")
    partial_query = text[at_idx + 1:].split()[0] if text[at_idx + 1:].split() else ""
    ref_picker = self.query_one("#reference-picker", ReferencePickerOverlay)
    ref_picker.set_suggestions(partial_query, suggestions(partial_query))

Severity Assessment

Non-critical — the reference picker is a UI overlay feature. The actual reference resolution (parse_references) works correctly. However, the picker overlay shows incorrect suggestions for any prompt containing @ references, which degrades the user experience.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area:** TUI Reference and Command Input System — @ Reference Picker **Component:** `src/cleveragents/tui/app.py` **ADR Reference:** ADR-046 §Reference Picker Overlay — Activation and Lifecycle --- ## What Was Tested Code-level analysis of the reference picker activation logic in `src/cleveragents/tui/app.py` (lines 203–208) against ADR-046's reference picker specification. --- ## Expected Behavior (from ADR-046 §Reference Picker Overlay) > User types `@` anywhere in the prompt → overlay appears with all items (most recent first) > User continues typing after `@` → overlay filters results in real-time The reference picker should filter based on the text typed **after the current `@` token** — i.e., the partial reference text being entered at the cursor position. For a prompt like `"review @handler.py and @auth"`, if the cursor is after `@auth`, the picker should filter on `"auth"`, not on the full prompt text. --- ## Actual Behavior (from code) In `src/cleveragents/tui/app.py`, lines 203–208: ```python preview = result.expanded_text if "@" in text: ref_picker = self.query_one("#reference-picker", ReferencePickerOverlay) ref_picker.set_suggestions( text, suggestions(text.replace("@", "").strip()) ) ``` The implementation calls `text.replace("@", "").strip()` — this: 1. **Removes ALL `@` signs** from the entire prompt text 2. Passes the **entire prompt text** (minus `@` signs) as the search query For a prompt like `"review @handler.py and @auth"`, this would call `suggestions("review handler.py and auth")` — searching for the entire sentence, not just the current `@` token. This means: - Multi-reference prompts produce incorrect search results - The query passed to `suggestions()` includes unrelated words from the prompt - The `set_suggestions()` call passes `text` (the full prompt) as the first argument, but `ReferencePickerOverlay.set_suggestions()` expects the query string (the text after `@`) as the first argument --- ## Code Location - `src/cleveragents/tui/app.py`, lines 203–208 (reference picker activation in `on_input_submitted`) --- ## Expected Fix The reference picker should extract the last `@token` being typed (the text between the last `@` and the cursor position): ```python if "@" in text: # Extract the partial query after the last @ sign at_idx = text.rfind("@") partial_query = text[at_idx + 1:].split()[0] if text[at_idx + 1:].split() else "" ref_picker = self.query_one("#reference-picker", ReferencePickerOverlay) ref_picker.set_suggestions(partial_query, suggestions(partial_query)) ``` --- ## Severity Assessment Non-critical — the reference picker is a UI overlay feature. The actual reference resolution (`parse_references`) works correctly. However, the picker overlay shows incorrect suggestions for any prompt containing `@` references, which degrades the user experience. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#5958
No description provided.