feat(im): unify sort flags into --sort field and --order direction#1302
Conversation
|
Wondering what really moved? Review this PR in Change Stack to inspect semantic changes, definitions, and references. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis PR refactors IM shortcuts' sort/order flag naming and wiring. It introduces an ChangesIM shortcut flag alias refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
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. Comment |
7e9d54f to
71a5cd9
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1302 +/- ##
==========================================
+ Coverage 72.75% 72.85% +0.09%
==========================================
Files 730 732 +2
Lines 69034 69120 +86
==========================================
+ Hits 50228 50354 +126
+ Misses 15034 14989 -45
- Partials 3772 3777 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@4d8ec3e7f6eca01c92f61022e3caf2deaad6e8d4🧩 Skill updatenpx skills add larksuite/cli#feat/im-sort-flags-unify -y -g |
71a5cd9 to
4d8ec3e
Compare
Rebased onto main v1.0.54, which added IM content after this branch forked. Fold main's new facts into the slimmed/gotcha-only form and fix drift: - SKILL.md: compact the newly-merged chat.user_setting / chat.managers / chat.moderation API resources to the api_compact `action`(identity) form (consistent with the rest; regen-equivalent), and note the opt-in `--download-resources` flag on the three message-pulling shortcuts. - chat-search: fix stale `--sort-by` -> `--sort`, add `--chat-modes`, and fold the "`--sort` is always descending" caution (#1302/#1317). - chat-messages-list: note `--order` is the only sort axis (no field sort). - messages-send: split @mention by message type; interactive cards are not normalized and need card-native `<at>` syntax (#1419). - flag-cancel: document best-effort double-cancel (feed layer skipped with a stderr warning when chat type is undeterminable). - feed-group-list-item / query-item: p2p cards omit chat_name; resolve via chats/batch_query -> p2p_target_id -> contact lookup. - message-enrichment: add the `--download-resources` contract (merge_forward container-id 234003 trap, fail-silent isolation, no extra scope) (#1245). Docs only; no Go/--help/Desc changes.
Summary
The 4 im query commands had three inconsistent sort conventions and leaked upstream API jargon (
ByCreateTimeAsc,member_count_desc) directly to users. This PR unifies them on a single rule —--sortselects a field,--orderselects a direction, both from fixed enums — so an agent only ever picks from an enum, never constructs a string. Old flags (--sort-type,--sort-by, and--sorton messages/threads) are kept as hidden silent aliases (no deprecation warning), so existing scripts keep working byte-for-byte.Two design tradeoffs were reviewed and explicitly accepted (full rationale in the design spec):
--sortis overloaded across commands — a field selector onchat-list/chat-search, a hidden direction alias onmessages/threads. Accepted because the field-value set and direction-value set are disjoint, the clash is hidden from--help, and every mismatch fails fast (exit 2 / unknown flag) — no silent wrong sort, no compat break. The residual cost is conceptual + a latent naming conflict if those two commands ever gain a sortable field.Changes
shortcuts/im/sort_flags.go—aliasFlagValuehelper (pure, no IO) implementing the "old flag wins only if new not given" ruleshortcuts/im/im_chat_list.go— new--sort(create_time/active_time); old--sort-type→ hidden alias; map field →sort_typeshortcuts/im/im_chat_messages_list.go— rename--sort→--order(asc/desc); old--sort→ hidden alias (mapped through, not passed through)shortcuts/im/im_threads_messages_list.go— extract sharedbuildThreadsMessagesListParams(so DryRun and Execute share one asc/desc→sort_type mapping), then rename--sort→--order; old--sort→ hidden aliasshortcuts/im/im_chat_search.go— new--sort(create_time/update_time/member_count, always descending); old--sort-by→ hidden alias; map field →sorterskills/lark-im/references/*.md(4 files) — update flag tables/examples to the unified flags; add CAUTION notes on chat-messages-list (time-axis only) and chat-search (descending only)Test Plan
make unit-testpassed--sort asc/descon messages/threads → exit 0, byte-identical upstream), new-wins, invalid-value fail-fast (exit 2), rejected combos (chat-list --order→ unknown flag)Related Issues
N/A
Summary by CodeRabbit
Release Notes
New Features
--sortfor chat-list (withcreate_time/active_time),--orderfor chat-messages-list and threads-messages-list (withasc/desc), and--sortfor chat-search (withcreate_time/update_time/member_count)Documentation