Skip to content

feat(im): add --chat-mode topic to +chat-create#790

Merged
YangJunzhou-01 merged 1 commit into
larksuite:mainfrom
shifengjuan-dev:feat/im-chats-create-topic-group
May 13, 2026
Merged

feat(im): add --chat-mode topic to +chat-create#790
YangJunzhou-01 merged 1 commit into
larksuite:mainfrom
shifengjuan-dev:feat/im-chats-create-topic-group

Conversation

@shifengjuan-dev

@shifengjuan-dev shifengjuan-dev commented May 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds --chat-mode group|topic to lark-cli im +chat-create so users and AI agents can create 话题群 (topic chats) directly via the CLI. Without this, requests to create a topic chat silently fall back to a normal conversation group. Default remains group; chat_mode is now always emitted in the POST /open-apis/im/v1/chats request body.

Changes

  • shortcuts/im/im_chat_create.go: new --chat-mode group|topic flag (Enum, default group); always emit chat_mode in buildCreateChatBody; updated Description so AI agents discover the new capability.
  • shortcuts/im/builders_test.go: extended TestBuildCreateChatBody; added TestBuildCreateChatBody_TopicMode; updated TestShortcutDryRunShapes/ImChatCreate to register and assert chat_mode.
  • skills/lark-im/SKILL.md: added 创建群聊或话题群 to trigger keywords; updated +chat-create row to reference --chat-mode.
  • skills/lark-im/references/lark-im-chat-create.md: extended intro paragraph; added a topic-chat example; added --chat-mode row in Parameters; added a self-contained disambiguation block clarifying 话题群 (chat_mode=topic) vs 普通群+话题消息模式 (group_message_type=thread).
  • CHANGELOG.md: [Unreleased] Features entry.

Note: chat_mode=topic is not in the public OpenAPI doc (which says topic chats must be created via the Feishu client) but is verified to work end-to-end against a real tenant — see Test Plan.

Test Plan

  • make unit-test passes
  • go vet ./... clean
  • gofmt -l . empty
  • go mod tidy no diff in go.mod / go.sum
  • golangci-lint --new-from-rev=upstream/main reports 0 issues
  • Manual: lark-cli im +chat-create --name X --chat-mode topic --type public creates a real 话题群 in the Feishu client (verified by lighting up the resulting chat_id in the client)
  • Manual: omitting --chat-mode still produces a normal group (backward-compatible default)
  • Dry-run inspection confirms request body contains "chat_mode":"topic" (and "chat_mode":"group" for the default case)

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added a --chat-mode option to +chat-create to create topic chats (话题群) or group chats (default: group).
  • Documentation

    • Updated skill docs, command reference, examples, and parameter tables to describe --chat-mode, topic-chat usage, and differences vs. other group modes.
  • Tests

    • Added/updated tests to verify topic-mode behavior, fallback to group, and dry-run output.
  • Changelog

    • Added an [Unreleased] entry noting the new option.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a --chat-mode flag (default group, values group|topic) to +chat-create, writes chat_mode into the create-chat API payload (fallback to "group" if empty), updates unit tests for group/topic/fallback, and updates changelog and skill/reference docs with examples and parameter docs.

Changes

Topic Chat Mode Support

Layer / File(s) Summary
Flag Definition & Description
shortcuts/im/im_chat_create.go
Added --chat-mode flag with default group and enum values group|topic; updated command description to document topic chat creation capability.
Request Body Integration
shortcuts/im/im_chat_create.go
buildCreateChatBody() reads the runtime --chat-mode, falls back to group when empty, and sets body["chat_mode"] in the request payload.
Unit Tests
shortcuts/im/builders_test.go
Added and updated tests: set chat-mode: group in TestBuildCreateChatBody, added TestBuildCreateChatBody_TopicMode, added TestBuildCreateChatBody_EmptyChatModeFallsBack, and updated TestShortcutDryRunShapes to assert chat_mode appears in dry-run output.
Documentation & Changelog
CHANGELOG.md, skills/lark-im/SKILL.md, skills/lark-im/references/lark-im-chat-create.md
Added Unreleased changelog entry; expanded SKILL.md Shortcuts table; added prerequisite link, topic-chat example, --chat-mode parameter entry, and clarification distinguishing topic chats from thread-mode groups.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • YangJunzhou-01
  • MaxHuang22
  • jackie3927

Poem

🐰 I found a flag to sow,
group or topic — pick and go,
tests hop in tidy rows,
docs whisper where it grows,
chats bloom where ideas flow.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the primary change: adding --chat-mode topic to the +chat-create command in the IM module.
Description check ✅ Passed The pull request description is comprehensive and follows the template structure, including a clear summary, detailed changes list, thorough test plan, and related issues section.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.
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

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 May 9, 2026
@shifengjuan-dev
shifengjuan-dev force-pushed the feat/im-chats-create-topic-group branch 5 times, most recently from 5dcb2ef to 414ed1d Compare May 9, 2026 06:19
@shifengjuan-dev

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shifengjuan-dev
shifengjuan-dev force-pushed the feat/im-chats-create-topic-group branch from 414ed1d to a175794 Compare May 9, 2026 06:53
@shifengjuan-dev

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shifengjuan-dev

Copy link
Copy Markdown
Collaborator Author

@coderabbitai the Docstring Coverage check reports 71.43% (5/7). Could you list the specific functions that are counted in scope and which ones are missing docstrings? Please give file:line references so I can fix them precisely.

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Show all function declarations with surrounding context in the changed Go files
echo "=== shortcuts/im/im_chat_create.go ==="
cat -n shortcuts/im/im_chat_create.go

echo ""
echo "=== shortcuts/im/builders_test.go (new/changed test functions) ==="
cat -n shortcuts/im/builders_test.go

Length of output: 43422


Let me check the actual PR diff to pinpoint exactly which functions were added or modified, since the coverage tool likely scopes to diff-touched functions.


🏁 Script executed:

#!/bin/bash
git diff origin/main...HEAD -- shortcuts/im/builders_test.go shortcuts/im/im_chat_create.go | head -300

Length of output: 6386


🏁 Script executed:

#!/bin/bash
# Look for docstring/coverage tool config files
fd -t f -e yml -e yaml -e toml -e json -e cfg -e ini | xargs grep -l -i "docstring" 2>/dev/null
echo "---"
fd -t f ".docstring" 2>/dev/null
echo "---"
# Check for any CI/lint configuration that mentions docstring
fd -t f -e yml -e yaml | xargs grep -l -i "docstring\|doc_coverage\|godoc" 2>/dev/null | head -20
echo "---"
# Check for setRuntimeField in the package
rg -n "func setRuntimeField" shortcuts/im/
echo "---"
# Show all top-level function signatures in the im package (non-test file too)
rg -n "^func " shortcuts/im/

Length of output: 40133


🏁 Script executed:

