-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Feat/at reference #3560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,222
−47
Merged
Feat/at reference #3560
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/context-pills.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| 'use client' | ||
|
|
||
| import { X } from 'lucide-react' | ||
| import { Badge } from '@/components/emcn' | ||
| import { Database, File as FileIcon, Table as TableIcon } from '@/components/emcn/icons' | ||
| import { WorkflowIcon } from '@/components/icons' | ||
| import { cn } from '@/lib/core/utils/cn' | ||
| import type { ChatContext } from '@/stores/panel' | ||
| import { useWorkflowRegistry } from '@/stores/workflows/registry/store' | ||
|
|
||
| interface ContextPillsProps { | ||
| contexts: ChatContext[] | ||
| onRemoveContext: (context: ChatContext) => void | ||
| } | ||
|
|
||
| function WorkflowPillIcon({ workflowId, className }: { workflowId: string; className?: string }) { | ||
| const color = useWorkflowRegistry((state) => state.workflows[workflowId]?.color ?? '#888') | ||
| return ( | ||
| <div | ||
| className={cn('flex-shrink-0 rounded-[3px] border-[2px]', className)} | ||
| style={{ | ||
| backgroundColor: color, | ||
| borderColor: `${color}60`, | ||
| backgroundClip: 'padding-box', | ||
| }} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| function getContextIcon(ctx: ChatContext) { | ||
| switch (ctx.kind) { | ||
| case 'workflow': | ||
| case 'current_workflow': | ||
| return ( | ||
| <WorkflowPillIcon | ||
| workflowId={ctx.workflowId} | ||
| className='mr-[4px] h-[10px] w-[10px]' | ||
| /> | ||
| ) | ||
| case 'workflow_block': | ||
| return ( | ||
| <WorkflowPillIcon | ||
| workflowId={ctx.workflowId} | ||
| className='mr-[4px] h-[10px] w-[10px]' | ||
| /> | ||
| ) | ||
| case 'knowledge': | ||
| return <Database className='mr-[4px] h-[10px] w-[10px] text-[var(--text-icon)]' /> | ||
| case 'templates': | ||
| return <WorkflowIcon className='mr-[4px] h-[10px] w-[10px] text-[var(--text-icon)]' /> | ||
| case 'past_chat': | ||
| return null | ||
| case 'logs': | ||
| return <FileIcon className='mr-[4px] h-[10px] w-[10px] text-[var(--text-icon)]' /> | ||
| case 'blocks': | ||
| return <TableIcon className='mr-[4px] h-[10px] w-[10px] text-[var(--text-icon)]' /> | ||
| case 'table': | ||
| return <TableIcon className='mr-[4px] h-[10px] w-[10px] text-[var(--text-icon)]' /> | ||
| case 'file': | ||
| return <FileIcon className='mr-[4px] h-[10px] w-[10px] text-[var(--text-icon)]' /> | ||
| case 'docs': | ||
| return <FileIcon className='mr-[4px] h-[10px] w-[10px] text-[var(--text-icon)]' /> | ||
| default: | ||
| return null | ||
| } | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export function ContextPills({ contexts, onRemoveContext }: ContextPillsProps) { | ||
| const visibleContexts = contexts.filter((c) => c.kind !== 'current_workflow') | ||
|
|
||
| if (visibleContexts.length === 0) { | ||
| return null | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| {visibleContexts.map((ctx, idx) => ( | ||
| <Badge | ||
| key={`selctx-${idx}-${ctx.label}`} | ||
| variant='outline' | ||
| className='inline-flex items-center gap-1 rounded-[6px] px-2 py-[4.5px] text-xs leading-[12px]' | ||
| title={ctx.label} | ||
| > | ||
| {getContextIcon(ctx)} | ||
| <span className='max-w-[140px] truncate leading-[12px]'>{ctx.label}</span> | ||
| <button | ||
| type='button' | ||
| onClick={() => onRemoveContext(ctx)} | ||
| className='text-muted-foreground transition-colors hover:text-foreground' | ||
| title='Remove context' | ||
| aria-label='Remove context' | ||
| > | ||
| <X className='h-3 w-3' strokeWidth={1.75} /> | ||
| </button> | ||
| </Badge> | ||
| ))} | ||
| </> | ||
| ) | ||
| } | ||
1 change: 1 addition & 0 deletions
1
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { ContextPills } from './context-pills' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.