feat: add docs history shortcuts#1612
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds 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. ChangesDoc history CLI
API test harness
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
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@7aae6e91844b6423ce99db65988682e2f3c93d45🧩 Skill updatenpx skills add larksuite/cli#feat/docs_revert -y -g |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
6982572 to
f8fc948
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/cli_e2e/docs/docs_update_dryrun_test.go (1)
90-122: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winParse the dry-run JSON instead of matching formatted fragments.
The new history assertions depend on exact serialization details like
"page_size": 5and"task_id": "task_1". A whitespace or pretty-print change will fail this test even if the request shape is still correct. Parseresult.Stdoutand assert the dry-runapi[0]URL/body/params fields directly instead of searchingstdout+stderrfor 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
📒 Files selected for processing (10)
.gitignoreshortcuts/doc/docs_history.goshortcuts/doc/docs_history_test.goshortcuts/doc/shortcuts.goshortcuts/register_test.goskills/lark-doc/SKILL.mdskills/lark-doc/references/lark-doc-history.mdtests/cli_e2e/docs/coverage.mdtests/cli_e2e/docs/docs_history_workflow_test.gotests/cli_e2e/docs/docs_update_dryrun_test.go
f8fc948 to
78a2d43
Compare
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
a5d7a42 to
a6faffb
Compare
8feaca9 to
5a14768
Compare
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.
5a14768 to
7aae6e9
Compare
Summary
Add
docshistory shortcuts so users and agents can list Docx history versions, revert to a selectedhistory_version_id, and poll revert task status through structured CLI flows.Changes
docs +history-list,docs +history-revert, anddocs +history-revert-statusshortcuts backed by Docs AI history APIs.history_version_id, wait timeout, and task ID with typederrs.*validation errors.lark-docskill documentation and coverage notes with the history workflow andrevision_idtohistory_version_idguidance.Test Plan
make unit-testRelated Issues
Summary by CodeRabbit