Skip to content

[FEATURE] Let the user choose the saved approval scope in the "Always allow" prompt (e.g. parent directories for external_directory) #64430

Closed as duplicate

Description

@mezen

Current behavior

When a permission prompt resolves to ask, the tool decides which pattern an
Allow always reply will save — the user only picks whether to save, not
what gets saved. (Since #47369 the prompt previews the proposed pattern,
which confirms the behavior but offers no choice.) For external_directory,
the proposed pattern is the exact canonical directory boundary the access
touched.

Problem

The proposed pattern is frequently the wrong trust scope. Concrete pain:

Prompt: external_directory C:/projects/acme/components/libs/src/net/core/*
        [ Allow once ]  [ Always allow ]  [ Reject ]

Clicking Always allow saves C:/projects/acme/components/libs/src/net/core/*
— that one leaf. The intent was "trust the whole components tree under
C:/projects/acme/components". Every later access to a sibling
(.../src/net/protocols/, .../widgets/, a directory added to the tree later)
prompts again, because each new leaf is a new "first touch". There is no way
in the UI to say "allow everything a few levels up"; the only workarounds are
hand-editing opencode.jsonc or rewriting the stored rule in the SQLite DB
directly (#50600).

The mirror-image problem (the tool proposes a pattern that is too broad,
e.g. webfetch always saving *) is the same feature family from the other
direction and would be covered by the same design: the saved pattern should be
a choice the user makes, with the tool's proposal as default.

Requested change

When an approval prompt is shown, let the user pick the scope of the pattern
that "Always allow" will persist, with the tool-proposed pattern as the default
selection:

  1. external_directory: offer the ancestor chain of the proposed boundary
    as selectable options (top-down by breadth):
    Always allow for:
    ▸ C:/projects/acme/components/libs/src/net/core/*   (proposed)
    ▸ C:/projects/acme/components/libs/src/net/*
    ▸ C:/projects/acme/components/libs/*
    ▸ C:/projects/acme/components/*
    ▸ C:/projects/acme/*
    
    (depth capped to a reasonable bound, and/or free-text pattern entry
    validated against the whole-value wildcard grammar)
  2. webfetch: the same mechanism with host/path derivation (the
    mirror-image case, e.g. https://example.com/docs/* instead of *;
    requested separately in the companion path-scoping issue).
  3. shell / others: keep the current single proposal where sensible
    (command prefixes), but route through the same UX so users can widen or
    narrow before saving (see also [FEATURE]: Add a way to choose "exact command" vs. "pattern" when granting always-allow #49165 for the shell-specific exact-match
    variant).

Why it matters

  • Trust decisions are made at the tree level in practice (a repo, a component
    set, a vendor dir), not at the first-touched leaf; today the UI only encodes
    the leaf, forcing prompt churn or manual DB/config surgery.
  • Turns "Allow always" from an all-or-nothing gamble into a deliberate,
    visible grant — the saved pattern is exactly what the user saw and picked.
  • Directly reduces the need for broad * grants that users later have to
    audit away.

Open questions

Environment

  • opencode version: 2.3.0
  • OS: Windows 11 (Windows 10.0.26300, win32 x64)
  • Terminal: Unavailable (terminal environment variables not set)
  • Shell: C:\WINDOWS\system32\cmd.exe (PowerShell used for tooling)
  • Install/channel: release (latest)
  • Active plugins: none found in config

Activity

  1. opencodejr commented on Nov 17, 2026

    @opencodejr
    Contributor

    Thanks for the thorough write-up. You're asking for a way to choose which pattern Always allow saves, with the tool's proposal selected by default. For external_directory that would be a list of parent folders; webfetch and shell would use the same picker to widen or narrow the pattern.

    Some context from the current code: the docs describe Always allow as saving "the tool's proposed patterns for the project". For external_directory, the saved pattern is the external folder's project root plus /* if it has one, otherwise the folder itself plus /*. The prompt doesn't offer any other choice, so this is a new feature rather than a bug. Maintainers will consider it.

    Related issues:

    As far as I could tell, a plugin can't add choices to the approval prompt or change the saved pattern, so this would need a change in OpenCode itself.

  2. added
    area/core
    type/feature
    version/v2
    on Nov 17, 2026
  3. neriousy commented on Nov 23, 2026

    @neriousy
    Member

    Closing as a duplicate of #48011: choosing the scope saved by "Always allow". Please follow that issue for updates and add any extra details there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreplatform/windowstype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions