Skip to content

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

Open
shifengjuan-dev wants to merge 1 commit intolarksuite:mainfrom
shifengjuan-dev:feat/im-chats-create-topic-group
Open

feat(im): add --chat-mode topic to +chat-create#790
shifengjuan-dev wants to merge 1 commit intolarksuite:mainfrom
shifengjuan-dev:feat/im-chats-create-topic-group

Conversation

@shifengjuan-dev
Copy link
Copy Markdown
Contributor

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

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 (defaults to 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 verifying topic-mode behavior, fallback to group, and dry-run output.
  • Changelog

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

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7fbd23a4-bc60-493d-9ab7-97a418f1dfa8

📥 Commits

Reviewing files that changed from the base of the PR and between 12deb62 and f7c6bf2.

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

📝 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
Updated TestBuildCreateChatBody to include chat-mode: group; added TestBuildCreateChatBody_TopicMode; added TestBuildCreateChatBody_EmptyChatModeFallsBack; 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

Possibly related PRs

  • larksuite/cli#242: Modifies the same ImChatCreate shortcut and touches related flag/behavior handling.

Suggested reviewers

  • YangJunzhou-01
  • sammi-bytedance

Poem

🐰 I found a flag to sow,
group or topic — pick and go,
tests hop in tidy rows,
docs whisper how 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 summarizes the main change: adding --chat-mode topic support to the +chat-create command.
Description check ✅ Passed The description follows the template structure with all required sections: Summary, Changes, Test Plan, and Related Issues. All sections are complete and provide comprehensive details about the feature.
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
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

✅ 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
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

✅ 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
Contributor 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
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

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
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

✅ 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.

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 12deb62 to f7c6bf2 Compare May 9, 2026 07:13
@shifengjuan-dev
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

✅ 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.

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