Skip to content

Commit 19644f6

Browse files
committed
refactor(plane): name block fields after the tool params they fill
The identifier, url, and title fields were canvas-only ids remapped in the params function, which kept the platform from applying its own precedence (user-configured values over agent values) and from hiding filled params from the agent schema. They now use the tool's param ids with per-operation conditions, and the remaps are gone.
1 parent 1486a7b commit 19644f6

2 files changed

Lines changed: 21 additions & 51 deletions

File tree

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,16 @@ import { PlaneBlock } from '@/blocks/blocks/plane'
77
const params = (input: Record<string, unknown>) => PlaneBlock.tools.config.params?.(input) ?? {}
88

99
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', () => {
10+
it('passes fields named after tool params through unchanged, from the canvas or an agent', () => {
2711
expect(
2812
params({ operation: 'plane_get_work_item_by_identifier', identifier: 'ENG-42' })
2913
).toMatchObject({ identifier: 'ENG-42' })
3014
expect(params({ operation: 'plane_create_project', identifier: 'ENG' })).toMatchObject({
3115
identifier: 'ENG',
3216
})
33-
const link = params({ operation: 'plane_create_link', url: 'https://x.dev', title: 'X' })
34-
expect(link).toMatchObject({ url: 'https://x.dev', title: 'X' })
17+
expect(
18+
params({ operation: 'plane_create_link', url: 'https://x.dev', title: 'X' })
19+
).toMatchObject({ url: 'https://x.dev', title: 'X' })
3520
expect(params({ operation: 'plane_create_label', parentId: 'label-1' })).toMatchObject({
3621
parentId: 'label-1',
3722
})

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

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const PlaneBlock: BlockConfig = {
8080
],
8181
plane_get_work_item: [{ text: 'Read work item', field: 'workItemId', core: true }],
8282
plane_get_work_item_by_identifier: [
83-
{ text: 'Read work item', field: 'workItemIdentifier', core: true },
83+
{ text: 'Read work item', field: 'identifier', core: true },
8484
],
8585
plane_list_work_items: [
8686
{ text: 'List work items in project', field: 'projectId', core: true },
@@ -104,7 +104,7 @@ export const PlaneBlock: BlockConfig = {
104104
plane_update_comment: [{ text: 'Edit comment', field: 'commentId', core: true }],
105105
plane_delete_comment: [{ text: 'Delete comment', field: 'commentId', core: true }],
106106
plane_create_link: [
107-
{ text: 'Link', field: 'linkUrl', core: true },
107+
{ text: 'Link', field: 'url', core: true },
108108
{ text: 'to work item', field: 'workItemId', core: true },
109109
],
110110
plane_list_links: [{ text: 'List links on work item', field: 'workItemId', core: true }],
@@ -127,7 +127,7 @@ export const PlaneBlock: BlockConfig = {
127127
plane_get_project: [{ text: 'Read project', field: 'projectId', core: true }],
128128
plane_create_project: [
129129
{ text: 'Create project', field: 'name', core: true },
130-
{ text: ', with identifier', field: 'projectIdentifier' },
130+
{ text: ', with identifier', field: 'identifier' },
131131
],
132132
plane_list_states: [{ text: 'List states in project', field: 'projectId', core: true }],
133133
plane_list_labels: [{ text: 'List labels in project', field: 'projectId', core: true }],
@@ -230,7 +230,7 @@ export const PlaneBlock: BlockConfig = {
230230
required: { field: 'operation', value: [...WORK_ITEM_SCOPED_OPS] },
231231
},
232232
{
233-
id: 'workItemIdentifier',
233+
id: 'identifier',
234234
title: 'Work Item Identifier',
235235
type: 'short-input',
236236
placeholder: 'e.g., PROJ-123',
@@ -252,7 +252,7 @@ export const PlaneBlock: BlockConfig = {
252252
},
253253
},
254254
{
255-
id: 'projectIdentifier',
255+
id: 'identifier',
256256
title: 'Project Identifier',
257257
type: 'short-input',
258258
placeholder: 'e.g., ENG (work items become ENG-1, ENG-2, ...)',
@@ -425,15 +425,15 @@ export const PlaneBlock: BlockConfig = {
425425
condition: { field: 'operation', value: 'plane_create_comment' },
426426
},
427427
{
428-
id: 'linkUrl',
428+
id: 'url',
429429
title: 'URL',
430430
type: 'short-input',
431431
placeholder: 'https://github.com/org/repo/pull/42',
432432
condition: { field: 'operation', value: 'plane_create_link' },
433433
required: { field: 'operation', value: 'plane_create_link' },
434434
},
435435
{
436-
id: 'linkTitle',
436+
id: 'title',
437437
title: 'Link Title',
438438
type: 'short-input',
439439
placeholder: 'Display title',
@@ -638,10 +638,6 @@ export const PlaneBlock: BlockConfig = {
638638
labelIds,
639639
workItemIds,
640640
clearFields,
641-
workItemIdentifier,
642-
projectIdentifier,
643-
linkUrl,
644-
linkTitle,
645641
...rest
646642
} = params
647643
const result: Record<string, unknown> = { ...rest }
@@ -661,23 +657,10 @@ export const PlaneBlock: BlockConfig = {
661657
const fieldsToClear = parsePlaneIdList(clearFields)
662658
if (fieldsToClear) result.clearFields = fieldsToClear
663659

664-
switch (operation) {
665-
case 'plane_get_work_item_by_identifier':
666-
if (workItemIdentifier !== undefined) result.identifier = workItemIdentifier
667-
break
668-
case 'plane_create_project':
669-
if (projectIdentifier !== undefined) result.identifier = projectIdentifier
670-
break
671-
case 'plane_create_link':
672-
if (linkUrl !== undefined) result.url = linkUrl
673-
if (linkTitle !== undefined) result.title = linkTitle
674-
break
675-
case 'plane_upload_attachment': {
676-
const normalizedFile = normalizeFileInput(file, { single: true })
677-
if (!normalizedFile) throw new Error('A file is required to upload an attachment.')
678-
result.file = normalizedFile
679-
break
680-
}
660+
if (operation === 'plane_upload_attachment') {
661+
const normalizedFile = normalizeFileInput(file, { single: true })
662+
if (!normalizedFile) throw new Error('A file is required to upload an attachment.')
663+
result.file = normalizedFile
681664
}
682665
return result
683666
},
@@ -691,9 +674,11 @@ export const PlaneBlock: BlockConfig = {
691674
baseUrl: { type: 'string', description: 'Self-hosted Plane URL (defaults to Plane Cloud)' },
692675
projectId: { type: 'string', description: 'Project ID' },
693676
workItemId: { type: 'string', description: 'Work item ID' },
694-
workItemIdentifier: { type: 'string', description: 'Work item identifier (e.g., PROJ-123)' },
677+
identifier: {
678+
type: 'string',
679+
description: 'Work item identifier (e.g., PROJ-123) or new project identifier (e.g., ENG)',
680+
},
695681
name: { type: 'string', description: 'Work item, project, or label name' },
696-
projectIdentifier: { type: 'string', description: 'New project identifier (e.g., ENG)' },
697682
description: { type: 'string', description: 'Description (HTML for work items)' },
698683
stateId: { type: 'string', description: 'State ID' },
699684
priority: { type: 'string', description: 'Priority (urgent, high, medium, low, none)' },
@@ -711,8 +696,8 @@ export const PlaneBlock: BlockConfig = {
711696
commentId: { type: 'string', description: 'Comment ID' },
712697
comment: { type: 'string', description: 'Comment body (HTML)' },
713698
access: { type: 'string', description: 'Comment visibility (INTERNAL or EXTERNAL)' },
714-
linkUrl: { type: 'string', description: 'URL to link' },
715-
linkTitle: { type: 'string', description: 'Link title' },
699+
url: { type: 'string', description: 'URL to link' },
700+
title: { type: 'string', description: 'Link title' },
716701
linkId: { type: 'string', description: 'Link ID' },
717702
file: { type: 'json', description: 'File to upload (UserFile or reference)' },
718703
attachmentId: { type: 'string', description: 'Attachment ID' },

0 commit comments

Comments
 (0)