Skip to content

fix(bot): align nested tsconfig base paths#482

Open
sevencat2004 wants to merge 6 commits into
profullstack:masterfrom
sevencat2004:fix/bot-tsconfig-base-paths
Open

fix(bot): align nested tsconfig base paths#482
sevencat2004 wants to merge 6 commits into
profullstack:masterfrom
sevencat2004:fix/bot-tsconfig-base-paths

Conversation

@sevencat2004
Copy link
Copy Markdown

Fixes #452.

Summary:

  • correct the nested packages/bot/* tsconfig base path from ../../tsconfig.base.json to ../../../tsconfig.base.json
  • fix the WhatsApp Baileys socket initialization exposed once the package inherits the real strict base config
  • wire creds.update to the existing auth-state save callback

Validation:

  • corepack pnpm --dir packages/bot/core typecheck
  • corepack pnpm --dir packages/bot/discord typecheck
  • corepack pnpm --dir packages/bot/signal typecheck
  • corepack pnpm --dir packages/bot/telegram typecheck
  • corepack pnpm --dir packages/bot/whatsapp typecheck
  • git diff --check

Submitted for the ugig bounty/gig: Need someone to test submit bugs and PRs to fix those bugs.

Solana wallet for bounty payout:
Dy4yMkjCfupxaURt6iTMUrxqSDEmAJPPkKF66QahxJZD

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 30, 2026

Greptile Summary

This PR corrects the extends path in five packages/bot/*/tsconfig.json files from ../../tsconfig.base.json to ../../../tsconfig.base.json (the correct depth for the three-level nesting) and fixes the WhatsApp Baileys socket initialization to use the modern config-object API.

  • tsconfig path fixes — all five bot packages now correctly point at the root tsconfig.base.json; the old two-level path would silently fall back to no base config or resolve to the wrong file.
  • Baileys API fixmakeBaileysBot(state, { print, browser }) is updated to makeBaileysBot({ auth: state, browser }), matching the current Baileys socket signature, and creds.update is wired to saveState.
  • Incomplete auth persistenceuseMultiFileAuthState remains a local stub that returns empty state and a no-op saveState; wiring creds.update to it does not actually persist credentials to disk, so the bot re-authenticates from scratch on every restart.

Confidence Score: 3/5

Safe to merge the tsconfig and Baileys API changes, but the WhatsApp bot will still fail to persist auth credentials across restarts because the stub auth state is never replaced with the real Baileys implementation.

The tsconfig path corrections are straightforward and correct. The Baileys socket API fix is also correct. However, the stated goal of persisting credentials via creds.update is not achieved - saveState remains a no-op stub, so the bot will require a QR re-scan every time it restarts.

packages/bot/whatsapp/src/index.ts - the local useMultiFileAuthState stub needs to be replaced with the real import from the baileys package

Important Files Changed

Filename Overview
packages/bot/whatsapp/src/index.ts Fixes Baileys socket init API and wires creds.update; however, the local useMultiFileAuthState stub returns a no-op saveState and empty state, so credentials are never persisted
packages/bot/core/tsconfig.json Corrects extends path from ../../ to ../../../tsconfig.base.json — valid fix for three-level nesting
packages/bot/discord/tsconfig.json Same path depth correction as core; change is correct
packages/bot/signal/tsconfig.json Same path depth correction as core; change is correct
packages/bot/telegram/tsconfig.json Same path depth correction as core; change is correct
packages/bot/whatsapp/tsconfig.json Same path depth correction as other bot packages; change is correct

Sequence Diagram

sequenceDiagram
    participant App
    participant WhatsAppBot
    participant Baileys as makeBaileysBot
    participant AuthStub as useMultiFileAuthState (stub)
    participant Disk

    App->>WhatsAppBot: start()
    WhatsAppBot->>AuthStub: useMultiFileAuthState("./auth")
    AuthStub-->>WhatsAppBot: "{ state: {}, saveState: noop }"
    Note over AuthStub,Disk: Disk is never read - state is always empty
    WhatsAppBot->>Baileys: "makeBaileysBot({ auth: state, browser })"
    Baileys-->>WhatsAppBot: sock (WASocket)
    WhatsAppBot->>WhatsAppBot: sock.ev.on(creds.update, saveState)
    Note over WhatsAppBot: saveState is a no-op - nothing is written
    Baileys-->>WhatsAppBot: creds.update event
    WhatsAppBot->>AuthStub: saveState()
    AuthStub-->>Disk: no-op - nothing written
    Baileys-->>WhatsAppBot: messages.upsert event
    WhatsAppBot->>App: handler(IncomingMessage)
Loading

Reviews (1): Last reviewed commit: "fix(bot): align nested tsconfig base pat..." | Re-trigger Greptile

Comment on lines +108 to +115
function useMultiFileAuthState(
dir: string
): { state: any; saveState: () => void } {
return {
state: {},
saveState: () => {},
};
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 useMultiFileAuthState stub silently discards all credentials

The local stub always returns state: {} (so Baileys starts unauthenticated on every launch) and saveState: () => {} (a no-op). Wiring creds.update to this callback — one of the stated goals of the PR — will never actually persist credentials to disk, so the bot will require a fresh QR-code scan on every restart. Baileys exports the real useMultiFileAuthState from the "baileys" package; it should be imported rather than re-implemented here.

Comment on lines +91 to +93
async stop(): Promise<void> {
this.running = false;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 stop() leaves the socket connection open

stop() flips this.running but never calls this.sock?.end() (or the equivalent Baileys close method). The underlying WebSocket stays connected and event listeners keep firing after stop() returns, which can cause unexpected behavior or resource leaks if start() is called again.

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.

packages/bot typecheck extends missing base tsconfig

1 participant