Repository navigation
fix(ui): show files a shell command deletes as deleted, with Undo - #5561
Conversation
A file the agent removed with `del notes.txt`, `rm notes.txt` or `Remove-Item notes.txt` showed in Changes only as untracked shell work, so Undo could not bring it back. The shell tool now reads plain deletes with literal operands, copies each named workspace file before the command runs, and records it in the turn like the file tools do. A delete it cannot read exactly (wildcards, variables, recursion, folders, files outside the allowed paths, several statements) keeps the untracked label.
|
Verdict: Approve with suggestions When the agent deletes a named workspace file with a plain shell command (
Real-world evidenceN/A: there is no 🔍 Technical detailsIssues 🟡 No surface evidence for the Changes/Undo behaviour. The PR changes what a turn's ledger reports ( 🟢 Adjacent quoted tokens split differently from cmd.exe ( if '""' in text:
return None
try:
tokens = shlex.split(text, posix=False)🟢 🟢 Doc wording ( Parser checks run here (loaded the module directly): Strengths
|
del ab split into two names where the program may read one, so Undo could claim a file it never copied; a cmd line with an empty quote pair is now left untracked. An sh delete with # is left untracked too, since sh reads the rest as a comment. The guide now names the powershell form of Remove-Item, the only one GAIA reads.
|
Both parser edges are closed, CI is green, and the guide now names the form GAIA actually reads ( The Agent UI screenshot of a deleted-then-restored file isn't attached yet. It needs a model to choose the delete on a real-inference machine. The recorder tests run a real 🔍 Technical details
|
|
Checked live in the Agent UI: the file deleted by 🔍 Technical detailsSame live build as #5562 (with #5553 for relayed recording), Fireworks DeepSeek V4 Flash, relayed desktop chat. After the turn: "Changed 1 file · Review changes · Undo this turn"; Outputs listed notes.txt as "File deleted"; Undo restored |

When the agent deleted a file with a shell command (
del notes.txt,rm notes.txt,Remove-Item notes.txt), the turn's Changes view only said it ran a command GAIA can't track, and Undo couldn't bring the file back. Now a plain delete of named files in the workspace shows each file as deleted, with its old contents in the diff, and Undo this turn restores it. A delete GAIA can't read exactly (a wildcard, a variable, a folder, a file outside the workspace, or extra steps on the line) still shows as untracked shell work, so Undo never claims more than it has.Relayed (desktop) chats get this once #5553 lands: the shell tool records into the same turn recorder the sidecar opens there. On
maintoday, relayed turns record nothing at all, shell or otherwise.Test plan
pytest tests/unit/test_shell_undo_marks.py:del/rmof a workspace file shows as deleted byrun_shell_command, with no untracked entry, its old text in the diff, andrestore_turnputs it back.del *.txtstays untracked with no files. Deleting a file outside the allowed paths stays untracked and isn't recorded as restorable. A copy that fails leaves the file and doesn't run the command.pytest tests/unit/agents/test_shell_deletes.py: which delete forms are read (cmd, sh, PowerShell) and which are left as unknown.del notes.txtunderchanges_turn_id: the relayed turn lists the file as deleted, with no untracked work, and Undo restores it. This was a local check only, not added here, because it depends on fix(ui): show a relayed agent's file changes in Outputs, Changes and Undo #5553.pytest tests/unit/test_shell_*.py tests/unit/chat tests/unit/agents -n 4: 7688 passed. There was 1 setup error from a thread left running by an earlier test (test_step_timing), and that test passes when run alone.origin/mainalso had 1 setup error in the same run, in a different test (test_email_phishing_guard).python util/lint.py --black --isort --pylint --flake8🔍 Technical details
shell_deletes.split_exactsplits a step the way cmd.exe or sh will hand it to the program. It returns None for anything that could expand or re-split:%,^,!,*,?,$, backticks,~, redirections, cmd's,;=name separators, or single quotes under cmd.delete_operandsreadsdel/erase(/f,/q),rm(-f,-v,--),unlink, andpowershell/pwshrunning oneRemove-Itemstatement (-Path/-LiteralPath/positional,-Force,-Confirm:$false). Recursive flags,/s,/p,-i, drive-relative paths, ADS/device paths and names Windows trims are all refused.ShellToolsMixin._snapshot_shell_deletesruns wherenote_untracked("shell", …)used to, after the cancel check and before anything spawns. It callsbefore_change(path, "run_shell_command")for each operand that is a regular file (not a link), at most 64 MiB, outside credential folders, and inside_path_allowed(..., prompt_user=False). The untracked note is skipped only when every step is acdor a fully copied delete. ASnapshotErrorreturns NOT_EXECUTED, the same rule the file tools follow.change: "deleted"with a diff, and the webui already renders that, so there's no frontend change.