Skip to content

Add +dashboard-arrange command for auto-arranging dashboard blocks …#388

Merged
zhouyue-bytedance merged 1 commit intomainfrom
base_dashboard
Apr 10, 2026
Merged

Add +dashboard-arrange command for auto-arranging dashboard blocks …#388
zhouyue-bytedance merged 1 commit intomainfrom
base_dashboard

Conversation

@huangxincola
Copy link
Copy Markdown
Collaborator

@huangxincola huangxincola commented Apr 10, 2026

…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
  • Unit tests pass (go test ./shortcuts/base/...)
  • All dashboard-related tests pass including new TestBaseDashboardExecuteArrange
  • Text block type validation tests pass
  • None

Summary

Changes

  • Change 1
  • Change 2

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark xxx command works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added +dashboard-arrange command for automatic dashboard block layout arrangement using server-side recommendations with adaptive positioning
    • Introduced text block type for creating Markdown-formatted rich text blocks supporting headings, formatting, and lists
  • Documentation

    • Updated documentation to cover the new dashboard arrange command with usage examples and parameters
    • Added reference documentation for text block type configuration and supported Markdown syntax

…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
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new +dashboard-arrange command for server-side auto-arrangement of dashboard block layouts, adds text-type dashboard blocks supporting Markdown, refactors validation logic to handle text versus chart types distinctly, and expands helper functions for dashboard operations. Tests and comprehensive documentation are included.

Changes

Cohort / File(s) Summary
Dashboard Arrange Command
shortcuts/base/dashboard_arrange.go, shortcuts/base/shortcuts.go
New shortcut definition for +dashboard-arrange command with base:dashboard:update scope, optional --user-id-type flag, and wiring into the shortcuts registry.
Helper Functions & Operations
shortcuts/base/dashboard_ops.go, shortcuts/base/helpers.go
Added 25+ helper and execute functions for dashboard/block CRUD and arrange operations; extended text-type validation in validateBlockDataConfig to check required text field and skip chart-specific validations.
Block Type Support
shortcuts/base/dashboard_block_create.go, shortcuts/base/dashboard_block_update.go
Added text type support and validation in create; refactored update to remove local strong-type validation and delegate to backend.
Test Coverage
shortcuts/base/base_dashboard_execute_test.go, shortcuts/base/base_shortcuts_test.go
Added four new test functions covering text-type block creation/update, arrange execution, and dry-run; updated shortcut catalog expectations.
Documentation Updates
skills/lark-base/SKILL.md, skills/lark-base/references/dashboard-block-data-config.md, skills/lark-base/references/lark-base-dashboard-arrange.md, skills/lark-base/references/lark-base-dashboard-block-create.md, skills/lark-base/references/lark-base-dashboard.md
Documented text component type (Markdown support), new arrange command with usage guidelines and examples, parameter tables, and updated command indices.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Suggested labels

domain/base, size/M

Suggested reviewers

  • zhouyue-bytedance
  • kongenpei

Poem

🐰 A text block blooms, markdown dreams unfold,
Dashboards arrange themselves, smart and bold!
From chaos to order, the layout takes flight,
New commands in place, the vision shines bright! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete and poorly structured. It begins with substantive content but then includes incomplete template sections that were not filled out, making the overall description confusing and unprofessional. Remove or complete the template sections at the end. Move the bulleted list under the 'Changes' section and ensure all template sections are properly filled or removed entirely.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: adding a new +dashboard-arrange command for auto-arranging dashboard blocks and introducing text block type support.
Docstring Coverage ✅ Passed Docstring coverage is 98.21% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch base_dashboard

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added domain/base PR touches the base domain size/M Single-domain feat or fix with limited business impact labels Apr 10, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR adds a +dashboard-arrange command that triggers server-side auto-layout via POST .../dashboards/{id}/arrange, and extends the existing block commands with a new text block type that accepts Markdown content with its own validation path in validateBlockDataConfig. The implementation follows the established pattern of the other dashboard commands, the validation logic is correct, and the test coverage is thorough.

