feat(im): support file input for message content#917
Conversation
|
|
📝 WalkthroughWalkthroughThe PR enables the ChangesMessage Content Input Sources
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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.
🧹 Nitpick comments (2)
tests/cli_e2e/im/messages_send_content_input_test.go (2)
69-74: ⚡ Quick winConsider adding config directory isolation.
As per coding guidelines, E2E tests should use
t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())to isolate config state and prevent side effects. While dry-run tests may not write config files, adding this isolation improves test reliability and follows the established pattern.🔒 Proposed addition for config isolation
func setDryRunConfigEnv(t *testing.T) { t.Helper() + t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) t.Setenv("LARKSUITE_CLI_APP_ID", "cli_dryrun_test") t.Setenv("LARKSUITE_CLI_APP_SECRET", "secret_dryrun_test") t.Setenv("LARKSUITE_CLI_BRAND", "feishu") }As per coding guidelines for test isolation.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/cli_e2e/im/messages_send_content_input_test.go` around lines 69 - 74, The helper setDryRunConfigEnv should also isolate config state by setting LARKSUITE_CLI_CONFIG_DIR to a temporary folder; update setDryRunConfigEnv to call t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) alongside the existing t.Setenv calls so tests use an isolated config directory (refer to setDryRunConfigEnv and its existing t.Setenv uses).
30-39: 💤 Low valueConsider removing redundant
DefaultAsfield.Both test cases specify
"--as", "bot"inArgs(lines 32, 51) and also setDefaultAs: "bot"(lines 38, 57). The explicit--asflag makesDefaultAsredundant.♻️ Simplify by removing DefaultAs
result, err := clie2e.RunCmd(ctx, clie2e.Request{ Args: []string{"im", "+messages-send", "--as", "bot", "--chat-id", "oc_dryrun_chat", "--msg-type", "interactive", "--content", "@" + cardPath, "--dry-run", }, - DefaultAs: "bot", })Apply the same change to the stdin test case (lines 49-58).
Also applies to: 49-58
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/cli_e2e/im/messages_send_content_input_test.go` around lines 30 - 39, The test sets the --as flag explicitly in clie2e.Request Args so the DefaultAs field is redundant; remove the DefaultAs: "bot" entries from both RunCmd calls in tests (the Request literal where Args include "--as", "bot") so the tests rely on the explicit flag only and apply the same removal in the stdin test case as well.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/cli_e2e/im/messages_send_content_input_test.go`:
- Around line 69-74: The helper setDryRunConfigEnv should also isolate config
state by setting LARKSUITE_CLI_CONFIG_DIR to a temporary folder; update
setDryRunConfigEnv to call t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())
alongside the existing t.Setenv calls so tests use an isolated config directory
(refer to setDryRunConfigEnv and its existing t.Setenv uses).
- Around line 30-39: The test sets the --as flag explicitly in clie2e.Request
Args so the DefaultAs field is redundant; remove the DefaultAs: "bot" entries
from both RunCmd calls in tests (the Request literal where Args include "--as",
"bot") so the tests rely on the explicit flag only and apply the same removal in
the stdin test case as well.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 40c60319-8c87-4661-a721-80ad87d1654e
📒 Files selected for processing (2)
shortcuts/im/im_messages_send.gotests/cli_e2e/im/messages_send_content_input_test.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #917 +/- ##
=======================================
Coverage 65.92% 65.92%
=======================================
Files 523 523
Lines 49687 49687
=======================================
Hits 32757 32757
Misses 14131 14131
Partials 2799 2799 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@b1f9e6aedf80d5e4833e4743b4f81d55944592e2🧩 Skill updatenpx skills add Mycheers/cli#feat/im-message-content-file-stdin -y -g |
Summary
Support file and stdin input for
im +messages-send --content, making scripted interactive-card sends safer and less brittle than passing large JSON through one shell argument.Changes
--contentas a file/stdin-capable input flag, enabling--content @card.jsonand--content ---contenthelp text to document the new input modesTest Plan
lark xxxcommand works as expectedgofmt: command not found)Related Issues
Summary by CodeRabbit
New Features
--contentflag for sending instant messages now supports reading message content from local files and standard input.Tests