core-agent-ide/codex-cli/tests
moppywhip bc4e6db749
feat: @mention files in codex (#701)
Solves #700

## State of the World Before

Prior to this PR, when users wanted to share file contents with Codex,
they had two options:
- Manually copy and paste file contents into the chat
- Wait for the assistant to use the shell tool to view the file

The second approach required the assistant to:
1. Recognize the need to view a file
2. Execute a shell tool call
3. Wait for the tool call to complete
4. Process the file contents

This consumed extra tokens and reduced user control over which files
were shared with the model.

## State of the World After

With this PR, users can now:
- Reference files directly in their chat input using the `@path` syntax
- Have file contents automatically expanded into XML blocks before being
sent to the LLM

For example, users can type `@src/utils/config.js` in their message, and
the file contents will be included in context. Within the terminal chat
history, these file blocks will be collapsed back to `@path` format in
the UI for clean presentation.

Tag File suggestions:
<img width="857" alt="file-suggestions"
src="https://github.com/user-attachments/assets/397669dc-ad83-492d-b5f0-164fab2ff4ba"
/>

Tagging files in action:
<img width="858" alt="tagging-files"
src="https://github.com/user-attachments/assets/0de9d559-7b7f-4916-aeff-87ae9b16550a"
/>

Demo video of file tagging:
[![Demo video of file
tagging](https://img.youtube.com/vi/vL4LqtBnqt8/0.jpg)](https://www.youtube.com/watch?v=vL4LqtBnqt8)

## Implementation Details

This PR consists of 2 main components:

1. **File Tag Utilities**:
- New `file-tag-utils.ts` utility module that handles both expansion and
collapsing of file tags
- `expandFileTags()` identifies `@path` tokens and replaces them with
XML blocks containing file contents
- `collapseXmlBlocks()` reverses the process, converting XML blocks back
to `@path` format for UI display
- Tokens are only expanded if they point to valid files (directories are
ignored)
   - Expansion happens just before sending input to the model

2. **Terminal Chat Integration**:
- Leveraged the existing file system completion system for tabbing to
support the `@path` syntax
   - Added `updateFsSuggestions` helper to manage filesystem suggestions
- Added `replaceFileSystemSuggestion` to replace input with filesystem
suggestions
- Applied `collapseXmlBlocks` in the chat response rendering so that
tagged files are shown as simple `@path` tags

The PR also includes test coverage for both the UI and the file tag
utilities.

## Next Steps

Some ideas I'd like to implement if this feature gets merged:

- Line selection: `@path[50:80]` to grab specific sections of files
- Method selection: `@path#methodName` to grab just one function/class
- Visual improvements: highlight file tags in the UI to make them more
noticeable
2025-04-30 16:19:55 -07:00
..
__fixtures__ Initial commit 2025-04-16 12:56:08 -04:00
__snapshots__ refactor(updates): fetch version from registry instead of npm CLI to support multiple managers (#446) 2025-04-21 00:00:20 -07:00
agent-cancel-early.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-cancel-prev-response.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-cancel-race.test.ts perf: optimize token streaming with balanced approach (#635) 2025-04-25 10:49:38 -07:00
agent-cancel.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-dedupe-items.test.ts fix: duplicate messages in quiet mode (#680) 2025-04-26 09:14:50 -07:00
agent-function-call-id.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-generic-network-error.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-interrupt-continue.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-invalid-request-error.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-max-tokens-error.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-network-errors.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-project-doc.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-rate-limit-error.test.ts feat: lower default retry wait time and increase number of tries (#720) 2025-04-28 21:11:30 -07:00
agent-server-retry.test.ts feat: lower default retry wait time and increase number of tries (#720) 2025-04-28 21:11:30 -07:00
agent-terminate.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
agent-thinking-time.test.ts chore: upgrade prettier to v3 (#644) 2025-04-25 07:21:50 -07:00
api-key.test.ts Initial commit 2025-04-16 12:56:08 -04:00
apply-patch.test.ts feat: more loosely match context for apply_patch (#610) 2025-04-24 09:05:19 -07:00
approvals.test.ts when a shell tool call invokes apply_patch, resolve relative paths against workdir, if specified (#556) 2025-04-22 14:07:47 -07:00
cancel-exec.test.ts fix: remove unused _writableRoots arg to exec() function (#762) 2025-04-30 14:08:27 -07:00
check-updates.test.ts refactor(updates): fetch version from registry instead of npm CLI to support multiple managers (#446) 2025-04-21 00:00:20 -07:00
clear-command.test.tsx fix: remove outdated copy of text input and external editor feature (#670) 2025-04-25 16:11:16 -07:00
config.test.tsx fix(utils): save config (#578) 2025-04-24 17:32:33 -07:00
config_reasoning.test.ts feat: add --reasoning CLI flag (#314) 2025-04-29 07:30:49 -07:00
create-truncating-collector.test.ts include fractional portion of chunk that exceeds stdout/stderr limit (#497) 2025-04-21 19:06:03 -07:00
disableResponseStorage.agentLoop.test.ts Fixes issue #726 by adding config to configToSave object (#728) 2025-04-29 13:10:16 -04:00
disableResponseStorage.test.ts Fixes issue #726 by adding config to configToSave object (#728) 2025-04-29 13:10:16 -04:00
dummy.test.ts Initial commit 2025-04-16 12:56:08 -04:00
exec-apply-patch.test.ts feat: create parent directories when creating new files. (#552) 2025-04-22 19:45:17 -04:00
file-system-suggestions.test.ts feat: @mention files in codex (#701) 2025-04-30 16:19:55 -07:00
file-tag-utils.test.ts feat: @mention files in codex (#701) 2025-04-30 16:19:55 -07:00
fixed-requires-shell.test.ts fix: command pipe execution by improving shell detection (#437) 2025-04-20 21:11:19 -07:00
format-command.test.ts Back out @lib indirection in tsconfig.json (#111) 2025-04-16 14:16:53 -07:00
history-overlay.test.tsx perf: optimize token streaming with balanced approach (#635) 2025-04-25 10:49:38 -07:00
input-utils.test.ts re-enable Prettier check for codex-cli in CI (#417) 2025-04-19 11:22:45 -07:00
invalid-command-handling.test.ts fix: remove unused _writableRoots arg to exec() function (#762) 2025-04-30 14:08:27 -07:00
markdown.test.tsx Initial commit 2025-04-16 12:56:08 -04:00
model-info.test.ts feat: add openai model info configuration (#551) 2025-04-22 17:31:25 -04:00
model-utils-network-error.test.ts chore: consolidate model utils and drive-by cleanups (#476) 2025-04-21 12:33:57 -04:00
model-utils.test.ts feat: add openai model info configuration (#551) 2025-04-22 17:31:25 -04:00
multiline-ctrl-enter-submit.test.tsx Initial commit 2025-04-16 12:56:08 -04:00
multiline-dynamic-width.test.tsx Initial commit 2025-04-16 12:56:08 -04:00
multiline-enter-submit-cr.test.tsx Initial commit 2025-04-16 12:56:08 -04:00
multiline-history-behavior.test.tsx fix: remove outdated copy of text input and external editor feature (#670) 2025-04-25 16:11:16 -07:00
multiline-input-test.ts Initial commit 2025-04-16 12:56:08 -04:00
multiline-newline.test.tsx Initial commit 2025-04-16 12:56:08 -04:00
multiline-shift-enter-crlf.test.tsx fix: remove outdated copy of text input and external editor feature (#670) 2025-04-25 16:11:16 -07:00
multiline-shift-enter-mod1.test.tsx Fix handling of Shift+Enter in e.g. Ghostty (#338) 2025-04-18 09:19:06 -07:00
multiline-shift-enter.test.tsx Initial commit 2025-04-16 12:56:08 -04:00
package-manager-detector.test.ts refactor(updates): fetch version from registry instead of npm CLI to support multiple managers (#446) 2025-04-21 00:00:20 -07:00
parse-apply-patch.test.ts Back out @lib indirection in tsconfig.json (#111) 2025-04-16 14:16:53 -07:00
pipe-command.test.ts fix: command pipe execution by improving shell detection (#437) 2025-04-20 21:11:19 -07:00
project-doc.test.ts Initial commit 2025-04-16 12:56:08 -04:00
raw-exec-process-group.test.ts fix: remove unused _writableRoots arg to exec() function (#762) 2025-04-30 14:08:27 -07:00
requires-shell.test.ts fix: command pipe execution by improving shell detection (#437) 2025-04-20 21:11:19 -07:00
responses-chat-completions.test.ts bug: non-openai mode - fix for gemini content: null, fix 429 to throw before stream (#563) 2025-04-22 20:37:48 -04:00
slash-commands.test.ts feat: /diff command to view git diff (#426) 2025-04-19 16:23:27 -07:00
terminal-chat-completions.test.tsx feat: tab completions for file paths (#279) 2025-04-20 22:34:27 -07:00
terminal-chat-input-compact.test.tsx feat: /diff command to view git diff (#426) 2025-04-19 16:23:27 -07:00
terminal-chat-input-file-tag-suggestions.test.tsx feat: @mention files in codex (#701) 2025-04-30 16:19:55 -07:00
terminal-chat-input-multiline.test.tsx fix: only allow going up in history when not already in history if input is empty (#654) 2025-04-25 09:39:24 -07:00
terminal-chat-model-selection.test.tsx feat: display error on selection of invalid model (#594) 2025-04-24 16:56:00 -07:00
terminal-chat-response-item.test.tsx Initial commit 2025-04-16 12:56:08 -04:00
text-buffer-copy-paste.test.ts Back out @lib indirection in tsconfig.json (#111) 2025-04-16 14:16:53 -07:00
text-buffer-crlf.test.ts Back out @lib indirection in tsconfig.json (#111) 2025-04-16 14:16:53 -07:00
text-buffer-gaps.test.ts Back out @lib indirection in tsconfig.json (#111) 2025-04-16 14:16:53 -07:00
text-buffer-word.test.ts fix(text-buffer): correct word deletion logic for trailing spaces (Ctrl+Backspace) (#131) 2025-04-16 16:25:08 -07:00
text-buffer.test.ts feat: @mention files in codex (#701) 2025-04-30 16:19:55 -07:00
token-streaming-performance.test.ts perf: optimize token streaming with balanced approach (#635) 2025-04-25 10:49:38 -07:00
typeahead-scroll.test.tsx chore: consolidate model utils and drive-by cleanups (#476) 2025-04-21 12:33:57 -04:00
ui-test-helpers.tsx Initial commit 2025-04-16 12:56:08 -04:00
user-config-env.test.ts feat: user config api key (#569) 2025-04-26 10:13:30 -07:00