Skip to content

feat(im): add at-chatter-ids filter to +messages-search#612

Merged
YangJunzhou-01 merged 2 commits intolarksuite:mainfrom
arnold9672:feat/im-messages-search-at-chatter-ids
Apr 25, 2026
Merged

feat(im): add at-chatter-ids filter to +messages-search#612
YangJunzhou-01 merged 2 commits intolarksuite:mainfrom
arnold9672:feat/im-messages-search-at-chatter-ids

Conversation

@arnold9672
Copy link
Copy Markdown
Contributor

@arnold9672 arnold9672 commented Apr 22, 2026

Summary

Add a new filter --at-chatter-ids to the im +messages-search shortcut so users can narrow search results to messages that @mention specific users. Matched results naturally include messages that @all.

Changes

  • shortcuts/im/im_messages_search.go: register the --at-chatter-ids flag; parse comma-separated ou_* user IDs, validate via common.ValidateUserID, and pass as filter.at_chatter_ids in the search body
  • shortcuts/im/coverage_additional_test.go: add two table-driven sub-tests (valid IDs populate the filter; malformed ID returns a validation error)
  • shortcuts/im/im_messages_search_execute_test.go: register the new flag in the execute-test runtime helper
  • skills/lark-im/references/lark-im-messages-search.md: document the flag and add a usage example

Test Plan

  • make unit-test passes locally
  • Manual verification: lark-cli im +messages-search --query "release" --at-chatter-ids ou_xxx,ou_yyy — confirm the request payload in --dry-run includes filter.at_chatter_ids: [ou_xxx, ou_yyy]
  • Manual verification: lark-cli im +messages-search --at-chatter-ids bad_id — confirm it surfaces invalid user ID format

Related Issues

N/A

Summary by CodeRabbit

  • New Features

    • Added a new --at-chatter-ids option to filter instant messages by mentioned user IDs (comma-separated).
  • Documentation

    • Updated usage docs with example and parameter details for the new --at-chatter-ids filter.
  • Tests

    • Added tests covering parsing and validation of the new flag, acceptance of valid IDs, rejection with error for malformed IDs, and test harness updated to support the flag.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact labels Apr 22, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

Adds a new CLI flag --at-chatter-ids to ImMessagesSearch; the flag CSV-parses and validates user IDs and, when present, injects them into the request filter as at_chatter_ids. Includes implementation, unit tests, test helper update, and documentation.

Changes

Cohort / File(s) Summary
Implementation
shortcuts/im/im_messages_search.go
Added --at-chatter-ids flag; CSV-splits the value, validates each token as a user ID, and sets filter.at_chatter_ids when non-empty.
Tests
shortcuts/im/coverage_additional_test.go, shortcuts/im/im_messages_search_execute_test.go
Extended TestBuildMessagesSearchRequest with positive and negative subtests for at-chatter-ids; test helper registers the at-chatter-ids string flag for parsing.
Documentation
skills/lark-im/references/lark-im-messages-search.md
Added --at-chatter-ids <ids> parameter and usage example; documents comma-separated open_id filtering (matches may include @all).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • sammi-bytedance
  • YangJunzhou-01

Poem

🐰 I nibbled flags beneath the moonlight,
Commas hopped in rows so bright.
At-chatter-ids now listed neat,
Tests checked hops with careful feet.
Tiny ears, a feature complete!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely describes the main feature being added: a new --at-chatter-ids filter to the im +messages-search command.
Description check ✅ Passed The pull request description comprehensively follows the template with all required sections completed: Summary clearly explains the motivation, Changes list all modified files and their purposes, Test Plan documents both unit and manual verification, and Related Issues is addressed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.96%. Comparing base (fd4c35b) to head (5f1d157).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #612      +/-   ##
==========================================
+ Coverage   62.67%   62.96%   +0.28%     
==========================================
  Files         434      436       +2     
  Lines       38072    38604     +532     
==========================================
+ Hits        23862    24306     +444     
- Misses      12076    12150      +74     
- Partials     2134     2148      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2026

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@5f1d157306d2a036fc6dc2f63076155cf712b398

🧩 Skill update

npx skills add arnold9672/cli#feat/im-messages-search-at-chatter-ids -y -g

Add --at-chatter-ids flag to shortcuts/im/im_messages_search.go that
passes filter.at_chatter_ids to the search API, restricting results to
messages that @mention any of the given user open_ids. Messages that
@ALL are included automatically.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@arnold9672 arnold9672 force-pushed the feat/im-messages-search-at-chatter-ids branch from 3b5dfea to f618c96 Compare April 24, 2026 09:53
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
shortcuts/im/coverage_additional_test.go (1)

405-432: LGTM — good coverage of happy path and validation error.

The two subtests cleanly exercise the new --at-chatter-ids parsing/validation path: the happy case also implicitly asserts that common.SplitCSV trims the whitespace in "ou_a, ou_b" down to "ou_a" / "ou_b", and the error case pins the exact error substring emitted by common.ValidateUserID. Using newMessagesSearchTestRuntimeContext is the right call here since it registers page-size/page-limit as Int flags (per the fix-up commit).

