Skip to content

fix(global-settings): push auth lost when the message carries an image (v2.5.1) - #792

Open
WilcoLouwerse wants to merge 1 commit into
mainfrom
fix/push-auth-skip-ismeta
Open

WilcoLouwerse wants to merge 1 commit into
mainfrom
fix/push-auth-skip-ismeta

Conversation

@WilcoLouwerse

Copy link
Copy Markdown
Contributor

Problem

A push phrase (push for me, commit and push, …) typed in a message that also carries a pasted image is never recognised: every push in that turn is denied.

git_push_authorized() treats the last type=="user" transcript entry with a text block as "the last human message". Claude Code also writes isMeta entries of that shape:

  • after a message with a pasted image: [Image: source: /tmp/…/images/1.png]
  • after a skill invocation: the skill body (Base directory for this skill: …)

The meta entry therefore wins. Side effect in the other direction: a skill body that mentions a phrase (e.g. "commit and push the fixes") authorizes a push the human never asked for.

Fix

  • Skip isMeta entries.
  • Count a typed slash command (string content, <command-name> / <command-args>) as a human message, with its arguments as the text. Without this, skipping isMeta alone would let an older phrase survive a later slash command, because string content was ignored entirely.
  • Other string content (task notifications, other-session messages, compaction summaries) stays ignored, as before — it neither grants nor revokes.
  • Streams (jq -c … | tail -n 1) instead of slurping; a 39 MB transcript takes 0.4 s.

Version bump to 2.5.1; one paragraph added to docs/claude/global-claude-settings.md.

Tests

Eight new push-auth layouts (I–P) in test-block-write-commands.sh; make_transcript gained tokens that mirror the real transcript shapes (image message, image meta, slash command, skill meta, task notification, attachment).

Layout Scenario Expect Old hook
I phrase in message with pasted image allow deny
J later image message without phrase deny deny
K phrase in slash-command args allow deny
L later slash command without phrase deny deny
M phrase only inside a skill body deny allow
N phrase only inside an isMeta entry deny allow
O task notification after phrase allow allow
P phrase only inside a task notification deny deny

With the fix: 7556/7556, block-polling 29/29, block-config-tool-writes 80/80. Also checked against real transcripts (typed text found after an image message and after a skill invocation). shellcheck was not run locally.

🤖 Generated with Claude Code

…e (v2.5.1)

git_push_authorized() read the last type=="user" transcript entry with a
text block as "the last human message". Claude Code also writes isMeta
entries of that shape: after a message with a pasted image it appends
"[Image: source: …/images/1.png]", and an invoked skill's body lands as
one too. The meta entry therefore became the last message, so:

- a push phrase typed alongside a screenshot was never seen — every push
  in that turn was denied;
- a skill body that mentions a phrase ("commit and push the fixes")
  authorized a push the human never asked for.

The check now skips isMeta entries. Skipping them alone would let an older
phrase survive a later slash command (typed commands are string content,
which the check ignored), so a typed slash command now counts as a human
message with its <command-args> as the text — it can grant and revoke.
Other string content (task notifications, other-session messages,
compaction summaries) stays ignored, as before.

Tests: eight new push-auth layouts (I–P) covering the image message, a
later image message revoking, slash-command args granting and revoking,
phrases inside a skill body / isMeta entry / task notification not
authorizing, and a task notification not revoking. Against the old hook
I, K, M and N fail; with the fix all suites pass (7556/7556, 29/29,
80/80). Also checked on real transcripts: the typed text is found after
an image message and after a skill invocation; a 39 MB transcript takes
0.4 s.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

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