Skip to content

Recognize patronus on/off/status behind host context blocks - #90

Merged
benediktveith merged 1 commit into
mainfrom
fix/chat-control-host-envelopes
Oct 25, 2026
Merged

benediktveith merged 1 commit into
mainfrom
fix/chat-control-host-envelopes

Conversation

@benediktveith

Copy link
Copy Markdown
Contributor

Problem

patronus off stopped working in the Claude and Codex desktop apps. The apps put their own tagged context next to the typed message (Claude: a separate <system-reminder>Linked sessions now …</system-reminder> text block; Codex app: blocks like <external_codex_apps_open_page>…). chatCommand only matched a single, exact text value, so the control was scanned as an ordinary prompt and the chat was never paused.

Fix

chatCommand (shared by native hosts and DeepSeek) now sets aside leading <tag>…</tag> blocks in each text value, drops values that become empty, and still requires exactly one remaining value that is exactly the command. Quoted or embedded commands and result text still never match; the check stays at the user-input boundary.

Bundles for Claude, Codex and Cursor rebuilt from the repo root.

Tests

  • plugins/native settings.test.ts: 8/8 pass, with new cases for a prefixed command (matches) and a command followed by extra text (does not match).
  • Manually ran the rebuilt Claude and Codex hooks with a <system-reminder> / <external_codex_apps_open_page> prefix and with Claude's block-array prompt: all return the chat status.
  • Typecheck not run locally (needs DSH_SOURCE_ROOT); left to CI.

🤖 Generated with Claude Code

The Claude and Codex desktop apps put their own tagged context (e.g.
<system-reminder>, <external_codex_apps_open_page>) next to the typed
message, so the exact-message check never matched and chat controls
were scanned as ordinary prompts. Leading tagged blocks are now set
aside before matching; quoted or embedded commands still never match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T17:27:45.607686Z 8063174 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8063174f73

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


/** Only an entire user-authored text value is a control, never result text or a quoted fragment. */
/** Context the host app wraps around the typed message, e.g. `<system-reminder>…</system-reminder>`. */
const hostEnvelope = /^\s*<([a-z][\w-]*)>[\s\S]*?<\/\1>/i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict envelope stripping to known host context tags

When a user submits XML-formatted instructions followed by a command example, this regex discards the instructions as though they were host context. For example, <document>Please explain the following command:</document>\npatronus off now resolves to off. I reproduced this through Claude's handleHook: it invokes the chat control and performs zero scans, so an ordinary explanation request instead disables protection for subsequent input and results. Limit stripping to recognized host context tags rather than treating every leading XML element as disposable.

Useful? React with 👍 / 👎.

@benediktveith
benediktveith merged commit 9a49c48 into main Oct 25, 2026
16 checks passed
@benediktveith
benediktveith deleted the fix/chat-control-host-envelopes branch October 25, 2026 17:39
@benediktveith benediktveith mentioned this pull request Oct 25, 2026
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