chore(doc): inject docs scene into v2 requests#808
Conversation
|
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 (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughExtract a server-owned "docs scene" string from runtime context and conditionally inject it into fetch, create, and update OpenAPI request bodies; new helpers implement extraction/injection and tests validate trimmed inclusion or omission. ChangesDocs Scene Context Injection
Sequence Diagram(s)sequenceDiagram
participant buildCreateBody
participant buildFetchBody
participant buildUpdateBody
participant injectDocsScene
participant docsSceneFromContext
participant runtimeCtx
participant bodyMap
buildCreateBody->>injectDocsScene: injectDocsScene(runtime, body)
buildFetchBody->>injectDocsScene: injectDocsScene(runtime, body)
buildUpdateBody->>injectDocsScene: injectDocsScene(runtime, body)
injectDocsScene->>docsSceneFromContext: docsSceneFromContext(runtime.Ctx())
docsSceneFromContext->>runtimeCtx: read docsSceneContextKey
runtimeCtx-->>docsSceneFromContext: scene string (maybe empty)
docsSceneFromContext-->>injectDocsScene: trimmed scene
injectDocsScene->>bodyMap: set body["scene"] if non-empty
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
shortcuts/doc/docs_fetch_v2_test.go (1)
61-95: ⚡ Quick winUse the standard unit-test factory pattern here.
The runtime setup helpers on Lines 61-95 should use
cmdutil.TestFactory(t, config)to stay consistent with the repo’s unit-test harness conventions.As per coding guidelines
**/*_test.go: Usecmdutil.TestFactory(t, config)for test factories in unit tests.🤖 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 `@shortcuts/doc/docs_fetch_v2_test.go` around lines 61 - 95, The three test helper functions newFetchBodyTestRuntime, newCreateBodyTestRuntime, and newUpdateBodyTestRuntime must be converted to use the repo test-factory pattern: change their signature to accept *testing.T, build a factory with cmdutil.TestFactory(t, config) (where config sets the command and flags currently created in each helper), and use that factory to produce the RuntimeContext instead of calling common.TestNewRuntimeContextWithCtx; update callers in tests accordingly so they pass t and rely on the factory-created runtime.shortcuts/doc/helpers.go (1)
15-18: ⚡ Quick winUse a typed context key instead of a string constant.
Line 17 defines
docsSceneContextKeyas a plain string, which is non-idiomatic for Go contexts and risks key collisions. Use a private typed constant instead.🔧 Proposed patch
-const docsSceneContextKey = "lark_cli_docs_scene" +type docsSceneContextKeyType string + +const docsSceneContextKey docsSceneContextKeyType = "lark_cli_docs_scene"Also applies to: 73-79
🤖 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 `@shortcuts/doc/helpers.go` around lines 15 - 18, Replace the untyped string context key docsSceneContextKey with a private typed key to avoid collisions: define a new unexported type (e.g., type contextKey string) and a package-level const/var of that type (e.g., var docsSceneContextKey = contextKey("lark_cli_docs_scene")), then update all uses (including the places around the other occurrence at lines ~73-79) to use that typed key when setting/getting values from context; ensure the key remains unexported so only this package can use it.
🤖 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.
Nitpick comments:
In `@shortcuts/doc/docs_fetch_v2_test.go`:
- Around line 61-95: The three test helper functions newFetchBodyTestRuntime,
newCreateBodyTestRuntime, and newUpdateBodyTestRuntime must be converted to use
the repo test-factory pattern: change their signature to accept *testing.T,
build a factory with cmdutil.TestFactory(t, config) (where config sets the
command and flags currently created in each helper), and use that factory to
produce the RuntimeContext instead of calling
common.TestNewRuntimeContextWithCtx; update callers in tests accordingly so they
pass t and rely on the factory-created runtime.
In `@shortcuts/doc/helpers.go`:
- Around line 15-18: Replace the untyped string context key docsSceneContextKey
with a private typed key to avoid collisions: define a new unexported type
(e.g., type contextKey string) and a package-level const/var of that type (e.g.,
var docsSceneContextKey = contextKey("lark_cli_docs_scene")), then update all
uses (including the places around the other occurrence at lines ~73-79) to use
that typed key when setting/getting values from context; ensure the key remains
unexported so only this package can use it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: dd14627f-8975-4741-937e-03fb796fbd43
📒 Files selected for processing (5)
shortcuts/doc/docs_create_v2.goshortcuts/doc/docs_fetch_v2.goshortcuts/doc/docs_fetch_v2_test.goshortcuts/doc/docs_update_v2.goshortcuts/doc/helpers.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #808 +/- ##
==========================================
+ Coverage 65.60% 65.67% +0.06%
==========================================
Files 513 513
Lines 47644 47655 +11
==========================================
+ Hits 31259 31297 +38
+ Misses 13685 13652 -33
- Partials 2700 2706 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@0922bff41a5efdf9c6d95959886640f10cbacd11🧩 Skill updatenpx skills add larksuite/cli#sun/chore -y -g |
Change-Id: I4f23880e24164c8b229a5403942bfa1b7ddb0ce6
Change-Id: I4f23880e24164c8b229a5403942bfa1b7ddb0ce6
Changes
inject docs scene into v2 requests
Summary by CodeRabbit
New Features
Tests