Skip to content

Commit 7501ab1

Browse files
committed
Fix fast edit
1 parent d7a1353 commit 7501ab1

File tree

7 files changed

+73
-47
lines changed

7 files changed

+73
-47
lines changed

apps/sim/app/workspace/[workspaceId]/home/components/message-content/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Calendar,
88
ClipboardList,
99
Database,
10+
Eye,
1011
File,
1112
FolderCode,
1213
Hammer,
@@ -59,6 +60,7 @@ const TOOL_ICONS: Record<MothershipToolName | SubagentName | 'mothership', IconC
5960
debug: Bug,
6061
edit: Pencil,
6162
fast_edit: Pencil,
63+
open_resource: Eye,
6264
}
6365

6466
export function getAgentIcon(name: string): IconComponent {

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reportManualRunToolStop,
99
} from '@/lib/copilot/client-sse/run-tool-execution'
1010
import { MOTHERSHIP_CHAT_API_PATH } from '@/lib/copilot/constants'
11-
import { VFS_DIR_TO_RESOURCE } from '@/lib/copilot/resource-types'
1211
import { isWorkflowToolName } from '@/lib/copilot/workflow-tools'
1312
import { getNextWorkflowColor } from '@/lib/workflows/colors'
1413
import { invalidateResourceQueries } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-registry'
@@ -198,36 +197,6 @@ function ensureWorkflowInRegistry(resourceId: string, title: string, workspaceId
198197
return true
199198
}
200199

201-
function extractResourceFromReadResult(
202-
path: string | undefined,
203-
output: unknown
204-
): MothershipResource | null {
205-
if (!path) return null
206-
207-
const segments = path.split('/')
208-
const resourceType = VFS_DIR_TO_RESOURCE[segments[0]]
209-
if (!resourceType || !segments[1]) return null
210-
211-
const obj = output && typeof output === 'object' ? (output as Record<string, unknown>) : undefined
212-
if (!obj) return null
213-
214-
let id = obj.id as string | undefined
215-
let name = obj.name as string | undefined
216-
217-
if (!id && typeof obj.content === 'string') {
218-
try {
219-
const parsed = JSON.parse(obj.content)
220-
id = parsed?.id as string | undefined
221-
name = parsed?.name as string | undefined
222-
} catch {
223-
// content is not JSON
224-
}
225-
}
226-
227-
if (!id) return null
228-
return { type: resourceType, id, title: name || segments[1] }
229-
}
230-
231200
export interface UseChatOptions {
232201
onResourceEvent?: () => void
233202
}
@@ -554,18 +523,6 @@ export function useChat(
554523
error: (parsed.error ?? getPayloadData(parsed)?.error) as string | undefined,
555524
}
556525
flush()
557-
558-
if (tc.name === 'read' && tc.status === 'success') {
559-
const readArgs = toolArgsMap.get(id)
560-
const resource = extractResourceFromReadResult(
561-
readArgs?.path as string | undefined,
562-
tc.result.output
563-
)
564-
if (resource) {
565-
addResource(resource)
566-
onResourceEventRef.current?.()
567-
}
568-
}
569526
}
570527

571528
break

apps/sim/app/workspace/[workspaceId]/home/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export type MothershipToolName =
7373
| 'debug'
7474
| 'edit'
7575
| 'fast_edit'
76+
| 'open_resource'
7677

7778
/**
7879
* Subagent identifiers dispatched via `subagent_start` SSE events.
@@ -95,6 +96,9 @@ export type SubagentName =
9596
| 'debug'
9697
| 'edit'
9798
| 'fast_edit'
99+
| 'run'
100+
| 'agent'
101+
| 'job'
98102

99103
export type ToolPhase =
100104
| 'workspace'
@@ -181,7 +185,10 @@ export const SUBAGENT_LABELS: Record<SubagentName, string> = {
181185
plan: 'Plan agent',
182186
debug: 'Debug agent',
183187
edit: 'Edit agent',
184-
fast_edit: 'Edit agent',
188+
fast_edit: 'Build agent',
189+
run: 'Run agent',
190+
agent: 'Agent manager',
191+
job: 'Job agent',
185192
} as const
186193

187194
export interface ToolUIMetadata {
@@ -227,6 +234,7 @@ export const TOOL_UI_METADATA: Partial<Record<MothershipToolName, ToolUIMetadata
227234
debug: { title: 'Debugging', phaseLabel: 'Debug', phase: 'subagent' },
228235
edit: { title: 'Editing workflow', phaseLabel: 'Edit', phase: 'subagent' },
229236
fast_edit: { title: 'Editing workflow', phaseLabel: 'Edit', phase: 'subagent' },
237+
open_resource: { title: 'Opening resource', phaseLabel: 'Resource', phase: 'resource' },
230238
}
231239

232240
export interface SSEPayloadUI {

apps/sim/lib/copilot/orchestrator/tool-executor/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,30 @@ const SIM_WORKFLOW_TOOL_HANDLERS: Record<
992992
glob: (p, c) => executeVfsGlob(p, c),
993993
read: (p, c) => executeVfsRead(p, c),
994994
list: (p, c) => executeVfsList(p, c),
995+
996+
// Resource visibility
997+
open_resource: async (p) => {
998+
const resourceType = p.type as string | undefined
999+
const resourceId = p.id as string | undefined
1000+
if (!resourceType || !resourceId) {
1001+
return { success: false, error: 'type and id are required' }
1002+
}
1003+
const validTypes = new Set(['workflow', 'table', 'knowledgebase', 'file'])
1004+
if (!validTypes.has(resourceType)) {
1005+
return { success: false, error: `Invalid resource type: ${resourceType}` }
1006+
}
1007+
return {
1008+
success: true,
1009+
output: { message: `Opened ${resourceType} ${resourceId} for the user` },
1010+
resources: [
1011+
{
1012+
type: resourceType as 'workflow' | 'table' | 'knowledgebase' | 'file',
1013+
id: resourceId,
1014+
title: resourceType,
1015+
},
1016+
],
1017+
}
1018+
},
9951019
}
9961020

9971021
/**

apps/sim/lib/copilot/orchestrator/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export interface SSEEvent {
2525
/** Authoritative tool call state set by the Go backend */
2626
state?: string
2727
data?: Record<string, unknown>
28+
/** Parent agent that produced this event */
29+
agent?: string
30+
/** Subagent identifier (e.g. "build", "fast_edit") */
2831
subagent?: string
2932
toolCallId?: string
3033
toolName?: string

