Remove spinnies dependency and add proper logging framework#135
Remove spinnies dependency and add proper logging framework#1359cb14c1ec0 merged 12 commits intomasterfrom
Conversation
|
Warning Rate limit exceeded@9cb14c1ec0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 36 seconds before requesting another review. ⌛ 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 (1)
📝 WalkthroughWalkthroughReplaced Spinnies-based spinners with a pluggable logger API across the codebase; removed spinnies dependency, typings, and utility; added logger module and config option; removed createWidWrapper and migrated WAPI chat lookups to WidFactory/FindOrCreateChat with updated logging and error handling. Changes
Sequence Diagram(s)(Skipped — changes are cross-cutting logging and chat-resolution adjustments and do not introduce a new multi-component sequential feature per criteria.) Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/api/helpers/delete-file.ts (1)
25-25: Empty catch block silently swallows errors.Consider logging the error for debugging purposes instead of silently ignoring it.
🔎 Proposed fix
- } catch (e) {} + } catch (e) { + logFail(`Error during file deletion: ${e}`); + }src/controllers/browser.ts (1)
385-414: Consider usingCreateConfigtype instead of inline type definition.The inline options type duplicates most of
CreateConfig. Using the existing type would reduce maintenance burden and ensure consistency.🔎 Proposed simplification
-export async function initBrowser(options: { - session?: string; - folderNameToken?: string; - mkdirFolderToken?: string; - headless?: false | 'new' | 'old'; - devtools?: boolean; - debug?: boolean; - browserWS?: string; - browserArgs?: string[]; - addBrowserArgs?: string[]; - puppeteerOptions?: LaunchOptions; - browser?: Browser | BrowserContext; - page?: Page; - logQR?: boolean; - disableWelcome?: boolean; - updatesLog?: boolean; - autoClose?: number; - createPathFileToken?: boolean; - waitForLogin?: boolean; - BrowserFetcher?: boolean; - forceConnect?: boolean; - attemptsForceConnectLoad?: number; - forceConnectTime?: number; - addProxy?: string[]; - userProxy?: string; - userPass?: string; - browserPathExecutable?: string; - forceWebpack?: boolean; - webVersion?: boolean | string; -}): Promise<Browser | false> { +export async function initBrowser( + options: CreateConfig +): Promise<Browser | false> {src/utils/logger.ts (1)
5-13: Consider usingconsole.errorfor failure and warning levels.Using the appropriate console method improves debuggability as errors and warnings can be filtered separately in browser dev tools and log aggregators.
🔎 Proposed enhancement
const defaultLogger: LoggerFunction = (message: string, level: LogLevel) => { const prefix = { info: '[INFO]', success: '[SUCCESS]', fail: '[FAIL]', warn: '[WARN]' }; - console.log(`${prefix[level]} ${message}`); + const logMethod = level === 'fail' || level === 'warn' ? console.error : console.log; + logMethod(`${prefix[level]} ${message}`); };
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (12)
package.jsonsrc/api/helpers/delete-file.tssrc/api/layers/host.layer.tssrc/api/layers/listener.layer.tssrc/config/create-config.tssrc/controllers/browser.tssrc/controllers/initializer.tssrc/lib/wapi/functions/get-chat.jssrc/types/spinnies.d.tssrc/utils/logger.tssrc/utils/qr-generator.tssrc/utils/spinnies.ts
💤 Files with no reviewable changes (3)
- package.json
- src/utils/spinnies.ts
- src/types/spinnies.d.ts
🧰 Additional context used
📓 Path-based instructions (6)
src/api/layers/*.layer.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Keep functionality layers in src/api/layers using the *.layer.ts naming (e.g., sender.layer.ts, listener.layer.ts, group.layer.ts, profile.layer.ts, controls.layer.ts, retriever.layer.ts)
Files:
src/api/layers/listener.layer.tssrc/api/layers/host.layer.ts
src/lib/wapi/functions/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI functions in src/lib/wapi/functions are JavaScript files injected into the browser; after changing them, run
npm run build:wapito rebuild
Files:
src/lib/wapi/functions/get-chat.js
src/lib/wapi/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI layer code is built with webpack and injected into the Puppeteer browser context
Files:
src/lib/wapi/functions/get-chat.js
src/controllers/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Controllers (initializer.ts for session creation, browser.ts for Puppeteer management, auth.ts for authentication/QR) live under src/controllers
Files:
src/controllers/initializer.tssrc/controllers/browser.ts
src/api/helpers/**/*.{ts,js}
📄 CodeRabbit inference engine (CLAUDE.md)
Put utility helpers (e.g., encryption, QR code utilities) under src/api/helpers
Files:
src/api/helpers/delete-file.ts
src/config/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Keep browser/Puppeteer and session management configuration under src/config
Files:
src/config/create-config.ts
🧠 Learnings (4)
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/api/layers/*.layer.ts : Keep functionality layers in src/api/layers using the *.layer.ts naming (e.g., sender.layer.ts, listener.layer.ts, group.layer.ts, profile.layer.ts, controls.layer.ts, retriever.layer.ts)
Applied to files:
src/api/layers/listener.layer.tssrc/api/layers/host.layer.ts
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/controllers/*.ts : Controllers (initializer.ts for session creation, browser.ts for Puppeteer management, auth.ts for authentication/QR) live under src/controllers
Applied to files:
src/api/layers/host.layer.tssrc/controllers/initializer.tssrc/controllers/browser.ts
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/config/**/*.ts : Keep browser/Puppeteer and session management configuration under src/config
Applied to files:
src/config/create-config.ts
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/lib/wapi/**/*.js : WAPI layer code is built with webpack and injected into the Puppeteer browser context
Applied to files:
src/config/create-config.tssrc/controllers/browser.ts
🧬 Code graph analysis (7)
src/lib/wapi/functions/get-chat.js (1)
src/lib/wapi/helper/fix-lid-migration.js (4)
chatWid(6-6)createWidWrapper(1-42)_(25-38)chat(24-24)
src/utils/logger.ts (1)
src/api/layers/host.layer.ts (1)
log(43-53)
src/api/layers/host.layer.ts (1)
src/utils/logger.ts (3)
logSuccess(33-35)logFail(37-39)logInfo(29-31)
src/controllers/initializer.ts (3)
src/utils/logger.ts (4)
setLogger(17-19)logInfo(29-31)logFail(37-39)logSuccess(33-35)app.js (2)
browser(25-25)page(24-24)src/controllers/browser.ts (3)
initBrowser(385-602)initWhatsapp(41-122)statusLog(654-684)
src/api/helpers/delete-file.ts (2)
src/api/helpers/index.ts (1)
deleteFiles(9-9)src/utils/logger.ts (3)
logInfo(29-31)logFail(37-39)logSuccess(33-35)
src/config/create-config.ts (1)
src/utils/logger.ts (1)
LoggerFunction(3-3)
src/controllers/browser.ts (2)
src/config/options.ts (1)
options(5-106)src/utils/logger.ts (3)
logSuccess(33-35)logFail(37-39)logInfo(29-31)
🔇 Additional comments (10)
src/utils/qr-generator.ts (1)
39-40: LGTM!Minor formatting adjustment to the dynamic import. No functional changes.
src/api/layers/listener.layer.ts (1)
59-62: LGTM!The migration from
spintologfor the page close event aligns with the PR's goal of replacing spinnies with the new logger framework. Thelogmethod is properly inherited fromHostLayerand handles the 'fail' status correctly.src/config/create-config.ts (2)
62-66: LGTM!Clean replacement of
disableSpinswith the newloggeroption. The JSDoc documentation clearly explains the behavior and the default fallback toconsole.log.
155-155: LGTM!Default
nullvalue correctly triggers the fallback todefaultLoggerinsetLogger().src/controllers/initializer.ts (2)
156-159: LGTM!Good placement of logger initialization early in the
createfunction, allowing all subsequent logging to use the custom logger if provided.
251-254: LGTM!Clean callback pattern for
statusLogthat properly routes events through the logger while maintaining the existingstatusFindcallback behavior.src/api/layers/host.layer.ts (1)
43-53: LGTM!Well-designed helper method that:
- Adds session context to all log messages for easier debugging in multi-session scenarios
- Cleanly maps the status parameter to the appropriate logger function
- Uses a sensible default of 'info' for the status parameter
src/controllers/browser.ts (2)
451-551: LGTM!Logger calls appropriately replace spinnies throughout the browser initialization flow. Status messages maintain semantic consistency (success for completions, info for progress, fail for errors).
723-757: LGTM!The
removeStoredSingletonLockfunction properly uses the logger for all status updates during the SingletonLock file management process.src/utils/logger.ts (1)
1-43: LGTM!Clean and simple pluggable logger implementation. The design allows external consumers to inject custom logging behavior while providing sensible defaults.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/lib/wapi/functions/get-chat.js (1)
16-21: Critical: Missing return statement causesfoundto beundefined.The
.then()callback accessesresult.chat(line 20) but doesn't return it. This causesfoundto be assignedundefinedinstead of the chat object, breaking the entire function. The ESLint disable comment on line 19 confirms this is a no-op expression.🔎 Proposed fix
found = await window.Store.FindOrCreateChat.findOrCreateLatestChat( chatWid ).then((result) => { - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - result.chat; + return result.chat; });Alternatively, use the simpler approach from the original past review suggestion:
- found = await window.Store.FindOrCreateChat.findOrCreateLatestChat( - chatWid - ).then((result) => { - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - result.chat; - }); + const result = await window.Store.FindOrCreateChat.findOrCreateLatestChat(chatWid); + found = result.chat;
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/api/helpers/exposed.enum.tssrc/api/layers/listener.layer.tssrc/lib/wapi/functions/get-chat.js
🚧 Files skipped from review as they are similar to previous changes (1)
- src/api/layers/listener.layer.ts
🧰 Additional context used
📓 Path-based instructions (3)
src/lib/wapi/functions/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI functions in src/lib/wapi/functions are JavaScript files injected into the browser; after changing them, run
npm run build:wapito rebuild
Files:
src/lib/wapi/functions/get-chat.js
src/lib/wapi/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI layer code is built with webpack and injected into the Puppeteer browser context
Files:
src/lib/wapi/functions/get-chat.js
src/api/helpers/**/*.{ts,js}
📄 CodeRabbit inference engine (CLAUDE.md)
Put utility helpers (e.g., encryption, QR code utilities) under src/api/helpers
Files:
src/api/helpers/exposed.enum.ts
🔇 Additional comments (3)
src/api/helpers/exposed.enum.ts (1)
16-17: LGTM!The new
onLogenum member is correctly added and follows the existing naming convention. This properly supports the new logging framework introduced in this PR.src/lib/wapi/functions/get-chat.js (2)
23-23: LGTM!The logging statements have been correctly migrated from
console.info/console.logtowindow.OnLog, aligning with the new logging framework introduced in this PR.Also applies to: 28-28, 34-34
1-54: Reminder: Rebuild WAPI after changes.Since this is a WAPI function file, remember to run
npm run build:wapiafter making changes to rebuild the injected browser code.Based on coding guidelines for files matching
src/lib/wapi/functions/**/*.js.
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/wapi/functions/send-file.js (1)
27-34: Copy-paste bug: wrong variable in length check.The validation checks
chatid.length === 0but should checkfilename.length === 0. This means invalid filenames won't be caught. The same bug exists at lines 36 and 45 forcaptionandfilerespectively.🔎 Proposed fix for all three validations
- if (typeof filename !== 'string' || chatid.length === 0) { + if (typeof filename !== 'string' || filename.length === 0) { return WAPI.scope( chatid, true, null, 'incorrect parameter filename, insert an string' ); } - if (typeof caption !== 'string' || chatid.length === 0) { + if (typeof caption !== 'string' || caption.length === 0) { return WAPI.scope( chatid, true, null, 'incorrect parameter caption, insert an string' ); } - if (typeof file !== 'string' || chatid.length === 0) { + if (typeof file !== 'string' || file.length === 0) { return WAPI.scope( chatid, true, null, 'incorrect parameter file, insert an string' ); }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/lib/wapi/functions/get-chat.jssrc/lib/wapi/functions/send-file.jssrc/lib/wapi/functions/send-message.jssrc/lib/wapi/functions/send-ptt.jssrc/lib/wapi/functions/simulate-typing.jssrc/lib/wapi/helper/fix-lid-migration.jssrc/lib/wapi/helper/index.js
💤 Files with no reviewable changes (2)
- src/lib/wapi/helper/index.js
- src/lib/wapi/helper/fix-lid-migration.js
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/wapi/functions/get-chat.js
🧰 Additional context used
📓 Path-based instructions (2)
src/lib/wapi/functions/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI functions in src/lib/wapi/functions are JavaScript files injected into the browser; after changing them, run
npm run build:wapito rebuild
Files:
src/lib/wapi/functions/simulate-typing.jssrc/lib/wapi/functions/send-file.jssrc/lib/wapi/functions/send-message.jssrc/lib/wapi/functions/send-ptt.js
src/lib/wapi/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI layer code is built with webpack and injected into the Puppeteer browser context
Files:
src/lib/wapi/functions/simulate-typing.jssrc/lib/wapi/functions/send-file.jssrc/lib/wapi/functions/send-message.jssrc/lib/wapi/functions/send-ptt.js
🧠 Learnings (1)
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/lib/wapi/functions/**/*.js : WAPI functions in src/lib/wapi/functions are JavaScript files injected into the browser; after changing them, run `npm run build:wapi` to rebuild
Applied to files:
src/lib/wapi/functions/send-file.js
🧬 Code graph analysis (3)
src/lib/wapi/functions/send-file.js (11)
src/lib/wapi/functions/send-message.js (2)
wid(30-30)chat(31-31)src/lib/wapi/wapi.js (2)
chat(443-443)chat(502-502)src/lib/wapi/functions/send-contact-vcard-list.js (1)
chat(29-29)src/lib/wapi/functions/send-sticker.js (1)
chat(2-2)src/lib/wapi/functions/send-contact-vcard.js (1)
chat(15-15)src/lib/wapi/functions/send-buttons.js (1)
chat(40-40)src/lib/wapi/functions/reply.js (1)
chat(26-26)src/lib/wapi/functions/send-list-menu.js (1)
chat(98-98)src/lib/wapi/functions/send-message-scope.js (1)
chat(39-39)src/lib/wapi/functions/send-type-buttons.js (1)
chat(2-2)src/lib/wapi/functions/open-chat.js (4)
chat(7-7)chat(16-16)chat(18-18)chat(36-36)
src/lib/wapi/functions/send-message.js (4)
src/lib/wapi/functions/send-file.js (2)
wid(59-59)chat(60-60)src/lib/wapi/functions/set-new-message.js (1)
chat(9-11)src/lib/wapi/functions/send-buttons.js (1)
chat(40-40)src/lib/wapi/functions/check-number-status.js (1)
err(3-3)
src/lib/wapi/functions/send-ptt.js (14)
src/lib/wapi/functions/send-message.js (2)
wid(30-30)chat(31-31)src/lib/wapi/functions/simulate-typing.js (1)
chat(4-4)src/lib/wapi/wapi.js (3)
chat(443-443)chat(502-502)chat(511-511)src/lib/wapi/functions/send-contact-vcard-list.js (1)
chat(29-29)src/lib/wapi/functions/send-sticker.js (1)
chat(2-2)src/lib/wapi/functions/send-contact-vcard.js (1)
chat(15-15)src/lib/wapi/functions/send-buttons.js (1)
chat(40-40)src/lib/wapi/functions/reply.js (1)
chat(26-26)src/lib/wapi/functions/send-location.js (1)
chat(7-7)src/lib/wapi/functions/send-list-menu.js (1)
chat(98-98)src/lib/wapi/functions/send-message-scope.js (1)
chat(39-39)src/lib/wapi/functions/send-type-buttons.js (1)
chat(2-2)src/lib/wapi/functions/delete-messages.js (1)
chat(10-10)src/lib/wapi/functions/check-number-status.js (1)
err(3-3)
🔇 Additional comments (2)
src/lib/wapi/functions/simulate-typing.js (2)
1-15: Reminder: Rebuild WAPI after changes.As per coding guidelines, after modifying WAPI functions in
src/lib/wapi/functions/, runnpm run build:wapito rebuild the injected browser code.
13-13: Store.ChatStates API migration is complete and consistent.The plural form
Store.ChatStates.sendChatStateComposing()is correctly used in this file and consistently applied across the codebase. No remaining references to the old singularStore.ChatStateform exist, confirming the migration is fully implemented.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
package.json
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/lib/wapi/**/*.js : WAPI layer code is built with webpack and injected into the Puppeteer browser context
🔇 Additional comments (1)
package.json (1)
114-133: Spinnies dependency has been completely removed.No references to spinnies remain in the source code.
| "changelog:preview": "conventional-changelog -p angular -u", | ||
| "changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s", | ||
| "clean": "shx rm -rf session dist", | ||
| "clean": "rm -rf session dist", |
There was a problem hiding this comment.
Restore shx to maintain cross-platform compatibility.
The change from shx rm -rf... to rm -rf... breaks Windows compatibility. The rm -rf command is not available natively on Windows systems. Since shx is already in devDependencies and used in other scripts (line 30: copy:vendor), it should be retained here for consistency and cross-platform support.
🔎 Proposed fix
- "clean": "rm -rf session dist",
+ "clean": "shx rm -rf session dist",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "clean": "rm -rf session dist", | |
| "clean": "shx rm -rf session dist", |
🤖 Prompt for AI Agents
In package.json around line 37, the "clean" script uses the Unix-only command
"rm -rf session dist", which breaks Windows; change it back to use the
cross-platform shim by replacing the command with "shx rm -rf session dist" so
the script remains consistent with other scripts and works on Windows and Unix.
There was a problem hiding this comment.
shx isn't available by default on all linux systems.
There was a problem hiding this comment.
@9cb14c1ec0, I understand your concern. However, shx is already a devDependency in your package.json (line 77), so it will be available after npm install when developers run these scripts. The npm scripts execute in the context of installed dependencies.
The main considerations are:
- Cross-platform compatibility:
rm -rfworks on Linux/macOS but fails on Windows without WSL/Git Bash - Consistency: The
copy:vendorscript (line 30) still usesshx cp -r vendor dist/
You have a few options:
- Keep
shxfor consistency: Useshx rm -rfto match thecopy:vendorscript and maintain Windows compatibility - Remove
shxentirely: Change both scripts to native commands (but Windows users would need WSL/Git Bash) - Platform-specific scripts: Use different commands per platform (more complex)
What's your preference? If you want to drop shx entirely, you'd need to update copy:vendor as well and note in the README that Windows users need WSL/Git Bash.
There was a problem hiding this comment.
@9cb14c1ec0, how would you like to proceed? I'm here to help if you have any questions or need assistance with this change.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lib/wapi/functions/simulate-typing.js
🧰 Additional context used
📓 Path-based instructions (2)
src/lib/wapi/functions/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI functions in src/lib/wapi/functions are JavaScript files injected into the browser; after changing them, run
npm run build:wapito rebuild
Files:
src/lib/wapi/functions/simulate-typing.js
src/lib/wapi/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI layer code is built with webpack and injected into the Puppeteer browser context
Files:
src/lib/wapi/functions/simulate-typing.js
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/lib/wapi/**/*.js : WAPI layer code is built with webpack and injected into the Puppeteer browser context
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/lib/wapi/functions/simulate-typing.js (1)
4-13: Critical: Wid vs Chat object mismatch still unresolved.The previous review comment on this code segment remains valid.
WidFactory.createWid(chatId)creates a Wid (WhatsApp ID) object, not a Chat object. ThesendChatStateComposing()method expects a Chat object. Additionally,createWid()constructs and returns a Wid—it won't be falsy, making theif (!chat)check ineffective.Follow the two-step pattern used in other WAPI functions:
🔎 Proposed fix using FindOrCreateChat pattern
export async function startTyping(chatId) { console.log(`startTyping: chatId ${chatId}`); try { - let chat = window.Store.WidFactory.createWid(chatId); - if (!chat) { + const wid = window.Store.WidFactory.createWid(chatId); + const chat = await window.Store.FindOrCreateChat.findOrCreateLatestChat(wid); + if (!chat) { throw { error: true, code: 'chat_not_found', message: 'Chat not found', chatId: chatId }; } await Store.ChatStates.sendChatStateComposing(chat);
🧹 Nitpick comments (1)
src/lib/wapi/functions/simulate-typing.js (1)
13-13: InconsistentStorereference.Line 4 uses
window.Store.WidFactorybut line 13 usesStore.ChatStateswithout thewindow.prefix. Use a consistent reference style throughout the function for maintainability.🔎 Proposed fix
- await Store.ChatStates.sendChatStateComposing(chat); + await window.Store.ChatStates.sendChatStateComposing(chat);
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/api/layers/sender.layer.tssrc/lib/wapi/functions/simulate-typing.js
✅ Files skipped from review due to trivial changes (1)
- src/api/layers/sender.layer.ts
🧰 Additional context used
📓 Path-based instructions (2)
src/lib/wapi/functions/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI functions in src/lib/wapi/functions are JavaScript files injected into the browser; after changing them, run
npm run build:wapito rebuild
Files:
src/lib/wapi/functions/simulate-typing.js
src/lib/wapi/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI layer code is built with webpack and injected into the Puppeteer browser context
Files:
src/lib/wapi/functions/simulate-typing.js
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/lib/wapi/**/*.js : WAPI layer code is built with webpack and injected into the Puppeteer browser context
🧬 Code graph analysis (1)
src/lib/wapi/functions/simulate-typing.js (1)
src/lib/wapi/wapi.js (3)
chat(443-443)chat(502-502)chat(511-511)
Fixes # .
Changes proposed in this pull request
To test (it takes a while):
npm install github:<username>/venom#<branch>Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Chores
Style
✏️ Tip: You can customize this high-level summary in your review settings.