Skip to content

feat: request thread roots for chat message list#635

Open
YangJunzhou-01 wants to merge 1 commit intolarksuite:mainfrom
YangJunzhou-01:feat/read-history-thread-root-only
Open

feat: request thread roots for chat message list#635
YangJunzhou-01 wants to merge 1 commit intolarksuite:mainfrom
YangJunzhou-01:feat/read-history-thread-root-only

Conversation

@YangJunzhou-01
Copy link
Copy Markdown
Collaborator

@YangJunzhou-01 YangJunzhou-01 commented Apr 23, 2026

Summary

Update im +chat-messages-list to request only thread root messages from /open-apis/im/v1/messages by default. This aligns the shortcut request shape with topic-group usage and makes the intended API behavior explicit in both runtime params and dry-run output.

Changes

  • Add only_thread_root_messages=true to the shared query params built by shortcuts/im/im_chat_messages_list.go
  • Extend dry-run coverage to verify the generated request includes the root-only query parameter
  • Extend request-builder coverage to verify the runtime query params include only_thread_root_messages
  • Ignore local Hammer artifacts by adding .hammer/ to .gitignore

Test Plan

  • make unit-test
  • Manual local verification confirms lark-cli im +chat-messages-list --chat-id <oc_xxx> --page-size 5 --sort desc --dry-run --format json includes only_thread_root_messages=true
  • Manual local verification confirms lark-cli im +chat-messages-list --chat-id <oc_xxx> --page-size 5 --sort desc --format json returns the expected root-level message set

Related Issues

  • None

Summary by CodeRabbit

  • Features

    • Chat message list now filters to display only thread root messages.
  • Tests

    • Expanded test coverage for message list filtering behavior.
  • Chores

    • Updated project ignore patterns.

Change-Id: I3901b27e70b0e4db506ff199eb03c96fcf98671d
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

A new query parameter only_thread_root_messages=true is added to chat message list API calls in the IM shortcuts module. This parameter filters results to return only thread root messages. Corresponding test cases are added to verify the parameter is correctly included in requests. The .hammer/ directory is added to gitignore.

Changes

Cohort / File(s) Summary
Gitignore Configuration
.gitignore
Added pattern to exclude .hammer/ directory from version control.
API Parameter Implementation
shortcuts/im/im_chat_messages_list.go
Added only_thread_root_messages=true query parameter to buildChatMessageListParams function for filtering chat message list requests to thread root messages only.
Test Coverage
shortcuts/im/builders_test.go, shortcuts/im/coverage_additional_test.go
Extended test suite with new assertions and test cases verifying that the only_thread_root_messages=true parameter is correctly included in formatted dry-run output and API request parameters.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A whisker-twitch of joy, we add a flag so fine,
Only root messages now, in threads they'll align!
Tests bloom like clover, checking all is right,
The .hammer/ hops away—out of sight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.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 title 'feat: request thread roots for chat message list' accurately and specifically describes the primary change: adding the only_thread_root_messages parameter to request only thread root messages from the chat message list API.
Description check ✅ Passed The pull request description includes all required template sections (Summary, Changes, Test Plan, Related Issues) with comprehensive details about the modifications, testing approach, and manual verification steps performed.
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 Apr 23, 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/builders_test.go (1)

750-774: Consider removing the duplicate dry-run assertion.

The new subtest and standalone test both create the same runtime and assert the same only_thread_root_messages=true substring. Keeping one is enough; coverage_additional_test.go already covers the lower-level params.

♻️ Proposed cleanup
 	t.Run("ImChatMessageList dry run includes root-only query", func(t *testing.T) {
 		runtime := newTestRuntimeContext(t, map[string]string{
 			"chat-id":   "oc_123",
 			"page-size": "20",
 			"sort":      "desc",
 		}, nil)
 		formatted := ImChatMessageList.DryRun(context.Background(), runtime).Format()
 		if !strings.Contains(formatted, "only_thread_root_messages=true") {
 			t.Fatalf("ImChatMessageList.DryRun().Format() = %s, want only_thread_root_messages=true", formatted)
 		}
 	})
 }
-
-func TestChatMessageListOnlyThreadRootMessagesDryRun(t *testing.T) {
-	runtime := newTestRuntimeContext(t, map[string]string{
-		"chat-id":   "oc_123",
-		"page-size": "20",
-		"sort":      "desc",
-	}, nil)
-
-	formatted := ImChatMessageList.DryRun(context.Background(), runtime).Format()
-	if !strings.Contains(formatted, "only_thread_root_messages=true") {
-		t.Fatalf("ImChatMessageList.DryRun().Format() = %s, want only_thread_root_messages=true", formatted)
-	}
-}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/im/builders_test.go` around lines 750 - 774, The test duplicates
the same assertion on ImChatMessageList.DryRun().Format() — remove one of them
to avoid redundancy: delete either the subtest "ImChatMessageList dry run
includes root-only query" or the standalone
TestChatMessageListOnlyThreadRootMessagesDryRun function so only a single
assertion for only_thread_root_messages=true remains (leave the other intact);
make sure any helper call newTestRuntimeContext and the runtime setup remain in
the kept test.
🤖 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/builders_test.go`:
- Around line 750-774: The test duplicates the same assertion on
ImChatMessageList.DryRun().Format() — remove one of them to avoid redundancy:
delete either the subtest "ImChatMessageList dry run includes root-only query"
or the standalone TestChatMessageListOnlyThreadRootMessagesDryRun function so
only a single assertion for only_thread_root_messages=true remains (leave the
other intact); make sure any helper call newTestRuntimeContext and the runtime
setup remain in the kept test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ed61726-c658-4803-98e3-1fc5232a5d3b

📥 Commits

Reviewing files that changed from the base of the PR and between 600fa50 and 0125519.

📒 Files selected for processing (4)
  • .gitignore
  • shortcuts/im/builders_test.go
  • shortcuts/im/coverage_additional_test.go
  • shortcuts/im/im_chat_messages_list.go

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.37%. Comparing base (600fa50) to head (0125519).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #635      +/-   ##
==========================================
+ Coverage   60.52%   62.37%   +1.85%     
==========================================
  Files         415      415              
  Lines       43710    36096    -7614     
==========================================
- Hits        26454    22515    -3939     
+ Misses      15201    11526    -3675     
  Partials     2055     2055              

☔ 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

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add YangJunzhou-01/cli#feat/read-history-thread-root-only -y -g

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