Skip to content

fix(providers): surface OpenCode dynamic approval requests - #7788

Open
triamazikamno wants to merge 2 commits into
pingdotgg:mainfrom
triamazikamno:fix/opencode-invisible-approvals
Open

fix(providers): surface OpenCode dynamic approval requests#7788
triamazikamno wants to merge 2 commits into
pingdotgg:mainfrom
triamazikamno:fix/opencode-invisible-approvals

Conversation

@triamazikamno

@triamazikamno triamazikamno commented Aug 21, 2026

Copy link
Copy Markdown

What Changed

  • Surface OpenCode permissions that do not map to shell, read, or edit as actionable dynamic-tool approvals.
  • Include the tool name, authorization scope, and bounded arguments in approval details.
  • Recover tool arguments when OpenCode emits a permission request before its tool input is populated.
  • Keep previously persisted unknown OpenCode approvals actionable on web and mobile.
  • Preserve the existing approval-required permission policy; this does not introduce new filesystem allowances.

Why

OpenCode can emit permission types such as glob, grep, or external tool names that T3 Code previously classified as unknown. Clients did not treat those requests as actionable, leaving the thread stuck in an Approval state without response controls.

OpenCode can also emit the permission request before the corresponding tool input is populated. The adapter now correlates the exact tool call and performs a bounded, abortable lookup for its arguments. If enrichment fails or exceeds 250 ms, the approval still appears with the available permission scope.

Approval details are normalized at the provider boundary. For example:

  • glob: *.md
  • grep: OpenCode
  • skill: fix-review
  • gh_grep_searchGitHub with its structured arguments

The complete display detail is capped at 2,000 characters, while the structured arguments remain intact.

UI Changes

Before, OpenCode threads could remain stuck in Approval without actionable controls, or show only an ambiguous pattern such as *.md.

After, the approval includes response controls and identifies both the tool and requested scope.

Before After
CleanShot 2026-08-20 at 12 30 48@2x + stuck at CleanShot 2026-08-20 at 12 23 15@2x CleanShot 2026-08-21 at 12 47 31@2x

Verification

  • OpenCode adapter and ingestion tests: 40 passed
  • Web approval derivation tests: 76 passed
  • Mobile approval derivation tests: 15 passed
  • Server, web, and mobile typechecks passed
  • Manually verified against a local OpenCode session

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes

Implemented with Codex (gpt-5.6-sol) through the T3 Code Codex harness.


Note

Medium Risk
Touches provider permission mapping and approval UX, including a timed SDK fetch on the event path. Does not change auth or filesystem policy, but a mapping/timeout bug could still stall or mislabel approvals.

Overview
Makes OpenCode permissions that are not bash/read/edit actionable instead of classifying them as unknown and leaving threads stuck in Approval.

The adapter now maps those permissions to dynamic_tool_call, labels them with the tool/skill name and scope, and attaches structured args when available. If the permission arrives before tool input is populated, it looks up the matching tool part (cached first, then a 250ms abortable session.message fetch) and still emits the approval on timeout. Display details are capped at 2,000 characters.

Ingestion stamps these as command approvals. Web and mobile also treat persisted unknown request types as command so older OpenCode approvals remain respondable.

Reviewed by Cursor Bugbot for commit 05ee826. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Surface OpenCode dynamic tool approvals and fix legacy 'unknown' request classification

  • Maps non-standard OpenCode permissions to a new dynamic_tool_call request type and emits request.opened with enriched details (tool name, pretty-printed args) merged from tool input and metadata
  • Enrichment fetches the message via session.message but is bounded to 250 ms (OPENCODE_PERMISSION_ENRICHMENT_TIMEOUT_MS); on timeout it falls back to metadata-only and aborts the fetch. Details are truncated to 2000 characters
  • Extends runOpenCodeSdk to pass an AbortSignal into the callback so SDK calls can be cancelled on timeout
  • Fixes requestKindFromRequestType in session-logic.ts, threadActivity.ts, and ProviderRuntimeIngestion.ts to classify legacy unknown and dynamic_tool_call request types as command instead of dropping them
  • Risk: mapPermissionToRequestType in OpenCodeAdapter.ts now returns dynamic_tool_call instead of unknown for non-standard permissions; any downstream consumer expecting unknown will no longer see it

Macroscope summarized 05ee826.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 343876cc-bdaa-4426-b535-073e544217b7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 21, 2026
@triamazikamno triamazikamno changed the title fix(opencode): surface dynamic approval requests fix(providers): surface OpenCode dynamic approval requests Aug 21, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 460b7fb. Configure here.

Comment thread apps/server/src/provider/Layers/OpenCodeAdapter.ts
@macroscopeapp

macroscopeapp Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces new capability for surfacing dynamic tool approval requests with enriched details. The changes affect core provider orchestration behavior and how approval requests are classified and displayed to users, warranting human review.

You can add or adjust custom eligibility rules. Learn more.

@triamazikamno
triamazikamno force-pushed the fix/opencode-invisible-approvals branch from cb492c3 to 05ee826 Compare August 22, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant