fix(tui): extract @token text correctly in on_input_submitted suggestions query #11226

Closed
HAL9000 wants to merge 4 commits from fix-11004-tui-suggestions into master

4 Commits

Author SHA1 Message Date
HAL9000 c84507cf2e fix(tests): fix BDD step setup for issue #4741 @token extraction tests
CI / push-validation (pull_request) Successful in 30s
CI / helm (pull_request) Successful in 39s
CI / build (pull_request) Successful in 45s
CI / lint (pull_request) Successful in 59s
CI / quality (pull_request) Successful in 59s
CI / typecheck (pull_request) Successful in 1m48s
CI / security (pull_request) Successful in 1m48s
CI / integration_tests (pull_request) Successful in 4m10s
CI / unit_tests (pull_request) Successful in 6m51s
CI / docker (pull_request) Successful in 2m13s
CI / coverage (pull_request) Successful in 12m48s
CI / status-check (pull_request) Successful in 3s
- Replace __import__() with importlib.import_module() so step code
  correctly accesses cleveragents.tui.app (not the top-level package)
- Fix context.add_cleanup(_restore_modules) → lambda so context arg
  is passed when Behave invokes the cleanup
- Remove redundant double-quotes from Examples table values; the step
  definition's own quotes already delimit the parameter, causing the
  regex to capture a trailing quote and the assertion to fail
- Apply ruff format to bring file in line with project style

ISSUES CLOSED: #4741
2026-05-28 19:26:30 -04:00
HAL9000 886473a80b fix(tui): fix lint errors and test cleanup in BDD steps for #4741
CI / lint (pull_request) Successful in 39s
CI / helm (pull_request) Successful in 33s
CI / build (pull_request) Successful in 35s
CI / typecheck (pull_request) Successful in 1m2s
CI / quality (pull_request) Successful in 1m4s
CI / security (pull_request) Successful in 1m15s
CI / push-validation (pull_request) Successful in 1m6s
CI / integration_tests (pull_request) Successful in 2m52s
CI / unit_tests (pull_request) Failing after 4m25s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
- Remove unused imports: re, patch, Context, persona registry/state
- Remove unused variable: original_suggestions
- Replace undefined MockStatic() with MagicMock()
- Replace no-op tuple lambda cleanup with proper _cleanup_tmpdir function
- Add shutil.rmtree cleanup for tempfile.mkdtemp() temp directory
- Replace try/except/pass with contextlib.suppress(Exception)
- Remove @tdd_expected_fail tag from feature file (tests now pass)
- Apply ruff format to bring file into compliance
2026-05-28 18:58:29 -04:00
controller-ci-rerun 831ee434e4 chore: re-trigger CI [controller]
CI / lint (pull_request) Failing after 33s
CI / quality (pull_request) Successful in 50s
CI / helm (pull_request) Successful in 32s
CI / build (pull_request) Successful in 41s
CI / typecheck (pull_request) Successful in 1m26s
CI / security (pull_request) Successful in 1m26s
CI / push-validation (pull_request) Successful in 32s
CI / integration_tests (pull_request) Successful in 3m0s
CI / unit_tests (pull_request) Successful in 4m33s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
2026-05-28 18:48:24 -04:00
HAL9000 2606688c76 fix(tui): extract @token text correctly in on_input_submitted suggestions query
Bug #4741: The TUI on_input_submitted handler passed
text.replace("@", "").strip() to suggestions(), e.g. "analyse @proj" ->
"analyse proj", producing garbage fuzzy matches because all @ characters
were stripped and surrounding words polluted the query.

Fix uses re.findall(r"@(\S+)", text)[-1] which extracts only the last
@token as the suggestion query, without surrounding words.

Changes:
- Replace text.replace("@", "").strip() with regex @token extraction in
  src/cleveragents/tui/app.py on_input_submitted handler
- Add TDD BDD regression test covering 4 input scenarios:
  single-token (@proj), category-prefixed (@project:doc), multi-token
  (@actor:x @tool:y -> tool:y), and standalone (@skill:name)
- Update CHANGELOG.md under [Unreleased]/Fixed
- Update CONTRIBUTORS.md with contribution entry

ISSUES CLOSED: #4741
2026-05-28 18:48:24 -04:00