feat(tui): save exact file ask rules from write approvals#3547
Merged
Conversation
Extend the approval modal's "save ask rule" action (previously exec_shell only) to write_file and edit_file. Pressing `S` on a write approval now persists an exact, workspace-relative ToolAskRule::file_path so a later edit/write of the same file is matched. The saved path is normalized through the same codewhale_execpolicy::normalize_workspace_relative_path helper that runtime ask-rule matching uses, so the stored rule equals what matching compares against later. When the path is empty, traversing, drive-relative, or outside the workspace, no rule is built: the preview stays hidden and the `S` shortcut stays disabled. read_file is intentionally excluded — this boundary is about persisting write approvals only. Persistence reuses the existing ConfigStore::append_ask_rules flow (dedup, atomic write, permission handling). No new persistence, directory rules, globs, allow/deny typing, or apply_patch support is added, and YOLO mode is unaffected (approvals are bypassed before the modal is built). Refs Hmbown#1186 (partial) Refs Hmbown#2242 (partial) Validation: - cargo fmt --all - git diff --check - cargo test -p codewhale-execpolicy --locked - cargo test -p codewhale-tui --bin codewhale-tui --locked file_ask_rule
|
Thanks @greyfreedom for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
Extend the approval modal's "save ask rule" action (previously exec_shell
only) to write_file and edit_file. Pressing
Son a write approval persistsan exact, workspace-relative
ToolAskRule::file_path, so a later edit/writeof the same file is matched. The saved path is normalized through the same
codewhale_execpolicy::normalize_workspace_relative_pathhelper that runtimematching uses, so the stored rule equals what matching compares against.
Scope:
write_fileandedit_fileSsave only.stored in their workspace-relative form.
rule: the preview is hidden and
Sstays disabled.ConfigStore::append_ask_rulesdedup / atomic write /permission handling — no change to the persistence layer.
normalize_workspace_relative_pathaspub(no behavior change).Not in this slice:
read_file(this boundary is write approvals only).apply_patch, directory rules, globs, allow/deny typing.the modal is built, so YOLO retains full freedom).
Builds on:
fix(tui): normalize file ask-rule paths relative to workspace(already on main) — reuses its workspace-relative normalization.
Issues:
Validation: