Skip to content

feat(docs): add --lang to docs +fetch v2 for cite user display language#1322

Closed
herbertliu wants to merge 2 commits into
mainfrom
feat/docs-cite-user-lang-bq
Closed

feat(docs): add --lang to docs +fetch v2 for cite user display language#1322
herbertliu wants to merge 2 commits into
mainfrom
feat/docs-cite-user-lang-bq

Conversation

@herbertliu

@herbertliu herbertliu commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a --lang flag to docs +fetch v2 (OpenAPI path) so <cite type="user"> display names are returned in the requested language.

  • v2FetchFlags(): new --lang flag (e.g. zh_cn / en_us / ja_jp)
  • buildFetchBody(): injects body["lang"] with priority explicit --lang > runtime.Lang() (user default) > omit
  • RuntimeContext.Lang(): now nil-Config safe
  • lark-doc skill fetch reference: documents --lang
  • Tests: explicit lang + omitted-when-unset

Maps to OpenAPI request field OpenDocsAIFetchDocumentRequest.Lang (api.json="lang", field-id 8, already on master). Backend passthrough (ai_edit + office_ai_sdk) tracked separately.

Verify

docs +fetch --api-version v2 --doc <token> --lang ja_jp --dry-run   # body carries "lang":"ja_jp"
docs +fetch --api-version v2 --doc <token> --dry-run                 # falls back to runtime user lang, or omits

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a hidden CLI --lang option to control citation display language for document fetches (e.g., zh_cn, en_us, ja_jp); when omitted, the user's configured language is used.
  • Bug Fixes

    • Improved handling when a user's language preference is unset so language resolution falls back sensibly.
  • Documentation

    • Docs updated with --lang usage, guidance for writing messages to documents, and updated rules/examples for the sub-page-list resource.

BE-1 of docs-cite-user-lang-bq. Adds a --lang flag to `docs +fetch` v2 and
injects body["lang"] (priority: explicit --lang > runtime.Lang() > omit) so
<cite type="user"> display names return in the requested language. Also makes
RuntimeContext.Lang() nil-Config safe and documents --lang in the lark-doc
skill fetch reference. Tests cover explicit lang + omitted-when-unset.

Spec source: active@42414488f6e15281f1ba4162fed116f019b865af0e978b51999a141da379dc36

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels Jun 8, 2026
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds a hidden --lang flag to the v2 OpenAPI document fetch to control user-citation display language, injects that value (or runtime fallback) into the fetch request body, adds defensive nil-handling in RuntimeContext.Lang(), includes tests for the behaviour, and updates documentation.

Changes

Language Flag Support for Document Fetch v2

Layer / File(s) Summary
RuntimeContext.Lang() nil-safety
shortcuts/common/runner.go
Added nil-check for ctx.Config to return empty string instead of panicking.
V2 fetch lang flag and injection
shortcuts/doc/docs_fetch_v2.go
Added hidden --lang flag and injectLang used by buildFetchBody: prefer explicit flag, else runtime.Lang(), else omit lang.
V2 fetch lang tests and runtime setup
shortcuts/doc/docs_fetch_v2_test.go
Added parallel tests verifying explicit lang is included and omitted when empty; registered lang flag on test cobra.Command.
Document fetch CLI docs
skills/lark-doc/references/lark-doc-fetch.md
Documented --lang usage for <cite type="user"> language, omission/fallback rules, and server-side format tolerance.
Doc XML updates and username-write rules
skills/lark-doc/references/lark-doc-xml.md
Added <sub-page-list> resource block, marked it copy-supported, inserted example, and added username-writing rules requiring <cite type="user" user-id="..."> with lookup guidance.
IM -> Document username citation guidance
skills/lark-im/SKILL.md
Added "Writing Messages to Lark Documents" section requiring <cite> for open_id-based users and describing resolution workflow when only names exist.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • larksuite/cli#1132: Related previous changes to RuntimeContext.Lang() implementation and language-resolution path.
  • larksuite/cli#1168: Overlapping documentation edits for <sub-page-list> in the lark-doc XML reference.

Suggested labels

feature, documentation, size/M

Suggested reviewers

  • SunPeiYang996
  • fangshuyu-768

Poem

🐰 I hop across flags, a tiny guide,
--lang tucked close to names worldwide,
Nil-checked paths keep panics at bay,
Tests nod yes, docs show the way,
User cites now speak the tongue they tried.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% 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 accurately summarizes the main change: adding a --lang flag to docs +fetch v2 for controlling cite user display language.
Description check ✅ Passed The description covers all required template sections: Summary explains motivation, Changes lists main modifications, Test Plan includes verification examples, and Related Issues is noted.
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
  • Commit unit tests in branch feat/docs-cite-user-lang-bq

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

- Unify modal verbs to "必须" throughout the user name writing rules
- Add per-scenario coverage table: sender, mentions, reactions, cards,
  system messages, and merge_forward
- Add open_id resolution workflow via lark-contact +search-user for
  plain-text names (system messages, merge_forward content)
- Add Writing Messages to Lark Documents section in lark-im SKILL.md
  with field-to-cite mapping and cross-reference to lark-doc-xml.md
@github-actions github-actions Bot added the domain/im PR touches the im domain label Jun 11, 2026
@fangshuyu-768
fangshuyu-768 deleted the feat/docs-cite-user-lang-bq branch June 11, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain domain/im PR touches the im domain size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants