feat(base): add dashboard-arrange command and text block type support#341
feat(base): add dashboard-arrange command and text block type support#341zhouyue-bytedance merged 1 commit intomainfrom
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:
📝 Walkthrough📝 WalkthroughWalkthroughAdds a new Changes
Sequence DiagramsequenceDiagram
participant User
participant CLI as "CLI Handler"
participant API as "Base API v3"
participant Backend
User->>CLI: run `lark-cli base +dashboard-arrange --base-token --dashboard-id [--user-id-type]`
CLI->>CLI: parse flags, include user_id_type if provided
CLI->>API: POST /open-apis/base/v3/bases/:base_token/dashboards/:dashboard_id/arrange
API->>Backend: forward arrange request
Backend->>Backend: compute auto-layout
Backend->>API: return arranged dashboard JSON (includes arranged: true)
API->>CLI: relay response
CLI->>User: print arranged dashboard JSON with dashboard_id and blocks[].layout
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR adds a Confidence Score: 5/5Safe to merge — both previously flagged issues are resolved and no new P0/P1 issues found Both prior review concerns (nil-map panic in executeDashboardArrange and missing POST body in dryRunDashboardArrange) have been addressed. The text block validation logic is correct, the arrange command wiring is complete, test coverage includes execute, dry-run, and validation failure paths, and the shortcuts catalog test is updated. No new defects identified. No files require special attention Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as CLI (+dashboard-arrange)
participant DryRun as DryRun()
participant Execute as Execute()
participant API as Lark API
alt --dry-run
CLI->>DryRun: dryRunDashboardArrange()
DryRun-->>CLI: POST /arrange params={user_id_type} body={}
else execute
CLI->>Execute: executeDashboardArrange()
Execute->>API: POST /open-apis/base/v3/bases/{token}/dashboards/{id}/arrange
API-->>Execute: {data: {dashboard_id, blocks, ...}} or null
Execute->>Execute: if data==nil then data={}
Execute->>Execute: data[arranged]=true
Execute-->>CLI: Out(data)
end
participant CLI2 as CLI (+dashboard-block-create type=text)
CLI2->>CLI2: Validate()
alt data-config empty AND type==text
CLI2-->>CLI2: error: text requires data-config
else data-config provided
CLI2->>CLI2: validateBlockDataConfig(text, cfg)
alt cfg.text blank
CLI2-->>CLI2: error: text field required
else valid
CLI2->>API: POST /blocks {type:text, data_config:{text:...}}
API-->>CLI2: {block_id, ...}
end
end
Reviews (10): Last reviewed commit: "Add `+dashboard-arrange` command for aut..." | Re-trigger Greptile |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@d2e38891df43155a5a7a7b4ece927429c9c3c7b8🧩 Skill updatenpx skills add larksuite/cli#base_dashboard -y -g |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
skills/lark-base/references/lark-base-dashboard-arrange.md (1)
44-74: Minor inconsistency in example ID prefixes.The command example on line 25 uses
--dashboard-id dsh_xxx, but the response example on line 46 shows"dashboard_id": "blk5jMdgj9yxxxx"with ablkprefix. Consider aligning the prefixes for consistency (either bothdsh_or bothblk).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/lark-base/references/lark-base-dashboard-arrange.md` around lines 44 - 74, The JSON response example uses a different ID prefix than the command example: update either the CLI example flag value (--dashboard-id dsh_xxx) or the JSON "dashboard_id" value ("blk5jMdgj9yxxxx") so both use the same prefix; locate the examples referencing --dashboard-id and the JSON object containing "dashboard_id" and make their sample IDs consistent (e.g., change "blk5jMdgj9yxxxx" to "dsh_..." or change the CLI example to use a blk_ id) so the two examples match.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/base/base_dashboard_execute_test.go`:
- Around line 658-676: The test "text block with extra fields allowed" uses a
data-config containing a series field which conflicts with the updated contract
that text blocks must not include data-source fields; update the test's args
(the --data-config JSON) to remove "series" and only include allowed text fields
(e.g., "text"), and update the validator used when creating blocks (e.g., the
code path in CreateDashboardBlock/ValidateBlockData or the CLI handler that
interprets "--data-config") to reject data-source fields for type "text" (or,
alternatively, if you intend to keep supporting series for text, update the
validator and docs to permit series—pick one behavior and make the test,
validator (ValidateBlockData/CreateDashboardBlock), and docs consistent).
- Around line 612-803: The test helper newExecuteFactory currently calls
cmdutil.TestFactory(t, config) but lacks config isolation; update
newExecuteFactory to call t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())
before creating the factory so tests do not read/write machine-local cache; keep
the t.Setenv invocation immediately prior to the cmdutil.TestFactory(t, config)
call to ensure isolation.
In `@shortcuts/base/dashboard_ops.go`:
- Around line 317-329: In executeDashboardArrange, guard against data being nil
after the baseV3Call call: check if data == nil and if so initialize it to an
empty map[string]interface{} (or handle the nil by creating a map and setting
arranged), then set data["arranged"] = true and call runtime.Out as before;
update the code around the baseV3Call result handling to avoid a potential panic
when writing to the nil map returned by baseV3Call.
---
Nitpick comments:
In `@skills/lark-base/references/lark-base-dashboard-arrange.md`:
- Around line 44-74: The JSON response example uses a different ID prefix than
the command example: update either the CLI example flag value (--dashboard-id
dsh_xxx) or the JSON "dashboard_id" value ("blk5jMdgj9yxxxx") so both use the
same prefix; locate the examples referencing --dashboard-id and the JSON object
containing "dashboard_id" and make their sample IDs consistent (e.g., change
"blk5jMdgj9yxxxx" to "dsh_..." or change the CLI example to use a blk_ id) so
the two examples match.
🪄 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: 983099ca-5849-4060-987c-7416fd3b0a25
📒 Files selected for processing (13)
shortcuts/base/base_dashboard_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/dashboard_arrange.goshortcuts/base/dashboard_block_create.goshortcuts/base/dashboard_block_update.goshortcuts/base/dashboard_ops.goshortcuts/base/helpers.goshortcuts/base/shortcuts.goskills/lark-base/SKILL.mdskills/lark-base/references/dashboard-block-data-config.mdskills/lark-base/references/lark-base-dashboard-arrange.mdskills/lark-base/references/lark-base-dashboard-block-create.mdskills/lark-base/references/lark-base-dashboard.md
aae4bd6 to
b72259e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@skills/lark-base/references/lark-base-dashboard.md`:
- Line 21: The command index references a new entry `+dashboard-arrange` but the
detailed "命令详细文档" table is missing its corresponding row; add a matching
detailed entry for `+dashboard-arrange` in the command details section that
links to lark-base-dashboard-arrange.md, mirror the format used by other
commands in that table, include the command name (`+dashboard-arrange`), a brief
Chinese description, and the file link so navigation is consistent.
🪄 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: af78756d-7a2e-410f-ad87-875f04de2f40
📒 Files selected for processing (13)
shortcuts/base/base_dashboard_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/dashboard_arrange.goshortcuts/base/dashboard_block_create.goshortcuts/base/dashboard_block_update.goshortcuts/base/dashboard_ops.goshortcuts/base/helpers.goshortcuts/base/shortcuts.goskills/lark-base/SKILL.mdskills/lark-base/references/dashboard-block-data-config.mdskills/lark-base/references/lark-base-dashboard-arrange.mdskills/lark-base/references/lark-base-dashboard-block-create.mdskills/lark-base/references/lark-base-dashboard.md
✅ Files skipped from review due to trivial changes (6)
- shortcuts/base/dashboard_block_create.go
- shortcuts/base/shortcuts.go
- skills/lark-base/SKILL.md
- shortcuts/base/helpers.go
- skills/lark-base/references/lark-base-dashboard-arrange.md
- shortcuts/base/dashboard_arrange.go
🚧 Files skipped from review as they are similar to previous changes (6)
- shortcuts/base/base_shortcuts_test.go
- skills/lark-base/references/lark-base-dashboard-block-create.md
- shortcuts/base/dashboard_block_update.go
- shortcuts/base/dashboard_ops.go
- skills/lark-base/references/dashboard-block-data-config.md
- shortcuts/base/base_dashboard_execute_test.go
|
Tip: Greploops — Automatically fix all review issues by running Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal. |
6797836 to
7c66b9a
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
skills/lark-base/references/lark-base-dashboard.md (1)
228-239:⚠️ Potential issue | 🟡 Minor命令详细文档表缺少
+dashboard-arrange条目。Line 21 的能力速览表已包含
+dashboard-arrange,但此处的命令详细文档表未列出该命令。建议补充以保持文档导航一致性。| `+dashboard-block-update` | 更新组件 | [lark-base-dashboard-block-update.md](lark-base-dashboard-block-update.md) | | `+dashboard-block-delete` | 删除组件 | [lark-base-dashboard-block-delete.md](lark-base-dashboard-block-delete.md) | +| `+dashboard-arrange` | 智能重排布局 | [lark-base-dashboard-arrange.md](lark-base-dashboard-arrange.md) |🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/lark-base/references/lark-base-dashboard.md` around lines 228 - 239, Add the missing CLI entry for +dashboard-arrange to the detailed command table: update the table rows that list commands (the block containing `+dashboard-list`, `+dashboard-get`, etc.) to include a new row for `+dashboard-arrange` with a short Chinese description (e.g., "调整仪表盘布局" or similar) and a link to its detailed doc file (e.g., lark-base-dashboard-arrange.md), ensuring the table now matches the abilities overview that already lists `+dashboard-arrange`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@skills/lark-base/references/lark-base-dashboard.md`:
- Around line 228-239: Add the missing CLI entry for +dashboard-arrange to the
detailed command table: update the table rows that list commands (the block
containing `+dashboard-list`, `+dashboard-get`, etc.) to include a new row for
`+dashboard-arrange` with a short Chinese description (e.g., "调整仪表盘布局" or
similar) and a link to its detailed doc file (e.g.,
lark-base-dashboard-arrange.md), ensuring the table now matches the abilities
overview that already lists `+dashboard-arrange`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 626bc543-f6f6-48d5-9122-bd1825c6f95d
📒 Files selected for processing (13)
shortcuts/base/base_dashboard_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/dashboard_arrange.goshortcuts/base/dashboard_block_create.goshortcuts/base/dashboard_block_update.goshortcuts/base/dashboard_ops.goshortcuts/base/helpers.goshortcuts/base/shortcuts.goskills/lark-base/SKILL.mdskills/lark-base/references/dashboard-block-data-config.mdskills/lark-base/references/lark-base-dashboard-arrange.mdskills/lark-base/references/lark-base-dashboard-block-create.mdskills/lark-base/references/lark-base-dashboard.md
✅ Files skipped from review due to trivial changes (9)
- shortcuts/base/dashboard_block_create.go
- shortcuts/base/base_shortcuts_test.go
- shortcuts/base/shortcuts.go
- skills/lark-base/references/lark-base-dashboard-block-create.md
- shortcuts/base/helpers.go
- shortcuts/base/base_dashboard_execute_test.go
- skills/lark-base/SKILL.md
- skills/lark-base/references/lark-base-dashboard-arrange.md
- shortcuts/base/dashboard_arrange.go
🚧 Files skipped from review as they are similar to previous changes (2)
- shortcuts/base/dashboard_block_update.go
- skills/lark-base/references/dashboard-block-data-config.md
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@skills/lark-base/references/dashboard-block-data-config.md`:
- Around line 51-52: The doc incorrectly implies the CLI rejects fields like
series/count_all/group_by/filter for `type=text`; instead, clarify that the
limitation is a backend constraint and that `validateBlockDataConfig` only
checks for `type === 'text'` and returns early (so local CLI validation does not
actively reject those fields). Update the text in dashboard-block-data-config.md
wherever it states “不需要数据源配置” or “不支持字段” (lines referenced) to explicitly say
the backend ignores/does not use `table_name`, `series`, `group_by`, `filter`
for `type=text` and that `validateBlockDataConfig` merely bypasses further
validation for text blocks rather than actively forbidding those fields.
🪄 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: dc04faa5-43c1-443d-9f53-21ad94646494
📒 Files selected for processing (13)
shortcuts/base/base_dashboard_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/dashboard_arrange.goshortcuts/base/dashboard_block_create.goshortcuts/base/dashboard_block_update.goshortcuts/base/dashboard_ops.goshortcuts/base/helpers.goshortcuts/base/shortcuts.goskills/lark-base/SKILL.mdskills/lark-base/references/dashboard-block-data-config.mdskills/lark-base/references/lark-base-dashboard-arrange.mdskills/lark-base/references/lark-base-dashboard-block-create.mdskills/lark-base/references/lark-base-dashboard.md
✅ Files skipped from review due to trivial changes (6)
- skills/lark-base/SKILL.md
- shortcuts/base/dashboard_block_create.go
- shortcuts/base/shortcuts.go
- skills/lark-base/references/lark-base-dashboard-arrange.md
- shortcuts/base/dashboard_arrange.go
- shortcuts/base/dashboard_ops.go
🚧 Files skipped from review as they are similar to previous changes (6)
- shortcuts/base/base_shortcuts_test.go
- skills/lark-base/references/lark-base-dashboard-block-create.md
- shortcuts/base/dashboard_block_update.go
- shortcuts/base/helpers.go
- shortcuts/base/base_dashboard_execute_test.go
- skills/lark-base/references/lark-base-dashboard.md
7cd2f35 to
0beb162
Compare
|
Note Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it. Generating unit tests... This may take up to 20 minutes. |
|
✅ Created PR with unit tests: #351 |
5e3b34b to
3a57b79
Compare
…layout and introduce `text` block type with Markdown support for dashboard visualization.
- Add `+dashboard-arrange` command that triggers server-side smart layout optimization via POST /open-apis/base/v3/bases/{token}/dashboards/{id}/arrange
- Add `text` block type support for dashboard blocks with Markdown syntax (headers, bold, italic, strikethrough, lists)
- Update `validateBlockDataConfig()` to handle text-specific validation rules
- Update documentation (SKILL.md, lark-base-dashboard.md, dashboard-block-data-config.md, lark-base-dashboard-arrange.md)
- Add comprehensive unit tests for new commands and block type
- [x] Unit tests pass (`go test ./shortcuts/base/...`)
- [x] All dashboard-related tests pass including new `TestBaseDashboardExecuteArrange`
- [x] Text block type validation tests pass
- None
3a57b79 to
d2e3889
Compare
Summary
Add
+dashboard-arrangecommand for auto-arranging dashboard blocks layout and introducetextblock type with Markdown support for dashboard visualization.Changes
+dashboard-arrangecommand that triggers server-side smart layout optimization via POST /open-apis/base/v3/bases/{token}/dashboards/{id}/arrangetextblock type support for dashboard blocks with Markdown syntax (headers, bold, italic, strikethrough, lists)validateBlockDataConfig()to handle text-specific validation rulesTest Plan
go test ./shortcuts/base/...)TestBaseDashboardExecuteArrangeRelated Issues
Summary by CodeRabbit
New Features
Behavior Changes
Tests
Documentation