Skip to content

fix(cli): match real gh pr create invocations and use the hook payload cwd - #1060

Merged
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
fix/pre-pr-hook-cwd-match
Oct 3, 2026
Merged

Zach Dunn (zachdunn) merged 1 commit into
mainfrom
fix/pre-pr-hook-cwd-match

Conversation

@zachdunn

Copy link
Copy Markdown
Member

Summary

Two fixes to uploads hook pre-pr-screenshot:

  1. False trigger. looksLikeGhPrCreate used command.includes("gh pr create"), so the reminder fired on commands that only mention the text, such as grep "gh pr create" f.
  2. Wrong branch. The handler ran git in process.cwd(). In Claude desktop worktree sessions that is the main checkout, not the session's worktree.

How it reproduced

The reminder fired on a grep for the phrase, and it reported the main checkout's branch (codex/openai-directory) from a desktop worktree session.

Matching rule

  • Quoted substrings are blanked first, so grep "gh pr create" f and echo 'gh pr create' do not match.
  • gh pr create must be in command position: at the start, or after ;, &, |, ( or a newline, with optional VAR=value prefixes.
  • gh pr create-ish does not match.
  • Working directory order: hook payload cwd (or Cursor workspace_roots[0]), then deps.cwd, then process.cwd(). A leading cd <dir> && overrides it when the directory exists.

This is a pragmatic check, not a shell parser.

Tests

  • pnpm --filter @buildinternet/uploads test: 84 files, 1534 tests pass (new cases cover matching, non-matching, cwd precedence and leading cd, using real temp git repos).
  • pnpm --filter @buildinternet/uploads typecheck and root pnpm typecheck: pass.
  • oxlint on the changed files: clean. Root pnpm lint fails in a fresh worktree on missing generated worker-configuration.d.ts in apps/api, auth and mcp, which this change does not touch.

Includes a patch changeset for @buildinternet/uploads.

Follow-up

plugins/claude/uploads/hooks/register.tsx has a similarly loose PR_CREATE = /\bgh\s+pr\s+create\b/ regex. It should get the same command-position treatment in a separate change.

@changeset-bot

changeset-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7b77e39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@buildinternet/uploads Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (2)
  • coderabbit:review
  • review
🚫 Excluded labels (none allowed) (1)
  • wip

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: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b65c48e3-399d-468c-b868-c3cffae10a4c

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
  • Autopilot · 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.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
uploads-auth 7b77e39 Oct 03 2026, 10:31 PM

@zachdunn
Zach Dunn (zachdunn) merged commit 02a800a into main Oct 3, 2026
4 checks passed
@zachdunn
Zach Dunn (zachdunn) deleted the fix/pre-pr-hook-cwd-match branch October 3, 2026 23:07
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