Skip to content

feat: add docs history shortcuts#1612

Merged
caojie0621 merged 1 commit into
mainfrom
feat/docs_revert
Jul 3, 2026
Merged

feat: add docs history shortcuts#1612
caojie0621 merged 1 commit into
mainfrom
feat/docs_revert

Conversation

@caojie0621

@caojie0621 caojie0621 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add docs history shortcuts so users and agents can list Docx history versions, revert to a selected history_version_id, and poll revert task status through structured CLI flows.

Changes

  • Add docs +history-list, docs +history-revert, and docs +history-revert-status shortcuts backed by Docs AI history APIs.
  • Validate Docx-only document refs, page size, positive history_version_id, wait timeout, and task ID with typed errs.* validation errors.
  • Register the new shortcuts and extend dry-run output coverage for history list/revert/status request shapes.
  • Add unit tests, dry-run E2E coverage, and a gated live history workflow E2E for create -> update -> list history -> revert -> fetch verification.
  • Update lark-doc skill documentation and coverage notes with the history workflow and revision_id to history_version_id guidance.

Test Plan

  • make unit-test

Related Issues

  • None

Summary by CodeRabbit

  • New Features
    • Added document history shortcuts to list history versions, start a rollback to a selected version, and check rollback task status.
    • Updated docs command/help wiring so the new history shortcuts appear with the existing docs workflow guidance.
  • Documentation
    • Added a dedicated document-history reference with a safe rollback workflow, parameters, return examples, and command examples.
  • Tests
    • Added unit tests covering flag validation, dry-run API shapes, and list/revert/revert-status execution.
    • Added gated end-to-end workflow tests for create/update/history list/revert/poll plus final fetch verification; expanded CLI coverage assertions.
  • Chores
    • Adjusted ignore rules so history test documentation assets are not excluded.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds docs history shortcuts for listing, reverting, and polling document history, wires them into docs help and skill documentation, expands shortcut and e2e coverage, and refactors API tests to use shared Cobra command helpers.

Changes

Doc history CLI

Layer / File(s) Summary
History shortcuts
shortcuts/doc/docs_history.go
Implements the three docs history shortcuts with shared doc/version validation, request construction, dry-run metadata, and HTTP execution.
Help wiring and registration
shortcuts/doc/shortcuts.go, shortcuts/register_test.go
Maps the new history shortcuts into docs skill/help lookup and verifies they mount under the docs service with the expected long help.
Skill and reference docs
skills/lark-doc/SKILL.md, skills/lark-doc/references/lark-doc-history.md
Updates the lark-doc skill guide and adds the history reference page with the list, revert, and status flows.
Shortcut tests
shortcuts/doc/docs_history_test.go, tests/cli_e2e/docs/docs_update_dryrun_test.go
Adds validation, dry-run, execution, and URL-parsing tests for the docs history shortcuts and updates the dry-run expectations for history requests.
E2E workflow and coverage
.gitignore, tests/cli_e2e/docs/docs_history_workflow_test.go, tests/cli_e2e/docs/coverage.md
Adds the gated live history workflow test, updates the docs E2E coverage report, and adds ignore patterns for the docs E2E directory.

API test harness

Layer / File(s) Summary
Shared test command helpers
cmd/api/api_test.go
Adds shared Cobra command constructors and rewires API tests to use them with standardized silence settings.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DocsHistoryShortcut
  participant Docs OpenAPI
  participant Docs History Task

  User->>DocsHistoryShortcut: +history-list / +history-revert / +history-revert-status
  DocsHistoryShortcut->>Docs OpenAPI: GET or POST with doc token, params, body
  Docs OpenAPI-->>DocsHistoryShortcut: JSON response
  DocsHistoryShortcut->>Docs History Task: use task_id when revert is running
  Docs History Task-->>DocsHistoryShortcut: status update
  DocsHistoryShortcut-->>User: raw response / final status
Loading

Possibly related PRs

  • larksuite/cli#1536: Both PRs touch the docs dry-run test harness in tests/cli_e2e/docs/docs_update_dryrun_test.go.

