Promo Manager, Announcements, Content‑Drops, and admin UX refactor; SSHV/health improvements; add smoke checks - #86
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Sequence DiagramThe PR enhances the smoke test to scan all .js files, extract callback button IDs and bot.action handlers (including regex patterns), and verify every callback has a matching handler (literal or pattern). This diagram shows the core successful path of that static verification. sequenceDiagram
participant TestRunner
participant FileSystem
participant SmokeCheck
participant BotSource
TestRunner->>FileSystem: Collect all .js files under repo
SmokeCheck->>BotSource: Read and concatenate JS sources
SmokeCheck->>BotSource: Extract callback button IDs
SmokeCheck->>BotSource: Extract literal action handlers and regex action patterns
SmokeCheck->>SmokeCheck: Match callbacks against literals or regex patterns
SmokeCheck-->>TestRunner: Pass if all callbacks covered (else fail)
Generated by CodeAnt AI |
Nitpicks 🔍
|
|
|
||
| function extractLiteralIds(source, kind) { | ||
| const regex = kind === 'callback' | ||
| ? /Markup\.button\.callback\([^,]+,\s*(["'`])((?:\\.|(?!\1).)*)\1\)/g |
There was a problem hiding this comment.
Suggestion: The smoke test currently treats callback IDs built with template literals (e.g., containing ${...}) as literal IDs and then tries to match them against regex-based handlers, which will always fail, causing valid dynamically-generated callback buttons like pamenu_gw_end_${gw.id} or help_page_${page - 1} to be reported as "uncovered" even though matching bot.action(/.../) handlers exist; restricting the callback scan to only single/double-quoted literals avoids these false positives while still checking all statically-known IDs. [logic error]
Severity Level: Major ⚠️
- ❌ Smoke test fails despite valid dynamic callback handlers.
- ⚠️ CI/test pipeline may be blocked by false alarms.
- ⚠️ Reduces trust in static callback-to-handler coverage check.| ? /Markup\.button\.callback\([^,]+,\s*(["'`])((?:\\.|(?!\1).)*)\1\)/g | |
| ? /Markup\.button\.callback\([^,]+,\s*(["'])((?:\\.|(?!\1).)*)\1\)/g |
Steps of Reproduction ✅
1. Run the smoke tests, e.g. `node test/smoke.test.js` or the project's test script, which
executes `test('menu callback buttons map to handlers (literal or dynamic patterns)',
...)` in `test/smoke.test.js:50-65`.
2. That test reads all JS sources via `collectJsFiles('.')` and concatenates them into
`combinedSource`, then calls `extractLiteralIds(combinedSource, 'callback')` at
`test/smoke.test.js:56`, using the current regex that matches Markup.button.callback IDs
quoted with single, double, or backtick literals.
3. In `index.js:2293-2294`, callback buttons are defined with template literals for their
callback data, e.g. `Markup.button.callback(#${gw.id} End Early, pamenu_gw_end_${gw.id})`
and similarly for extend/cancel/participants, and in `index.js:3046-3048` help pagination
buttons are defined as `help_page_${page - 1}` / `help_page_${page + 1}`.
4. `extractLiteralIds` currently treats those backtick template literals as literal IDs
(e.g. the string `pamenu_gw_end_${gw.id}`), but when the test compares them against
handlers, the corresponding regex handlers like `bot.action(/^pamenu_gw_end_(\d+)$/, ...)`
at `index.js:4839` and `bot.action(/^help_page_(\d+)$/, ...)` at `index.js:4483` do not
match those literal template strings, so they appear in `uncovered` and cause the
assertion at `test/smoke.test.js:64` to fail with "Uncovered callback handlers:
pamenu_gw_end_${gw.id}, help_page_${page - 1}, ...".Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** test/smoke.test.js
**Line:** 27:27
**Comment:**
*Logic Error: The smoke test currently treats callback IDs built with template literals (e.g., containing `${...}`) as literal IDs and then tries to match them against regex-based handlers, which will always fail, causing valid dynamically-generated callback buttons like `pamenu_gw_end_${gw.id}` or `help_page_${page - 1}` to be reported as "uncovered" even though matching `bot.action(/.../)` handlers exist; restricting the callback scan to only single/double-quoted literals avoids these false positives while still checking all statically-known IDs.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.|
CodeAnt AI finished reviewing your PR. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
User description
Motivation
Description
promoManagerStore) persisted todata/promo-manager-db.json, with new types/fields (PROMO_STATUS,PROMO_REQUIREMENT) and functions for listing, loading, saving, eligibility evaluation, claim creation, and admin approval/denial (/pmapprove,/pmdeny).promoStore/promoCodeStoreflows with DB-backed promos and updates the user-facing/promoand claim flows to use the new promo manager, including admin UI changes (🎛 Promo Manager) and many callback/action renames/aliases for backward compatibility.announceBuilderKeyboard,sendAnnouncementTargets) and maps legacy broadcast actions to the new flow.postTipToConfiguredTarget, better failure handling,/register_chatto capture group/channel targets, and UI/strings updated accordingly.isHealthTlsEnabled, sandbox restriction hint for exec errors, safer editor save with error logging, more admin logs for ctrl actions, GC timersunref()calls, and support for TLS local health checks when keys/certs configured..env.examplecomment forWEBAPP_HMAC_KEY, updated.gitignoreto allow example env files and persist data backups, migration additions tocreateDefaultUser(new flags), many keyboard/menu text refinements and backward-compatible aliases across the bot.test/smoke.test.jsthat syntactically checksindex.jsand performs a static scan to ensure inline callback button IDs map tobot.actionhandlers or regex patterns.Testing
node --check index.jsand the static callback-to-handler coverage test fromtest/smoke.test.js, and both passed locally./register_chatflow were tested withtiptestto confirm messages are attempted to the configured group and failures produce helpful guidance.Codex Task
CodeAnt-AI Description
Scan all JavaScript files for menu callbacks and action handlers in smoke checks
What Changed
Impact
✅ Fewer CI false positives from single-file scans✅ Fewer missed handler mismatches across files✅ Shorter debugging when callbacks lack handlers💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.