Skip to content

chore: pull protos from BSR module instead of vendoring - #11

Merged
Ryan Zhu (underthestars-zhy) merged 4 commits into
mainfrom
chore/protos-from-bsr
Jul 21, 2026
Merged

chore: pull protos from BSR module instead of vendoring#11
Ryan Zhu (underthestars-zhy) merged 4 commits into
mainfrom
chore/protos-from-bsr

Conversation

@invisicat

@invisicat Andy (invisicat) commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

switching proto sourcing from vendored in-tree files to the Buf Schema Registry. buf generate now pulls directly from buf.build/photon-hq/whatsapp (tracking main), and the local proto/ directory and buf.yaml are removed.

Verification

  • ✅ bun run generate pulls from the BSR (incl. with clean HOME/no auth, matching CI)
  • ✅ git diff src/generated/ - photon service files byte-identical, comment-only churn in timestamp.ts
  • ✅ tsc --noEmit clean
  • ✅ bun test - 70/70 pass
  • ✅ bun run build (generate + tsup) succeeds

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

Medium Risk
Build and release packaging change how schema is sourced and verified; runtime API should stay equivalent if the pinned BSR ref matches the old protos, but CI now gates on BSR availability and committed generated output.

Overview
Proto sourcing moves from in-repo proto/ to a pinned Buf Schema Registry module (buf.build/photon-hq/whatsapp in buf.gen.yaml). Local buf.yaml and all vendored .proto files are removed; bun run generate now drives codegen from BSR. Published npm tarballs no longer include proto—only dist.

CI adds a GitHub Actions workflow on PRs and main pushes: install with frozen lockfile, run generate, fail if src/generated/ drifts from BSR, then type-check, lint, test, and build.

Docs clarify that generate targets the BSR module. Regenerated timestamp.ts has comment/range churn only; mapper gets a formatting-only tweak on inbound order productItems mapping.

Reviewed by Cursor Bugbot for commit 4acb471. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Breaking Changes

    • Removed WhatsApp shared, message, and media service interfaces (including sending messages, event subscriptions, missed-event fetching, and media upload/URL retrieval/deletion).
    • Removed associated webhook/message and related type definitions.
  • Build & Distribution

    • Protobuf types are now generated from the hosted WhatsApp schema using a pinned reference.
    • Published packages now include compiled output only (protocol sources excluded).
  • Documentation

    • Updated development instructions to reflect the protobuf generation source.
  • Bug Fixes

    • Improved inbound order mapping to consistently return mapped productItems (or an empty list).
  • CI

    • Added CI to regenerate/verify protos, then run checks, lint, tests, and build.

Point buf generate at buf.build/photon-hq/whatsapp and remove the
vendored proto/ directory and buf.yaml. Codegen (ts-proto/nice-grpc)
and runtime are unchanged; raw protos are no longer shipped in the
npm tarball.
@invisicat Andy (invisicat) self-assigned this Jul 20, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 23:37

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Buf generation now references a pinned remote WhatsApp module, CI verifies generated output and project checks, npm packaging excludes proto, and inbound order product items are mapped explicitly.

Changes

WhatsApp generation and validation

Layer / File(s) Summary
Remote protobuf generation and publishing
buf.gen.yaml, README.md, package.json
Buf generation uses the pinned buf.build/photon-hq/whatsapp module, documentation identifies the source, and published packages include only dist.
CI generation checks
.github/workflows/ci.yaml
CI regenerates protobuf code, checks src/generated/ for drift, then runs type-checking, linting, tests, and the build.
Inbound order product mapping
src/transport/mapper.ts
Inbound order mapping derives product items from the protobuf payload and defaults to an empty array when unavailable.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: copilot

Poem

A rabbit hops through Buf’s bright lane,
Remote types arrive like spring rain.
CI checks each generated byte,
Order items map just right.
“Neat!” twitches whiskers again.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the switch from vendored protos to the Buf Schema Registry module.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/protos-from-bsr

Comment @coderabbitai help to get the list of available commands.

…, build