One optional thought: if the PR description's claim that "messages that @all are also matched" implies any client-side handling (e.g., accepting a literal all/@all token in the CSV and translating it), a third subtest would guard that contract. If @all inclusion is purely server-side, feel free to ignore.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/im/coverage_additional_test.go` around lines 405 - 432, Add an
optional third subtest to assert how the client should handle an "@all" token:
create a test named like "at-chatter-ids accepts `@all` token" that uses
newMessagesSearchTestRuntimeContext with "at-chatter-ids": "@all", call
buildMessagesSearchRequest, and then assert the resulting request body
filter["at_chatter_ids"] contains the expected value (e.g., the literal "all" or
"@all") if client-side translation is required; if "@all" must be left for
server-side handling instead, add a test that ensures the client does not
translate it (and that common.SplitCSV/common.ValidateUserID do not reject it)
or skip adding the test if server-only behavior is intended.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@shortcuts/im/coverage_additional_test.go`:
- Around line 405-432: Add an optional third subtest to assert how the client
should handle an "@all" token: create a test named like "at-chatter-ids accepts
`@all` token" that uses newMessagesSearchTestRuntimeContext with "at-chatter-ids":
"@all", call buildMessagesSearchRequest, and then assert the resulting request
body filter["at_chatter_ids"] contains the expected value (e.g., the literal
"all" or "@all") if client-side translation is required; if "@all" must be left
for server-side handling instead, add a test that ensures the client does not
translate it (and that common.SplitCSV/common.ValidateUserID do not reject it)
or skip adding the test if server-only behavior is intended.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b504b89-c395-408e-bd9f-5955b1ab54ec

📥 Commits

Reviewing files that changed from the base of the PR and between f618c96 and 72c6e2e.

📒 Files selected for processing (1)
  • shortcuts/im/coverage_additional_test.go

newTestRuntimeContext does not register page-size as an int flag,
causing buildMessagesSearchRequest to fail validation. Switch to
newMessagesSearchTestRuntimeContext which registers page-size/page-limit
as Int flags with defaults.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@arnold9672 arnold9672 force-pushed the feat/im-messages-search-at-chatter-ids branch from 72c6e2e to 5f1d157 Compare April 25, 2026 11:52
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
shortcuts/im/coverage_additional_test.go (1)

405-422: LGTM — positive case correctly exercises CSV trimming.

The input "ou_a, ou_b" (with a leading space on ou_b) combined with the expected []string{"ou_a", "ou_b"} is a nice touch: it locks in that the parser trims whitespace around CSV tokens, which is easy to regress.

One optional tightening: rather than only asserting on filter["at_chatter_ids"], you could reflect.DeepEqual against the full expected messagesSearchRequest (as the sibling "valid request" sub-test does on Lines 357–381). That would also catch accidental leakage of unrelated filter fields when only --query and --at-chatter-ids are set.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/im/coverage_additional_test.go` around lines 405 - 422, The test
only asserts the at_chatter_ids slice from the returned request; change it to
construct the full expected messagesSearchRequest and compare it with the actual
result from buildMessagesSearchRequest using reflect.DeepEqual (like the "valid
request" sub-test does). Locate the sub-test named "at-chatter-ids accepts user
ids", use buildMessagesSearchRequest to get the actual, build an expected
messagesSearchRequest value with Query "standup" and Filter.AtChatterIDs
[]string{"ou_a","ou_b"} (and other default/zero fields), then replace the
single-field assertion on filter["at_chatter_ids"] with a DeepEqual assertion
comparing the entire messagesSearchRequest.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@shortcuts/im/coverage_additional_test.go`:
- Around line 405-422: The test only asserts the at_chatter_ids slice from the
returned request; change it to construct the full expected messagesSearchRequest
and compare it with the actual result from buildMessagesSearchRequest using
reflect.DeepEqual (like the "valid request" sub-test does). Locate the sub-test
named "at-chatter-ids accepts user ids", use buildMessagesSearchRequest to get
the actual, build an expected messagesSearchRequest value with Query "standup"
and Filter.AtChatterIDs []string{"ou_a","ou_b"} (and other default/zero fields),
then replace the single-field assertion on filter["at_chatter_ids"] with a
DeepEqual assertion comparing the entire messagesSearchRequest.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 53a417f7-99a2-48cc-bb27-4fcb1ff859ae

📥 Commits

Reviewing files that changed from the base of the PR and between 72c6e2e and 5f1d157.

📒 Files selected for processing (3)
  • coverage.txt
  • download.html
  • shortcuts/im/coverage_additional_test.go

@YangJunzhou-01 YangJunzhou-01 merged commit 97f817d into larksuite:main Apr 25, 2026
18 of 19 checks passed
@liangshuo-1 liangshuo-1 mentioned this pull request Apr 27, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants