gridstack_compact
Optimize dashboard layouts by compacting grid widgets to reduce empty space and improve visual organization. Choose from multiple compaction methods including move, scale, or combined approaches to create efficient widget arrangements.
Instructions
Compact the grid layout
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| layout | No | Compact layout type | moveScale |
| doSort | No | Sort widgets before compacting |
Implementation Reference
- src/tools/index.ts:936-944 (handler)The primary handler function implementing the gridstack_compact tool. It processes input parameters and generates executable JavaScript code to invoke GridStack's compact method.private async compact(params: CompactParams): Promise<string> { const { layout = "moveScale", doSort = true } = params; return this.utils.generateGridStackCode("compact", { layout, doSort, code: `grid.compact('${layout}', ${doSort});`, }); }
- src/tools/index.ts:283-302 (registration)Tool registration object returned by listTools(), defining the name, description, and input schema for gridstack_compact.{ name: "gridstack_compact", description: "Compact the grid layout", inputSchema: { type: "object", properties: { layout: { type: "string", enum: ["moveScale", "move", "scale", "none", "list"], description: "Compact layout type", default: "moveScale", }, doSort: { type: "boolean", description: "Sort widgets before compacting", default: true, }, }, }, },
- src/tools/index.ts:786-787 (registration)Dispatch logic in the callTool method's switch statement that routes calls to the specific compact handler.case "gridstack_compact": return this.compact(args as CompactParams);
- src/types.ts:220-223 (schema)TypeScript interface defining the input parameters for the gridstack_compact handler.export interface CompactParams { layout?: ColumnOptions; doSort?: boolean; }