Skip to content

Make terminal permission pattern suggestions subcommand-specific#49148

Merged
eholk merged 2 commits intozed-industries:mainfrom
eholk:subcommand-specific-terminal-patterns
Feb 18, 2026
Merged

Make terminal permission pattern suggestions subcommand-specific#49148
eholk merged 2 commits intozed-industries:mainfrom
eholk:subcommand-specific-terminal-patterns

Conversation

@eholk
Copy link
Contributor

@eholk eholk commented Feb 13, 2026

Previously, clicking "Always allow for cargo commands" after running cargo build --release would also silently permit cargo run (arbitrary code execution), cargo publish, and any other cargo subcommand. This was overly broad and did not match user intent.

Now the extracted pattern includes the subcommand when present, so the button reads "Always allow for cargo build commands" and the pattern ^cargo\s+build\b only matches cargo build invocations — not cargo test, cargo run, etc.

How it works

  • The second token is included in the pattern when it looks like a subcommand (alphanumeric, hyphens, underscores, no leading -).
  • When the second token is a flag (e.g. ls -la), only the command name is used — the user sees "Always allow for ls commands".
  • Single-word commands and path-like commands behave the same as before.

Examples

Command Pattern Button label
cargo build --release ^cargo\s+build\b Always for cargo build commands
cargo test -p search ^cargo\s+test\b Always for cargo test commands
npm install ^npm\s+install\b Always for npm install commands
ls -la ^ls\b Always for ls commands
ls ^ls\b Always for ls commands
./script.sh (rejected) (no pattern button)

Release Notes:

  • Agent: "Always allow" suggestions for terminal commands are now subcommand-specific (e.g. "Always allow for cargo build commands" instead of "Always allow for cargo commands").

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 13, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 13, 2026
@eholk eholk requested a review from rtfeldman February 13, 2026 22:50
@eholk eholk marked this pull request as ready for review February 13, 2026 22:51
@eholk eholk force-pushed the subcommand-specific-terminal-patterns branch from b957771 to ef11322 Compare February 13, 2026 23:16
Previously, clicking "Always allow for `cargo` commands" after running
`cargo build --release` would also silently permit `cargo run` (arbitrary
code execution), `cargo publish`, and any other cargo subcommand. This was
overly broad and did not match user intent.

Now the extracted pattern includes the subcommand when present, so the
button reads "Always allow for `cargo build` commands" and the pattern
`^cargo\s+build\b` only matches `cargo build` invocations — not
`cargo test`, `cargo run`, etc.

How it works:

- The second token is included in the pattern when it looks like a
  subcommand (alphanumeric, hyphens, underscores, no leading `-`).
- When the second token is a flag (e.g. `ls -la`), only the command name
  is used — the user sees "Always allow for `ls` commands".
- Single-word commands and path-like commands behave the same as before.

Examples:

  cargo build --release  ->  ^cargo\s+build\b  ("cargo build" commands)
  cargo test -p search   ->  ^cargo\s+test\b   ("cargo test" commands)
  npm install            ->  ^npm\s+install\b   ("npm install" commands)
  ls -la                 ->  ^ls\b              ("ls" commands)
  ./script.sh            ->  (rejected)

Release Notes:

- Agent: "Always allow" suggestions for terminal commands are now
  subcommand-specific (e.g. "Always allow for `cargo build` commands"
  instead of "Always allow for `cargo` commands").
@eholk eholk force-pushed the subcommand-specific-terminal-patterns branch from ef11322 to af5a560 Compare February 17, 2026 23:45
@eholk eholk requested a review from a team as a code owner February 18, 2026 00:30
@eholk eholk merged commit d60b291 into zed-industries:main Feb 18, 2026
27 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 18, 2026
�
I can now see the relevant commits. Let me generate the documentation update summary based on the Phase 6 format:

## Documentation Update Summary

### Changes Made

| File | Change | Related Code |
| --- | --- | --- |
| docs/src/ai/external-agents.md | Removed "resuming threads from history" from unavailable features list for Gemini CLI, Claude Agent, and Codex | PR #49449 (b4baea8) - Enable history for external agents |
| docs/src/ai/tool-permissions.md | Added documentation for subcommand-specific permission patterns in terminal commands | PR #49148 (d60b291) - Make terminal permission pattern suggestions subcommand-specific |
| docs/src/configuring-languages.md | Formatting fix - removed extra blank line in Storage Location list | PR #49177 (6daa541) - Apply documentation standards |
| docs/src/development.md | Formatting fix - removed extra blank lines in numbered list items | PR #49177 (6daa541) - Apply documentation standards |
| docs/src/extensions/themes.md | Formatting fix - removed extra blank lines between numbered list items and their content | PR #49177 (6daa541) - Apply documentation standards |
| docs/src/languages/r.md | Formatting fix - removed extra blank line in extension list | PR #49177 (6daa541) - Apply documentation standards |
| docs/src/reference/all-settings.md | Formatting fix - removed extra blank line in preview tabs description list | PR #49177 (6daa541) - Apply documentation standards |
| docs/src/vim.md | Formatting fix - removed extra blank line in text objects section | PR #49177 (6daa541) - Apply documentation standards |