apps/sim/lib/copilot/resources.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const RESOURCE_TOOL_NAMES = new Set([
1717
'create_workflow',
1818
'edit_workflow',
1919
'function_execute',
20-
'read',
2120
'knowledge_base',
2221
'knowledge',
2322
])
@@ -92,8 +91,7 @@ export function extractResourcesFromToolResult(
9291
return []
9392
}
9493

95-
case 'function_execute':
96-
case 'read': {
94+
case 'function_execute': {
9795
if (result.tableId) {
9896
return [
9997
{

apps/sim/lib/copilot/tools/client/tool-display-registry.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,18 @@ const META_mark_todo_in_progress: ToolMetadata = {
11851185
},
11861186
}
11871187

1188+
const META_open_resource: ToolMetadata = {
1189+
displayNames: {
1190+
[ClientToolCallState.generating]: { text: 'Opening resource', icon: Eye },
1191+
[ClientToolCallState.pending]: { text: 'Opening resource', icon: Eye },
1192+
[ClientToolCallState.executing]: { text: 'Opening resource', icon: Eye },
1193+
[ClientToolCallState.success]: { text: 'Opened resource', icon: Eye },
1194+
[ClientToolCallState.error]: { text: 'Failed to open resource', icon: XCircle },
1195+
[ClientToolCallState.rejected]: { text: 'Skipped opening resource', icon: XCircle },
1196+
[ClientToolCallState.aborted]: { text: 'Aborted opening resource', icon: XCircle },
1197+
},
1198+
}
1199+
11881200
const META_navigate_ui: ToolMetadata = {
11891201
displayNames: {
11901202
[ClientToolCallState.generating]: {
@@ -2187,6 +2199,26 @@ const META_edit: ToolMetadata = {
21872199
},
21882200
}
21892201

2202+
const META_fast_edit: ToolMetadata = {
2203+
displayNames: {
2204+
[ClientToolCallState.generating]: { text: 'Building', icon: Loader2 },
2205+
[ClientToolCallState.pending]: { text: 'Building', icon: Loader2 },
2206+
[ClientToolCallState.executing]: { text: 'Building', icon: Loader2 },
2207+
[ClientToolCallState.success]: { text: 'Built', icon: Wrench },
2208+
[ClientToolCallState.error]: { text: 'Failed to build', icon: XCircle },
2209+
[ClientToolCallState.rejected]: { text: 'Skipped build', icon: XCircle },
2210+
[ClientToolCallState.aborted]: { text: 'Aborted build', icon: XCircle },
2211+
},
2212+
uiConfig: {
2213+
subagent: {
2214+
streamingLabel: 'Building',
2215+
completedLabel: 'Built',
2216+
shouldCollapse: true,
2217+
outputArtifacts: [],
2218+
},
2219+
},
2220+
}
2221+
21902222
const META_debug: ToolMetadata = {
21912223
displayNames: {
21922224
[ClientToolCallState.generating]: { text: 'Debugging', icon: Loader2 },
@@ -2399,6 +2431,7 @@ const TOOL_METADATA_BY_ID: Record<string, ToolMetadata> = {
23992431
deploy_chat: META_deploy_chat,
24002432
deploy_mcp: META_deploy_mcp,
24012433
edit: META_edit,
2434+
fast_edit: META_fast_edit,
24022435
edit_workflow: META_edit_workflow,
24032436
get_block_outputs: META_get_block_outputs,
24042437
get_block_upstream_references: META_get_block_upstream_references,
@@ -2428,6 +2461,7 @@ const TOOL_METADATA_BY_ID: Record<string, ToolMetadata> = {
24282461
navigate_ui: META_navigate_ui,
24292462
oauth_get_auth_link: META_oauth_get_auth_link,
24302463
oauth_request_access: META_oauth_request_access,
2464+
open_resource: META_open_resource,
24312465
plan: META_plan,
24322466
read: META_read,
24332467
redeploy: META_redeploy,

0 commit comments

Comments
 (0)