Skip to content

fix(chat): report the sender's refusal when OpenCode skill typing is stopped before anything is typed - #1799

Merged
devswha merged 1 commit into
mainfrom
fix/opencode-skill-refusal
Oct 24, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/opencode-skill-refusal

Conversation

@devswha

@devswha devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • server/core/composer.ts, the OpenCode @skill typing in submitText: every write already passed the sender's check as herdr's write guard. Two problems remained.
    • The check dropped the refusal.
    • typed was set as soon as the check before a write passed, before herdr was reached.
  • What a sender revoked or switched to watching while the first piece was on its way got: submit_partial, "Part of the message was typed into OpenCode's input, but sending was not confirmed... Check the terminal", even though nothing was typed.
  • Now:
  • server/opencode-first-message.contract.test.ts: answers a sender that switched to observe while its @skill was on its way with its own refusal, typing nothing.
    • It uses the file's verified OpenCode 2.0.32 stand-in. The sender's connection switches to observe right before @effect reaches the isolated test herdr, and the real RPC then asks the guard.
    • It expects read_only, and that no write went through and the stand-in received nothing.
    • The file's pane and connection setup moved into openCodePane and connect, shared with the first-message cases.
  • changelog.d/opencode-skill-refusal.md.

Verification

  • On main the new test fails: the submit answers submit_partial. It passes with this change.
  • server/opencode-first-message.contract.test.ts 5/5, server/submit.contract.test.ts 88/88.
  • Unit tests in server/core, server/opencode-skill-attach.test.ts, server/opencode-native.test.ts and server/conventions.test.ts: 145/145.
  • Typecheck, bun run check fast.

Not changed here: queued delivery types skills through its own guard in server/core/pending.ts (open PR #1795 touches that file).

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8511a54 and 169b861.

Files selected for processing: 3
  • changelog.d/opencode-skill-refusal.md
  • server/core/composer.ts
  • server/opencode-first-message.contract.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • OpenCode messages that are blocked before any text is typed now report the original refusal instead of appearing partially typed. This includes cases where the device is revoked or switches to observe mode.
    • Messages that fail after typing has begun continue to be reported as partially submitted.

OpenCode skill typing now preserves authorization or deadline refusals when no write succeeds. The contract test verifies that switching to observe mode before typing returns read_only with no text written or typed.

Changes: OpenCode skill refusal handling

Layer / File(s) Summary
Preserve refusals before typing
server/core/composer.ts, changelog.d/opencode-skill-refusal.md
The wrapped text and key writers mark typing only after a permitted write. If no write succeeds, the composer throws the preserved refusal instead of the typing error. The changelog records the reported behavior.
Verify refusal before typing
server/opencode-first-message.contract.test.ts
The test setup supports explicit pane states and WebSocket connections. A new test checks that a switch to observe mode before an @effect write returns read_only and writes or types no text.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#1792: Both changes address sender authorization during immediate chat delivery in server/core/composer.ts.
  • devswha/ovis#1796: Both changes preserve authorization refusals in createSubmitText typing paths.
  • devswha/ovis#1798: Both changes preserve the sender's refusal instead of returning a typing cancellation error.
Merge Risk: Minimal · up to 169b8

The change appears ready to merge after normal checks: an OpenCode skill message refused before typing is reported as unsent rather than partially typed.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: reporting the sender's refusal when OpenCode skill typing stops before any text is typed.
Description check Passed The description explains the problem, resulting behavior, implementation scope, regression test, contract-test coverage, verification results, and explicitly notes the queued-delivery limitation. It u…
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (1 skipped: 1 u…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, resulting behavior, implementation scope, regression test, contract-test coverage, verification results, and explicitly notes the queued-delivery limitation. It uses Summary and Verification headings instead of the template's Change and Validation headings, but it provides the required information.

Full details: Docstring Coverage

Explanation

Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: this touches observe permissions, so this comment records the review. A gate reviewer on a different model than the author's found no blocking issues.

Behaviour checked:

  • typed is now set at herdr's real write guard, for both the skill text and the autocomplete keys.
  • If the first write is refused, the sender gets its own refusal (read_only, device_revoked or submit_timeout).
  • An error after a write went through is still submit_partial.
  • No path sends anything twice.

Tests:

  • 145 unit tests, the typecheck and 88 submit.contract tests pass.
  • All five OpenCode contracts pass in three separate isolated runs.
  • Seven extra fault-boundary probes pass.

Test refactor: moving the setup into openCodePane/connect keeps what the existing cases test, and adds no fixed sleeps. The fs.watch race seen on main ("no Enter after the message") is unchanged and didn't reproduce.

All required checks are green and no review thread is open.

@devswha
devswha merged commit 1eef5c7 into main Oct 24, 2026
17 checks passed
@devswha
devswha deleted the fix/opencode-skill-refusal branch October 24, 2026 02:55
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.

1 participant