Skip to content

fix(contact): stop bot match segments carrying tags or empty entries - #2115

Merged
liangshuo-1 merged 1 commit into
mainfrom
fix/search-bot-followup
Jul 30, 2026
Merged

fix(contact): stop bot match segments carrying tags or empty entries#2115
liangshuo-1 merged 1 commit into
mainfrom
fix/search-bot-followup

Conversation

@liangshuo-1

@liangshuo-1 liangshuo-1 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #2083. These changes were made after that PR's head was snapshotted for the squash merge, so they never reached main.

Changes

  • Bot search match segments no longer carry <h> tags or empty entries — the non-greedy highlight pattern can pair a stray <h> with the next </h>, leaving a tag inside the capture.
  • One buildBotSearchFilter shared by --query and --queries, replacing two copies of the same logic.
  • Test for the fanout scheduler's cancellation branch.
  • Docs: +search-bot affordance points at its skill reference; the 41050 recovery path no longer suggests switching to a bot identity for a user-only command.

Test Plan

  • go test ./shortcuts/contact/..., go vet, gofmt, skill-format-check all pass
  • --dry-run confirms the shared filter builder is behavior-preserving: no scope flags omits filter entirely, and --has-chatted yields the same filter for both flags

Related Issues

Summary by CodeRabbit

  • New Features

    • Enhanced contact bot search so request scoping behaves consistently.
    • Improved parsing of highlighted match segments for cleaner names and descriptions.
  • Bug Fixes

    • Strengthened fanout cancellation so queued work and already-canceled runs stop correctly and preserve cancellation causes.
    • Ensured unscoped searches omit filter data entirely rather than sending empty filters.
  • Documentation

    • Updated Skills guidance for “Permission denied” to reflect the correct number of affected commands.

@github-actions github-actions Bot added domain/contact PR touches the contact domain size/M Single-domain feat or fix with limited business impact labels Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Bot search requests now share scope-filter construction, omit empty filters, strip highlight tags consistently, and expand cancellation and parsing tests. Related contact documentation and permission guidance are updated.

Changes

Bot search behavior

Layer / File(s) Summary
Unified bot search request filtering
shortcuts/contact/contact_search_bot.go, shortcuts/contact/contact_search_bot_fanout.go, affordance/contact.md, skills/lark-contact/SKILL.md
Single-query, dry-run, and fanout requests use buildBotSearchFilter, while related command and permission guidance is updated.
Highlight tag parsing
shortcuts/contact/contact_search_bot.go, shortcuts/contact/contact_search_bot_test.go
Display-info parsing strips <h> tags consistently, with edge cases added to table-driven tests.
Fanout cancellation scheduling
shortcuts/contact/contact_search_bot_fanout_test.go, shortcuts/contact/contact_search_user_test.go
Context-aware command execution and fanout tests cover cancellation of active, queued, and pre-request operations.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • larksuite/cli#2083: Introduces the bot search shortcut and related request and parsing logic modified here.

Suggested labels: documentation, feature

Suggested reviewers: sang-neo03, sunpeiyang996

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% 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 matches the main fix: removing tags and empty entries from bot match segments.
Description check ✅ Passed The description follows the template with Summary, Changes, Test Plan, and Related Issues, and it is mostly complete.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/search-bot-followup

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.

The non-greedy highlight pattern can pair a stray `<h>` with the next `</h>`,
leaving a tag inside the capture, so a match segment could read differently from
the name and description it came from. Strip segments the same way, and drop a
blank highlight instead of appending an empty string.

- share one buildBotSearchFilter across --query and --queries, replacing two
  copies of the same logic and keeping "nil filter means no scope" explicit
- cover the fanout scheduler's cancellation branch
- point the +search-bot affordance at its skill reference
- correct the 41050 recovery path, which told the reader to switch to a bot
  identity even though +search-bot is user-only
@liangshuo-1
liangshuo-1 force-pushed the fix/search-bot-followup branch from 76cd5f5 to fb22bf6 Compare July 30, 2026 09:50
@liangshuo-1 liangshuo-1 changed the title fix(contact): drop stray tags and empty entries from bot search match segments fix(contact): stop bot match segments carrying tags or empty entries Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/search-bot-followup -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

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

Inline comments:
In `@shortcuts/contact/contact_search_bot_fanout_test.go`:
- Around line 522-549: The test’s cancellation can occur before all fanout
workers are occupied, so it does not reliably exercise queued-query
cancellation. Update TestBotFanoutCancelledSchedulingFailsQueuedQueries to
signal once from each blocked OnMatch handler, wait for fanoutConcurrency
signals before cancelling, and retain the timeout safeguard to prevent parked
workers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5e7819b8-2612-4ae2-93d6-34cee195c17c

📥 Commits

Reviewing files that changed from the base of the PR and between 76cd5f5 and fb22bf6.

📒 Files selected for processing (7)
  • affordance/contact.md
  • shortcuts/contact/contact_search_bot.go
  • shortcuts/contact/contact_search_bot_fanout.go
  • shortcuts/contact/contact_search_bot_fanout_test.go
  • shortcuts/contact/contact_search_bot_test.go
  • shortcuts/contact/contact_search_user_test.go
  • skills/lark-contact/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • affordance/contact.md
  • skills/lark-contact/SKILL.md

Comment thread shortcuts/contact/contact_search_bot_fanout_test.go
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.25%. Comparing base (a575a8b) to head (fb22bf6).

Files with missing lines Patch % Lines
shortcuts/contact/contact_search_bot.go 90.90% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2115   +/-   ##
=======================================
  Coverage   75.25%   75.25%           
=======================================
  Files         916      916           
  Lines       97173    97167    -6     
=======================================
- Hits        73123    73121    -2     
+ Misses      18437    18433    -4     
  Partials     5613     5613           

☔ View full report in Codecov by Harness.
📢 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.

@liangshuo-1
liangshuo-1 merged commit 87be09e into main Jul 30, 2026
34 of 45 checks passed
@liangshuo-1
liangshuo-1 deleted the fix/search-bot-followup branch July 30, 2026 10:08
This was referenced Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/contact PR touches the contact 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