Skip to content

feat: add IM chat disband shortcut#1197

Open
David-Buxy wants to merge 1 commit into
larksuite:mainfrom
David-Buxy:codex/im-chat-disband-shortcut
Open

feat: add IM chat disband shortcut#1197
David-Buxy wants to merge 1 commit into
larksuite:mainfrom
David-Buxy:codex/im-chat-disband-shortcut

Conversation

@David-Buxy
Copy link
Copy Markdown

@David-Buxy David-Buxy commented Jun 1, 2026

Summary

Add a high-risk IM shortcut for disbanding group chats through the documented DELETE /open-apis/im/v1/chats/{chat_id} API.

Changes

  • Add im +chat-disband with required --chat-id, --yes execution confirmation, dry-run output, and im:chat:delete scope metadata.
  • Register the shortcut and document usage, limits, permissions, and examples.
  • Add unit coverage, dry-run E2E coverage, and a live workflow E2E that skips clearly when the local app lacks im:chat:delete.

Test Plan

  • PATH=/Users/bytedance/.cache/codex-runtimes/go/go/bin:$PATH go test ./shortcuts/im -run 'TestImChatDisband|TestShortcutDryRunShapes|TestShortcuts' -count=1
  • PATH=/Users/bytedance/.cache/codex-runtimes/go/go/bin:$PATH go test ./tests/cli_e2e/im -run 'TestIM_ChatDisbandDryRun|TestIM_ChatDisbandWorkflowAsBot' -count=1
  • PATH=/Users/bytedance/.cache/codex-runtimes/go/go/bin:$PATH go test ./shortcuts/im -count=1
  • PATH=/Users/bytedance/.cache/codex-runtimes/go/go/bin:$PATH make fmt-check
  • PATH=/Users/bytedance/.cache/codex-runtimes/go/go/bin:$PATH go vet ./...
  • PATH=/Users/bytedance/.cache/codex-runtimes/go/go/bin:$PATH make unit-test
  • PATH=/Users/bytedance/.cache/codex-runtimes/go/go/bin:$PATH make build

Note: the live disband E2E skipped locally because the configured local app does not have im:chat:delete; the dry-run and shortcut tests validate the request shape locally.

Summary by CodeRabbit

  • New Features

    • Added im +chat-disband command to disband group chats; marked as high-risk operation requiring confirmation; supports dry-run mode.
  • Documentation

    • Added documentation for im +chat-disband command with usage examples and required permissions.
  • Tests

    • Added unit and E2E test coverage for the new command functionality.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a new high-risk IM shortcut +chat-disband that allows users to disband group chats via a DELETE request to /open-apis/im/v1/chats/{chat-id}. The implementation includes core shortcut handlers, unit and E2E tests, framework integration, and user documentation.

Changes

IM Chat Disband Feature

Layer / File(s) Summary
ImChatDisband shortcut implementation
shortcuts/im/im_chat_disband.go
ImChatDisband shortcut exports required scope im:chat:delete, defines --chat-id flag, and implements DryRun (preview DELETE request), Validate (enforce chat-id format), and Execute (perform HTTP DELETE with formatted result) handlers.
ImChatDisband unit tests
shortcuts/im/im_chat_disband_test.go
Unit test verifies Execute performs HTTP DELETE to the correct endpoint with empty body; helper constructs a Cobra command with --chat-id flag for testing.
Shortcut registry integration
shortcuts/im/shortcuts.go, shortcuts/im/helpers_test.go
ImChatDisband is registered in Shortcuts() function list and TestShortcuts expectations updated to include +chat-disband.
Generic shortcut framework tests
shortcuts/im/builders_test.go
Added subtests to TestShortcutValidateBranches and TestShortcutDryRunShapes that verify invalid chat-id error handling and expected DELETE endpoint/high-risk marker output.
End-to-end tests and infrastructure updates
tests/cli_e2e/im/chat_disband_dryrun_test.go, tests/cli_e2e/im/chat_disband_workflow_test.go, tests/cli_e2e/im/helpers_test.go
Dry-run E2E test validates output format; workflow E2E test creates a chat and executes disband with confirmation. E2E helper comments and cleanup behavior updated to reflect im:chat:delete scope requirement for chat disband.
User-facing documentation
skills/lark-im/SKILL.md, skills/lark-im/references/lark-im-chat-disband.md
SKILL.md adds +chat-disband to shortcuts table, API notes, and permissions mapping. New reference page documents command usage, required scopes, chat-id format (oc_xxx), irreversibility, and bash examples for both dry-run and confirmed execution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • larksuite/cli#401: Established the IM E2E test infrastructure (tests/cli_e2e/im/helpers_test.go) that this PR extends with chat disband cleanup behavior and scope requirements.

