Conversation
📝 WalkthroughWalkthroughA new Telegram send command (tg_send) is added to the serial CLI. The implementation includes a tg_send_args structure with chat_id and text parameters, a cmd_tg_send handler function that parses arguments and invokes telegram_send_message, and command registration during CLI initialization. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.OpenGrep is compatible with Semgrep configurations. Add an |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
main/cli/serial_cli.c (1)
86-98: Prefer async execution with timeout fortg_send.Line 94 performs a synchronous network send on the CLI path. If Telegram/API is slow, the REPL can block noticeably. Consider mirroring the
cmd_web_searchworker-task + timeout pattern for better CLI responsiveness.Proposed direction (same pattern as
cmd_web_search)static int cmd_tg_send(int argc, char **argv) { @@ - esp_err_t err = telegram_send_message(tg_send_args.chat_id->sval[0], - tg_send_args.text->sval[0]); + /* run send in a worker task + wait with timeout */ + esp_err_t err = run_tg_send_with_timeout( + tg_send_args.chat_id->sval[0], + tg_send_args.text->sval[0], + pdMS_TO_TICKS(15000)); printf("tg_send status: %s\n", esp_err_to_name(err)); return (err == ESP_OK) ? 0 : 1; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@main/cli/serial_cli.c` around lines 86 - 98, Replace the synchronous telegram_send_message call in cmd_tg_send with the same worker-task + timeout pattern used by cmd_web_search: spawn a short-lived worker (e.g., tg_send_worker) that calls telegram_send_message using tg_send_args.chat_id->sval[0] and tg_send_args.text->sval[0], have the worker post the esp_err_t result back via a queue or semaphore, and have cmd_tg_send wait for that result with a bounded timeout (e.g., 5s); on timeout log a clear timeout/error and return non-zero, otherwise print esp_err_to_name(result) and return 0 on ESP_OK. Ensure you clean up the worker and synchronization primitive the same way cmd_web_search does.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@main/cli/serial_cli.c`:
- Around line 86-98: Replace the synchronous telegram_send_message call in
cmd_tg_send with the same worker-task + timeout pattern used by cmd_web_search:
spawn a short-lived worker (e.g., tg_send_worker) that calls
telegram_send_message using tg_send_args.chat_id->sval[0] and
tg_send_args.text->sval[0], have the worker post the esp_err_t result back via a
queue or semaphore, and have cmd_tg_send wait for that result with a bounded
timeout (e.g., 5s); on timeout log a clear timeout/error and return non-zero,
otherwise print esp_err_to_name(result) and return 0 on ESP_OK. Ensure you clean
up the worker and synchronization primitive the same way cmd_web_search does.
Fix: add tg send command in cli
Summary by CodeRabbit