Suggested labels: documentation

Suggested reviewers: fangshuyu-768, SunPeiYang996

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.92% 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 is concise and accurately summarizes the main change: adding docs history shortcuts.
Description check ✅ Passed The description follows the required template and includes summary, changes, test plan, and related issues.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/docs_revert

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.

@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 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/docs_revert -y -g

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/larksuite/cli/issues/comments/4808214401","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- review_stack_entry_start -->\n\n[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/larksuite/cli/pull/1612?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)\n\n<!-- review_stack_entry_end -->\n<!-- This is an auto-generated comment: review in progress by coderabbit.ai -->\n\n> [!NOTE]\n> Currently processing new changes in this PR. This may take a few minutes, please wait...\n> \n> <details>\n> <summary>⚙️ Run configuration</summary>\n> \n> **Configuration used**: defaults\n> \n> **Review profile**: CHILL\n> \n> **Plan**: Pro\n> \n> **Run ID**: `ce3a1429-c7a9-46db-99f9-fee4303fd2fd`\n> \n> </details>\n> \n> <details>\n> <summary>📥 Commits</summary>\n> \n> Reviewing files that changed from the base of the PR and between 39d60cb7061d0771fc88ec0da276e9bf25b48077 and 6982572097dadf96a638c60f3d0967e8eaf45920.\n> \n> </details>\n> \n> <details>\n> <summary>📒 Files selected for processing (10)</summary>\n> \n> * `.gitignore`\n> * `shortcuts/doc/docs_history.go`\n> * `shortcuts/doc/docs_history_test.go`\n> * `shortcuts/doc/shortcuts.go`\n> * `shortcuts/register_test.go`\n> * `skills/lark-doc/SKILL.md`\n> * `skills/lark-doc/references/lark-doc-history.md`\n> * `tests/cli_e2e/docs/coverage.md`\n> * `tests/cli_e2e/docs/docs_history_workflow_test.go`\n> * `tests/cli_e2e/docs/docs_update_dryrun_test.go`\n> \n> </details>\n> \n> ```ascii\n>  _________________________________________________\n> < If you only knew now what you didn't know then. >\n>  -------------------------------------------------\n>   \\\n>    \\   \\\n>         \\ /\\\n>         ( )\n>       .( o ).\n> ```\n\n<!-- end of auto-generated comment: review in progress by coderabbit.ai -->\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n<details>\n<summary>📝 Generate docstrings</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> Create stacked PR\n- [ ] <!-- {\"checkboxId\": \"3e1879ae-f29b-4d0d-8e06-d12b7ba33d98\"} --> Commit on current branch\n\n</details>\n<details>\n<summary>🧪 Generate unit tests (beta)</summary>\n\n- [ ] <!-- {\"checkboxId\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Create PR with unit tests\n- [ ] <!-- {\"checkboxId\": \"6ba7b810-9dad-11d1-80b4-00c04fd430c8\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Commit unit tests in branch `feat/docs_revert`\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=larksuite/cli&utm_content=1612)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":3,"signal":{},"retries":3,"retryAfter":16}}}

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@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: 2

🧹 Nitpick comments (1)
tests/cli_e2e/docs/docs_update_dryrun_test.go (1)

90-122: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Parse the dry-run JSON instead of matching formatted fragments.

The new history assertions depend on exact serialization details like "page_size": 5 and "task_id": "task_1". A whitespace or pretty-print change will fail this test even if the request shape is still correct. Parse result.Stdout and assert the dry-run api[0] URL/body/params fields directly instead of searching stdout+stderr for substrings.

Also applies to: 136-139