Suggested labels

domain/im, size/M

Suggested reviewers

  • sammi-bytedance
  • YangJunzhou-01

Poem

🐰 A chat disbands with one command so fine,
/open-apis/im/v1/chats meets DELETE's line,
Tests validate, docs explain with care,
High-risk, confirmed—a builder's prayer! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% 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 title clearly and concisely describes the main change: adding a new IM chat disband shortcut feature.
Description check ✅ Passed The description provides a clear summary, lists the main changes, includes a comprehensive test plan with checkmarks, and notes about test execution and conditional skipping.
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 1, 2026
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/im_chat_disband_test.go (1)

41-49: ⚡ Quick win

Simplify body assertion to strictly enforce no request body.

The current logic unmarshals and checks for an empty JSON object, which would pass if the body is {}. For a DELETE request with nil body (line 42 of im_chat_disband.go), the HTTP layer should send zero bytes, not even an empty JSON object.

♻️ Proposed simplification
-	if len(stub.CapturedBody) != 0 {
-		var body map[string]interface{}
-		if err := json.Unmarshal(stub.CapturedBody, &body); err != nil {
-			t.Fatalf("request body invalid JSON: %v\n%s", err, string(stub.CapturedBody))
-		}
-		if len(body) != 0 {
-			t.Fatalf("request body = %#v, want empty", body)
-		}
-	}
+	if len(stub.CapturedBody) != 0 {
+		t.Fatalf("DELETE request sent body = %q, want no body", string(stub.CapturedBody))
+	}
🤖 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 `@shortcuts/im/im_chat_disband_test.go` around lines 41 - 49, The test in
im_chat_disband_test.go currently unmarshals stub.CapturedBody and allows an
empty JSON object ("{}"), but a DELETE with a nil body (as sent by
im_chat_disband.go) must be zero bytes; replace the current block with a strict
assertion that stub.CapturedBody length is zero and fail the test if any bytes
were sent (i.e., if len(stub.CapturedBody) != 0 then t.Fatalf with the raw
captured bytes), so the test fails on "{}" as well as any other payload.
🤖 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 `@shortcuts/im/im_chat_disband_test.go`:
- Around line 41-49: The test in im_chat_disband_test.go currently unmarshals
stub.CapturedBody and allows an empty JSON object ("{}"), but a DELETE with a
nil body (as sent by im_chat_disband.go) must be zero bytes; replace the current
block with a strict assertion that stub.CapturedBody length is zero and fail the
test if any bytes were sent (i.e., if len(stub.CapturedBody) != 0 then t.Fatalf
with the raw captured bytes), so the test fails on "{}" as well as any other
payload.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 22a71ec6-720c-43c8-a9be-30c89ae99445

📥 Commits

Reviewing files that changed from the base of the PR and between 99e314f and 36fd593.

📒 Files selected for processing (10)
  • shortcuts/im/builders_test.go
  • shortcuts/im/helpers_test.go
  • shortcuts/im/im_chat_disband.go
  • shortcuts/im/im_chat_disband_test.go
  • shortcuts/im/shortcuts.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-chat-disband.md
  • tests/cli_e2e/im/chat_disband_dryrun_test.go
  • tests/cli_e2e/im/chat_disband_workflow_test.go
  • tests/cli_e2e/im/helpers_test.go

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