### Rationale

These documentation updates were triggered by two code changes:

1. **External agent history feature** (PR #49449): External agents (Gemini CLI, Claude Agent, Codex) now support resuming threads from history, so this was removed from the "not yet available" features list in the external-agents documentation.

2. **Subcommand-specific terminal permissions** (PR #49148): Terminal tool permission patterns now include subcommands (e.g., `cargo build` instead of just `cargo`), providing more granular permission control. Documentation was updated to explain this behavior to users.

3. **Documentation formatting standards** (PR #49177): Several files had inconsistent formatting with extra blank lines in numbered/bulleted lists that were cleaned up to match Prettier/mdBook standards.

### Review Notes

- The external-agents.md changes are content updates reflecting new feature availability - reviewers should verify the history feature is indeed working for all three external agent types
- The tool-permissions.md change adds clarification for existing behavior - the example uses `cargo build` as a concrete illustration
- The remaining files (configuring-languages.md, development.md, extensions/themes.md, languages/r.md, reference/all-settings.md, vim.md) contain only formatting fixes with no semantic changes
- All changes follow the documentation conventions in `docs/AGENTS.md`

Triggered by: pr 48957

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request Feb 18, 2026
�
Now I have a clear picture. Let me generate the documentation update summary:

## Documentation Update Summary

### Changes Made

| File | Change | Related Code |
| --- | --- | --- |
| `docs/src/ai/external-agents.md` | Updated thread history availability notes for Gemini CLI, Claude Agent, and Codex—clarifying that thread history is now available for Claude Agent and Codex, while Gemini CLI depends on ACP capabilities | PR #49449 (`acp: Enable history for external agents for all users`) |
| `docs/src/ai/tool-permissions.md` | Added new "Subcommand-Specific Patterns" section explaining how terminal permission patterns extract subcommands (e.g., `cargo build` vs `cargo test`) | PR #49148 (`Make terminal permission pattern suggestions subcommand-specific`) |
| `docs/src/configuring-languages.md` | Removed unnecessary blank line before Storage Location list | PR #49177 (`docs: Apply documentation standards`) |
| `docs/src/development.md` | Removed unnecessary blank lines in workflow steps | PR #49177 (`docs: Apply documentation standards`) |
| `docs/src/extensions/themes.md` | Removed unnecessary blank lines after numbered list items | PR #49177 (`docs: Apply documentation standards`) |
| `docs/src/languages/r.md` | Removed unnecessary blank line in extension list | PR #49177 (`docs: Apply documentation standards`) |
| `docs/src/reference/all-settings.md` | Removed unnecessary blank line before list in preview tabs description | PR #49177 (`docs: Apply documentation standards`) |
| `docs/src/vim.md` | Removed unnecessary blank line before list in text objects section | PR #49177 (`docs: Apply documentation standards`) |

### Rationale

These documentation updates fall into two categories:

1. **Feature documentation updates**: The external agents and tool permissions changes reflect actual code changes that modified user-facing behavior:
   - Thread history was enabled for external agents (Claude Agent, Codex) in PR #49449
   - Terminal permission patterns now extract subcommands for more granular control in PR #49148

2. **Formatting standardization**: Several files had inconsistent blank line usage around numbered lists with sub-items. These were normalized to follow consistent markdown formatting without unnecessary blank lines.

### Review Notes

- **Thread history wording**: The external-agents.md changes distinguish between agents that fully support thread history (Claude Agent, Codex) and Gemini CLI which depends on its ACP implementation. Reviewers should verify this distinction is accurate.
- **Subcommand patterns table**: The new section in tool-permissions.md includes a table showing example patterns. Verify the regex patterns (`^cargo\s+build\b`, etc.) match the actual implementation in the codebase.
- **Formatting changes**: The blank line removals are purely cosmetic and shouldn't affect rendered output—they simply align with the project's markdown standards.

Triggered by: pr 48999

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant