Skip to content

Cut a long value in an approval between characters, not inside an emoji - #902

Open
kevin9327 wants to merge 1 commit into
CopilotKit:mainfrom
kevin9327:approval-cut-between-characters
Open

kevin9327 wants to merge 1 commit into
CopilotKit:mainfrom
kevin9327:approval-cut-between-characters

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

What this changes

An approval shows what a Bot is about to do. Two cuts there sliced by UTF-16 units:

  • approvalPreview in server/src/approvals/types.ts cuts a string argument longer than 2,000 units with args.slice(0, 1999) + "…".
  • clip in server/src/delivery/opentag.ts cuts each OpenTag approval field to 300 with text.slice(0, max - 1) + "…".

When the cut landed between the two halves of an emoji, the value ended in a lone high surrogate. The person approving then saw �…, and the approval row stored a string that is not valid Unicode.

Both now use cutAtCodeUnits from channels/text.ts, which the MCP, Google Drive, Composio, Arcade and routines result cuts already use. It drops the half character, so nothing gets longer than before. Secret masking runs on the cut text as before.

Where it runs

  • New state that outlives a request? None. The stored preview is the same shape, one unit shorter in the split case.
  • What happens on the second replica? Nothing new.
  • Anything serialised? The preview, as before; it is now always valid Unicode.
  • Anything fanned out to a browser? The same approval card as before.
  • New listener, port, or schedule? None.

Boundary and audit

  • Every acting call still goes through the gateway. Untouched; the preview is display only and the approved action's digest is computed from the full args.
  • New refusals and new failures each write a row. None added.
  • Nothing new is trusted from the client.

Changelog

  • A section in CHANGELOG.md under Unreleased; happy to rebase if it conflicts.

Proof

New case in server/tests/approvals.test.ts. On unmodified main:

Expected: false
Received: true
(fail) an approval preview cuts a long value between characters, not inside an emoji

With the change, bun test tests/approvals.test.ts (18 pass) and tests/delivery-routes.test.ts (25 pass) pass. tsc --noEmit in server/ and biome lint --error-on-warnings on the changed files are clean.

AI assistance: I used an AI coding assistant to find and write this change, and reviewed and tested it myself.

Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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 ⚠️ Failed 2026-10-30T13:38:31.865430Z
We couldn’t complete this review. Comment @codex review to try again.
22a066f 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.

This branch has not been deployed

No deployments
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