feat(messages): typingIndicator option on markRead - #12
Conversation
Pins the BSR module to ff29794 (spectrum-whatsapp-business 2cab0fb),
which added MarkReadRequest.typing_indicator. markRead() now accepts
{ typingIndicator: true } to show a typing bubble as a rider on the
read receipt — Meta dismisses it after 25s or on the next send; there
is no stop API. Bumps version to 0.2.1.
📝 WalkthroughWalkthroughThe mark-read API now accepts an optional typing indicator flag, exports its new option type, forwards the flag through gRPC, and tests default and explicit values. The package version and pinned BSR module digest are also updated. ChangesMark-read typing indicator
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/messages.test.ts (1)
6-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse an arrow function for the short test helper.
Convert
makeResourcetoconst makeResource = () => { ... };for consistency with the repository’s TypeScript style.As per coding guidelines, use arrow functions for callbacks and short functions.
Proposed refactor
-function makeResource() { +const makeResource = () => { const calls: MarkReadRequest[] = []; const client = { markRead: (request: MarkReadRequest) => { calls.push(request); return Promise.resolve({}); }, } as unknown as MessageServiceClient; return { messages: new MessagesResource(client), calls }; -} +};🤖 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 `@tests/unit/messages.test.ts` around lines 6 - 15, Convert the makeResource test helper from a function declaration to an arrow-function constant, preserving its existing client setup, calls tracking, and returned MessagesResource behavior.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@tests/unit/messages.test.ts`:
- Around line 6-15: Convert the makeResource test helper from a function
declaration to an arrow-function constant, preserving its existing client setup,
calls tracking, and returned MessagesResource behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1cedc002-10ba-4ebd-949d-2864b1b4e891
⛔ Files ignored due to path filters (1)
src/generated/photon/whatsapp/v1/message_service.tsis excluded by!**/generated/**
📒 Files selected for processing (6)
buf.gen.yamlpackage.jsonsrc/index.tssrc/resources/messages.tssrc/types/messages.tstests/unit/messages.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Cursor Bugbot
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use explicit types for function parameters and return values when they enhance clarity
Preferunknownoveranywhen 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:
tests/unit/messages.test.tssrc/index.tssrc/resources/messages.tssrc/types/messages.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
Preferfor...ofloops over.forEach()and indexedforloops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Useconstby default,letonly when reassignment is needed, nevervar
Alwaysawaitpromises in async functions - don't forget to use the return value
Useasync/awaitsyntax 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
Removeconsole.log,debugger, andalertstatements from production code
ThrowErrorobjects with descriptive messages, not strings or other values
Usetry-catchblocks 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 useeval()or assign directly todocument.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:
tests/unit/messages.test.tssrc/index.tssrc/resources/messages.tssrc/types/messages.ts
**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{test,spec}.{js,jsx,ts,tsx}: Write assertions insideit()ortest()blocks
Avoid done callbacks in async tests - use async/await instead
Don't use.onlyor.skipin committed code
Keep test suites reasonably flat - avoid excessivedescribenesting
Files:
tests/unit/messages.test.ts
**/index.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Avoid barrel files (index files that re-export everything)
Files:
src/index.ts
🔇 Additional comments (6)
src/types/messages.ts (1)
154-167: LGTM!src/index.ts (1)
92-92: LGTM!src/resources/messages.ts (1)
6-6: LGTM!Also applies to: 36-44
tests/unit/messages.test.ts (1)
1-4: LGTM!Also applies to: 17-29
package.json (1)
3-3: LGTM!buf.gen.yaml (1)
3-5: 🗄️ Data Integrity & IntegrationGenerated gRPC sources are already in sync
> Likely an incorrect or invalid review comment.
pins the BSR module to ff29794 (spectrum-whatsapp-business 2cab0fb), which added MarkReadRequest.typing_indicator. markRead() now accepts { typingIndicator: true } to show a typing bubble as a rider on the read receipt. theres no stop indicator b/c meta does not provide one.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
Low Risk
Backward-compatible optional flag on an existing API; scope is limited to mark-read/typing UX with tests.
Overview
Adds optional typing indicator support on
markRead()by wiring through the newMarkReadRequest.typing_indicatorfield from the updated WhatsApp BSR schema (pin bumped toff29794, package 0.2.1).markRead(messageId, options?)now acceptsMarkReadOptionswithtypingIndicator?: boolean(defaults tofalse), so callers can show a typing bubble on the same gRPC call as the read receipt.MarkReadOptionsis exported from the package public API.Unit tests cover default read-only behavior and
typingIndicator: trueforwarding to the gRPC client.Reviewed by Cursor Bugbot for commit d90fc94. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes
Chores