Also apply pending Biome formatting to mapper.ts so lint passes.
Copilot AI review requested due to automatic review settings July 20, 2026 23:39

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@buf.gen.yaml`:
- Around line 2-3: Pin the buf.build/photon-hq/whatsapp module in the inputs
configuration to an explicit stable commit or tag, ensuring buf generate uses a
reproducible BSR input instead of resolving the latest module.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cb5d3b4c-e929-44c0-a144-96ff3ab026b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1faf0c6 and 26d649b.

⛔ Files ignored due to path filters (1)
  • src/generated/google/protobuf/timestamp.ts is excluded by !**/generated/**
📒 Files selected for processing (7)
  • README.md
  • buf.gen.yaml
  • buf.yaml
  • package.json
  • proto/photon/whatsapp/v1/common.proto
  • proto/photon/whatsapp/v1/media_service.proto
  • proto/photon/whatsapp/v1/message_service.proto
💤 Files with no reviewable changes (4)
  • buf.yaml
  • proto/photon/whatsapp/v1/media_service.proto
  • proto/photon/whatsapp/v1/common.proto
  • proto/photon/whatsapp/v1/message_service.proto
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (2)
README.md (1)

67-67: LGTM!

package.json (1)

14-14: LGTM!

Comment thread buf.gen.yaml Outdated
Makes buf generate deterministic across dev, CI, and the
publish-time build; schema updates now require an explicit,
reviewable ref bump.
Copilot AI review requested due to automatic review settings July 20, 2026 23:43

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/ci.yaml (1)

17-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pin the Bun version used by CI.

Using latest allows an unrelated Bun release to change installation, generation, or build behavior. Use the repository’s pinned toolchain version or a committed version file instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yaml around lines 17 - 19, Update the Bun setup
configuration using oven-sh/setup-bun@v2 to reference the repository’s pinned
Bun toolchain version or committed version file instead of latest. Preserve the
existing CI setup while ensuring future Bun releases cannot change workflow
behavior unexpectedly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yaml:
- Around line 27-32: Update the “Check generated code is in sync” workflow step
to include untracked files when comparing src/generated/ against the repository
state. Ensure newly generated files cause the check to fail, while preserving
the existing error message and generation command guidance.
- Line 15: Update the actions/checkout@v4 step in the CI workflow to set
persist-credentials to false, ensuring the checkout action does not retain
GITHUB_TOKEN credentials for subsequent PR-controlled steps.

---

Nitpick comments:
In @.github/workflows/ci.yaml:
- Around line 17-19: Update the Bun setup configuration using
oven-sh/setup-bun@v2 to reference the repository’s pinned Bun toolchain version
or committed version file instead of latest. Preserve the existing CI setup
while ensuring future Bun releases cannot change workflow behavior unexpectedly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b8d98189-5c64-4073-860c-10082cf732d6

📥 Commits

Reviewing files that changed from the base of the PR and between 26d649b and 067214f.

📒 Files selected for processing (2)
  • .github/workflows/ci.yaml
  • src/transport/mapper.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Cursor Bugbot
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use explicit types for function parameters and return values when they enhance clarity
Prefer unknown over any when the type is genuinely unknown
Use const assertions (as const) for immutable values and literal types
Leverage TypeScript's type narrowing instead of type assertions

Files:

  • src/transport/mapper.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,jsx,ts,tsx}: Use meaningful variable names instead of magic numbers - extract constants with descriptive names
Use arrow functions for callbacks and short functions
Prefer for...of loops over .forEach() and indexed for loops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Use const by default, let only when reassignment is needed, never var
Always await promises in async functions - don't forget to use the return value
Use async/await syntax instead of promise chains for better readability
Handle errors appropriately in async code with try-catch blocks
Don't use async functions as Promise executors
Remove console.log, debugger, and alert statements from production code
Throw Error objects with descriptive messages, not strings or other values
Use try-catch blocks meaningfully - don't catch errors just to rethrow them
Prefer early returns over nested conditionals for error cases
Extract complex conditions into well-named boolean variables
Use early returns to reduce nesting
Prefer simple conditionals over nested ternary operators
Don't use eval() or assign directly to document.cookie
Avoid spread syntax in accumulators within loops
Use top-level regex literals instead of creating them in loops
Prefer specific imports over namespace imports

Files:

  • src/transport/mapper.ts
🪛 zizmor (1.26.1)
.github/workflows/ci.yaml

[warning] 15-15: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🔇 Additional comments (2)
.github/workflows/ci.yaml (1)

1-13: LGTM!

Also applies to: 21-25, 34-44

src/transport/mapper.ts (1)

513-519: 🩺 Stability & Availability

No change needed for productItems. OrderContent.productItems is always initialized to an array, so proto.order?.productItems.map(...) ?? [] is safe here.

			> Likely an incorrect or invalid review comment.

Comment thread .github/workflows/ci.yaml
Comment thread .github/workflows/ci.yaml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Andy (@invisicat) does this need release label?

Copilot AI review requested due to automatic review settings July 20, 2026 23:45

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@invisicat

Copy link
Copy Markdown
Collaborator Author

Ryan Zhu (@underthestars-zhy) no not yet, i am making changes to proto (adding typing indicator support)

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4acb471. Configure here.

Comment thread buf.gen.yaml
inputs:
# Pinned BSR commit (main @ spectrum-whatsapp-business 17e7e9c).
# To pick up schema changes: update the ref, run `bun run generate`, commit both.
- module: buf.build/photon-hq/whatsapp:b218d3336d65421c8b215137797db344

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale generated files evade sync check

Medium Severity

buf generate now pulls a remote BSR module, and CI treats a clean git diff on src/generated/ as proof of sync, but buf.gen.yaml does not set clean: true. If a later pin drops or renames protos, old generated files stay on disk untouched, so the sync check still passes and stale types can ship.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4acb471. Configure here.

@underthestars-zhy

Copy link
Copy Markdown
Member

so this is not ready to merge?

@underthestars-zhy
Ryan Zhu (underthestars-zhy) merged commit d6cd1db into main Jul 21, 2026
3 checks passed
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.

3 participants