#!/bin/bash
# Check CI config files for docstring tool info
fd -t f -e yml -e yaml ".github" | head -20
echo "---"
fd -t f -e yml -e yaml -e toml ".github" | xargs grep -l -i "docstring\|coverage\|lint\|godoc" 2>/dev/null
echo "---"
cat .github/workflows/*.yml 2>/dev/null | head -200
echo "---"
# Check for golangci config
cat .golangci.yml 2>/dev/null || cat .golangci.yaml 2>/dev/null || echo "no golangci config"
echo "---"
# Check if there are any docstring-related config or Makefile targets
cat Makefile 2>/dev/null | grep -i "doc\|lint" | head -20

Length of output: 14123


@shifengjuan-dev Based on inspecting the diff and the two changed files, here is the full picture:


Functions/symbols in the PR diff — docstring status

# Symbol File : Line Has Doc?
1 ImChatCreate (var) shortcuts/im/im_chat_create.go : Line 23 ✅ added in this PR (lines 19–22)
2 buildCreateChatBody shortcuts/im/im_chat_create.go : Line 153 ✅ added in this PR (lines 149–152)
3 TestBuildCreateChatBody shortcuts/im/builders_test.go : Line 91 ✅ added in this PR (lines 89–90)
4 TestBuildCreateChatBody_TopicMode shortcuts/im/builders_test.go : Line 125 ✅ present at creation
5 TestBuildCreateChatBody_EmptyChatModeFallsBack shortcuts/im/builders_test.go : Line 147 ✅ present at creation
6 TestShortcutDryRunShapes shortcuts/im/builders_test.go : Line 635 MISSING

That accounts for 5/6 directly touched symbols. The tool's 7th entry is most likely one of the undocumented helpers visible in builders_test.go that fall in the diff's context window:

# Symbol File : Line Has Doc?
7 mustMarshalDryRun shortcuts/im/builders_test.go : Line 18 MISSING
(alt) newTestRuntimeContext shortcuts/im/builders_test.go : Line 28 ❌ (also missing)

Suggested fixes

For TestShortcutDryRunShapes (Line 635):

// TestShortcutDryRunShapes verifies that each shortcut's DryRun function
// produces the expected API path, query parameters, and request body.
func TestShortcutDryRunShapes(t *testing.T) {

For mustMarshalDryRun (Line 18):

// mustMarshalDryRun marshals v to a JSON string, calling t.Fatalf on error.
func mustMarshalDryRun(t *testing.T, v interface{}) string {

Note: The "Docstring Coverage" check does not appear to come from golangci-lint (the .golangci.yml does not enable any doc-comment linter) or any CI workflow — the two workflows are Architecture Audit and CI (build/vet/test/lint only). The check is likely CodeRabbit's own incremental doc-comment analysis of the diff, which is why I can't show you the exact config. Adding the two doc comments above should bring coverage to 7/7.

@shifengjuan-dev
shifengjuan-dev force-pushed the feat/im-chats-create-topic-group branch from a175794 to 12deb62 Compare May 9, 2026 07:07
@shifengjuan-dev

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shifengjuan-dev
shifengjuan-dev force-pushed the feat/im-chats-create-topic-group branch from 12deb62 to f7c6bf2 Compare May 9, 2026 07:13
@shifengjuan-dev

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shifengjuan-dev
shifengjuan-dev force-pushed the feat/im-chats-create-topic-group branch 2 times, most recently from 3d3ac1b to 221ca2e Compare May 13, 2026 07:25
@shifengjuan-dev

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.90%. Comparing base (b0c9a4d) to head (ff32adf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #790   +/-   ##
=======================================
  Coverage   65.90%   65.90%           
=======================================
  Files         518      518           
  Lines       48830    48834    +4     
=======================================
+ Hits        32181    32185    +4     
  Misses      13882    13882           
  Partials     2767     2767           

☔ 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

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add shifengjuan-dev/lark-cli#feat/im-chats-create-topic-group -y -g

@shifengjuan-dev
shifengjuan-dev force-pushed the feat/im-chats-create-topic-group branch from 221ca2e to 002155e Compare May 13, 2026 09:14
Adds --chat-mode group|topic so users and AI agents can create
话题群 (topic chats) directly via the CLI. Default remains group;
chat_mode is now always emitted in the POST /open-apis/im/v1/chats
request body. Without this, "create a topic chat" requests would
silently fall back to a normal conversation group.

- shortcuts/im/im_chat_create.go: new --chat-mode flag (Enum,
  default group); buildCreateChatBody always emits chat_mode and
  defensively falls back to "group" when the value is empty
  (validateEnumFlags skips empty strings, so an explicit
  `--chat-mode ""` would otherwise reach the wire with unspecified
  server semantics); Description updated for AI-agent discoverability.
- shortcuts/im/builders_test.go: extended TestBuildCreateChatBody;
  added TestBuildCreateChatBody_TopicMode and
  TestBuildCreateChatBody_EmptyChatModeFallsBack; updated
  TestShortcutDryRunShapes/ImChatCreate to register and assert
  chat_mode.
- skills/lark-im/SKILL.md: added 创建群聊或话题群 to trigger
  keywords; +chat-create row references --chat-mode.
- skills/lark-im/references/lark-im-chat-create.md: extended intro
  paragraph; added topic-chat example; added --chat-mode parameter
  row; added disambiguation block clarifying 话题群
  (chat_mode=topic) vs 普通群+话题消息模式
  (group_message_type=thread).
- CHANGELOG.md: [Unreleased] Features entry.

Change-Id: I79385e2e8606f84e3f27de240d1b41037bf51261
@shifengjuan-dev
shifengjuan-dev force-pushed the feat/im-chats-create-topic-group branch from 002155e to ff32adf Compare May 13, 2026 09:20
@YangJunzhou-01
YangJunzhou-01 merged commit 5e0ac02 into larksuite:main May 13, 2026
18 checks passed
tuxedomm pushed a commit to zhumiaoxin/cli that referenced this pull request Jun 6, 2026
Adds --chat-mode group|topic to lark-cli im +chat-create so users and AI agents can create 话题群 (topic chats) directly via the CLI. Without this, requests to create a topic chat silently fall back to a normal conversation group. Default remains group; chat_mode is now always emitted in the POST /open-apis/im/v1/chats request body.

Change-Id: I79385e2e8606f84e3f27de240d1b41037bf51261
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.

2 participants