Confidence Score: 5/5

Safe to merge; all findings are minor style improvements with no impact on correctness or runtime behaviour.

Logic is correct across the new arrange command and text block type. Validation, normalization, and flag-overwrite flows all behave as intended. The two findings are P2 style suggestions only.

No files require special attention.

Important Files Changed

Filename Overview
shortcuts/base/dashboard_arrange.go New +dashboard-arrange shortcut definition — clean and consistent with existing dashboard command patterns.
shortcuts/base/dashboard_ops.go Adds dryRunDashboardArrange and executeDashboardArrange; one Chinese-language comment breaks the file's English commenting convention.
shortcuts/base/dashboard_block_create.go Adds text-type support with inline validation; the empty-data-config error for text blocks omits the documentation reference that the formatDataConfigErrors path provides.
shortcuts/base/helpers.go Adds validateBlockDataConfig text-type early-return path and normalizeDataConfig; logic is correct and consistent with existing chart-type validation.
shortcuts/base/base_dashboard_execute_test.go Comprehensive tests covering arrange execution, dry-run, text block create/update, and validation failure cases.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User invokes command] --> B{Command?}

    B -->|dashboard-arrange| C[BaseDashboardArrange]
    C --> D{dry-run?}
    D -->|yes| E[dryRunDashboardArrange\nPOST arrange with empty body]
    D -->|no| F[executeDashboardArrange\nPOST arrange with empty body]
    F --> G[Append arranged=true to response]
    G --> H[runtime.Out]

    B -->|dashboard-block-create| I[BaseDashboardBlockCreate]
    I --> J{no-validate flag?}
    J -->|yes| N[Skip validation]
    J -->|no| K{data-config empty AND type=text?}
    K -->|yes| L[Return error: missing data-config]
    K -->|no| M{data-config provided?}
    M -->|yes| O[parseJSONObject and normalizeDataConfig]
    O --> P[validateBlockDataConfig]
    P --> Q{type=text?}
    Q -->|yes| R[Check cfg.text is non-empty]
    Q -->|no| S[Check table_name, series/count_all, group_by, filter]
    R --> T[Overwrite flag with normalised JSON]
    S --> T
    M -->|no| N
    N --> U[executeDashboardBlockCreate]
    T --> U
Loading

Reviews (1): Last reviewed commit: "Add `+dashboard-arrange` command for aut..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#base_dashboard -y -g

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

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 (2)
shortcuts/base/dashboard_ops.go (1)

353-357: Keep the arrange response under a dashboard envelope.

+dashboard-get/create/update all expose dashboard data under a top-level dashboard key, but arrange currently flattens the API payload and adds arranged beside it. Since this command is new, it would be better to align the output shape now and avoid a one-off contract for automation.

♻️ Suggested shape
  if data == nil {
  	data = map[string]interface{}{}
  }
