fix(core): remember Windows session approvals (#4212) #4213
+214
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4212
What
Add
remember_approved_command
so both the displayed and executed command vectors are cached after an “Approve for this session” decision.Invoke the helper from the approval and sandbox-retry paths instead of
add_approved_command
.Add a regression test that previously failed on Windows because only the translated PowerShell vector was stored.
Fold in “Align Windows command allowlist with Unix” so the Windows sandbox now treats the same commands as auto-approved as Unix does:
cat
,cd
,echo
,false
,grep
,head
,ls
,nl
,pwd
,tail
,true
,wc
,which
find
provided none of{-exec, -execdir, -ok, -okdir, -delete, -fls, -fprint, -fprint0, -fprintf}
rg
when omitting--pre
,--hostname-bin
,--search-zip
, and-z
(including equals forms)git
subcommands:{branch, status, log, diff, show}
cargo check
sed -n {N|M,N}p FILE
with the same numeric validation as UnixWhy
How
codex-rs/core/src/codex.rs
to translate the cached vectors.codex::tests::remember_approved_command_records_both_variants
.is_safe_command_windows
so it mirrors the Unix logic and document its behavior with unit tests incodex-rs/core/src/command_safety/windows_safe_commands.rs
.Testing
cargo fmt
cargo clippy -p codex-core --fix --allow-dirty --tests --all-features
cargo test -p codex-core
(fails:unified_exec::tests::reusing_completed_session_returns_unknown_session
, known upstream)cargo test --all-features
(same known failure as above)NOTE: I merged in the windows safe commands branch I made because the original changes in this branch were still useless if there was no windows safe commands to begin with. Since we wrap pwsh.exe i used commands that alias the correct powershell commands. Would need to build a command string parser to handle straight powershell commands directly.