Introduce DB-backed Promo Manager, Announcements, Content Drops, and admin UX improvements - #87
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 · |
| const regex = kind === 'callback' | ||
| ? /Markup\.button\.callback\([^,]+,\s*(["'`])((?:\\.|(?!\1).)*)\1\)/g | ||
| : /bot\.action\(\s*(["'`])((?:\\.|(?!\1).)*)\1/g; | ||
| return new Set(Array.from(source.matchAll(regex), (m) => m[2])); |
There was a problem hiding this comment.
Suggestion: The smoke test currently treats callback IDs built with template literals (e.g., with ${...}) as fixed literal IDs, so they cannot be matched by the corresponding dynamic regex handlers and will always show up as "uncovered" even though handlers exist, causing the test to fail incorrectly; filtering out template-literal IDs from the static literal check fixes this logic error. [logic error]
Severity Level: Major ⚠️
- ❌ Smoke test fails despite valid dynamic callback handlers.
- ⚠️ CI or pre-commit test runs can be blocked.| return new Set(Array.from(source.matchAll(regex), (m) => m[2])); | |
| const ids = Array.from(source.matchAll(regex), (m) => m[2]); | |
| const literalIds = ids.filter((id) => !id.includes('${')); | |
| return new Set(literalIds); |
Steps of Reproduction ✅
1. Run the smoke tests (e.g. `node --test test/smoke.test.js`), which executes the "menu
callback buttons map to handlers (literal or dynamic patterns)" test defined in
`test/smoke.test.js:50-65`.
2. That test calls `collectJsFiles('.')` and concatenates all JS sources, then invokes
`extractLiteralIds(combinedSource, 'callback')` from `test/smoke.test.js:25-29` to collect
callback IDs from `Markup.button.callback(...)` usages.
3. In `index.js`, there are callback buttons whose callback data is built with template
literals, for example `Markup.button.callback('Next ▶️', \`help_page_${page + 1}\`)` at
`index.js:3048` and giveaway admin buttons like `Markup.button.callback(\`#${gw.id} End
Early\`, \`pamenu_gw_end_${gw.id}\`)` at `index.js:2293-2298`; `extractLiteralIds`
currently treats the literal source text `help_page_${page + 1}` /
`pamenu_gw_end_${gw.id}` as fixed IDs and adds them to `callbackButtons`.
4. The corresponding handlers are registered as dynamic regex actions, e.g.
`bot.action(/^help_page_(\d+)$/, ...)` at `index.js:4483` and
`bot.action(/^pamenu_gw_end_(\d+)$/, ...)` at `index.js:4844`, which are collected into
`dynamicActionPatterns` by `extractActionRegexPatterns` at `test/smoke.test.js:32-42`, but
when the smoke test checks `pattern.test(id)` in `test/smoke.test.js:60-62`, the regex
`/^help_page_(\d+)$/` does not match the static string `help_page_${page + 1}`, so these
entries remain in `uncovered` and cause the assertion `assert.deepEqual(uncovered, [],
...)` at `test/smoke.test.js:64` to fail even though runtime handlers exist.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** test/smoke.test.js
**Line:** 29:29
**Comment:**
*Logic Error: The smoke test currently treats callback IDs built with template literals (e.g., with `${...}`) as fixed literal IDs, so they cannot be matched by the corresponding dynamic regex handlers and will always show up as "uncovered" even though handlers exist, causing the test to fail incorrectly; filtering out template-literal IDs from the static literal check fixes this logic error.
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)
📝 WalkthroughWalkthroughReworks Admin UI to add a Tests & Bugs panel and related keyboards, adds auto-registration for forwarded chats into content-drop/group targets, updates admin help/promos and panel rendering, and refines callback-ID extraction in tests. Changes
Sequence DiagramsequenceDiagram
actor Admin
participant MessageHandler as MessageHandler
participant Extractor as extractForwardedChat()
participant AutoReg as autoRegisterForwardedChatIfPresent()
participant Store as StateStores
Admin->>MessageHandler: Send message (may be forwarded)
MessageHandler->>Extractor: extractForwardedChat(msg)
Extractor-->>MessageHandler: forwardedChat metadata
MessageHandler->>AutoReg: autoRegisterForwardedChatIfPresent(ctx, user)
AutoReg->>Store: update approvedGroupsStore / tipsStore.targetGroup / broadcastConfigStore
Store-->>AutoReg: persist confirmation
AutoReg-->>MessageHandler: registration result
MessageHandler-->>Admin: confirm content-drop target registered
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
✨ 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.jsonwith normalization, eligibility checks, claim recording, listing, and helper functions, and migrated user promo flows to use it instead of the legacy promo store./pmapprove,/pmdeny), plus user-facing claim handlers and auto-approve support.announceBuilderKeyboard,sendAnnouncementTargets) supporting DM/channel/group toggles, parse mode, and a single "Send Broadcast Now" action.postTipToConfiguredTarget), automatic target discovery/registration (/register_chat), scheduler robustness, and renamed commands/labels throughout UI and help text.isHealthTlsEnabledand TLS-aware health checks, SSHV improvements (sandbox hint, editor save error handling, admin logging), GC timers unref'd, and various smaller compatibility/migration fields for users..env.examplewith guidance forWEBAPP_HMAC_KEY, add exceptions and data backup patterns to.gitignore, and add a static smoke test (test/smoke.test.js) that verifies JS syntax and that callback buttons have handlers (literal or regex).Testing
node --check index.jsand the check completed successfully.npm test/ Nodenode:testrunner which executestest/smoke.test.js) and the smoke checks passed with no uncovered callback handlers.Codex Task
CodeAnt-AI Description
Update admin panels to replace messages, enhance giveaway view, add version info, and strengthen smoke test
What Changed
Impact
✅ Fewer leftover admin messages✅ Clearer giveaway status and faster actions✅ Fewer unhandled menu buttons caught by tests💡 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.
Summary by CodeRabbit
Release Notes
New Features
Improvements