Skip to content

Commit 38ee79d

Browse files
waleedlatif1claude
andcommitted
revert: remove inline rename UI from resource tabs
Keep the workspace_file rename tool for the mothership agent. Only the UI-side inline rename (double-click tabs) is removed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 28c8afc commit 38ee79d

File tree

5 files changed

+17
-95
lines changed

5 files changed

+17
-95
lines changed

apps/sim/app/workspace/[workspaceId]/components/inline-rename-input.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
'use client'
22

33
import { useEffect, useRef } from 'react'
4-
import { cn } from '@/lib/core/utils/cn'
54

65
interface InlineRenameInputProps {
76
value: string
87
onChange: (value: string) => void
98
onSubmit: () => void
109
onCancel: () => void
11-
className?: string
1210
}
1311

14-
export function InlineRenameInput({
15-
value,
16-
onChange,
17-
onSubmit,
18-
onCancel,
19-
className,
20-
}: InlineRenameInputProps) {
12+
export function InlineRenameInput({ value, onChange, onSubmit, onCancel }: InlineRenameInputProps) {
2113
const inputRef = useRef<HTMLInputElement>(null)
2214

2315
useEffect(() => {
@@ -40,10 +32,7 @@ export function InlineRenameInput({
4032
}}
4133
onBlur={onSubmit}
4234
onClick={(e) => e.stopPropagation()}
43-
className={cn(
44-
'min-w-0 flex-1 truncate border-0 bg-transparent p-0 font-medium text-[14px] text-[var(--text-body)] outline-none focus:outline-none focus:ring-0',
45-
className
46-
)}
35+
className='min-w-0 flex-1 truncate border-0 bg-transparent p-0 font-medium text-[14px] text-[var(--text-body)] outline-none focus:outline-none focus:ring-0'
4736
/>
4837
)
4938
}

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tabs.tsx

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { BookOpen, PanelLeft, Table as TableIcon } from '@/components/emcn/icons
1212
import { WorkflowIcon } from '@/components/icons'
1313
import { getDocumentIcon } from '@/components/icons/document-icons'
1414
import { cn } from '@/lib/core/utils/cn'
15-
import { InlineRenameInput } from '@/app/workspace/[workspaceId]/components/inline-rename-input'
1615
import type { PreviewMode } from '@/app/workspace/[workspaceId]/files/components/file-viewer'
1716
import type {
1817
MothershipResource,
@@ -48,8 +47,6 @@ function PreviewModeIcon({ mode, ...props }: { mode: PreviewMode } & SVGProps<SV
4847
)
4948
}
5049

51-
const RENAMABLE_TYPES = new Set(['file', 'table'])
52-
5350
interface ResourceTabsProps {
5451
resources: MothershipResource[]
5552
activeId: string | null
@@ -58,12 +55,6 @@ interface ResourceTabsProps {
5855
previewMode?: PreviewMode
5956
onCyclePreviewMode?: () => void
6057
actions?: ReactNode
61-
editingId?: string | null
62-
editValue?: string
63-
onEditValueChange?: (value: string) => void
64-
onStartRename?: (id: string, currentName: string) => void
65-
onSubmitRename?: () => void
66-
onCancelRename?: () => void
6758
}
6859

6960
const RESOURCE_ICONS: Record<Exclude<MothershipResourceType, 'file'>, ElementType> = {
@@ -91,12 +82,6 @@ export function ResourceTabs({
9182
previewMode,
9283
onCyclePreviewMode,
9384
actions,
94-
editingId,
95-
editValue,
96-
onEditValueChange,
97-
onStartRename,
98-
onSubmitRename,
99-
onCancelRename,
10085
}: ResourceTabsProps) {
10186
const scrollRef = useCallback<RefCallback<HTMLDivElement>>((node) => {
10287
if (!node) return
@@ -134,37 +119,20 @@ export function ResourceTabs({
134119
{resources.map((resource) => {
135120
const Icon = getResourceIcon(resource)
136121
const isActive = activeId === resource.id
137-
const isEditing = editingId === resource.id
138-
const isRenamable = RENAMABLE_TYPES.has(resource.type)
139122

140123
return (
141-
<Tooltip.Root key={resource.id} open={isEditing ? false : undefined}>
124+
<Tooltip.Root key={resource.id}>
142125
<Tooltip.Trigger asChild>
143126
<Button
144127
variant='subtle'
145128
onClick={() => onSelect(resource.id)}
146-
onDoubleClick={
147-
isRenamable && onStartRename
148-
? () => onStartRename(resource.id, resource.title)
149-
: undefined
150-
}
151129
className={cn(
152130
'shrink-0 bg-transparent px-[8px] py-[4px] text-[12px]',
153131
isActive && 'bg-[var(--surface-4)]'
154132
)}
155133
>
156134
<Icon className={cn('mr-[6px] h-[14px] w-[14px] text-[var(--text-icon)]')} />
157-
{isEditing && onEditValueChange && onSubmitRename && onCancelRename ? (
158-
<InlineRenameInput
159-
value={editValue ?? ''}
160-
onChange={onEditValueChange}
161-
onSubmit={onSubmitRename}
162-
onCancel={onCancelRename}
163-
className='min-w-[60px] max-w-[160px] text-[12px]'
164-
/>
165-
) : (
166-
resource.title
167-
)}
135+
{resource.title}
168136
</Button>
169137
</Tooltip.Trigger>
170138
<Tooltip.Content side='bottom'>

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/mothership-view.tsx

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
'use client'
22

3-
import { useCallback, useEffect, useRef, useState } from 'react'
3+
import { useCallback, useEffect, useState } from 'react'
44
import { cn } from '@/lib/core/utils/cn'
55
import { getFileExtension } from '@/lib/uploads/utils/file-utils'
66
import type { PreviewMode } from '@/app/workspace/[workspaceId]/files/components/file-viewer'
77
import type { MothershipResource } from '@/app/workspace/[workspaceId]/home/types'
8-
import { useRenameTable } from '@/hooks/queries/tables'
9-
import { useRenameWorkspaceFile } from '@/hooks/queries/workspace-files'
10-
import { useInlineRename } from '@/hooks/use-inline-rename'
118
import {
129
EmbeddedKnowledgeBaseActions,
1310
EmbeddedWorkflowActions,
@@ -29,7 +26,6 @@ interface MothershipViewProps {
2926
resources: MothershipResource[]
3027
activeResourceId: string | null
3128
onSelectResource: (id: string) => void
32-
onRenameResource: (id: string, newTitle: string) => void
3329
onCollapse: () => void
3430
isCollapsed: boolean
3531
className?: string
@@ -45,40 +41,12 @@ export function MothershipView({
4541
resources,
4642
activeResourceId,
4743
onSelectResource,
48-
onRenameResource,
4944
onCollapse,
5045
isCollapsed,
5146
className,
5247
}: MothershipViewProps) {
5348
const active = resources.find((r) => r.id === activeResourceId) ?? resources[0] ?? null
5449

55-
const { mutate: renameFile } = useRenameWorkspaceFile()
56-
const { mutate: renameTable } = useRenameTable(workspaceId)
57-
58-
const resourcesRef = useRef(resources)
59-
useEffect(() => {
60-
resourcesRef.current = resources
61-
}, [resources])
62-
63-
const handleRenameSave = useCallback(
64-
(id: string, newName: string) => {
65-
const resource = resourcesRef.current.find((r) => r.id === id)
66-
if (!resource) return
67-
68-
onRenameResource(id, newName)
69-
70-
if (resource.type === 'file') {
71-
renameFile({ workspaceId, fileId: id, name: newName })
72-
} else if (resource.type === 'table') {
73-
renameTable({ tableId: id, name: newName })
74-
}
75-
},
76-
[onRenameResource, renameFile, renameTable, workspaceId]
77-
)
78-
79-
const { editingId, editValue, setEditValue, startRename, submitRename, cancelRename } =
80-
useInlineRename({ onSave: handleRenameSave })
81-
8250
const [previewMode, setPreviewMode] = useState<PreviewMode>('split')
8351
const handleCyclePreview = useCallback(() => setPreviewMode((m) => PREVIEW_CYCLE[m]), [])
8452

@@ -114,12 +82,6 @@ export function MothershipView({
11482
actions={headerActions}
11583
previewMode={isActivePreviewable ? previewMode : undefined}
11684
onCyclePreviewMode={isActivePreviewable ? handleCyclePreview : undefined}
117-
editingId={editingId}
118-
editValue={editValue}
119-
onEditValueChange={setEditValue}
120-
onStartRename={startRename}
121-
onSubmitRename={submitRename}
122-
onCancelRename={cancelRename}
12385
/>
12486
<div className='min-h-0 flex-1 overflow-hidden'>
12587
{active && (

apps/sim/app/workspace/[workspaceId]/home/home.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ export function Home({ chatId }: HomeProps = {}) {
169169
resources,
170170
activeResourceId,
171171
setActiveResourceId,
172-
renameResource,
173172
} = useChat(workspaceId, chatId)
174173

175174
const [isResourceCollapsed, setIsResourceCollapsed] = useState(false)
@@ -347,7 +346,6 @@ export function Home({ chatId }: HomeProps = {}) {
347346
resources={resources}
348347
activeResourceId={activeResourceId}
349348
onSelectResource={setActiveResourceId}
350-
onRenameResource={renameResource}
351349
onCollapse={collapseResource}
352350
isCollapsed={isResourceCollapsed}
353351
className={animateResourcePanel ? 'animate-slide-in-right' : undefined}

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
extractFileResource,
3232
extractFunctionExecuteResource,
3333
extractKnowledgeBaseResource,
34+
extractKnowledgeRespondResources,
3435
extractResourcesFromHistory,
3536
extractTableResource,
3637
extractWorkflowResource,
@@ -47,7 +48,6 @@ export interface UseChatReturn {
4748
resources: MothershipResource[]
4849
activeResourceId: string | null
4950
setActiveResourceId: (id: string | null) => void
50-
renameResource: (id: string, newTitle: string) => void
5151
}
5252

5353
const STATE_TO_STATUS: Record<string, ToolCallStatus> = {
@@ -164,10 +164,6 @@ export function useChat(workspaceId: string, initialChatId?: string): UseChatRet
164164

165165
const { data: chatHistory } = useChatHistory(initialChatId)
166166

167-
const renameResource = useCallback((id: string, newTitle: string) => {
168-
setResources((prev) => prev.map((r) => (r.id === id ? { ...r, title: newTitle } : r)))
169-
}, [])
170-
171167
const addResource = useCallback((resource: MothershipResource) => {
172168
setResources((prev) => {
173169
const existing = prev.find((r) => r.type === resource.type && r.id === resource.id)
@@ -476,7 +472,7 @@ export function useChat(workspaceId: string, initialChatId?: string): UseChatRet
476472
registry.loadWorkflowState(resource.id)
477473
}
478474
}
479-
} else if (toolName === 'knowledge') {
475+
} else if (toolName === 'knowledge_base') {
480476
resource = extractKnowledgeBaseResource(parsed, storedArgs)
481477
if (resource) {
482478
queryClient.invalidateQueries({
@@ -486,6 +482,16 @@ export function useChat(workspaceId: string, initialChatId?: string): UseChatRet
486482
queryKey: knowledgeKeys.list(workspaceId),
487483
})
488484
}
485+
} else if (toolName === 'knowledge') {
486+
const kbResources = extractKnowledgeRespondResources(parsed)
487+
for (const r of kbResources) {
488+
addResource(r)
489+
}
490+
if (kbResources.length > 0) {
491+
queryClient.invalidateQueries({
492+
queryKey: knowledgeKeys.list(workspaceId),
493+
})
494+
}
489495
}
490496

491497
if (resource) addResource(resource)
@@ -741,6 +747,5 @@ export function useChat(workspaceId: string, initialChatId?: string): UseChatRet
741747
resources,
742748
activeResourceId,
743749
setActiveResourceId,
744-
renameResource,
745750
}
746751
}

0 commit comments

Comments
 (0)