Skip to content

Commit directory references when accepting @ completions - #766

Open
baixinghao wants to merge 1 commit into
huggingface:mainfrom
baixinghao:fix/issue-464
Open

baixinghao wants to merge 1 commit into
huggingface:mainfrom
baixinghao:fix/issue-464

Conversation

@baixinghao

Copy link
Copy Markdown

Summary

The @ picker listed directories with a trailing slash, but accepting one only replaced the token with @dir/, which immediately re-triggered completion on the directory's children. There was no way to commit a directory itself as a reference — users were forced to drill in and pick a file.

Accepting a directory completion now commits the reference: the caret moves past (or inserts) a separating space after @dir/, leaving the @ token so the picker closes instead of re-opening on children. This implements the "trailing space" option proposed in the issue discussion. Drilling into a directory still works by typing its path — every keystroke re-narrows the flat, recursive suggestion list.

Fixes #464.

Changes

  • src/tau_coding/tui/app.py — action_accept_completion: when the accepted completion is a FILE_REFERENCE ending with / (a directory), reuse an existing following whitespace character or insert a space, and place the caret after it. File completions, shell-path completions (!cat …), and all picker-screen accept dispatch are unchanged.
  • tests/test_tui_app.py — three new regression tests (see below).
  • website/content/guides/tui.md — the "Referencing files with @" section now documents that directories are shown with a trailing / and that inserting one commits it as a directory reference.

Tests

New tests in tests/test_tui_app.py (Textual run_test + FakeSession, matching neighboring completion tests):

  • test_tui_app_accepts_directory_reference_completion — Tab on @src/ commits inspect @src/ , closes the picker, and deleting the space re-opens child completion (drill-in by typing still works).
  • test_tui_app_accepts_directory_reference_before_existing_space — mid-text accept reuses the existing following space instead of doubling it, and parks the caret after it.
  • test_tui_app_submits_committed_directory_reference — Tab then Enter submits inspect @src/ to the session end to end.

Verification

  • Reproduced first: the new tests fail on unmodified main (assert 'inspect @src/' == 'inspect @src/ '), then pass with the fix.
  • uv run pytest tests/test_tui_autocomplete.py tests/test_commands.py — 88 passed.
  • uv run pytest tests/test_tui_app.py -k "completion or mention or footer_hints or directory_reference or file_reference or shell_path" — 31 passed.
  • Full tests/test_tui_app.py on this branch: 15 failed / 438 passed; on the stashed clean baseline: 13 failed / 437 passed. The differing tests (test_session_sidebar_lists_active_system_prompt_files, two login-picker tests) fail or pass flakily on both revisions and in isolation, and are unrelated to completion handling (sidebar rendering, login picker timing); the 12 remaining failures are identical pre-existing Windows failures on both revisions.
  • uv run ruff check / uv run ruff format --check on the changed files — clean; uv run mypy src/tau_coding/tui/app.py — no issues.
  • prettier --check content/guides/tui.md — clean.

Notes for reviewers

  • The issue discussion also floated a second layer — expanding @dir/ into the directory's contents at submit time. Tau currently does not expand @ references at all (the path is sent as prompt text and the agent uses its tools), so there is no resolver to extend; this PR is scoped to the picker. If inline directory expansion is wanted later, it can be built separately.
  • A side effect to be aware of: repeated Tab no longer walks into nested directories (each accepted directory commits). The completion list is flat and recursive with substring matching, so typing @login still finds src/components/auth/login.py directly, and typing a directory prefix by hand still lists its children.

Accepting a directory completion in the @ picker only inserted the
trailing slash, which immediately re-opened completion on the
directory's children and made it impossible to reference the directory
itself. Accepting a directory now moves past (or inserts) a separating
space so the @ token is committed and the picker closes; typing a path
by hand still completes into the directory's children.

Fixes huggingface#464.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to refer to a directory with @

1 participant