- data["arranged"] = true
- runtime.Out(data, nil)
+ runtime.Out(map[string]interface{}{
+ 	"dashboard": data,
+ 	"arranged":  true,
+ }, nil)
  return nil
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/base/dashboard_ops.go` around lines 353 - 357, The arrange response
is currently emitting fields flattened with an added arranged flag; wrap the
payload under a top-level "dashboard" envelope instead. Modify the code that
builds the response (the variable named data and the runtime.Out call) to create
an envelope like envelope := map[string]interface{}{"dashboard": dataOrEmpty}
then set envelope["dashboard"].(map[string]interface{})["arranged"] = true and
call runtime.Out(envelope, nil) so arrange matches the same top-level dashboard
shape as get/create/update.
shortcuts/base/base_dashboard_execute_test.go (1)

747-800: Assert the real arrange request body in one execute test.

These cases only lock the URL/query and response shape. If executeDashboardArrange() stops sending the explicit {} body, the execute tests still pass. Adding one request-body assertion here would pin the contract that this endpoint is posted with an empty JSON object.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/base/base_dashboard_execute_test.go` around lines 747 - 800, The
tests for dashboard arrange only validate URL/query and response; update the two
arrange tests (the ones that call newExecuteFactory, reg.Register and
runShortcut with BaseDashboardArrange) to also assert the actual request body
sent by executeDashboardArrange is an empty JSON object (e.g.
map[string]interface{}{}). After calling runShortcut, inspect the registered
mock requests (from the reg returned by newExecuteFactory) or the specific
httpmock.Stub that captured the request and add an assertion that the request
payload equals an empty map, so the test fails if executeDashboardArrange starts
sending a non-empty body.
🤖 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 49-55: Update the "text 类型特殊结构" section to explicitly state that
`count_all` is not supported in addition to `table_name`, `series`, `group_by`,
and `filter`; i.e., change the sentence that lists unsupported data-source
fields to include `count_all`, and mirror the same explicit exclusion in the
other text-block section that documents the `text` component (the similar block
later in the file that lists unsupported fields). Refer to the `text` field and
the unsupported list (`table_name`, `series`, `group_by`, `filter`, `count_all`)
when making the edit so readers won't accidentally copy-paste a data-source
config into text blocks.

In `@skills/lark-base/references/lark-base-dashboard.md`:
- Around line 63-67: The arrange example uses a block-style placeholder
(--dashboard-id blk_xxx) which is misleading; update the lark-cli base
+dashboard-arrange example and any other arrange examples that use
--dashboard-id blk_xxx to use a dashboard-style placeholder (--dashboard-id
dsh_xxx) so the commands target dashboards (e.g., replace instances of
"--dashboard-id blk_xxx" with "--dashboard-id dsh_xxx" in the arrange examples).

---

Nitpick comments:
In `@shortcuts/base/base_dashboard_execute_test.go`:
- Around line 747-800: The tests for dashboard arrange only validate URL/query
and response; update the two arrange tests (the ones that call
newExecuteFactory, reg.Register and runShortcut with BaseDashboardArrange) to
also assert the actual request body sent by executeDashboardArrange is an empty
JSON object (e.g. map[string]interface{}{}). After calling runShortcut, inspect
the registered mock requests (from the reg returned by newExecuteFactory) or the
specific httpmock.Stub that captured the request and add an assertion that the
request payload equals an empty map, so the test fails if
executeDashboardArrange starts sending a non-empty body.

In `@shortcuts/base/dashboard_ops.go`:
- Around line 353-357: The arrange response is currently emitting fields
flattened with an added arranged flag; wrap the payload under a top-level
"dashboard" envelope instead. Modify the code that builds the response (the
variable named data and the runtime.Out call) to create an envelope like
envelope := map[string]interface{}{"dashboard": dataOrEmpty} then set
envelope["dashboard"].(map[string]interface{})["arranged"] = true and call
runtime.Out(envelope, nil) so arrange matches the same top-level dashboard shape
as get/create/update.
🪄 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: 380f79f6-79b8-4d5f-ac79-f746ca742e27

📥 Commits

Reviewing files that changed from the base of the PR and between d30a947 and d2e3889.

📒 Files selected for processing (13)
  • shortcuts/base/base_dashboard_execute_test.go
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/dashboard_arrange.go
  • shortcuts/base/dashboard_block_create.go
  • shortcuts/base/dashboard_block_update.go
  • shortcuts/base/dashboard_ops.go
  • shortcuts/base/helpers.go
  • shortcuts/base/shortcuts.go
  • skills/lark-base/SKILL.md
  • skills/lark-base/references/dashboard-block-data-config.md
  • skills/lark-base/references/lark-base-dashboard-arrange.md
  • skills/lark-base/references/lark-base-dashboard-block-create.md
  • skills/lark-base/references/lark-base-dashboard.md

@zhouyue-bytedance zhouyue-bytedance merged commit e8e0c6f into main Apr 10, 2026
29 checks passed
@zhouyue-bytedance zhouyue-bytedance deleted the base_dashboard branch April 10, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/base PR touches the base domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants