Skip to content

Commit d489f79

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
feat(chat): add organization workspace tags and combine file picker
1 parent 7c115a1 commit d489f79

19 files changed

Lines changed: 363 additions & 74 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/home/components/chat-context-kind-registry/chat-context-kind-registry.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Task,
99
TerminalWindow,
1010
Workflow,
11+
Workspaces,
1112
} from '@sim/emcn/icons'
1213
import { AgentSkillsIcon, McpIcon } from '@/components/icons'
1314
import { getDocumentIcon } from '@/components/icons/document-icons'
@@ -54,6 +55,10 @@ function renderIntegrationTile({ context, className }: RenderIconArgs): ReactNod
5455
* without an icon.
5556
*/
5657
export const CHAT_CONTEXT_KIND_REGISTRY: Record<ChatContextKind, ChatContextKindConfig> = {
58+
workspace: {
59+
label: 'Workspace',
60+
renderIcon: ({ className }) => <Workspaces className={className} />,
61+
},
5762
browser_tab: {
5863
label: 'Browser tab',
5964
renderIcon: ({ className }) => <Globe className={className} />,

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ export function useResourceTreeSections({
204204
}
205205

206206
interface ResourceMenuSectionsProps {
207+
flat?: boolean
208+
/** Organization chat combines two selectable resource kinds under Files. */
209+
combineFileFolders?: boolean
207210
/** Foldered families, from {@link useResourceTreeSections}. */
208211
sections: ResourceTreeSection[]
209212
/** Every available family. Foldered ones are taken from `sections` instead. */
@@ -225,16 +228,21 @@ interface ResourceMenuSectionsProps {
225228
* canonical order.
226229
*/
227230
export function ResourceMenuSections({
231+
flat = false,
232+
combineFileFolders = false,
228233
sections,
229234
groups,
230235
onSelect,
231236
subContentClassName,
232237
}: ResourceMenuSectionsProps) {
233238
const sectionByType = new Map(sections.map((section) => [section.type, section]))
239+
const fileFolderItems = groups.find((group) => group.type === 'filefolder')?.items ?? []
234240
const entries = groups
235-
.filter(({ type, items }) =>
236-
FOLDERED_RESOURCE_TYPES.has(type) ? sectionByType.has(type) : items.length > 0
237-
)
241+
.filter(({ type, items }) => {
242+
if (combineFileFolders && type === 'filefolder') return false
243+
if (combineFileFolders && type === 'file') return items.length + fileFolderItems.length > 0
244+
return !flat && FOLDERED_RESOURCE_TYPES.has(type) ? sectionByType.has(type) : items.length > 0
245+
})
238246
.sort(byResourceMenuOrder)
239247

240248
return (
@@ -243,6 +251,13 @@ export function ResourceMenuSections({
243251
const config = getResourceConfig(type)
244252
const Icon = config.icon
245253
const section = sectionByType.get(type)
254+
const rows =
255+
combineFileFolders && type === 'file'
256+
? [
257+
...fileFolderItems.map((item) => ({ type: 'filefolder' as const, item })),
258+
...items.map((item) => ({ type: 'file' as const, item })),
259+
]
260+
: items.map((item) => ({ type, item }))
246261

247262
// The Browser and Terminal launchers are flat rows that open a new page
248263
// or shell. Live pages and shells offered as context are an ordinary
@@ -275,12 +290,12 @@ export function ResourceMenuSections({
275290
onSelect={onSelect}
276291
/>
277292
) : (
278-
items.map((item) => (
293+
rows.map(({ type: itemType, item }) => (
279294
<DropdownMenuItem
280-
key={`${item.workspaceId ?? ''}:${item.id}`}
281-
onClick={() => onSelect(resourceFromItem(type, item))}
295+
key={`${itemType}:${item.workspaceId ?? ''}:${item.id}`}
296+
onClick={() => onSelect(resourceFromItem(itemType, item))}
282297
>
283-
{config.renderDropdownItem({ item })}
298+
{getResourceConfig(itemType).renderDropdownItem({ item })}
284299
{typeof item.workspaceName === 'string' && (
285300
<span className='ml-auto text-[var(--text-muted)] text-xs'>
286301
{item.workspaceName}

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/chip-clipboard-codec.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const CHIP_LINK_SCHEME = 'sim'
2323
* no single portable id (an array / two ids / none) and degrade to plain text.
2424
*/
2525
const PORTABLE_KIND_TO_ID_FIELD = {
26+
workspace: 'workspaceId',
2627
table: 'tableId',
2728
file: 'fileId',
2829
folder: 'folderId',
@@ -235,6 +236,8 @@ export function parseChipLinks(text: string): ParsedChipLink[] {
235236
*/
236237
export function chipLinkToContext(link: ParsedChipLink): ChatContext {
237238
switch (link.kind) {
239+
case 'workspace':
240+
return { kind: 'workspace', workspaceId: link.id, label: link.label }
238241
case 'table':
239242
return { kind: 'table', tableId: link.id, label: link.label }
240243
case 'file':

0 commit comments

Comments
 (0)