Skip to content

Commit 9dfe1fe

Browse files
committed
fix(plane): keep agent-supplied params when the block remaps fields
The block's params transform assigned undefined for canvas-only field ids, overwriting url, title, identifier, and parentId that an Agent passes under the tool's own param names. Remaps now apply only when the canvas field is set, and work items and labels share one parent ID field.
1 parent 4dee0db commit 9dfe1fe

3 files changed

Lines changed: 69 additions & 22 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @vitest-environment node
3+
*/
4+
import { describe, expect, it } from 'vitest'
5+
import { PlaneBlock } from '@/blocks/blocks/plane'
6+
7+
const params = (input: Record<string, unknown>) => PlaneBlock.tools.config.params?.(input) ?? {}
8+
9+
describe('PlaneBlock params', () => {
10+
it('maps canvas-only field ids onto the tool params they fill', () => {
11+
expect(
12+
params({ operation: 'plane_get_work_item_by_identifier', workItemIdentifier: 'ENG-42' })
13+
).toMatchObject({ identifier: 'ENG-42' })
14+
expect(
15+
params({ operation: 'plane_create_project', name: 'Eng', projectIdentifier: 'ENG' })
16+
).toMatchObject({ identifier: 'ENG' })
17+
expect(
18+
params({
19+
operation: 'plane_create_link',
20+
linkUrl: 'https://github.com/org/repo/pull/1',
21+
linkTitle: 'PR 1',
22+
})
23+
).toMatchObject({ url: 'https://github.com/org/repo/pull/1', title: 'PR 1' })
24+
})
25+
26+
it('keeps values an agent passes under the tool param names', () => {
27+
expect(
28+
params({ operation: 'plane_get_work_item_by_identifier', identifier: 'ENG-42' })
29+
).toMatchObject({ identifier: 'ENG-42' })
30+
expect(params({ operation: 'plane_create_project', identifier: 'ENG' })).toMatchObject({
31+
identifier: 'ENG',
32+
})
33+
const link = params({ operation: 'plane_create_link', url: 'https://x.dev', title: 'X' })
34+
expect(link).toMatchObject({ url: 'https://x.dev', title: 'X' })
35+
expect(params({ operation: 'plane_create_label', parentId: 'label-1' })).toMatchObject({
36+
parentId: 'label-1',
37+
})
38+
})
39+
40+
it('turns comma-separated and array ID lists into arrays and numbers into numbers', () => {
41+
expect(
42+
params({
43+
operation: 'plane_update_work_item',
44+
assigneeIds: 'user-1, user-2',
45+
labelIds: ['label-1'],
46+
perPage: '25',
47+
})
48+
).toMatchObject({ assigneeIds: ['user-1', 'user-2'], labelIds: ['label-1'], perPage: 25 })
49+
expect(
50+
params({ operation: 'plane_add_work_items_to_cycle', workItemIds: '["a","b"]' })
51+
).toMatchObject({ workItemIds: ['a', 'b'] })
52+
})
53+
54+
it('requires a file for uploads', () => {
55+
expect(() => params({ operation: 'plane_upload_attachment' })).toThrow(
56+
'A file is required to upload an attachment.'
57+
)
58+
})
59+
})

‎apps/sim/blocks/blocks/plane.ts‎

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ export const PlaneBlock: BlockConfig = {
324324
},
325325
{
326326
id: 'parentId',
327-
title: 'Parent Work Item ID',
327+
title: 'Parent ID',
328328
type: 'short-input',
329-
placeholder: 'Parent work item UUID',
329+
placeholder: 'Parent work item UUID (or parent label UUID when creating a label)',
330330
mode: 'advanced',
331-
condition: { field: 'operation', value: [...WORK_ITEM_WRITE_OPS] },
331+
condition: { field: 'operation', value: [...WORK_ITEM_WRITE_OPS, 'plane_create_label'] },
332332
},
333333
{
334334
id: 'estimatePointId',
@@ -495,14 +495,6 @@ export const PlaneBlock: BlockConfig = {
495495
placeholder: 'Hex color, e.g., #EF4444',
496496
condition: { field: 'operation', value: 'plane_create_label' },
497497
},
498-
{
499-
id: 'labelParentId',
500-
title: 'Parent Label ID',
501-
type: 'short-input',
502-
placeholder: 'Parent label UUID',
503-
mode: 'advanced',
504-
condition: { field: 'operation', value: 'plane_create_label' },
505-
},
506498
{
507499
id: 'cycleView',
508500
title: 'Cycles to Show',
@@ -631,7 +623,6 @@ export const PlaneBlock: BlockConfig = {
631623
projectIdentifier,
632624
linkUrl,
633625
linkTitle,
634-
labelParentId,
635626
...rest
636627
} = params
637628
const result: Record<string, unknown> = { ...rest }
@@ -651,17 +642,14 @@ export const PlaneBlock: BlockConfig = {
651642

652643
switch (operation) {
653644
case 'plane_get_work_item_by_identifier':
654-
result.identifier = workItemIdentifier
645+
if (workItemIdentifier !== undefined) result.identifier = workItemIdentifier
655646
break
656647
case 'plane_create_project':
657-
result.identifier = projectIdentifier
648+
if (projectIdentifier !== undefined) result.identifier = projectIdentifier
658649
break
659650
case 'plane_create_link':
660-
result.url = linkUrl
661-
result.title = linkTitle
662-
break
663-
case 'plane_create_label':
664-
result.parentId = labelParentId
651+
if (linkUrl !== undefined) result.url = linkUrl
652+
if (linkTitle !== undefined) result.title = linkTitle
665653
break
666654
case 'plane_upload_attachment': {
667655
const normalizedFile = normalizeFileInput(file, { single: true })
@@ -692,7 +680,7 @@ export const PlaneBlock: BlockConfig = {
692680
labelIds: { type: 'string', description: 'Comma-separated label IDs' },
693681
startDate: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
694682
targetDate: { type: 'string', description: 'Target date (YYYY-MM-DD)' },
695-
parentId: { type: 'string', description: 'Parent work item ID' },
683+
parentId: { type: 'string', description: 'Parent work item ID, or parent label ID for labels' },
696684
estimatePointId: { type: 'string', description: 'Estimate point ID' },
697685
typeId: { type: 'string', description: 'Work item type ID' },
698686
externalSource: { type: 'string', description: 'External system name' },
@@ -711,7 +699,6 @@ export const PlaneBlock: BlockConfig = {
711699
defaultAssigneeId: { type: 'string', description: 'Default assignee user ID' },
712700
timezone: { type: 'string', description: 'Project timezone' },
713701
color: { type: 'string', description: 'Label color (hex)' },
714-
labelParentId: { type: 'string', description: 'Parent label ID' },
715702
cycleView: { type: 'string', description: 'Which cycles to list' },
716703
cycleId: { type: 'string', description: 'Cycle ID' },
717704
moduleId: { type: 'string', description: 'Module ID' },

‎apps/sim/lib/workflows/subblocks/display.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ const isUploadedFileRecord = (value: unknown): value is { name: string } =>
172172
typeof value.name === 'string' &&
173173
value.name.trim() !== '' &&
174174
typeof value.path === 'string' &&
175-
typeof value.size === 'number'
175+
typeof value.size === 'number' &&
176+
typeof value.type === 'string'
176177

177178
/**
178179
* Attempts to parse a JSON string, returning the parsed value or the

0 commit comments

Comments
 (0)