Skip to content

feat(im): add --chat-modes filter to chat search#1317

Open
shifengjuan-dev wants to merge 1 commit into
larksuite:mainfrom
shifengjuan-dev:feat/chat-search-chat-mode-filter
Open

feat(im): add --chat-modes filter to chat search#1317
shifengjuan-dev wants to merge 1 commit into
larksuite:mainfrom
shifengjuan-dev:feat/chat-search-chat-mode-filter

Conversation

@shifengjuan-dev

@shifengjuan-dev shifengjuan-dev commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a server-side --chat-modes filter to the im +chat-search shortcut so users can restrict results to regular groups and/or topic groups.

Details

  • New flag --chat-modes (comma-separated). The CLI exposes group/topic (consistent with +chat-create --chat-mode) and maps them to the v2 search wire values default/thread in filter.chat_modes — deduped, order preserved.
  • Validation rejects any value outside {group, topic}, mirroring the existing --search-types check, and runs before the page-size check.
  • The filter object is still omitted entirely when no filter flags are set; no interaction with the client-side --exclude-muted filter.

Verification

  • go test ./shortcuts/im/, go vet, go build ./... all pass (TDD: tests written red-first).
  • Real call confirms the server honors the filter: --chat-modes group returns only DEFAULT chats, --chat-modes topic returns only THREAD chats.

Note: the v2 search response reports chat_mode as uppercase DEFAULT/THREAD; output rendering is left as-is (pre-existing behavior) and intentionally out of scope here.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added --chat-modes flag to chat search, letting users restrict results to group or topic chats using comma-separated values.
  • Behavior Changes

    • Command now validates --chat-modes and reports errors for invalid values.
    • Multiple entries are deduplicated and translated to the appropriate server-side chat filters.
  • Documentation

    • Added examples and parameter docs for --chat-modes.
  • Tests

    • Added tests covering validation, mapping, and dry-run behavior.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e9393728-e62e-4ccf-a1fa-164aac23d260

📥 Commits

Reviewing files that changed from the base of the PR and between 58aa2ec and 05f46d7.

📒 Files selected for processing (3)
  • shortcuts/im/builders_test.go
  • shortcuts/im/im_chat_search.go
  • skills/lark-im/references/lark-im-chat-search.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-im/references/lark-im-chat-search.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • shortcuts/im/builders_test.go
  • shortcuts/im/im_chat_search.go

📝 Walkthrough

Walkthrough

Adds a new --chat-modes flag to the +chat-search shortcut, validates allowed values (group, topic), maps them to API values (default, thread) with deduplication in request payload, and adds tests and documentation.

Changes

Chat Modes Filtering for IM Chat Search

Layer / File(s) Summary
Flag, imports, and validation
shortcuts/im/im_chat_search.go, shortcuts/im/builders_test.go
Adds --chat-modes flag and errs import; validates comma-separated values allowing only group and topic; validation test asserts rejection for invalid value.
Request mapping and dry-run tests
shortcuts/im/im_chat_search.go, shortcuts/im/builders_test.go
buildSearchChatBody maps groupdefault and topicthread, deduplicates while preserving input order, and sets filter.chat_modes; dry-run tests verify mapping and deduplication.
User documentation
skills/lark-im/references/lark-im-chat-search.md
Adds +chat-search example using --chat-modes "topic" and documents --chat-modes <modes> parameter with allowed values group, topic.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • larksuite/cli#820: Related changes to ImChatSearch implementation and expanded TestShortcutDryRunShapes coverage.

Suggested Labels

feature

Suggested Reviewers

  • YangJunzhou-01

Poem

🐰 I nibble flags and map their codes,
group becomes default on winding roads,
topic threads leap into view,
duplicates hop away, leaving one true.
Tests and docs — a tidy little stew.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 PR title accurately and concisely describes the main change: adding a --chat-modes filter to the chat search command.
Description check ✅ Passed The PR description comprehensively covers all required template sections with clear details about motivation, implementation, validation, testing, and verification.
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.

@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 Jun 8, 2026
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.15%. Comparing base (a75420f) to head (05f46d7).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1317      +/-   ##
==========================================
+ Coverage   70.33%   71.15%   +0.82%     
==========================================
  Files         672      685      +13     
  Lines       65322    65785     +463     
==========================================
+ Hits        45941    46808     +867     
+ Misses      15728    15326     -402     
+ Partials     3653     3651       -2     

☔ View full report in Codecov by Harness.
📢 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

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@05f46d782de49b9c25729ac7228369535d0c1f4d

🧩 Skill update

npx skills add shifengjuan-dev/lark-cli#feat/chat-search-chat-mode-filter -y -g

Add a server-side --chat-modes filter to the im +chat-search shortcut so
users can restrict results to regular groups and/or topic groups. The CLI
exposes group/topic and maps them to the wire values default/thread in
filter.chat_modes (deduped, order preserved). Validation rejects any value
outside {group, topic}.

Change-Id: Ia59c2c05fb2e8e45bd741c8531ca0e3ca69de2f3
@shifengjuan-dev shifengjuan-dev force-pushed the feat/chat-search-chat-mode-filter branch from 58aa2ec to 05f46d7 Compare June 8, 2026 04:39
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.

1 participant