🤖 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 `@tests/cli_e2e/docs/docs_update_dryrun_test.go` around lines 90 - 122, The
dry-run history tests are matching serialized JSON substrings in stdout/stderr,
which makes them brittle to formatting changes. Update the relevant cases in the
CLI e2e test to parse result.Stdout as JSON and assert the dry-run request
fields directly on api[0] (URL, body, and params) instead of using wantContains
substring checks; apply the same change to the history revert and history revert
status cases.
🤖 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/doc/docs_history_test.go`:
- Around line 71-80: The failure-path tests in docs_history_test should assert
the full typed metadata, not just that some validation error exists or that the
URL matches a substring. In the relevant test cases, keep the existing errors.As
check against errs.ValidationError for Param, then also use errs.ProblemOf(err)
to verify the expected Category and Subtype, and assert the wrapped cause where
one is expected. Update the URL and other validation cases consistently so
regressions in validation classification are caught.

In `@tests/cli_e2e/docs/docs_history_workflow_test.go`:
- Around line 75-87: The polling closures around the history workflow are only
checking process exit code, so API-level failures with a successful exit can
silently retry until timeout. Update the logic in the history-list and
history-revert-status polling paths to inspect the JSON success/status flag (or
use AssertStdoutStatus) immediately after RunCmd returns, and fail fast with the
captured stdout/stderr instead of returning false. Use the existing
Eventually-based checks and the relevant helper symbols in this test flow to
surface the last API error right away rather than waiting for the timeout.

---

Nitpick comments:
In `@tests/cli_e2e/docs/docs_update_dryrun_test.go`:
- Around line 90-122: The dry-run history tests are matching serialized JSON
substrings in stdout/stderr, which makes them brittle to formatting changes.
Update the relevant cases in the CLI e2e test to parse result.Stdout as JSON and
assert the dry-run request fields directly on api[0] (URL, body, and params)
instead of using wantContains substring checks; apply the same change to the
history revert and history revert status cases.
🪄 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

Run ID: 61366e69-fa92-46bf-9f04-bfbc924206b0

📥 Commits

Reviewing files that changed from the base of the PR and between 39d60cb and f8fc948.

📒 Files selected for processing (10)
  • .gitignore
  • shortcuts/doc/docs_history.go
  • shortcuts/doc/docs_history_test.go
  • shortcuts/doc/shortcuts.go
  • shortcuts/register_test.go
  • skills/lark-doc/SKILL.md
  • skills/lark-doc/references/lark-doc-history.md
  • tests/cli_e2e/docs/coverage.md
  • tests/cli_e2e/docs/docs_history_workflow_test.go
  • tests/cli_e2e/docs/docs_update_dryrun_test.go

Comment thread shortcuts/doc/docs_history_test.go Outdated
Comment thread tests/cli_e2e/docs/docs_history_workflow_test.go Outdated
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.67123% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.42%. Comparing base (3595356) to head (7aae6e9).

Files with missing lines Patch % Lines
shortcuts/doc/docs_history.go 91.11% 6 Missing and 6 partials ⚠️
shortcuts/doc/shortcuts.go 45.45% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1612      +/-   ##
==========================================
+ Coverage   74.40%   74.42%   +0.02%     
==========================================
  Files         853      854       +1     
  Lines       88311    88457     +146     
==========================================
+ Hits        65704    65832     +128     
- Misses      17544    17556      +12     
- Partials     5063     5069       +6     

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

@caojie0621 caojie0621 force-pushed the feat/docs_revert branch 2 times, most recently from a5d7a42 to a6faffb Compare July 3, 2026 07:08
Comment thread skills/lark-doc/SKILL.md Outdated
Comment thread skills/lark-doc/SKILL.md Outdated
Comment thread skills/lark-doc/SKILL.md Outdated
@caojie0621 caojie0621 force-pushed the feat/docs_revert branch 2 times, most recently from 8feaca9 to 5a14768 Compare July 3, 2026 07:46
SunPeiYang996
SunPeiYang996 previously approved these changes Jul 3, 2026
Add docs +history-list, +history-revert, and +history-revert-status backed by docs_ai history OpenAPI endpoints.

Document the safe history workflow and extend dry-run/live E2E coverage for the new shortcuts.
@caojie0621 caojie0621 merged commit a1506cd into main Jul 3, 2026
25 checks passed
@caojie0621 caojie0621 deleted the feat/docs_revert branch July 3, 2026 08:21
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 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