Skip to content

feat(tui): save exact file ask rules from write approvals#3547

Merged
Hmbown merged 1 commit into
Hmbown:mainfrom
greyfreedom:feat/save-file-ask-rules
Jun 24, 2026
Merged

feat(tui): save exact file ask rules from write approvals#3547
Hmbown merged 1 commit into
Hmbown:mainfrom
greyfreedom:feat/save-file-ask-rules

Conversation

@greyfreedom

Copy link
Copy Markdown
Contributor

Summary:

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 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
matching uses, so the stored rule equals what matching compares against.

Scope:

  • write_file and edit_file S save only.
  • Save the exact workspace-relative path; absolute in-workspace paths are
    stored in their workspace-relative form.
  • Empty, traversing, drive-relative, or outside-workspace paths build no
    rule: the preview is hidden and S stays disabled.
  • Reuse the existing ConfigStore::append_ask_rules dedup / atomic write /
    permission handling — no change to the persistence layer.
  • Expose normalize_workspace_relative_path as pub (no behavior change).

Not in this slice:

  • read_file (this boundary is write approvals only).
  • apply_patch, directory rules, globs, allow/deny typing.
  • Any runtime matching or YOLO-mode change (approvals are bypassed before
    the modal is built, so YOLO retains full freedom).

Builds on:

  • 7a05cda fix(tui): normalize file ask-rule paths relative to workspace
    (already on main) — reuses its workspace-relative normalization.

Issues:

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

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
@greyfreedom greyfreedom requested a review from Hmbown as a code owner June 24, 2026 09:37
@github-actions

Copy link
Copy Markdown

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 CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

@Hmbown Hmbown merged commit b244dfd into Hmbown:main Jun 24, 2026
11 checks passed
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.

2 participants